Hello boys !

How does the instruction for BYTE-vars works with dwords?:

I want to do that with a dword variable. - but how.

Posted on 2003-09-04 12:47:26 by Bubu-Boy
Perhaps you mean this?

mov al,byte ptr
mov ax,word ptr
mov eax,dword ptr
Posted on 2003-09-04 12:55:51 by QvasiModo
hi, i did, but i cant compare it with something else.

mov eax, dword ptr
cmp eax, 'q'
je ...
Posted on 2003-09-04 13:00:00 by Bubu-Boy
Funny, that should assemble well... 'q' should be interpreted by MASM as a DWORD whose lowest byte is a "q" char, and the rest are zeroes. Exactly what error message do you get?
Posted on 2003-09-04 13:02:46 by QvasiModo
there are a few ways to treat a var

mov eax,var
mov eax,offset var

you cant move dword ptr a var it dose that automatically when compiled

so you should try

mov eax,dwvar
cmp eax,'q'

if your testing a string you could try this

mov eax,offset dwvar
cmp byte ptr ,'q'

then all you have to do is inc eax to try the next leter

mov eax,offset dwvar
cmp byte ptr ,'q'

if your var is already a pointer to the string
then just do
mov eax,dwvar
cmp byte ptr ,'q'
Posted on 2003-09-04 18:02:24 by devilsclaw
Many assemblers may complain if you try to load a register with a variable which has been declared as having a different size. The exception is when loading a register with a variable of lower size using the movzx or movsx instructions.

In general, the easiest way of loading a part of a declared variable (regardless of declared size) into an 8-bit register is by indirect referencing as in the following example:

[b]lea edx,ddvar[/b] ;use EDX as pointer to ddvar
[b]mov al,[edx+1][/b] ;AL=2nd byte of ddvar
[b]cmp byte ptr[edx+2],"q"[/b] ;compare the 3rd byte of ddvar to [b]q[/b]

Posted on 2003-09-04 22:17:11 by Raymond
yep that to..
Posted on 2003-09-05 00:46:28 by devilsclaw