Index | PAL Intro | Commands | Registers | Indices | Stack | Macros | Classes | Attributes | Errors
reg/load() - Define/iterate a walker
Synopsis
Description
Indirect Addressing
Error Handling
Examples
See Also
Author
reg/load write, (![target])
reg/load write, (walker)
A walker is a data structure that allows for iteration of nodes on a branch in the nexus. The reg/load instruction may be used to initialise a new walker and then return successive nodes in a branch. Use reg/clr to close down the walker. Note that nodes or branches may be locked when a walker is open on them, so they must not be left open longer than necessary.
In the first synopsis form above, initialises a new walker. The walker status will be stored in the register provided in the write argument (type PSUNIT_TYPE_WALKER), and the branch to be walked will be that directly underneath the node pointed to by the target argument. If the node does not have a branch underneath it, a NULL will be stored in the write argument.
In the second synopsis form, returns in the write argument a pointer to the next node to be iterated by the walker. The walker argument is a pointer to an initialised walker structure. If all nodes on the branch have already been iterated by this walker and there are none remaining, the instruction will return NULL in the write argument.
Using parentheses ( ) with the reg/load instruction invokes the indirect addressing behaviour described above when the initialisation command is provided with a pointer to a node.
See the reg_load(5) manual page for a description of other functionality available with this command.
A runtime error is generated if an object referenced in the target argument does not exist.
The following example dumps the nodes underneath the .prose.code branch in the nexus.
.main % Initialise a walker reg/load P0, (![.prose.code]) reg/jmpeq &[.loop_end], P0, NULL
.loop % Read next node on branch reg/load P1, (P0)
% Break out of loop if end of branch reached reg/jmpeq &[.loop_end], P1, NULL
% Debug node and continue loop obj/dump P1 local/jmp &[.loop]
.loop_end % Tidy up and exit reg/clr P0 func/rtn
pal_commands(5), pal_registers(5), pal_indices(5), reg_load(5), reg_clr(5),
PROSE Assembly Language at prose.sourceforge.net.
Copyright (c) 2002-2008 Mark R. Bannister <cambridge@users.sourceforge.net>.
This is free software and can be downloaded from prose.sourceforge.net; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
PAL 1.0 | reg_load_walker (5) | 1 December 2008 |