在Assembly x86中打印注册

use*_*298 3 printing x86 assembly

接下来是几个在线文档但当我尝试打印我存储在寄存器%ecx中的数字时,没有任何反应.这可能是因为我基本上执行计算然后尝试在循环中打印?

   mov     $48, %ecx  #Convert to ascii
   mov     $1, %edx   #Print Byte
   add     %eax, %ecx

   mov     $4, %eax          #Output To Console
   mov     $1, %ebx          #File Descriptor - Standardout
   int      $0x80            #Call the Kernel
Run Code Online (Sandbox Code Playgroud)

Jes*_*ter 5

write系统调用预计要打印的指针的数据.据我所知,你有一个数字.您可以暂时将其存储在堆栈上以进行打印,如下所示:

mov     $48, %ecx  #Convert to ascii
mov     $1, %edx   #Print Byte
add     %eax, %ecx
push    %ecx       # store on stack
mov     %esp, %ecx # load address
mov     $4, %eax   # Output To Console
mov     $1, %ebx   # File Descriptor - Standardout
int     $0x80      # Call the Kernel
pop     %ecx       # clean up stack
Run Code Online (Sandbox Code Playgroud)

请记住,对于多位数字,您需要更好的转换程序.