"dl" asked:
> Hi
Hello,
> How can i make sure, that an 32-Bit-Value (on a 32-Bit-System) is
> unsigned (positive).
If you talk about x86-CPUs, your question can be answered easy:
The CPU doesn't even know what "signed" may mean ...
> As exapmple : 0FFFFFFFFh : How can i make sure, that this is not -1 ?
> If i call a function, that allows positive and negative arguments, what
> have i to do ?
"Signed Integer" values are only found in High-level languages...
all x86-CPUs work on values (16/32/64 bits) which will rollover and
be truncated to the given size [and here we may think it's signed !]
Only a few x86-CPU instructions work really "signed" ie:
MOVSX reg,val
ADD/ADC...XOR mem/reg,8bit Sign-extextended
MUL reg,imm8
and just a few more in this families...
> Here an example:
>
> var dword 0
>
> ...
>
> mov var,0FFFFFFFFh
>
> ...
>
> push var
> call function
> or
> invoke function,var
Anyway: same as above
> As i said, the value has to be positive. In C i just have to cast
> "(unsigned)".
This is a problem of C here, we ASMers haven't any issues with it.
> And 2nd question: How can i make sure, that the value is negative in the
> example above ?
Negstive values (seen by the CPU) are just additives >0x8000_0000.
The inherent rollover-mechanics will automatically ADD 'signed'
even this 'signed' is a side-effect of rollover.
ie (16-bit): ;similar for 32 and 64-bit code
x:FFF0 jmp +32 ;
which results in FFF0+0020 which is 1_0010 (but all high bit ignored here.
Looks like signed, but it actually isn't :)
it just jumps backwards to x:0010 !
Otherwise we never could branch nor reference anything backwards...
__
wolfgang