thanks in advance
luc
Essentially, subtracts 0FFFFFFFFh from eax and sets flags, but doesn't
store the result in eax as "sub" would.
Best,
Frank
Ok thanks.. a lot the last question is to understand this instruction
mov eax, fd[eax*4]
thanks a lot for your support
luc
> On Jul 6, 1:42 pm, Frank Kotler <fbkot...@nospicedham.myfairpoint.net>
> wrote:
>> yqyq22 wrote:
>> > Hi all,
>> > I would like to understand what means:
>> > cmp eax, 0FFFFFFFFh
...
> Ok thanks.. a lot the last question is to understand this instruction
> mov eax, fd[eax*4]
If "fd" refers to the memory location of an array of integers (or
pointers, or some other 32-bit values), then
fd[eax*4]
uses the value of eax as an index into that array and
mov eax, fx[eax*4]
loads the value at that index into eax (overwriting the index).
In that context, the
cmp eax, 0FFFFFFFFh
effectively compares the value in eax to -1, probably to avoid
reading a value before the start of the array.
/L
--
Lasse Reichstein Holst Nielsen
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
As you say, CMP is the same as SUB, but only saving the flags, not
writing the result back to the register.
CMP/SUB EAX,0ffffffffh
is in fact the same as
CMP/SUB EAX,-1
which would give the same (register) result as
ADD EAX,1
but with different flags:
CMP EAX,-1
will (of course) set the zero flag only if EAX was -1, but the carry
flag will be set for all inputs except -1.
Doing ADD EAX,1 instead will set carry for the opposite condition, i.e.
clear for all values except -1.
It is most often seen in "trick" code that needs to propagate the carry
flag, or if you want an incrementing counter that saturates at a full
count, i.e. doesn't wrap around from 0xfff... to 0:
sub eax,-1 ;; Increment the counter
sbb eax,0 ;; Decrement if the previous operation wrapped around.
Terje
--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"
did i read it in 32/64bit code !?
anyway, i use some similiar method for utf8 validation
to know how many units follow the prefix in the codepoint
shr al,4 ;--- in al first unit of the cpt (when >= C2h)
sub al,0Dh
adc al,1 ;--- now num required units
because C2->DF share 1 only following unit
while E0->EF 2
and F0->F4 3
and this is one of the many interesting
utf-8 "properties"... that helps avoiding
branching on "cmp".
Cheers,
--
.:hopcode[marc:rainer:kranz]:.
x64 Assembly Lab
http://sites.google.com/site/x64lab
thanks to all for the useful explanaton.
Luc