4 Using ST20-C1 instructions
ssinc writes the half word in the two least significant b ytes of Breg to the location
addressed by Areg.
4.2.4 Memory block copy
A block memory copy may be implemented using the instructions lwinc and swinc.
These instructions load or store a word, and increment the addresses used.
To copy n bytes from source to destination, where source and destination are both
word-aligned, a loop should be written, using the temporary variable limit, as in the
following code:
ld source; ld n; ld destination
add; stl limit
LOOP: lwinc; rev; swinc
ldl limit; arot
gt; cj END; j LOOP;
END:
This is the most efficient method of copying, since it reads and writes full words,
making the best use of any 32-bit memory. However, this is not always possible if the
alignment of the source and destination blocks are different. In that case the byte or
half-word load and store should be used.
4.3 Expression evaluation
Expression evaluation and address calculation is performed using the evaluation
stack. For example, the evaluation of operations with two integer operands is
performed by instructions that operate on the values of Areg and Breg. The result is
left in Areg.
Arithmetic and boolean calculations are considered in sections 4.4 and 4.7 respec-
tively. This section describes how the evaluation stack is used. Loading and storing
instructions are described in section 4.2.
In this and subsequent sections, in examples of assembly code, a single letter or iden-
tifier wr itten as an instruction is either an expression or a segment of code. If it is an
expression then it means ‘evaluate the expression and leave the result in the Areg.
4.3.1 Using the evaluation stack
A compiler normally loads a constant expression c using ldc:
ldc c
Loading from a constant table is described in section 4.3.3.
An expression consisting of a single local variable is loaded using
ldl x
Methods for loading non-local variables are discussed in section 4.2, and array
elements in section 4.5.
33/205
®