News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Hex output [Clarification]

Started by eaOn, October 13, 2008, 02:18:04 PM

Previous topic - Next topic

eaOn

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



Neil


Mark Jones

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.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

eaOn

Wow! this is great. Makes coding a lot faster. :bg

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