User guide
3.3. GLOBAL FUNCTIONS 69
directory. If a val i d module is not found ther e and name is a relative file name, it
searches through the directories specified by the environment variable whose name
is in the rtn
pathvar element of the rootnode. This name is normally BCPLPATH
under Cintsys and POSPATH under Cintpos. See Section 3.6 for more information about
environment variables.
If l oadi ng is successful, loadseg returns the list of loaded program sections, other-
wise it returns zero. Before the loaded c ode can be used, its gl obal s must be initial i se d
using globin.
Cintcode modules generated by the BCPL compiler are typically text files con-
taining the compiled code encoded in hexadecimal. The compiled form of the logout
command:
SECTION "logout"
GET "libhdr"
LET start() BE abort(0)
is
000003E8 0000000E
0000000E 0000FDDF 474F4C0B 2054554F 20202020
0000DFDF 6174730B 20207472 20202020 7B1C2310
00000000 00000001 00000024 0000001C
The first two words (000003E8 0000000E) indicate the presence of a “hunk” of code
of size 14(000000E) words whi ch then follow. The first word of the hunk (000000E)
is again its length. The next four words (0000FDDF 474F4C0B 2054554F 20202020)
contain the SECTION name "logout". These are followed by the four words 0000DFDF
6174730B 20207472 20202020 which hold the name of the function "start". The
body of start is compiled into one word (7B1C2310) which correspond to the Cintcode
instructions:
L0 Load A wi th 0
K3G 28 Call the func ti on in global 28, incrementing the stack by 3
RTN Return from start – never reached
The remaining 4 words contain global initial i sat i on data that is read backwards during
global initialisation invoked by sys(Sys
globin,...). 0000001C (=28) is the highest
global variable referenced by this section. The pair 00000001 00000024 specifies that
the entry point at position 36 is t he initial value of global 1, and the next entry
(00000000) marks the end of the global i ni ti al i s ati on data.
The manifest constants t hunk, t reloc, t end, t hunk64, t reloc64, t end64,
t
bhunk, and t bhunk64 are declared in libhdr for the convenience of p r ogram s that
generate or read Cintsys and Cintpos object modules. The example above shows t
hunk
loading n 32-bit words encoded in hex bytes. Although the BCPL compile r used in both
Cintsys and Cintpos generates position independent code and has no need to modify
the loaded words of a hunk, other languages may need to perform relocation. This can
be done using t reloc which is followed by a 32-bit word n encoded in hex followed by a
further n words which each give the position of a word in the most recently loaded hunk