Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: bit masking

  1. #1
    New to the CF scene
    Join Date
    Nov 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    bit masking

    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

  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Code:
    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.
    OracleGuy


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •