4 Using ST20-C1 instructions
constant from the nth entry in the constant table stored at address constants_ptr the
following code would be used:
ldl constants_ptr ; ldnl n;
where the instruction ldnl n is explained in section 4.2.2.
This code sequence only takes 2 bytes, provided constants_ptr is less than 16 words
from the work space pointer address and there are no more than 16 word-length
constants. At worse it is unlikely to take more than 4 bytes. Hence, if a constant takes
4 or more bytes to load using ldc then this sequence often improves code compact-
ness — especially if the constant is used more than once.
4.3.4 Assignment
Single words, half words and bytes may be assigned using the load and store instruc-
tions described in section 4.2.
Word assignment
If x and y are both single word variables and e is a word valued expression then word
assignments are compiled as
x=y
compiles to
ld y; st x;
x=e
compiles to
e; st x;
Byte assignment
If a and b are both single byte variables and e is a byte valued expression then byte
assignments are compiled as
b=a
compiles to
address(a); lbinc; address(b); sbinc;
b=e
compiles to
e; address(b); sbinc;
where address(variable) is the address of variable. Forming addresses is discussed in
section 4.5.
Half word assignment
If a and b are both half-word variables and e is a half-word valued expression then
half-word assignments are compiled as
b=a
compiles to
address(a); lsinc; address(b); ssinc;
b=e
compiles to
e; address(b); ssinc;
where address(variable) is the address of variable. Forming addresses is discussed in
section 4.5.
4.4 Arithmetic
This section describes the use of the arithmetic instructions except for the multiply-
accumulate instructions, which are described in Chapter 5, and forming addresses,
which is described in section 4.5. Boolean expression evaluation is discussed in
35/205
®