User guide
192 CHAPTER 11. THE MC PACKAGE
mcRK(mc_mv, A, #x10000000)
mcPRF("With D=%8x ", D)
mcPRF("A=%8x ", A)
mcPRF("B=%8x*n", B)
mcR(mc_div, B)
mcPRF("the instruction: DIV B*n")
mcPRF("gives D=%8x ", D)
mcPRF("A=%8x ", A)
mcPRF("B=%8x*n", B)
This causes the following output:
With D= 1234567 A=89abcdef B=10000000
the instruction: DIV B
gives D= 9abcdef A=12345678 B=10000000
n := mcNextlab()
Allocate the next available label assigni ng its number to n. Labels are use by
instructions that refer to static data and in jump instructions. There i s essentially no
limit to the number of labels that may be allo c ate d.
mcComment(format, a, b,..., k)
This is a debugging aid to make the compiled code more readable using writef to
write a message to the l i st i ng output during code generation if the least significant bit
of mcDebug is a one. The variable mcDebug is set by the DEBUG direct i ve described
below.
res := mcDatap()
res := mcCodep()
These calls return the current positions in the data and code area respectively.
All the other functions compile MC directives and instructions and are described
below.
11.3 The MC La ng ua g e
The MC abstract machine language is fairly low level and is somewhat influenced by
the i386 architecture. Particularly the rather small number of MC registers allowed, the
rich variety of memory addr e ss i ng modes and the specification of the instructions for
multiplication, division and shifts. However, it is machine independent and reasonably
easy to compile into native machine code for most machines. Before describing the
MC instructions, a few key fe at ur es will be introduced. As mentioned earlier the
MC machine has six registers named A to F which are typically mapped directly onto
machine registers of the target architecture. These can be used for any purpose except
for a few instructions such as MUL, DIV and the shifts which may implicitly use some of
them implicitly.