If using the X2's there's PUSH and POP, PUSHRAM and POPRAM which can be used to that effect. The command descriptions are yet to be added to Manual 2 but is available online ...I really wish subroutines had their own variable space.
A problem with implementing block structured languages with local variables is all the context saving and restoring.I really wish subroutines had their own variable space
On non-X2's it is possible to use the RAM and 'bptr' variable to implement a LIFO stack and use macros to create PUSH and POP equivalents ...Thanks for that, but I have to use the 18M2 since that is what you guys put on the OLED. 8^)
#Picaxe 18m2
#Terminal 4800
#Macro PUSH(bytevar)
dec bptr
@bptr = bytevar
#EndMacro
#Macro POP(bytevar)
bytevar = @bptrInc
#EndMacro
Pause 2000
For b0 = 1 To 10
SerTxd( #b0, " " )
Gosub MySub
SerTxd( #b0, CR, LF )
Next
End
MySub:
PUSH(b0)
b0 = 99
SerTxd( #b0, " " )
POP(b0)
Return
Not quite, but, scroll down to #That I have, but MACRO does not seem to have made it to the manual, yet