...

View Full Version : bit masking



aspiringgeek
11-19-2008, 09:24 PM
I am trying to write the following assembly function store(regA,value) such that it writes to regA if first two bytes of regA are not 0xAB. If first two bytes of regA are 0xAB, store has to change first two bytes of regA so that writes go to some unknown other address.

I have this:
store(regA,val){
x0 = regA
x1 = regA and 0xFF00
x1 = x1 xor 0xAB00
if IsEqual(0, x1): write 0x0000, val
else write regA, val

I am told that it's possible to write this function in just two lines, not counting "write" instruction. Can anyone see how?

thanks

oracleguy
11-20-2008, 12:07 AM
store(regA,val)
{


if IsEqual(regA and 0xFF00, 0xAB00): write 0, val
else write regA, val

}


That should do the same thing as your code.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum