Compiled code: statements

Peter C. Capon, Pete J. Jinks · 1988

This chapter outlines code sequences for evaluating expressions and performing assignments for all Pascal types. It also describes sequences for control constructs such as while, for and if statements. Examples are given both for the PDP11 and 68000. For convenience, the compiled code is presented in assembly language form, rather than pure binary instructions. Standard assembly language conventions are used wherever possible, but the reader is warned that, particularly for the 68000, different assemblers may accept slight variations in the instructions as presented here. It is assumed that code is being generated in a one address style, on-the-fly, perhaps with some peephole optimisation. There is no attempt to make optimal use of registers. One main register is used as the accumulator, with occasional use of a second register in certain sequences, mainly for double length operations or for Booleans. For the PDP11 R3 is used for evaluating fixed point expressions with R2 occasionally used as the second register. Similarly D0 and sometimes D1 will be used in the 68000. As the compiled code sequences are considered it will become clear that there are ample registers available on the 68000, but a shortage of registers on the PDP11 means that R2 will sometimes be used for additional purposes.

Read the paper · More papers on PaperTik