I'm not quite sure about the actual data representation of these two data types (or, unsinged, and signed data types)
E.g.
if there is a variable defined in c/c++ like this:

USHORT length1=1;

can I just do it like the following in asm?

.data
length1 dw 0
.......
.code
mov eax,1
mov length1,eax
......

???
if so, is the asm code the same, if the length1 is SHORT?
what's the difference between signed and unsigned short/int then ?
Thank you for any adivce
Posted on 2004-04-22 11:27:36 by FredLiu
use a dword and it would be much easier for you (No need to switch from 16bit to 32bit and 32bit to 16bit).

There is not much difference between unsigned and signed dword/word/byte except for the case of conditional jumps.

Say for instance eax= -1 and ecx=1
Which is bigger?
If you view eax as signed and use jg/jl/jge/jle etc, eax is bigger than ecx. If you view eax as unsigned, eax is bigger than 1. 0ffffffffh is definitely bigger than 1. So use the correct conditional jumps depending on whether you want to view the dword as signed or unsigned.
Posted on 2004-04-22 11:31:44 by roticv
a short, unsigned or not, is a "WORD" in intel assembly.

Because of the way numbers are encoded (2-complement), most operations work the same - you have things like add and sub and so forth that don't care if your number is signed or unsigned.

The big differences are with conditional jumps, as roticv says there's a different smaller/larger set depending on whether you use signed or unsigned numbers. If you use masm highlevel syntax to check numbers, you'll need to add "SWORD PTR" to tell masm it's a signed word.

Then of course there's also some different logic when converting signed numbers to ascii representation :)
Posted on 2004-04-22 12:18:25 by f0dder
so, to sum up: if i don't use conditional jmp, signed and unsigned numbers are the same to me, is it?
ha, that's pretty handy~~
thank you very much!:grin:
Posted on 2004-04-23 02:56:57 by FredLiu