Positron Compiler Documentation

cPtr8, cPtr16, cPtr24, cPtr32, cPtr64

Positron16 · Revision 1.1.3.5 · PDF pages 384–386

Assignment Variable = cPtr8 (Address) Assignment Variable = cPtr16 (Address) Assignment Variable = cPtr24 (Address) Assignment Variable = cPtr32 (Address) Assignment Variable = cPtr64 (Address)

Indirectly read code memory using a variable to hold the 16-bit or 32-bit address.

Assignment Variable is a user defined variable that holds the result of the indirectly addressed code memory area. Address is a Word or Dword variable that holds the 16-bit or 32-bit address of the code memory area of interest.

Address can also post or pre increment or decrement:

(MyAddress++) Post increment MyAddress after retrieving its RAM location. (MyAddress --) Post decrement MyAddress after retrieving its RAM location. (++MyAddress) Pre increment MyAddress before retrieving its RAM location. (--MyAddress) Pre decrement MyAddress before retrieving its RAM location.

cPtr8 will retrieve a value with an optional 8-bit post or pre increment or decrement. cPtr16 will retrieve a value with an optional 16-bit post or pre increment or decrement. cPtr24 will retrieve a value with an optional 24-bit post or pre increment or decrement. cPtr32 will retrieve a value with an optional 32-bit post or pre increment or decrement. cPtr64 will retrieve a value with an optional 64-bit post or pre increment or decrement.

8-bit Example.

'
' Read 8-bit constant values from flash memory
'
  Device = 24FJ64GA002               ' Select the device to compile for
  Declare Xtal = 16
  Declare Hserial_Baud = 9600         ' UART1 Baud rate
  Declare Hrsout1_Pin = PORTB.14      ' Select pin to be used for TX
'
' Create an 8-bit flash memory table
'
  Dim CodeArray As Code = as Byte 1, 2, 3, 4, 5, 6, 7, 8, 9, 0
  Dim MyByte As Byte               ' Create a byte variable
  Dim bIndex As Byte
  Dim wAddress As Word             ' Create variable to hold 16-bit address
Main:
  RPOR7 = 3                         ' Make PPS Pin RP14 U1TX
'
' Read from flash memory
'
  wAddress = AddressOf(CodeArray)   ' Load wAddress with address of memory
  Do                                ' Create a loop
     MyByte = cPtr8(wAddress++)     ' Retrieve from flash memory with post increment
     If MyByte = 0 Then Break       ' Exit when a null(0) is read from code
     HRSOutLn Dec MyByte           ' Transmit the byte read from flash
  Loop
View original PDF page 384Open page in PDFOriginal PDF page 384

16-bit Example.

'
' Read 16-bit constant values from flash memory
'
  Device = 24FJ64GA002               ' Select the device to compile for
  Declare Xtal = 16
  Declare Hserial_Baud = 9600          ' UART1 Baud rate
  Declare Hrsout1_Pin = PORTB.14     ' Select pin is to be used for TX
'
' Create a 16-bit flash memory table
'
  Dim CodeArray As Code = as Word 100, 200, 300, 400, 500, 600, 700, 0
  Dim MyWord As Word                ' Create a word variable
  Dim bIndex As Byte
   Dim wAddress As Word             ' Create variable to hold 16-bit address

Main:
  RPOR7 = 3                         ' Make PPS Pin RP14 U1TX
'
' Read from flash memory
'
  wAddress = AddressOf(CodeArray)   ' Load wAddress with address of memory
  Do                                ' Create a loop
     MyWord = cPtr16(wAddress++)    ' Retrieve from flash memory with post increment
     If MyWord = 0 Then Break       ' Exit when a null(0) is read from flash
     HRSOutLn Dec MyWord           ' Transmit the word read from flash
  Loop

24-bit Example.

'
' Read 24-bit constant values from flash memory
'
  Device = 24FJ64GA002               ' Select the device to compile for
  Declare Xtal = 16
  Declare Hserial_Baud = 9600          ' UART1 Baud rate
  Declare Hrsout1_Pin = PORTB.14     ' Select pin is to be used for TX
'
' Create a 24-bit flash memory table
'
  Dim CodeArray As Code = as Long 100, 200, 300, 400, 500, 600, 700, 0
  Dim MyDword As Dword              ' Create a Dword variable
  Dim bIndex As Byte
   Dim wAddress As Word             ' Create variable to hold 16-bit address

Main:
  RPOR7 = 3                         ' Make PPS Pin RP14 U1TX
'
' Read from flash memory
'
  wAddress = AddressOf(CodeArray)   ' Load wAddress with address of memory
  Do                                ' Create a loop
     MyDword = cPtr24(wAddress++)    ' Retrieve from flash memory with post increment
     If MyDword = 0 Then Break      ' Exit when a null(0) is read from flash
     HRSOutLn Dec MyDword           ' Transmit the dword read from flash
  Loop
View original PDF page 385Open page in PDFOriginal PDF page 385

32-bit Example.

'
' Read 32-bit constant values from flash memory
'
  Device = 24FJ64GA002             ' Select the device to compile for
  Declare Xtal = 16
  Declare Hserial_Baud = 9600       ' UART1 Baud rate
  Declare Hrsout1_Pin = PORTB.14    ' Select pin is to be used for TX
'
' Create a 32-bit flash memory table
'
  Dim CodeArray As Code = as Dword 100, 200, 300, 400, 500, 600, 700, 0
  Dim MyDword As Dword              ' Create a dword variable
  Dim bIndex As Byte
  Dim wAddress As Word             ' Create variable to hold 16-bit address

Main:
  RPOR7 = 3                         ' Make PPS Pin RP14 U1TX
'
' Read from code memory
'
  wAddress = AddressOf(CodeArray)   ' Load wAddress with address of memory
  Do                                ' Create a loop
     MyDword = cPtr32(wAddress++)   ' Retrieve from flash memory with post increment
     If MyDword = 0 Then Break      ' Exit when a null(0) is read from flash
     HRSOutLn Dec MyDword           ' Transmit the dword read from flash
  Loop

See also: AddressOf, Cread8, Cread16, Cread24, Cread32, Cread64,

cPtr8, cPtr16, cPtr24, cPtr32, cPtr64.

View original PDF page 386Open page in PDFOriginal PDF page 386