User guide
11.3. THE MC LANGUAGE 193
When an MC function is decl ar ed it has a specified number of arguments and local
variables (see the ENTRY statement below). When a function is called by the CALL
instruction, the required number of arguments must have already been pushed onto the
stack. On return these argu ments will have been automatically popped from the stack.
If the wrong number of arguments are given, the effect is undefined. By convention,
the result of a function is returned in register A.
Numeric labels are used to refer to static data and positions i n the code. They
are alloc ate d by calls of mcNextlab, described above. Many architect ur e s allow both
conditional and unconditi onal jumps to use short offse ts (typically single bytes) to
specify the relative address of the destinati on . Jump i nst r uc ti ons automatically use
short relative addre ss e s for backward jumps if possible, but, for forward jumps, the
programmer is required to give a hint. Jump instructions compiled by mcJS expect
forward jumps to use short relat i ve addresses while mcJL specifies that larger relative
addresses are to be used. If a short relative address proves insufficent and error message
is generated telling the programmer that mcJL should have been use d. The function
mcJR is use d when the destination address of a jump instruction is in a register.
Conditional jump instructions inspect the condition code to determine whether or
not to jump. The condition code is set by the CMP, ADD, ADDC, SUB and SUBC instructions
and preserved by jump instructions (JMP and Jcc). All ot he r instructions (including
INC and DEC leave the condition code undefined.
All MC directives and instructions are described below in al phabetical order. The
name of the operation is given in bold caplital letter s together with the list of possible
operand types. The BCPL manifest for the operation consists of the name in lower
case letters preceeded by mc
. For example, mc add is the manifest constant for the
ADD operation, and since RDXs appears in its li st of operand types, it can be compiled
by, for instance, mcRDXs(mc
add, mc a, 20, mc d, 4).
ADD RA RV RG RM RL RD RDX RDXs RDXsB
RR AR VR GR MR LR DR DXR DXsR DXsBR
RK AK VK GK MK LK DK DXK DXsK DXsBK
Add the second operand into the fir s t and set the condit i on code appropriately. For
example, mcRG(mc add, mc d, 150) will compile c ode to add global 150 in register D.
ADDC RA RV RG RM RL RD RDX RDXs RDXsB
RR AR VR GR MR LR DR DXR DXsR DXsBR
RK AK VK GK MK LK DK DXK DXsK DXsBK
Add the condition code carry bit and the second operand into the first an d set the
condition code appropriately. Adding 1 into the 64-bit value held in B:A can be done
by the code generated by:
mcRK( mc_add, mc_a, 1) // Don’t use INC here!
mcRK( mc_addc, mc_b, 0)
ALIGNC K
Align the next instructi on to an address which is a multiple of k which must be 2,
4 or 8.