Restore the contents of RAM 0-15 (variables b0-b15) from the 4 level 'RAM stack'.
To reuse variables within a macro/sub-procedure it can be useful to 'free up' variables so that they can be reused as temporary variables within the macro. The pushram command pushs the contents of b0-b15 onto the ram stack so that they can then be reused for other purposes. The popram command then restores the original values at the end of the macro.
The 4-level stack used for pushram and popram is separate to the stack used for push and pop commands.
Protecting variable values
Before calling a subroutine a 'pushram' is executed so variables can be restored, if the subroutine uses those variables and alters their values. After the subroutine completes a 'popram' must be executed to restore the original variable values as they were previously.
Use within subroutine
On entry into the subroutine a 'pushram' is used to allow re-use of variables within the routine. At the end of the routine, before any return, a 'popram' must be executed to restore the original variable values as they were outside the subroutine.
Submit Your Own Code!
You must be logged in to submit code examples. Login now.