User guide
11.1. MC EXAMPLE 189
// MV A,A1
movl 20(%ebp), %eax
573: 8B 45 14
// ADD A,A2
addl 24(%ebp), %eax
576: 03 45 18
// LAB L1
lab L1
579: L1:
// ADD A,A3
addl 28(%ebp), %eax
579: 03 45 1C
// DEC A
decl %eax
582: 48
// CMP A,$100
cmpl $100, %eax
583: 83 F8 64
// JLT L1
jl L1
586: 7C F7
// DEBUG 3
// RTN
// ENDFN
// END
F1(10, 20, 30) => 117
The re sul t of 117 (= 10+20+(30-1)*3) shows that the body of the loop was correctly
executed three times.
The header file (mc.h) defines manifests (such as mc
mv and mc add) and globals
(such as mcK and mcRA) provided by the package. The package itself must be dynami-
cally loaded (by globin(loadseg("mci386"))) and then selected (by mcSelect(mcb)).
MC instructions are compil ed by calls such as mcRA(op,... or mcRK(op,... where op
specifies the instruction or directive and the letters following mc (eg RA or RK) specify
the sort of operands supplied.
A register operand is denoted by R and an integer operand by K. There are 9 possible
kinds of memor y operands denoted by A, V, G, M, L, D, DX, DXs and DXsB. A denotes an
specified argume nt of the current function, V denotes a specified l ocal variable of the
current function, G denotes a specified BCPL global variable, M denotes a location in
Cintcode memory specified by a BCPL pointer, L denotes the position within the data
or code areas of the compiled code corresponding to a gi ven label, D denotes a speci fie d
absolute machine address, DX denotes a location whose machine address is the sum of
a given byte offset and register, DXs is similar to DX only the index register is scaled
by a given factor of 1, 2, 4 or 8 and finally DXsB is like DXs but has a second specified
register added int o the effective address.
The following table summarises the MC code generation functions. The first ar-
gument is always specifies the directive or ins tr uc t i on and the remaining arguments
specify the operands. The destination of any i n st ru ct i on that updates a register or
memory location is always the first operand.