Chapter 7. PAVM: The Programmable Agent Platform
222
7.3.1 Program Code Frame
An FORTH code frame (see Figure 7.4) starts with a fixed size boot section
immediately followed by a program lookup relocation table (LUT). The instruc-
tions in the boot section are used to
Set up the LUT offset register LP (always the first instruction);
Enable program parameter loading (passed by the data stack);
Restore stack content after migration or program suspending;
Branch the program flow to the transition table section.
The program counter IP points to the next instruction to be executed. The
LUT is a reserved area in the program frame initially empty, and is used by the
VM to relocate variable, word, and transition table row references. A LUT row
consists of the entries: {Type, Code Offset, Code Frame, Secondary Offset}. Possi-
ble row types are: Type = {FREE, PAR, VAR, ACT, FUN, FUNG, SIGH(S), TRANS}. The
signal handler type SIGH is indeed a negative value, specifying the signal num-
ber S that is related to the signal handler.
Within the program code, all address references from the frame objects,
i.e., variables, user defined words, and transitions, are relocated by the LUT at
run-time. This indirect addressing approach eases the reconfiguration of the
program code at run-time and the code migration significantly. If a program
frame is executed the first time or after a migration, the code frame is exe-
cuted on top-level, where the LUT is updated and filled with entries by
processing all object definitions of the frame from the beginning to the end.
Code inside user defined words are bypassed in this initialization phase. Vari-
able, parameter, and word definitions (var V, par P
, :W ) update at
initialization-time entries in the LUT (code offset, code frame), and transition
branches ?A updates entries at run-time (secondary offset specifying the rela-
tive offset of an activity call in the transition table section). On programming
AFL level, generic function, activity, and signal handler word definitions are dis-
tinguished by different syntax (:F, :*A, :$S), whereas not on machine
instruction AML level (DEF).
After the LUT section, parameter and variable object definitions (private
agent data) follow and some top-level instructions used to initialize agent
parameters with values passed by the data stack.
The main part of the code frame consists of activity, function, and signal
handler word definitions (:F .. ;, :*A .. ;, :$S .. ;, with names F/A/S,
respectively).
Finally, the transition table section is defined (:%T ..;). A transition table
consists of transition rows, which group all transitions outgoing from one spe-
cific activity, discussed later. Because of more than one transition table can be
defined, but only one may be used by a process at one time, a top-level transi-
S. Bosse, Unified Distributed Sensor and Environmental Information Processing with Multi-Agent Systems
epubli, ISBN 9783746752228 (2018)