MSB - The Most Significant Bit

The Most Significant Bit(MSB) is the far left bit of a byte that represents a value of 128. Many tasking ports and commands reference this bit. It also determines the state of the minus flag.
Some bitfield commands move values into the MSB.

  • SHL - The Shift Left Command

  • ROR - The Roll Right Command

  • ROL - The Roll Left Command

  • BMI - The Branch if Minus Flag Set Command

  • BCC - The Branch if Minus Flag Cleared Command

  • Port ^10 - The Keyboard(Button) Port

  • Port ^39 - The IR Button Port

Tips for working with the MSB
  • OR a value of 0x80 to set the MSB

  • AND a value of 0x80 to clear the MSB

  • AND a value of 0x7F to isolate the LSB

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

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

Examples

Example 1

Task1()
{
    Name="Dipswitch 8 checker"
    LDA ^59,0           //Get the dipswitch port
    SHL                 //Move Dipswitch 8 into the carry flag
    BRC DipSwitch8Set   //If carry flag is set branch if not assume cleared
    ...
}

Example 2

Button state checker

Task1()
{
LDA ^10,0       // Get the keyboard port
BMI ButtonPress // If a button press branch if not assume release.
...
}