78/317
4 - Architecture of the ST7 core
in memory below address
100h
. The assembler automatically takes care of this, by selecting
the appropriate addressing mode when possible.
Example: the instruction
LD A, 1234h
A is loaded with the value stored in an absolute extended memory
address.
loads the accumulator with the value stored in memory at address
1234h
. The coding of the in-
struction is (in hexadecimal):
C6 12 34
This instruction takes three bytes of memory. It should be noted that the most significant byte
of the address comes first.
Indexed mode
In this mode, the contents of register
X
(or
Y
if the prefix is used) is used as the address of the
data to read or write. As the index register is only 8-bit, the address is lower than 100h.
Example: if the register
X
contains the value
26h
, the instruction:
LD A, (X)
A is loaded with the value stored in a memory address in page
zero pointed to by the chosen index register.
loads the accumulator with the value stored in memory at address
26h
. The coding of the in-
struction is (in hexadecimal):
F6
This instruction takes only one byte of memory. This mode is used if the address of the op-
erand is not known at assembly time and must be calculated according to some rule.
Indexed with short offset mode
This mode works like indexed mode, but the instruction is followed by a byte, called displace-
ment or offset, whose value is added to the value in the index to get the effective address.
Example: to access byte 4 of a character string starting at
23h
in data memory, we first load
the
X
index with the value 4. Then, the instruction:
LD A, (23h,X)
A is loaded with the value of the RAM address memory pointed
to by the sum of the specified 8-bit offset and the contents
of the chosen index register.
loads the accumulator with the value stored in memory at address
27h
(
23
+
4
). The coding of
the instruction is (in hexadecimal):