Positron Compiler Documentation

Rol

Source: Positron8 Compiler User Manual, PDF page 350

Syntax

Rol Variable {,Set or Clear}

Overview

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

Parameters

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 LSB (Least Significant Bit) of Variable.

Example.

' Demonstrate the Rol 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 = 0b10000000
  Dim Byteout As Byte
'
' Rotate the carry flag through MyByte
  Rol MyByte
  Rol MyByte
  Rol MyByte
  Rol MyByte
  Rol MyByte
  Rol MyByte
  Rol MyByte
  Rol MyByte
'
' Set each bit of MyByte with every rotate
  MyByte = 0b00000000
  For Index  = 0 To 7
                                  ' Create a loop of 8 iterations
     Rol MyByte, Set
                                  ' Rotate MyByte and set the Least 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
     Rol MyByte, Clear
                                  ' Rotate MyByte and clear the Least Significant Bit
     HRsoutLn Bin8 MyByte
  Next
  HRsoutLn "----------"
'
' Transfer the value of MyByte to Byteout, but reversed
  MyByte = 0b10000000
  Byteout = 0b00000000
  For Index = 0 To 7
                                  ' Create a loop of 8 iterations
     Rol MyByte
                                  ' Rotate MyByte into the Carry bit of STATUS
     Ror Byteout
                                  ' Rotate the Carry bit into Byteout
     HRsoutLn Bin8 Byteout
  Next

See also: Ror.