News:

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

Question from newbie

Started by sayang, February 14, 2009, 07:05:54 AM

Previous topic - Next topic

sayang

Hi,

just learn masm about 2 days and little bit confuse the benefit or usage of using eax,ah and al.

maybe this is such stupid question and so sorry about that but i still dont understand and need some reference.

my question is like this.

1.

mov al,1
mov ah,2

what's the value of EAX now? is it 3 ?

How to display value in integer for EAX?


Thank you to any help.






donkey

Hi sayang,

No, the value is not 3. It works like this

EEEEEEEEEEEEEEEEHHHHHHHHLLLLLLLL
EEEEEEEEEEEEEEEEXXXXXXXXXXXXXXXX


Where E is the upper 16 bits, H is the high 8 bits of the (old) 16 bit X register and L is the lower 8 bits. So when you move something into AL it moves it into the lower 8 bits...

mov AL, 1

EAX = 00000000000000000000000000000001 = 1

If you move something into the AH register it is moved into the upper 8 bits of the X register...

mov AH, 1

EAX = 00000000000000000000000100000000 = 256

To move something into the complete lower half of the register you use AX...

mov AX, 257

EAX = 00000000000000000000000100000001 = 257

The E part or the Extended part of the register is not directly addressable, you have to move a full 32 bits into the register, replacing the contents of AL/AH/AX

So if you mov 1 into AL and 1 into AH the result is 257.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

sayang

Thanks  :U

you have enlighten me  :toothy

PBrennick

Remember, even though the upper 16 bits of eax are not directly addressable, they will certainly have an impact on the result of any changes you may make to AX (or AH and/or AL). When doing 8 bit (or 16 bit calculations, it is always best to clear eax first (or mask the upper 16 bits.

Donkey sure hit on an easy way to see what is what.  :U

Paul
The GeneSys Project is available from:
The Repository or My crappy website