Does anyone know how to get an unsigned DWORD value to a register?

for example for an unsigned byte there is

bbyte db 255

MOVSX eax, ;this is signed F BE

and unsigned by using opcode F B6

but how to read an

ddword dd FFFFFFFFh

mov eax,  ;is signed and so it is -1

So how can I get a unsigned dword?

it should be:
4294967295 (max value of unsigned dword)

but I only can work out:
2147483647 (max value of signed dword)

thanks for any help

Posted on 2005-11-28 15:03:32 by Emod
A dword is unsigned !

The unsigned versions are:  dword (dd), word (dw), and byte (db).
  uitem1 byte  1    ;  8-bit  0 to 255
  uitem2 word  1    ; 16-bit  0 to 65535
  uitem4 dword 1    ; 32-bit  0 to 4294967295

The signed versions are:  sdword, sword, sbyte
  sitem1 sbyte  -1    ;  8-bit -128 to 0 to 127
  sitem2 sword  -1    ; 16-bit -32768 to 0 to 32767
  sitem4 sdword -1    ; 32-bit -2147483648 to 0 to 2147483647
Posted on 2005-11-28 15:20:16 by dsouza123
Ok I see, but how about the other way.. moving a signed dword to eax.

I need the opcode for:
mov eax, ??

the other way is:
mov eax,
and encodes to
A1h [00000000h]

or do I missunderstand something? and there is no way?
Posted on 2005-11-28 19:24:03 by Emod
Any value in memory is unsigned unless YOU, as the programmer, wants to consider it as signed.  In that case, you would need to use the IMUL and IDIV instructions for integer multiplication and division with the general CPU registers, and use the movzx or movsx for loading a 32-bit register with an 8- or 16-bit value. The 8-, 16- and 32-bit registers will take whatever value is in the equivalent memory size.

The only exception to the above statement is when you would load WORDS, DWORDS or QWORDS to the FPU registers for floating point operations. The FPU ALWAYS considers them as signed, regardless of YOUR interpretation.

Posted on 2005-11-28 20:13:02 by Raymond
The 2's-complement arithmetic allows to write a number and consider it either signed or unsigned without the need for 2 different write methods. you write 32 bits at a location. whether it's signed byte, unsigned word, or signed dword, it's up to you, and the way you use that value. it can be 32-bit float if you wish.

0xFFFFFFFF = 4'294'967'295

by adding 2 to the above, we get:

0x00000001 = 1 (overflow is set, indicatng that the result is 33 bit)
0x00000001 = 1 ( -1 + 2 = 1 )

so we get correct result regardless of how we treat the number (as signed or as unsigned).
Posted on 2005-11-29 23:12:07 by ti_mo_n

by adding 2 to the above, we get:

0x00000001 = 1 (overflow is set, indicatng that the result is 33 bit)
0x00000001 = 1 ( -1 + 2 = 1 )

    Nope, it's the carry flag that determines whether a unsigned result is greater than its word size for add/sub operations.  The overflow flag is used for signed add/sub operations.  In the above example, the overflow flag will NOT be set, but the carry flag will be.  See the link below for a more through discussion and explanation.  Ratch
Posted on 2005-11-30 19:13:39 by Ratch
Yeah - you're right. I always accidentaly misuse them :mrgreen: luckily that conditional jump mnemonics are "ja" and "jg", so I don't have to memorize them :P
Posted on 2005-11-30 19:24:19 by ti_mo_n