Positron Compiler Documentation

Ptr8, Ptr16, Ptr32, Ptr64

Positron16 · Revision 1.1.3.5 · PDF pages 343–345

Assignment Variable = Ptr8 (Address) Assignment Variable = Ptr16 (Address) Assignment Variable = Ptr32 (Address) Assignment Variable = Ptr64 (Address)

or

Ptr8 (Address) = Variable Ptr16 (Address) = Variable Ptr32 (Address) = Variable Ptr64 (Address) = Variable

Indirectly address RAM for loading or retrieving using a variable to hold the 16-bit address.

Variable is a user defined variable that holds the result of the indirectly address RAM area, or the variable to place into the indirectly addressed RAM area. Address is a Word variable that holds the 16-bit address of the RAM 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.

Ptr8 will load or retrieve a value with an optional 8-bit post or pre increment or decrement. Ptr16 will load or retrieve a value with an optional 16-bit post or pre increment or decrement. Ptr32 will load or retrieve a value with an optional 32-bit post or pre increment or decrement. Ptr64 will load or retrieve a value with an optional 64-bit post or pre increment or decrement.

8-bit Example.

'
' Load and Read 8-bit values indirectly from/to RAM
'
  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

  Dim MyByteArray[20] As Byte          ' Create a byte array
  Dim MyByte As Byte                   ' Create a byte variable
  Dim bIndex As Byte
  Dim wAddress as Word               ' Create a variable to hold address
View original PDF page 343Open page in PDFOriginal PDF page 343
Main:
  RPOR7 = 3                         ' Make PPS Pin RP14 U1TX
'
' Load into RAM
'
  wAddress = AddressOf(MyByteArray) ' Load wAddress with address of array
  For bIndex = 19 To 0 Step -1      ' Create a loop
     Ptr8(wAddress++) = bIndex      ' Load RAM with address post increment
  Next
'
' Read from RAM
'
  wAddress = AddressOf(MyByteArray) ' Load wAddress with address of array
  Do                                ' Create a loop
     MyByte = Ptr8(wAddress++)       ' Retrieve from RAM with post increment
     HRSOut Dec MyByte, 13          ' Transmit the byte read from RAM
     If MyByte = 0 Then Break       ' Exit when a null(0) is read from RAM
  Loop

16-bit Example.

' Load and Read 16-bit values indirectly from/to RAM
'
  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

  Dim MyWordArray[20] As Word        ' Create a word array
  Dim MyWord As Word                 ' Create a word variable
  Dim bIndex As Byte
  Dim wAddress as Word               ' Create a variable to hold the address

Main:
  RPOR7 = 3                            ' Make PPS Pin RP14 U1TX
'
' Load into RAM
'
  wAddress = AddressOf(MyWordArray)   ' Load wAddress with address of array
  For bIndex = 19 To 0 Step -1         ' Create a loop
     Ptr16(wAddress++) = bIndex        ' Load RAM with address post increment
  Next
'
' Read from RAM
'
  wAddress = AddressOf(MyWordArray)   ' Load wAddress with address of array
  Do                                  ' Create a loop
     MyWord = Ptr16(wAddress++)        ' Retrieve from RAM with post increment
     HRSOut Dec MyWord, 13             ' Transmit the word read from RAM
     If MyWord = 0 Then Break          ' Exit when a null(0) is read from RAM
  Loop
View original PDF page 344Open page in PDFOriginal PDF page 344

32-bit Example.

' Load and Read 32-bit values indirectly from RAM
'
  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

  Dim MyDwordArray[20] As Dword      ' Create a dword array
  Dim MyDword As Dword               ' Create a dword variable
  Dim bIndex As Byte
  Dim wAddress as Word               ' Create a variable to hold the address

Main:
  RPOR7 = 3                          ' Make PPS Pin RP14 U1TX
'
' Load into RAM
'
  wAddress = AddressOf(MyDwordArray)  ' Load wAddress with address of array
  For bIndex = 19 To 0 Step -1        ' Create a loop
     Ptr32(wAddress++) = bIndex        ' Load RAM with address post increment
  Next
'
' Read from RAM
'
  wAddress = AddressOf(MyDwordArray)  ' Load wAddress with address of array
  Do                                  ' Create a loop
     MyDword = Ptr32(wAddress++)       ' Retrieve from RAM with post increment
     HRSOut Dec MyDword, 13            ' Transmit the dword read from RAM
     If MyDword = 0 Then Break         ' Exit when a null(0) is read from RAM
  Loop

See also: AddressOf, cPtr8, cPtr16, cPtr32, cPtr64.

View original PDF page 345Open page in PDFOriginal PDF page 345