OR - The Bitwise OR Command

The OR command is a bitwise operation that OR’s the value held in the accumulator with the specified value (argument) and resaves the new value into the accumulator.
"OR"ing a bit turns it on. The value you specify in the command is known as a mask. Bits in the argument that are on will become on in the result. Bits that are off in the argument will maintain state in the result.
Sometimes it is useful to store binary states in a single byte and use bitwise operations like this to do targeted edits. One example would be tracking partition states in a ballroom.
This command is the opposite of the AND command.

Example Bitfield for OR command

ACC

1

1

1

0

0

0

0

1

MASK

0

1

1

0

1

1

0

0

RESULT

1

1

1

0

1

1

0

1

Syntax

OR x
Where x is the value, memory location, or tasking port you want to OR against the accumulator value.

Examples

Example 1

{
LDA #0xA0  //Load the value in 0xA0 to the accumulator
OR #0x01   //Use OR to turn on bit 1 regardless of the previous state
STA ~1     //Store the new result of #0xA1 into ~1
}

Example 2

{
LDA ~2    //Copy the value in ~2 to the Accumulator
OR ~10    //OR with the value in ~10 (the Mask)
STA ~2    //Copy the result from the Accumulator to ~2
}

Example 3

This excerpt stores the state of a partition into a single byte tracking all of them.

{
...
Partition1:
		LDA PresetByte			//get preset byte
		CMP #0					//preset 1
		BRZ Part1P1
		CMP #3					//preset 4
		BRZ Part1P4
		Null
		Part1P1:					//Partition open
			LDA RoomState
			OR #0x01				//Set the bit to on
			STA RoomState
			BRA SendMessage
		Part1P4:					//Partition closed
			LDA RoomState
			AND #0xFE				//Set the bit to off
			STA RoomState
			BRA SendMessage
...
}