80/317
4 - Architecture of the ST7 core
Example:
At address 1200h, the following instruction:
JRA 11F1h
The absolute address supplied in the source code will be translated
into a relative displacement by the assembler.
is coded as:
20 EF
The two bytes of the instruction occupy addresses 1200h and 1201h. Thus, the nextinstruction
will be found at address
1202h. The offset is calculated from this displacement. The distance
between
1202h and 11F1h is -11h. In 8-bit, two’s complement, this is noted EFh.AddingEFh to
1202h yields 11F1, which is the address of the destination of the jump. It should be noted that
although the jump is relative, the operand of the jump instruction is the destination of the jump.
The assembler automatically calculates the difference. If the destination is out of reach, that is
farther than 127 bytes in either direction, the assembler generates an error message.
Relative indirect mode
This mode is also only used for Jump Relative instructions. The opcode is followed by a byte
that is the address in memory that contains the displacement.
Example: if the displacement
EEh is stored in the memory byte at address 58h, the following in-
struction is stored at address
1200h:
JRA [58h]
The value of the relative displacement is stored at the specified
memory address in page zero
is coded as:
92 20 58
The three bytes of the instruction occupy addresses 1200h to 1202h. Thus, the next instruction
will be found at address
1203h. The byte at address 58h is read, giving EEh or -12h that is
added to the Program Counter, giving
1203h - 12h = 11F1h
In this mode, the operand of the jump instruction is the address of the displacement. This dis-
placement must be supplied separately, if necessary by an expression that is calculated at as-
sembly time. Example:
Displ dc.b THERE - HERE
It is up to the programmer to supply the right expression
for the displacement, but the calculation with the actual
values will be performed by the assembler.