Positron Compiler Documentation

Ror

Positron8 · Revision 4.0.6.5 · PDF page 351

Ror Variable {,Set or Clear}

Bitwise rotate a variable right, with or without the microcontroller’s Carry flag.

Variable may be any standard variable type, but not an array or expression. Set or Clear are optional parameters that will clear or set the Carry flag before the rotate. If no parameter is placed after Variable, the current Carry flag state will be rotated into the MSB (Most Significant Bit) of Variable.

' Demonstrate the Ror Command
'
  Device = 18F25K22
  Declare Xtal = 16          ' Tell the compiler the device is operating at 16MHz
  Declare Hserial_Baud = 9600      ' HRsoutLn Baud rate

  Dim Index As Byte
  Dim MyByte As Byte = 0b00000001
  Dim Byteout As Byte
'
' Rotate the carry through MyByte
  Ror MyByte
  Ror MyByte
  Ror MyByte
  Ror MyByte
  Ror MyByte
  Ror MyByte
  Ror MyByte
  Ror MyByte
'
' Set each bit of MyByte with every rotate
  MyByte = 0b00000000
  For Index  = 0 To 7        ' Create a loop of 8 iterations
     Ror MyByte, Set          ' Rotate MyByte and set the Most Significant Bit
     HRsoutLn Bin8 MyByte
  Next
  HRsoutLn "----------"
'
' Clear each bit of MyByte with every rotate
  MyByte = 0b11111111
  For Index = 0 To 7          ' Create a loop of 8 iterations
     Ror MyByte, Clear        ' Rotate MyByte and clear the Most Significant Bit
     HRsoutLn Bin8 MyByte
  Next
  HRsoutLn "----------"
'
' Transfer the value of MyByte to Byteout, but reversed
  MyByte = 0b00000001
  Byteout = 0b00000000
  For Index = 0 To 7         ' Create a loop of 8 iterations
     Ror MyByte               ' Rotate MyByte into the Carry bit of STATUS
     Rol Byteout               ' Rotate the Carry bit into Byteout
     HRsoutLn Bin8 Byteout
  Next

See also: Rol.

View original PDF page 351Open page in PDFOriginal PDF page 351