To finish with the topic of this thread, I leave an example with the updated function to assign a pointer to a variable using a simple code in machine code. The function allows you to assign the pointer to any type of variable and even to functions. The example in this case only considers array, byte and string data collections. In any case, the string data in the most recent IDE updates now allows you to work with pointers natively in the language, but this will be for another thread.
Example:
'Pointer assignment from ASM Pic18
'By Cos, 2024/04/21, PSI Compiler Pic18, v5.45
'---------------------------------------------------
#define STRING_MAX_LENGTH = 70
'Include "_Pic18F26K22Library.bas"
'---------------------------------------------------
'Variables
Dim List(5) As Byte
Dim StrAisNMEA[5] As String
'Pointers
Dim P_List As Word
Dim P_StrAisNMEA As Word
'Pointer Assignment Pic18
ASM: LFSR 2, List
P_List = _PointerWord()
ASM: LFSR 2, StrAisNMEA
P_StrAisNMEA = _PointerWord()
While True
Wend
End
'Pointer assignment Pic18
Function _PointerWord() As Word
Symbol _Return_HB = _PointerWord.HB
Symbol _Return_LB = _PointerWord.LB
ASM: MOVFW FSR2H
ASM: MOVWF _Return_HB
ASM: MOVFW FSR2L
ASM: MOVWF _Return_LB
End Function
As can be seen in the window capture of the "Watch Variables" simulator, the variables P_List and P_StrAisNMEA contain the address of the first element of List and StrAisNMEA respectively.
Of course this is convenient to do at the beginning of the main and before activating the interrupts if they are used.