Writing out a single register in Assembly

强颜欢笑 提交于 2019-12-13 21:07:42

问题


Fairly simple question this time. How do I write to screen the contents of a single register in Assembly? I'm getting a bit tired of calling DumpRegs just to see the value of one register.

I'm using x86 architecture, and MASM in Visual Studio, and Irvine32.lib.


回答1:


Irvines's DumpReg uses repeatedly a macro of Macros.inc: mShowRegister. It can be used directly. Example:

INCLUDE Irvine32.inc
INCLUDE Macros.inc

.code
main PROC

    mov esi, 0DeadBeefh
    mShowRegister ESI, ESI

    exit
main ENDP

END main

A documented macro with more options is mShow. Example:

INCLUDE Irvine32.inc
INCLUDE Macros.inc

.code
main PROC

    mov esi, 0DeadBeefh
    mshow ESI, h

    exit
main ENDP

END main



回答2:


Irvine32 has output functions that take a value in EAX, such as WriteDec (unsigned base 10).

See the documentation http://programming.msjc.edu/asm/help/source/irvinelib/writedec.htm which has links to WriteHex (hex = base 16), and WriteInt (signed base 10).

These functions use the Irvine32 calling convention and preserve all registers, including the arg-passing register EAX, so you can even insert them as a debug-print for EAX at least. More usually you'd use them as simply normal output functions.

Usually for asm debugging you'd use a debugger, not debug-print function calls.



来源:https://stackoverflow.com/questions/22181320/writing-out-a-single-register-in-assembly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!