assemblymicrocontrollerz80

Extracting LSB and MSB on Z80 Assembly


Lets say i have a data (15H) on memory 0040.

My question is, how an I extract that most significant and least significant bit for further usage?

I have lookup on the Z80 User manual and found nothing. Any help will be appreciated


Solution

  • I just want to wrote down what @Jester already explained to me

    how to get the LSB

    1. using AND
    LD A, 1
    LD B, 19H ;The data
    AND B     ;LSB is at register A
    
    1. using RRCA
    2. using BIT

    how to get the MSB

    1. using RLCA followed by AND
    2. using BIT