.data
num dd 090F0433H
.code
mov ax, @data
mov ds, ax
mov ax, word ptr num
mov bx, word ptr num+2
mov cl, byte ptr num+1
For mov ax, word ptr num, AH = 04, AL = 33.
Why? Can someone explain to me how to figure this out?
num dd 090F0433H
This defines a dword in memory. Since x86 uses little endianness, the lowest byte of this dword will be stored at the lowest address. You chose to name this lowest address "num".
In memory:
33h,04h,0Fh,09h
^
|
\num points here
mov ax, word ptr num
When you wrote this mov ax, word ptr num
you effectively asked to retrieve only the lowest word (2 bytes) at the "num" address.
You got the 1st byte 33h in AL
and the 2nd byte 04h in AH
, combined in one register: AX=0433h
.
mov bx, word ptr num+2
This one works similarly but will instead give only the highest word.
You'll get BX=090Fh
mov cl, byte ptr num+1
Here you asked to retrieve only the 2nd byte at the "num" address.
You'll get CL=04h
.