LSB - The Least Significant Bit

The Least Significant Bit(LSB) is the far right bit of a byte that represents a value of 1. It determines if the value is odd or even.
Some bitfield commands move values into the LSB.

  • SHR - The Shift Right Command

  • ROR - The Roll Right Command

  • ROL - The Roll Left Command

  • ^57 - The Display Backlight Port

Tips for working with the LSB
  • OR a value of 0x01 to set the LSB

  • AND a value of 0x01 to clear the LSB

  • AND a value of 0xFE to isolate the LSB

  • Use the SHR or ROR commands to move the LSB into the carry flag

  • Use the ROL command to move the carry flag into the LSB

Examples

Example 1

Task1()
{
    Name="Dipswitch checker"    //Branches on the lowest dipswitch set
    LDA ^59,0           //Get the dipswitch port
    SHR                 //Move Dipswitch 1 into the carry flag
    BRC DipSwitch1Set   //If carry flag is set branch.
    SHR                 //Move next Dipswitch into the carry flag
    BRC DipSwitch2Set   //If carry flag is set branch.
    ...
}

Example 2

Turns on the display backlight of a device.

Task1()
{
    Name="Task 1"
    LDA ^57,0           //Load the state of the lightwash and screen
    OR #1               //Set the LSB leaving the other bits intact
    STA ^57,0           //Store the new value back into the backlight port
}