Source code: nxdump.pal

From PROSE Programming Language - Wiki
Jump to: navigation, search
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% nxdump.pal
% Author: Mark R. Bannister
% Date: 17/Feb/2007
%
% Creates the system function tools.nxdump() for dumping all nodes in nexus
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

~Module
EQUS {[sys.tools]}

._init
func/def	[nxdump], &[.dump]
local/rtn

.dump
stack/lock
reg/load	PUSH, (![.prose])
obj/dump	PEEK

.loop
reg/load	P0, (PEEK)
reg/jmpeq	&[.loop_next], P0, NULL
obj/dump	P0
reg/load	P1, (P0)
reg/jmpeq	&[.loop], P1, NULL

stack/push	P1
local/jmp	&[.loop]

.loop_next
reg/clr		PULL
reg/jmpneq	&[.loop], PEEK, LOCK
stack/unlock
func/rtn