The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: eaOn on October 13, 2008, 02:18:04 PM

Title: Hex output [Clarification]
Post by: eaOn on October 13, 2008, 02:18:04 PM
Hello. I use to program in 16-bit DOS assembly but decided to study masm32 but I need some clarification. You see, when I try to study numbers.asm [which can be found in the tutoria folder]l, this had me think, well, "Is it possible for an output in HEX?"

You see I tried to expirement, changes minor things. T
For example, originally  on numbers.asm it's coded like this right?

    mov eax, 100                ; copy the IMMEDIATE number 100 into the EAX register
    mov ecx, 250                ; copy the IMMEDIATE number 250 into the ECX register
    add ecx, eax                ; ADD EAX to ECX
    print str$(ecx)             ; show the result at the console


I decided to include an "h" on it so that it will be hex.


    mov eax, 100h             ; I included an h so that it will be in hex. I'm familiar on this one.
    mov ecx, 250h             
    add ecx, eax               
    print str$(ecx)             ; it's hex alright but it's output is in decimal


Compiling runs smooth. But when I run it, the output is in decimal.  print str$(ecx) is not new to me and it bothers me a lot.
As mentioned above, Is it possible for my output to be in hex? Or do I have to create a decimal to hex conversion statement [like the old ways]?

I'm still studying masm32 but I'm totally enjoying this. :green
I was planning to port all my 16-bit project in masm32 in the future.
Thanks for the support!  :U


Title: Re: Hex output [Clarification]
Post by: Neil on October 13, 2008, 02:31:18 PM
Try print uhex$(ecx)
Title: Re: Hex output [Clarification]
Post by: Mark Jones on October 13, 2008, 07:23:10 PM
Yes, technically uhex$() and str$() are macros, which take the value provided to them and format them for display.

Search the \masm32\macros\macros.asm file for UHEX$ and STR$ and you will find the macro definitions. I wouldn't bother with all the technicalities of macros at the moment, just understand that they are helping you format these numbers as you wish, and they are placeholders for more complex code.
Title: Re: Hex output [Clarification]
Post by: eaOn on October 14, 2008, 01:23:21 AM
Wow! this is great. Makes coding a lot faster. :bg

Thanks for the tips guys!
I'll keep this in mind.  :U