打印注册在大会86 [英] Print Register in Assembly x86

查看:159
本文介绍了打印注册在大会86的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

随后几个联机文档,然而,当我尝试打印的数量我都存储在寄存器%ecx中没有任何反应。难道这是因为我本质上进行计算,然后试图打印,而在一个循环?

  MOV $ 48%ECX #Convert为ASCII
   MOV $ 1,EDX%字节#PRINT
   添加%EAX,ECX%   MOV $ 4,%EAX #Output到控制台
   MOV $ 1,%ebx中#FILE描述 - Standardout
   诠释$ 0x80的#CALL内核


解决方案

系统调用希望打印的指针数据。据我所知,你有一个单一的数字。您可以临时存储在堆栈上要打印如下:

  MOV $ 48%ECX #Convert为ASCII
MOV $ 1,EDX%字节#PRINT
添加%EAX,ECX%
推栈%ECX#店面
MOV%ESP,ECX%负载#地址
MOV $ 4,%EAX#输出到控制台
MOV $ 1,EBX%#文件描述符 - Standardout
INT 0x80的$#调用内核
流行%ECX#清理堆栈

记住,你将需要多位数更好的转换过程。

Followed a couple of online documents and yet when I try to print the number I have stored in the register %ecx nothing happens. Could this be because I'm essentially performing calculations and then trying to print while in a loop?

   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

解决方案

The write system call expects a pointer to the data to be printed. As far as I can tell, you have a single digit. You can temporarily store that on the stack for printing as follows:

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

Remember that you will need a better conversion routine for multi-digit numbers.

这篇关于打印注册在大会86的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆