The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: lonewolff on September 19, 2006, 04:51:54 AM

Title: Simple register question (Newbie)
Post by: lonewolff on September 19, 2006, 04:51:54 AM
Hi all,

I have just downloaded MASM v9.0 and I must say this looks good.
I have been out of the 'Assembler' scene for a little bit and this is my first time playing with 32bit assembly.

First question;

I cant get the following to compile. (No probs in debug.exe)

    mov al,ff      ;or even
    mov al,ffh

I find that the following works - but is this actually filling the register with FF?

    mov al,255

I also find if I work with 32 bit registers like eax I can use the following to view the register.

    print str$(eax)
   
But if I use the following the program crashes.

    print str$(al)

Under 32 bit programming do you have to use the full 32 bit register? Or can you still use 8 & 16 bit registered to perform a task?
     
Title: Re: Simple register question (Newbie)
Post by: gnewz10 on September 19, 2006, 05:12:36 AM
mov al,0FFh

-gnewz
Title: Re: Simple register question (Newbie)
Post by: hutch-- on September 19, 2006, 06:35:12 AM
Hi lonewolff,

Welcome on board. The "print" macro assumes a DWORD sized value so if you need to view a BYTE or WORD, use MOVZX to extend it to a 32 bit register.


    mov al, 123

  movzx eax, al    ; zero extend BYTE to DWORD.

  print str$(eax),13,10


You could make a macro to do this but you would have to do the same thing in the macro.
Title: Re: Simple register question (Newbie)
Post by: zooba on September 19, 2006, 09:03:39 AM
Quote from: gnewz10 on September 19, 2006, 05:12:36 AM
mov al,0FFh

-gnewz

To more fully explain this, anything that is to be interpreted as a number actually needs to start with a number (in this case, zero). If you start an operand with a letter (in your case, F) it tries to find a variable named that, rather than converting it to an immediate. In general, if your hex number starts with a letter, put a zero out the front (note that this only affects hexadecimal numbers, as no other supported radix/base contains letters (binary, decimal, and octal)).

Cheers,

Zooba :U
Title: Re: Simple register question (Newbie)
Post by: lonewolff on September 20, 2006, 08:08:36 AM
Thanks for the replies. This has cleared up a bit.  :U