why does this loop?
mainloop:
xor ebx,ebx
loopA:
cmp ecx,dwcnt
jg dropdis ;does not jump, ecx is way less then dwcnt
cmp bl,255
jg mainloop ;however this does, is it a flag setting?
I went ahead and used CMP EBX,255 and it works.
Since you're comparing BL (one byte) and usign a signed conditional jump, you have to regard 0xFF (255 decimal) as -1 in two's complement notation. So your program was actually comparing 0 to -1, instead of 255 as intended.
Hope that helps! :)
drarem,
In your line:
cmp bl,255
the byte value 255 is considered a negative number; most significant bit is set. And in the next line you choose to use "jg" which is used to compare signed values. This means if either value can be considered signed, it will be.
For unsigned comparisons--where you don't want either value to be considered signed--use:
jb, jbe, ja, jae They test the Carry flag
and for signed comparisons use:
jl, jle, jg, jge They test the Sign & Overflow flags
hth,
farrier
Also note that an unsigned comparison of a byte value with 255 will always have the same result, no matter what value it is. For example, cmp bl,255 / ja mainloop behaves just as jmp mainloop. That's because unsigned byte values can only be in the range 0-255.
THhanks qvasimodo and farrier, the explanations help.