ROR - The Roll Right Command
The ROR command is a bitwise operation that takes the value in the accumulator and moves all of the bits to towards the LSB (to the right). The bit in the LSB is placed into the Carry Flag and the state of the Carry Flag becomes the MSB.
After 9 ROR commands the bits are restored to their original positions.
You can use this in conjunction with the BCC and BRC commands to interrogate individual bits without destroying their contents.
This command is the opposite of the ROL command.
Syntax
ROR
Notice that there are no values attached to the command. It simply moves everything one spot right putting the LSB in the Carry Flag and moving the Carry Flag into the MSB.
The ROR command has the byproduct of dividing the value by 2. |
Examples
Example 1
Task1()
{
Name="Dipswitch checker" //Branches on the lowest dipswitch set
LDA ^59,0 //Get the dipswitch port
ROR //Move Dipswitch 1 into the carry flag
BRC DipSwitch1Set //If carry flag is set branch.
ROR //Move next Dipswitch into the carry flag
BRC DipSwitch2Set //If carry flag is set branch.
...
}
Example 2
Task1()
{
Name="Occupancy Trigger" //Checks the state of dry contact 3.
LDA ^17,0 //Get the dipswitch port
ROR //Move Dipswitch 1 into the carry flag
ROR //Move Dipswitch 2 into the carry flag
ROR //Move Dipswitch 3 into the carry flag
BRC Occupancy //If carry flag is set sensor saw motion
...
}