As in variable pointers not as in “tips”.
The Atom Pro compiler supports a new variable type called “pointer”. here is an example program that uses one.
[code]temp var pointer
temp2 var long
main
temp = @TEMP2 ;temp = the address of temp2
@temp = 0x1234 ;set the value of the memory location temp points at to 0x1234
serout s_out,i9600,"temp2 set by ptr = ",hex temp2,13]
pause 100
temp2 = 0
serout s_out,i9600,"temp2 set directly = ",hex temp2,13]
pause 100
goto main[/code]
The two new items are the “pointer” variable type and the “@” modifier. The @ modifer tells the compiler to use the value of the variable as the address of the target/source. The address consists of the byte address and type information. The low 16bits are the byte address. Type information is stored in the high 16bits. Pointers are equivilent to long variables but with a type flag that indicates they can be used as a pointer.
So you could use a pointer type variable in an argument of a subroutine and pass along the address of the variable you really want to access like so:
[code]temp1 var long
temp2 var long
temp1 = 0x1234
temp2 = 0x4321
main
gosub test@temp1]
gosub test@temp2]
goto main
arg var pointer
test [arg]
serout s_out,i9600,"Value is ",hex @arg,13]
pause 100
return[/code]
In this example I am passing the address of temp1 or temp2 to the subroutine and displaying the value stored at the address.
Note that the variable type that the pointer points at doesn’t matter. Here is a slightly modified version of the above sample showing me sending a long and then a word sized variable address to the subroutine.
[code]temp1 var long
temp2 var word
temp1 = 0x12345678
temp2 = 0x87654321
main
gosub test@temp1]
gosub test@temp2]
goto main
arg var pointer
test [arg]
serout s_out,i9600,"Value is ",hex @arg,13]
pause 100
return[/code]
Pointers can also be used to return values from a subroutine without using a value in the return statement or in addition to the value in the return.
[code]temp1 var long
main
temp1 = 0x12345678
serout s_out,i9600,"Value is ",hex temp1,13]
pause 100
gosub test@temp1]
serout s_out,i9600,"Value is ",hex temp1,13]
pause 100
goto main
arg var pointer
test [arg]
@arg = 0
return[/code]