The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: CollegeBoy88 on July 16, 2010, 01:36:08 AM

Title: output register value
Post by: CollegeBoy88 on July 16, 2010, 01:36:08 AM
I've been searching both Google and the forum, and I can't find out how one can output the value of a register/variable on the screen.  int 21h doesn't work, windows displays an error when it is run.

For example, how do I output the value of register AX?
Here's the code:

include \masm32\include\masm32rt.inc

.code
start:
    mov ax, 0
    mov cx, 0
a: add cx,1
    add ax, cx
    cmp cx, 5
    jne a
    exit
end start
Title: Re: output register value
Post by: oex on July 16, 2010, 01:37:50 AM
in 32 bit you could

movzx ebx, ax
print str$(ebx)
inkey

I think also this would work but not sure:
movzx eax, ax
print str$(eax)
inkey

movzx zeros the other 2 bytes, inkey pauses the application untl a key is pressed so you can see output before application quits
Title: Re: output register value
Post by: CollegeBoy88 on July 16, 2010, 01:44:03 AM
It works fine. Thanks.  :U