Positron Compiler Documentation

Ror

Positron16 · Revision 1.1.3.5 · PDF pages 354–355

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. Set or Clear are optional parameters that will clear or set the Carry flag before the rotate. If no parameter is placed after the Variable, the current Carry flag state will be rotated into the MSB (Most Significant Bit) of variable.

' Demonstrate the Ror Command
'
  Device = 24FJ64GA002             ' Select the device to compile for
  Declare Xtal = 32
  Declare Hserial_Baud = 9600      ' UART1 Baud rate
  Declare Hrsout1_Pin = PORTB.14   ' Select the pin for TX with USART1

  Dim bIndex As Byte
  Dim MyByte As Byte
  Dim Byteout As Byte

  RPOR7 = 3                       ' Make Pin RP14 U1TX
'
' Rotate the carry through MyByte
'
  MyByte = %00000001
  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 = %00000000
  For bIndex = 0 To 7
     Ror MyByte, Set
     HRSOutLn Bin8 MyByte
  Next
  HRSOutLn "----------"
'
' Clear each bit of MyByte with every rotate
'
  MyByte = %11111111
  For bIndex = 0 To 7
     Ror MyByte, Clear
     HRSOutLn Bin8 MyByte
  Next
  HRSOutLn "----------"
View original PDF page 354Open page in PDFOriginal PDF page 354
'
' Transfer the value of MyByte to Byteout, but reversed
'
  MyByte = %00000001
  Byteout = %00000000
  For bIndex = 0 To 7
     Ror MyByte
     Rol Byteout
     HRSOutLn Bin8 Byteout
  Next
'
' Configure for internal 8MHz oscillator with PLL
' OSC pins are general purpose I/O
'
  Config Config1 = JTAGEN_OFF, GCP_OFF, GWRP_OFF, BKBUG_OFF,_
                   COE_OFF, ICS_PGx1, FWDTEN_OFF, WINDIS_OFF,_
                   FWPSA_PR128, WDTPOST_PS256
  Config Config2 = IOL1WAY_OFF, COE_OFF, IESO_OFF, FNOSC_FRCPLL,_
                   FCKSM_CSDCMD, OSCIOFNC_ON, POSCMOD_NONE

See also: Rol.

View original PDF page 355Open page in PDFOriginal PDF page 355