News:

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

Simple register question (Newbie)

Started by lonewolff, September 19, 2006, 04:51:54 AM

Previous topic - Next topic

lonewolff

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?
     


hutch--

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.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

zooba

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

lonewolff

Thanks for the replies. This has cleared up a bit.  :U