how would you move a dd variable to ax like lets say var1 dd 0 ,
mov ,ax ; this wouldn't work
Posted on 2002-09-21 17:29:14 by CyberGuy
If you want to move it to ax then it's the other way around :)

dd is a dword - 2 words
ax is a word.

so, you can't move a dd into ax.

here's to move a word into ax:

mov ax, word


PS: I'm pretty sure the Fasm Documentation - explains all of this...
Posted on 2002-09-21 17:33:43 by JimmyClif
are you sure....I thought that...lets say
mov ,88 ;Is var1 = 88
so...
mov ax, word ; wouldn't this be ax = var1 ?

I wanted to move var1 to ax

If you can't move it , then how do you do calculations and stuff like how you can do...
mov ax,5*8/32+55

for a dd?
Posted on 2002-09-21 18:38:56 by CyberGuy
Yep mov ax,word does make ax = var1, maybe its just a typo in your first post but you typed it the oppisite way :) .
Posted on 2002-09-21 18:48:46 by Eóin

are you sure....I thought that...lets say
mov ,88 ;Is var1 = 88

Good so far.


mov ax, word ; wouldn't this be ax = var1 ?

In this case, yes.

However since you are moving a 32 bit value to a 16 bit register care
must be taken to stay within bounds or else this is *not* the case.
Consider the following:

max AX can hold: 65535 or #FFFF
max var1 can hold: 4294967295 or #FFFFFFFF

So what happens when you do the following?
mov ,70000
mov ax, word

The short of the answer is that ax now contains the lower portion of
what var1 did. 70000 in hex is #11170 so the lower word value if I
am not mistaken would be #1170 or 4464. And its quite clear 4464
does not equal 70000.

So when you say "wouldn't this be ax = var1 ?" the answer is yes
if you use it properly.

Someone please correct me if I just led CyberGuy down the perverbial
garden path :grin:
Posted on 2002-09-21 18:54:24 by Graebel

Someone please correct me if I just led CyberGuy down the perverbial garden path :grin:
I happen to like garden paths. ;)
Nothing wrong with your explaination, though.

CyberGuy, the complete story is MOV AX, {memory} will only load two bytes into AX because AX is 16 bits = 2 bytes, but you have stated var1 to be a DWORD = 32 bits. This instruction will only be using half of var1 and good assemblers will require the programmer to explicitly state they wish to access memory other than it was defined. I.E. MOV AX, var1 is an error, but MOV AX, WORD PTR var1 is not. Assembly lets us do want every we want with memory. :)
Posted on 2002-09-21 22:25:05 by bitRAKE