User manual

ST Assembler-Linker ST7 and STM8 addressing modes
Doc ID 11392 Rev 4 13/89
www.st.com. This chapter only gives a brief explanation of the main addressing mode
types.
3.2 General instruction syntax
The ST7 and STM8 instruction sets provide a single source-coding model regardless of
which components are operands.
For the ST7 the operands may be:
–the accumulator (A),
an 8-bit index register (X or Y)
an 8-bit stack pointer (S)
the condition code register (CC), or a memory location.
For the STM8 the operands may be:
–the accumulator (A),
a 16-bit index register (X or Y)
XH,XL (where XH is the high byte, and XL is the low byte)
YH,YL (where YH is the high byte, and YL is the low byte)
a 16-bit stack pointer (SP)
the condition code register (CC), or a memory location.
For example, a single instruction, ld, originates register to register transfers as well as
memory to accumulator data movements.
Two-operand instructions are coded with the destination operand in the first position.
For example,
lab01 ld A,memory ; load accumulator A with memory contents
lab02 ld memory,A ; load memory location with A contents
ld X,A ; load X with accumulator contents (ST7 only)
ld XL,A ; load XL with accumulator contents (STM8 only)
3.3 Short and long addressing modes
The ST7 has two addressing modes that differ in memory address size (one byte for short
mode and two bytes for long mode).
For the STM8, in addition to long and short modes, there is also an extended addressing
mode (three bytes).
Because of these different addressing modes, the target address range of the operands
depends upon the addressing mode chosen:
0-$FF for short addressing mode
$100-$FFFF for long addressing mode
$10000-$FFFFFF extended addressing mode (STM8 only)
Some instructions accept both long and short addressing modes, while others only accept
one or the other. For example:
lab10 add A,memory ; accepts both types of addressing modes
lab11 inc memory ; ST7 instruction accepts only short