hey..
i have a small q..[ kinda lame..but hey :P]

i need to know if a readed byte is >= 80h
using logic operations only! (xor, and, not, or)..

num>80h ->x1xxxxxxxx
80h -> 10000000
num<80h -> 0xxxxxxxx

meaning i must find such operation which checks the 8's left bit of the binary
number if its 1...
i was unable to find a good sulotion..any idea?
Posted on 2002-11-18 09:54:55 by wizzra
So you want to and something with something else?

You sure you've looked for a way to do this?

The mnemonic and performs the bitwise operation and, its not rocket science.
Similarly the test operation performs a bitwise and, except it doesn't store the result it only sets the flags (test for non-zero)

Alternatively as you are checking for the last byte being set how about these:



; assume al holds the byte to check
or al, al
js somewhere ; jump if bit 7 is set - al unchanged

test al, 80h
jnz somewhere ; jump if bit 7 is set - al unchanged

test al, 80h
js somewhere ; jump if bit 7 is set - al unchanged

and al, 80h
jnz somewhere ; jump if bit 7 is set - al = 80h if bit 7 set, else al = 00h

and al, 0FFh
js somewhere ; jump if bit 7 is set - al unchanged

shl al, 1
jc somewhere ; jump if bit 7 was set - al = (al && 7Fh) * 2

xor al, 80h
jns somewhere ; jump if bit 7 was set - al = al with bit 7 inverted

not al
jns somewhere ; jump if bit 7 was set - al = ~al


There are a whole lot more if I can use sub, add, cmp, and the rest of the instructions...
Are you sure you looked for this information?

Mirno
Posted on 2002-11-18 10:46:16 by Mirno
i only needed and,or,xor,not
anyway, thnx ;P
Posted on 2002-11-18 11:18:11 by wizzra