
- •1 STM8 architecture
- •1.1 STM8 development support
- •1.2 Enhanced STM8 features
- •2 Glossary
- •3 STM8 core description
- •3.1 Introduction
- •3.2 CPU registers
- •4 STM8 memory interface
- •4.1 Program space
- •4.2 Data space
- •Figure 3. Address spaces
- •4.3 Memory interface architecture
- •Figure 4. Memory Interface Architecture
- •5 Pipelined execution
- •Figure 5. Pipelined execution principle
- •5.1 Description of pipelined execution stages
- •Figure 6. Pipelined execution stages
- •5.1.1 Fetch stage
- •5.1.2 Decoding and addressing stage
- •5.1.3 Execution stage
- •5.2 Data memory conflicts
- •5.3 Pipelined execution examples
- •5.4 Conventions
- •5.4.1 Optimized pipeline example – execution from Flash Program memory
- •5.4.2 Optimize pipeline example – execution from RAM
- •5.4.3 Pipeline with Call/Jump
- •Table 11. Legend
- •5.4.4 Pipeline stalled
- •Table 13. Legend
- •5.4.5 Pipeline with 1 wait state
- •Table 15. Legend
- •6 STM8 addressing modes
- •Table 16. STM8 core addressing modes
- •6.1 Inherent addressing mode
- •6.2 Immediate addressing mode
- •Table 19. Immediate addressing instructions
- •Figure 7. Immediate addressing mode example
- •6.3 Direct addressing mode (Short, Long, Extended)
- •Table 21. Available Long and Short Direct addressing mode instructions
- •Table 22. Available Extended Direct addressing mode instructions
- •Table 23. Available Long Direct addressing mode instructions
- •6.3.1 Short Direct addressing mode
- •Figure 8. Short Direct addressing mode example
- •6.3.2 Long Direct addressing mode
- •6.3.3 Extended Direct addressing mode (only for CALLF and JPF)
- •Figure 10. Far Direct addressing mode example
- •6.4 Indexed addressing mode (No Offset, Short, SP, Long, Extended)
- •Table 25. No Offset, Long, Short and SP Indexed instructions
- •6.4.1 No Offset Indexed addressing mode
- •Figure 11. No Offset Indexed addressing mode example
- •6.4.2 Short Indexed addressing mode
- •Figure 12. Short Indexed - 8-bit offset - addressing mode example
- •6.4.3 SP Indexed addressing mode
- •Figure 13. SP Indexed - 8-bit offset - addressing mode example
- •6.4.4 Long Indexed addressing mode
- •Figure 14. Long Indexed - 16-bit offset - addressing mode example
- •6.4.5 Extended Indexed (only LDF instruction)
- •Figure 15. Far Indexed - 16-bit offset - addressing mode example
- •6.5 Indirect (Short Pointer Long, Long Pointer Long)
- •Table 28. Overview of Indirect addressing instructions
- •Table 29. Available Long Pointer Long and Short Pointer Long Indirect Instructions
- •Table 30. Available Long Pointer Long Indirect Instructions
- •6.6 Short Pointer Indirect Long addressing mode
- •Figure 16. Short Pointer Indirect Long addressing mode example
- •6.7 Long Pointer Indirect Long addressing mode
- •Figure 17. Long Pointer Indirect Long addressing mode example
- •6.8 Indirect Indexed (Short Pointer Long, Long Pointer Long, Long Pointer Extended) addressing mode
- •6.9 Short Pointer Indirect Long Indexed addressing mode
- •Figure 18. Short Pointer Indirect Long Indexed addressing mode example
- •6.10 Long Pointer Indirect Long Indexed addressing mode
- •Figure 19. Long Pointer Indirect Long Indexed addressing mode example
- •6.11 Long Pointer Indirect Extended Indexed addressing mode
- •Figure 20. Long Pointer Indirect Extended Indexed addressing mode example
- •6.12 Relative Direct addressing mode
- •Table 36. Available Relative Direct instructions
- •Figure 21. Relative Direct addressing mode example
- •6.13 Bit Direct (Long) addressing mode
- •Table 38. Available Bit Direct instructions
- •Figure 22. Bit Long Direct addressing mode example
- •6.14 Bit Direct (Long) Relative addressing mode
- •Table 40. Available Bit Direct Relative instructions
- •Figure 23. Bit Long Direct Relative addressing mode example
- •7 STM8 instruction set
- •7.1 Introduction
- •Table 41. Instruction groups
- •7.2 Nomenclature
- •7.2.1 Operators
- •7.2.2 CPU registers
- •7.2.3 Code condition bit value notation
- •7.2.4 Memory and addressing
- •7.2.5 Operation code notation
- •7.3 Instruction set summary
- •7.4 Instruction set
- •ADDW
- •BCCM
- •BCPL
- •BREAK
- •BRES
- •BSET
- •BTJF
- •BTJT
- •CALL
- •CALLF
- •CALLR
- •CLRW
- •CPLW
- •DECW
- •DIVW
- •EXGW
- •HALT
- •INCW
- •IRET
- •JRxx
- •NEGW
- •POPW
- •PUSH
- •PUSHW
- •RETF
- •RLCW
- •RLWA
- •RRCW
- •RRWA
- •SLLW/SLAW
- •SRAW
- •SRLW
- •SUBW
- •SWAP
- •SWAPW
- •TNZW
- •TRAP
- •8 Revision history
- •Table 43. Document revision history

STM8 instruction set |
PM0044 |
|
|
7.2.5Operation code notation
ee |
extended order byte of 24-bit extended address |
ww |
high order byte of 16-bit long address or middle order byte of 24-bit extended address |
bb |
short address or low order byte of 16-bit long address or 24-bit extended address |
ii |
immediate data byte or low order byte of 16-bit immediate data |
iw |
high order byte of 16-bit immediate data |
rr relative offset byte in a range of [-128..+127]
7.3Instruction set summary
Table 42. |
Instruction set summary |
|
|
|
|
|
|
|
|
|
|
|||||||||
Mnemo |
|
|
|
Effect on CC register |
|
|
|
|
Example |
(1) |
Pipe |
|||||||||
Description |
|
|
|
|
|
|
|
|
|
|
|
|
|
Syntax example |
Operation |
op- |
Cycles |
|||
|
V |
I1 |
H |
I0 |
N |
Z |
|
C |
|
|
||||||||||
|
|
|
|
|
|
code(s) |
|
|
||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
carrytheifSetfrom R6 is |
thefromdifferentcarry bit C |
|
4 |
otherwisecleared |
|
|
otherwisecleared |
|
otherwisecleared |
|
carryaisthereifSet from R7 |
otherwisecleared |
|
|
|
|
|
ADC |
Add with carry |
- |
carryaisthereifSetfrom bit 3 to |
- |
R7ifSetis set |
R=$00ifSet |
|
ADC A,($12,SP) |
A ← A + M(SP+shortoff) + |
19 bb |
1 |
|
||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|||||||||
|
|
|
|
|
|
|
|
|
|
|
CC.C |
|
||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
carrytheifSetfrom R6 is |
fromdifferentthe carry bit C |
|
4 |
|
|
|
|
|
|
|
isthereifSeta carry from R7 |
|
|
|
|
|
|
ADD |
|
Add without |
- |
carryaisthereifSet from bit 3 to |
clearedotherwise |
- |
R7ifSetis set |
clearedotherwise |
ifSetR=$00 |
clearedotherwise |
|
clearedotherwise |
ADD A,($12,SP) |
A ← A + M(SP+shortoff) |
1B bb |
1 |
|
|||
|
|
|
|
|
|
|
|
|
|
|
|
|
||||||||
|
carry |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- |
|
- |
|
- |
- |
|
- |
|
- |
|
- |
|
ADD SP,#$12 |
SP ← SP + imm.b |
5B ii |
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
carrytheifSetfrom R14 is |
thefromdifferentcarry bit C |
|
8 |
otherwisecleared |
|
|
otherwisecleared |
|
otherwisecleared |
|
carryaisthereifSet from R15 |
otherwisecleared |
|
|
|
|
|
ADDW |
|
Add word |
- |
carryaisthereifSetfrom bit 7 to |
- |
R15ifSetis set |
R=$0000ifSet |
|
ADDW X,($12,SP) |
X ←-X + M(SP+shortoff) |
72 FB bb |
2 |
|
|||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
||||||||
without carry |
|
|
|
|
|
|
|
|
|
|
|
|
||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AND |
Logical AND |
- |
|
- |
|
- |
- |
R7ifSetis set |
otherwisecleared |
R=$00ifSet |
otherwisecleared |
|
- |
|
AND A,($12,SP) |
A ← A AND |
14 bb |
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|||||||||||
|
|
|
|
|
|
|
|
|
M(SP+shortoff) |
|
||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64/162 |
Doc ID 13590 Rev 3 |

PM0044 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
STM8 instruction set |
||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||||
Table 42. |
Instruction set summary |
(continued) |
|
|
|
|
|
|
||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
Mnemo |
|
|
|
|
Effect on CC register |
|
|
|
|
|
|
Example |
(1) |
Pipe |
||||||||
Description |
|
|
|
|
|
|
|
|
|
|
|
|
|
Syntax example |
Operation |
op- |
Cycles |
|||||
|
V |
|
I1 |
H |
I0 |
N |
Z |
|
C |
|
|
|||||||||||
|
|
|
|
|
|
|
|
|
code(s) |
|
|
|||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BCCM |
|
Copy carry |
|
- |
|
- |
- |
- |
|
- |
|
- |
|
- |
|
BCCM $1234,#1 |
M(longmem).bit ← CC.C |
90 1n ww bb |
1 |
|
||
in memory bit |
|
|
|
|
|
|
n= 2*bit |
|
||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isR7ifSetset |
otherwisecleared |
R=$00ifSet |
otherwisecleared |
|
|
|
|
test {A AND |
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||
BCP |
|
Logical bit |
|
|
|
- |
- |
- |
|
|
|
|
|
- |
|
BCP A,($12,SP) |
M(SP+shortoff) } |
15 bb |
1 |
|
||
|
compare |
|
|
|
|
|
|
|
|
|
N and Z are updated |
|
||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
accordingly |
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||
BCPL |
Complement bit |
|
- |
|
- |
- |
- |
|
- |
|
- |
|
- |
|
BCPL $1234,#1 |
M(longmem).bit ← |
90 1n ww bb |
1 |
|
|||
|
in memory |
|
|
|
|
|
|
M(longmem).bit |
n= 2*bit |
|
||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BREAK |
|
Software |
|
- |
|
- |
- |
- |
|
- |
|
- |
|
- |
|
SW-BREAK |
|
|
|
8B |
1 |
Flush |
|
breakpoint |
|
|
|
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BRES |
|
Bit reset |
|
- |
|
- |
- |
- |
|
- |
|
- |
|
- |
|
BRES $1234,#1 |
M(longmem).bit ← 0 |
72 1n ww bb |
1 |
|
||
|
|
|
|
|
|
|
n= 1 + 2*bit |
|
||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BSET |
|
Bit set |
|
- |
|
- |
- |
- |
|
- |
|
- |
|
- |
|
BSET $1234,#1 |
M(longmem).bit ← 1 |
72 1n ww bb |
1 |
|
||
|
|
|
|
|
|
|
n= 2*bit |
|
||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bit test and |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
relative |
|
|
|
|
|
|
|
|
|
|
|
tested |
bit |
|
if M(longmem).bit=0 |
72 0n ww bb |
|
Flush |
||
|
|
condition is |
|
|
|
|
|
|
|
|
|
|
|
|
else PC ← PC + 4 |
|
||||||
BTJF |
|
jump if |
|
- |
|
- |
- |
- |
|
- |
|
- |
|
|
|
BTJF $1234,#1,label |
then PC ← PC + 4 + rr |
n= 1 + 2*bit |
2/3 |
(2) |
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
false |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bit test and |
|
|
|
|
|
|
|
|
|
|
|
tested |
|
|
if M(longmem).bit=1 |
|
|
|
||
|
|
relative |
|
|
|
|
|
|
|
|
|
|
|
bit |
|
72 0n ww bb |
|
Flush |
||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else PC ← PC + 4 |
|
|||||||
BTJT |
|
jump if |
|
- |
|
- |
- |
- |
|
- |
|
- |
|
|
|
BTJT $1234,#1,label |
then PC ← PC + 4 + rr |
n= 2*bit |
2/3 |
(2) |
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
condition is true |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
Call to |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PC← PC + 4 |
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
M(SP--) ← PCL |
|
|
|
|||
|
Subroutine with |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||
CALL |
|
- |
|
- |
- |
- |
|
- |
|
- |
|
- |
|
CALL [$1234.w] |
M(SP--) ← PCH |
72 CD ww bb |
6 |
Flush |
||||
|
address in |
|
|
|
|
|
|
|||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PCH← M(longmem) |
|
|
|
|||
|
same section |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PCL← M(longmem + 1) |
|
|
|
||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
Call to |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PC ← PC+4 |
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
M(SP--) ← PCL |
|
|
|
|||
|
|
subroutine |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||
CALLF |
|
|
- |
|
- |
- |
- |
|
- |
|
- |
|
- |
|
CALLF $123456 |
M(SP--) ← PCH |
8D ee ww bb |
5 |
Flush |
|||
with extended |
|
|
|
|
|
|
||||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
M(SP--) ← PCE |
|
|
|
||||
|
|
address |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PC ← extmem |
|
|
|
|||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PC ← PC + 4 |
|
|
|
||
CALLR |
Call Subroutine |
|
- |
|
- |
- |
- |
|
- |
|
- |
|
- |
|
CALLR label |
M(SP--) ← PCL |
AD bb |
4 |
Flush |
|||
|
relative |
|
|
|
|
|
|
M(SP--) ← PCH |
||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PC ← PC + rr |
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Complement |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CCF |
- |
|
- |
- |
- |
|
- |
|
- |
|
C |
CCF |
CC.C ← CC.C |
8C |
1 |
|
||||||
|
carry flag |
|
|
|
|
|
|
|||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
CLR |
|
Clears the |
|
- |
|
- |
- |
- |
0 |
1 |
|
- |
|
CLR ([$1234.w],X) |
M( M(longmem).w + X ) ← |
72 6F ww bb |
4 |
|
||||
destination byte |
|
|
|
|
0x00 |
|
||||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Clears the |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
X ← 0x0000 |
|
|
|
||
CLRW |
|
destination |
|
- |
|
- |
- |
- |
0 |
1 |
|
- |
|
CLRW X |
5F |
1 |
|
|||||
|
index register |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CP |
|
Compare |
(signedmem-AifSet values) |
clearedoverflows,otherwise |
- |
- |
- |
R7ifSetis set |
otherwisecleared |
R=$00ifSet |
otherwisecleared |
|
(unsignedA<memifSet values) |
otherwisecleared |
CP A,($12,SP) |
test { A - M(SP+shortoff) } |
11 bb |
1 |
|
|||
|
|
|
|
|
|
|
|
|
|
|
|
|||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Doc ID 13590 Rev 3 |
65/162 |

STM8 instruction set |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PM0044 |
|||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||||
Table 42. |
Instruction set summary |
(continued) |
|
|
|
|
||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
Mnemo |
|
|
|
|
Effect on CC register |
|
|
|
|
Example |
(1) |
Pipe |
||||||||
Description |
|
|
|
|
|
|
|
|
|
|
|
|
|
Syntax example |
Operation |
op- |
Cycles |
|||
|
V |
|
I1 |
H |
I0 |
N |
Z |
|
C |
|
|
|||||||||
|
|
|
|
|
|
|
code(s) |
|
|
|||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CPW |
Compare word |
XmmemifSet(signed values) |
clearedoverflows,otherwise |
|
- |
- |
- |
R15ifSetis set |
otherwisecleared |
R=$0000ifSet |
otherwisecleared |
|
(unsignedX<memifSet values) |
otherwisecleared |
CPW X,($12,SP) |
test { X - M(SP+shortoff) } |
13 bb |
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setisR7ifSet |
otherwisecleared |
R=$00ifSet |
otherwisecleared |
|
|
|
|
M(M(longmem).w +X) ← |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Logical 1’s |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FF - M(M(longmem).w+X) |
|
|
|
CPL |
|
|
|
|
|
- |
- |
|
|
|
|
|
1 |
CPL ([$1234.w],X) |
or |
72 63 ww bb |
4 |
|
||
|
complement |
|
|
|
|
|
|
|
|
|
|
|||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
M(M(longmem).w+X) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
XOR FF |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Logical 1’s |
|
|
|
|
|
|
R15ifSetis set |
otherwisecleared |
R=$0000ifSet |
otherwisecleared |
|
|
|
|
X ← FFFF - X |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
CPLW |
|
|
|
|
|
- |
- |
|
|
|
|
|
1 |
CPLW X |
or |
53 |
2 |
|
||
|
complement |
|
|
|
|
|
|
|
|
|
|
|||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
X XOR FFFF |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DEC |
Decrement byte |
signifSetoverflow |
otherwisecleared |
|
- |
- |
- |
R7ifSetis set |
otherwisecleared |
R=$00ifSet |
otherwisecleared |
|
- |
|
DEC ([$1234.w],X) |
M(M(longmem).w + X) ← |
72 6A ww bb |
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|||||||||||
|
by one |
|
|
|
|
|
|
|
|
|
M(M(longmem).w + X) - 1 |
|
||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DECW |
|
Decrement |
signifSetoverflow |
otherwisecleared |
|
- |
- |
- |
R15ifSetis set |
otherwisecleared |
R=$0000ifSet |
otherwisecleared |
|
- |
|
DECW X |
X← X - 1 |
5A |
1 |
|
|
|
|
|
|
|
|
|
|
|
|
||||||||||
|
word by one |
|
|
|
|
|
|
|
|
|
|
|||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Q=$0000ifSet |
otherwisecleared |
|
bydivideifSet0 |
otherwisecleared |
DIV X,A |
X ← X/A (Quotient) |
62 |
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
A ← X%A (Remainder) |
|
|||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||
|
|
16 by 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DIV |
|
Unsigned |
0 |
|
- |
0 |
- |
0 |
|
|
|
|
|
|
Y ← Y/A (Quotient) |
|
|
|
||
|
|
division |
|
|
|
|
|
|
|
|
|
|
|
|
|
DIV Y,A |
90 62 |
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
A ← Y%A (Remainder) |
|
|||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 by 16 |
|
|
|
|
|
|
|
|
Q=$0000ifSet |
otherwisecleared |
|
divideifSetby 0 |
otherwisecleared |
|
X ← X/Y (Quotient) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
DIVW |
|
Unsigned |
0 |
|
- |
0 |
- |
0 |
|
|
|
|
|
DIVW X,Y |
65 |
16 |
|
|||
|
|
|
|
|
|
|
Y ← X%Y (Remainder) |
|
||||||||||||
|
|
division |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EXG A,$1234 |
A ↔ M(longmem) |
31 ww bb |
3 |
|
|
|
Data byte |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EXG |
|
|
- |
|
- |
- |
- |
|
- |
- |
|
|
- |
|
EXG A,XL |
A ↔ XL |
41 |
1 |
|
|
|
exchange |
|
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EXG A,YL |
A ↔ YL |
61 |
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EXGW |
|
Data word |
|
- |
|
- |
- |
- |
|
- |
- |
|
|
- |
|
EXGW X,Y |
X ↔ Y |
51 |
1 |
|
|
exchange |
|
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Halt oscillator |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CC.I0 ← 0 , CC.I1 ← 1 |
|
|
|
|
HALT |
|
(CPU + |
|
- |
|
1 |
- |
0 |
|
- |
- |
|
|
- |
|
HALT |
Oscillator stopped till an |
8E |
10 |
|
|
|
Peripherals) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interrupt occurs |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66/162 |
Doc ID 13590 Rev 3 |

PM0044 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
STM8 instruction set |
||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||||
Table 42. |
Instruction set summary |
(continued) |
|
|
|
|
|||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
Mnemo |
|
|
|
|
Effect on CC register |
|
|
|
Example |
(1) |
Pipe |
||||||||
Description |
|
|
|
|
|
|
|
|
|
|
|
|
Syntax example |
Operation |
op- |
Cycles |
|||
|
V |
|
I1 |
H |
I0 |
N |
Z |
C |
|
|
|||||||||
|
|
|
|
|
|
code(s) |
|
|
|||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INC |
Increment byte |
signifSetoverflow |
otherwisecleared |
|
- |
- |
- |
R7ifSetis set |
otherwisecleared |
R=$00ifSet |
otherwisecleared |
|
- |
INC ([$1234.w],X) |
M(M(longmem).w + X) ← |
72 6C ww bb |
4 |
|
|
|
|
|
|
|
|
|
|
|
|||||||||||
|
by one |
|
|
|
|
|
|
|
|
M(M(longmem).w + X) + 1 |
|
||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INCW |
Increment word |
signifSetoverflow |
otherwisecleared |
|
- |
- |
- |
R15ifSetis set |
otherwisecleared |
R=$0000ifSet |
otherwisecleared |
|
- |
INCW X |
X ← X + 1 |
5C |
2 |
|
|
|
|
|
|
|
|
|
|
|
|||||||||||
|
by one |
|
|
|
|
|
|
|
|
|
|||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INT |
|
Interrupt |
|
- |
|
- |
- |
- |
|
- |
- |
|
|
- |
INT $123456 |
PC ← extmem |
82 ee ww bb |
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(++SP) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CC ← M(++SP) |
|
|
|
|
|
|
Updated according to the value pop |
|
A ← M(++SP) |
|
|
|
|||||||||||
|
|
|
|
X ← M(++SP); SP++ |
|
|
|
||||||||||||
IRET |
Interrupt return |
|
from the stack into CC register |
|
IRET |
80 |
11 |
Flush |
|||||||||||
|
|
Y ← M(++SP); SP++ |
|||||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PCE ← M(++SP) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PCH ← M(++SP) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PCL ← M(++SP) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Jump to an |
|
|
|
|
|
|
|
|
|
|
|
|
|
PC ← M(longmem).w + X |
|
|
|
JP |
|
address in |
|
- |
|
- |
- |
- |
|
- |
- |
|
|
- |
JP ([$1234.w],X) |
72 DC ww bb |
5 |
Flush |
|
|
|
section 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Jump to |
|
|
|
|
|
|
|
|
|
|
|
|
|
PC ← extmem |
|
|
|
JPF |
|
an extended |
|
- |
|
- |
- |
- |
|
- |
- |
|
|
- |
JPF $123456 |
AC ee ww bb |
2 |
Flush |
|
|
|
address |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JRA |
Unconditional |
|
- |
|
- |
- |
- |
|
- |
- |
|
|
- |
JRA Label |
PC ← PC + 2+ rr |
20 bb |
2 |
Flush |
|
relative jump |
|
|
|
|
|
||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if CC.C =1 |
|
|
Flush |
JRC |
Jump if C = 1 |
|
- |
|
- |
- |
- |
|
- |
- |
|
|
- |
JRC Label |
then PC ← PC + 2+ rr |
25 bb |
1/2 |
||
|
|
|
|
|
(2) |
||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else PC ← PC + 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Jump if Z = |
|
|
|
|
|
|
|
|
|
|
|
|
|
if CC.Z = 1 |
|
|
Flush |
JREQ |
|
|
- |
|
- |
- |
- |
|
- |
- |
|
|
- |
JREQ Label |
then PC ← PC + 2+ rr |
27 bb |
1/2 |
||
|
1(equal) |
|
|
|
|
|
(2) |
||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else PC ← PC + 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JRF |
|
Never Jump |
|
- |
|
- |
- |
- |
|
- |
- |
|
|
- |
JRF Label |
---------------- |
21 bb |
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if CC.H = 1 |
|
|
Flush |
JRH |
Jump if H = 1 |
|
- |
|
- |
- |
- |
|
- |
- |
|
|
- |
JRH Label |
then PC ← PC + 2+ rr |
90 29 bb |
1/2 |
||
|
|
|
|
|
(2) |
||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else PC ← PC + 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Jump if Port INT |
|
|
|
|
|
|
|
|
|
|
|
|
|
if Port INT pin =1 |
|
|
Flush |
|
JRIH |
|
- |
|
- |
- |
- |
|
- |
- |
|
|
- |
JRIH Label |
then PC ← PC + 2+ rr |
90 2F bb |
1/2 |
|||
|
pin = 1 |
|
|
|
|
|
(2) |
||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else PC ← PC + 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Jump if Port INT |
|
|
|
|
|
|
|
|
|
|
|
|
|
if Port INT pin = 0 |
|
|
Flush |
|
JRIL |
|
- |
|
- |
- |
- |
|
- |
- |
|
|
- |
JRIL Label |
then PC ← PC + 2+ rr |
90 2E bb |
1/2 |
|||
|
pin = 0 |
|
|
|
|
|
(2) |
||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else PC ← PC + 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Jump if |
|
|
|
|
|
|
|
|
|
|
|
|
|
if I0 AND I1 = 1 |
|
|
Flush |
JRM |
Interrupts are |
|
- |
|
- |
- |
- |
|
- |
- |
|
|
- |
JRM Label |
then PC ← PC + 2 + rr |
90 2D bb |
1/2 |
||
|
|
|
|
|
(2) |
||||||||||||||
|
|
masked |
|
|
|
|
|
|
|
|
|
|
|
|
|
else PC ← PC + 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Jump if N = |
|
|
|
|
|
|
|
|
|
|
|
|
|
if CC.N = 1 |
|
|
Flush |
JRMI |
|
|
- |
|
- |
- |
- |
|
- |
- |
|
|
- |
JRMI Label |
then PC ← PC + 2+ rr |
2B bb |
1/2 |
||
|
1(minus) |
|
|
|
|
|
(2) |
||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else PC ← PC + 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if CC.C =0 |
|
|
Flush |
JRNC |
jump if C = 0 |
|
- |
|
- |
- |
- |
|
- |
- |
|
|
- |
JRNC Label |
then PC ← PC + 2+ rr |
24 bb |
1/2 |
||
|
|
|
|
|
(2) |
||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else PC ← PC + 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Doc ID 13590 Rev 3 |
67/162 |

STM8 instruction set |
|
|
|
|
|
|
|
|
|
|
|
PM0044 |
||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
Table 42. |
Instruction set summary |
(continued) |
|
|
|
|
||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mnemo |
|
|
|
Effect on CC register |
|
|
|
Example |
(1) |
Pipe |
||||||
Description |
|
|
|
|
|
|
|
|
|
Syntax example |
Operation |
op- |
Cycles |
|||
|
V |
|
I1 |
H |
I0 |
N |
Z |
|
C |
|
|
|||||
|
|
|
|
|
|
|
code(s) |
|
|
|||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Jump if Z =0 |
|
|
|
|
|
|
|
|
|
|
if CC.Z = 0 |
|
|
Flush |
|
JRNE |
- |
|
- |
- |
- |
- |
- |
|
- |
JRNE Label |
then PC ← PC + 2+ rr |
26 bb |
1/2 |
|||
|
(not equal) |
|
|
(2) |
||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
else PC ← PC + 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if CC.H = 0 |
|
|
Flush |
JRNH |
Jump if H = 0 |
- |
|
- |
- |
- |
- |
- |
|
- |
JRNH Label |
then PC ← PC + 2+ rr |
90 28 bb |
1/2 |
||
|
|
(2) |
||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
else PC ← PC + 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Jump if |
|
|
|
|
|
|
|
|
|
|
if I0 AND I1= 0 |
|
|
Flush |
JRNM |
Interrupts are |
- |
|
- |
- |
- |
- |
- |
|
- |
JRNM Label |
then PC ← PC + 2 + rr |
90 2C bb |
1/2 |
||
|
|
(2) |
||||||||||||||
|
|
not masked |
|
|
|
|
|
|
|
|
|
|
else PC ← PC + 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if CC.C =0 |
|
|
Flush |
JRNV |
jump if V = 0 |
- |
|
- |
- |
- |
- |
- |
|
- |
JRNV Label |
then PC ← PC + 2+ rr |
28 bb |
1/2 |
||
|
|
(2) |
||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
else PC ← PC + 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Jump if |
|
|
|
|
|
|
|
|
|
|
if CC.N = 0 |
|
|
Flush |
JRPL |
|
- |
|
- |
- |
- |
- |
- |
|
- |
JRPL Label |
then PC ← PC + 2+ rr |
2A bb |
1/2 |
||
|
N = 0 (plus) |
|
|
(2) |
||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
else PC ← PC + 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Jump if |
|
|
|
|
|
|
|
|
|
|
if (CC.N xor CC.V) = 0 |
|
|
Flush |
JRSGE |
|
- |
|
- |
- |
- |
- |
- |
|
- |
JRSGE Label |
then PC ← PC + 2+ rr |
2E bb |
1/2 |
||
(N xor V) = 0 |
|
|
(2) |
|||||||||||||
|
|
|
|
|
|
|
|
|
|
|
else PC ← PC + 2 |
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Jump if |
|
|
|
|
|
|
|
|
|
|
if (CC.Z or (CC.N xor |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CC.V)) = 0 |
|
|
Flush |
|
JRSGT |
(Z or (N xor V)) |
- |
|
- |
- |
- |
- |
- |
|
- |
JRSGT Label |
2C bb |
1/2 |
|||
|
|
then PC ← PC + 2+ rr |
(2) |
|||||||||||||
|
|
= 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else PC ← PC + 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Jump if |
|
|
|
|
|
|
|
|
|
|
if (CC.Z or (CC.N xor |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CC.V)) = 1 |
|
|
Flush |
|
JRSLE |
(Z or (N xor V)) |
- |
|
- |
- |
- |
- |
- |
|
- |
JRSLE Label |
2D bb |
1/2 |
|||
|
|
then PC ← PC + 2+ rr |
(2) |
|||||||||||||
|
|
= 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else PC ← PC + 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Jump if |
|
|
|
|
|
|
|
|
|
|
if (CC.N xor CC.V) = 1 |
|
|
Flush |
JRSLT |
|
- |
|
- |
- |
- |
- |
- |
|
- |
JRSLT Label |
then PC ← PC + 2+ rr |
2F bb |
1/2 |
||
(N xor V) = 1 |
|
|
(2) |
|||||||||||||
|
|
|
|
|
|
|
|
|
|
|
else PC ← PC + 21 |
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JRT |
Jump relative |
- |
|
- |
- |
- |
- |
- |
|
- |
JRT Label |
PC ← PC + 2+ rr |
20 bb |
2 |
Flush |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if CC.C = 0 |
|
|
Flush |
JRUGE |
Jump if C = 0 |
- |
|
- |
- |
- |
- |
- |
|
- |
JRUGE Label |
then PC ← PC + 2+ rr |
24 bb |
1/2 |
||
|
|
(2) |
||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
else PC ← PC + 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Jump if |
|
|
|
|
|
|
|
|
|
|
if (CC.C = 0 and CC.Z = 0) |
|
|
|
JRUGT |
|
- |
|
- |
- |
- |
- |
- |
|
- |
JRUGT Label |
then PC ← PC + 2+ rr |
22 bb |
1/2 |
Flush |
|
|
(C+Z = 0) |
|
|
|||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
else PC ← PC + 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Jump if |
|
|
|
|
|
|
|
|
|
|
if (CC.C = 1 and CC.Z = 1) |
|
|
|
JRULE |
|
- |
|
- |
- |
- |
- |
- |
|
- |
JRULE Label |
then PC ← PC + 2+ rr |
23 bb |
1/2 |
Flush |
|
|
(C+Z =1) |
|
|
|||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
else PC ← PC + 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if CC.C = 1 |
|
|
Flush |
JRULT |
Jump if C = 1 |
- |
|
- |
- |
- |
- |
- |
|
- |
JRULT Label |
then PC ← PC + 2+ rr |
25 bb |
1/2 |
||
|
|
(2) |
||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
else PC ← PC + 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if CC.V =1 |
|
|
|
JRV |
Jump if V = 1 |
- |
|
- |
- |
- |
- |
- |
|
- |
JRV Label |
then PC ← PC + 2+ rr |
29 bb |
1/2 |
Flush |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else PC ← PC + 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
A register load |
|
|
|
|
|
ifSetR7 is set clearedotherwise |
Setif R=$00 clearedotherwise |
|
|
LD A,($12,SP) |
A ← M(SP+shortoff) |
7B bb |
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
LD |
A register store |
- |
|
- |
- |
- |
|
- |
LD ($12,SP),A |
M(SP+shortoff) ← A |
6B bb |
1 |
|
|||
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
|
|
|
|
|
||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Register to |
|
|
|
|
|
- |
- |
|
|
LD A, XH |
A ← XH |
95 |
1 |
|
|
register move |
|
|
|
|
|
|
|
|
|||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68/162 |
Doc ID 13590 Rev 3 |

PM0044 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
STM8 instruction set |
||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||||
Table 42. |
Instruction set summary |
(continued) |
|
|
|
|
||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
Mnemo |
|
|
|
|
Effect on CC register |
|
|
|
|
Example |
(1) |
Pipe |
||||||||
Description |
|
|
|
|
|
|
|
|
|
|
|
|
|
Syntax example |
Operation |
op- |
Cycles |
|||
|
V |
|
I1 |
H |
I0 |
N |
Z |
|
C |
|
|
|||||||||
|
|
|
|
|
|
|
code(s) |
|
|
|||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LDF A,($123456,X) |
A ← M(X+extoff) |
AF ee ww |
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bb |
|
|||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setisR7ifSet |
otherwisecleared |
R=$00ifSet |
otherwisecleared |
|
|
|
LDF A,($123456,Y) |
A ← M(Y+extoff) |
90 AF ee ww |
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
bb |
|
|||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||
|
|
Data load / |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LDF A,([$1234.e],X) |
A ← M(X+[longptr.e]) |
92 AF ww bb |
5 |
|
|
LDF |
|
store |
|
- |
|
- |
- |
- |
|
|
|
|
|
- |
|
|
||||
with extended |
|
|
|
|
|
|
|
|
|
|
|
|
|
|||||||
|
|
|
|
|
|
|
|
LDF ($123456,X),A |
M(X+extoff) ← A |
A7 ee ww |
1 |
|
||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||||
|
|
address |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bb |
|
||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LDF ($123456,Y),A |
M(Y+extoff) ← A |
90 A7 ee ww |
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bb |
|
|||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LDF ([1234.e],X),A |
M(X+[longptr.e]) ← A |
92 A7 ww bb |
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
X register load |
|
|
|
|
|
|
isR15ifSetset |
otherwisecleared |
R=$0000ifSet |
otherwisecleared |
|
|
|
LDW X,($12,SP) |
X ← M(SP+shortoff) |
1E bb |
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||
|
X register store |
|
|
|
|
|
|
|
|
|
LDW ($12,SP),X |
M(SP+shortoff) ← X |
1F bb |
2 |
|
|||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Y register load |
|
|
|
|
|
|
|
|
|
|
|
|
|
LDW Y,($12,SP) |
Y ← M(SP+shortoff) |
16 bb |
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LDW |
Y register store |
|
- |
|
- |
- |
- |
|
|
|
|
|
- |
|
LDW ($12,SP),Y |
M(SP+shortoff) ← Y |
17 bb |
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SP register load |
|
|
|
|
|
|
|
|
|
|
|
|
|
LDW SP,X |
SP ← X |
94 |
1 |
|
|
|
|
/ store |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- |
- |
|
|
|
|
LDW X,SP |
X ← SP |
96 |
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
Index register |
|
|
|
|
|
|
|
|
|
|
|
|
|
LDW X, Y |
X ← Y |
93 |
1 |
|
|
|
|
move |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MOV $1234,#$12 |
M(longmem) ← imm.b |
35 ii ww bb |
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MOV |
Data byte move |
|
- |
|
- |
- |
- |
|
- |
- |
|
|
- |
|
MOV $12,$34 |
M(mem1.b) ← |
44 b2 b1 |
1 |
|
|
|
|
|
|
|
|
MOV mem1,mem2 |
M(mem2.b) |
|
||||||||||||
|
|
|
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MOV $1234,$5678 |
M(mem1.w) ← |
45 w2 b2 w1 |
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MOV mem1,mem2 |
M(mem2.w) |
b1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 by 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
MUL X,A |
X ← X*A |
42 |
4 |
|
MUL |
multiplication |
|
- |
|
- |
0 |
- |
|
- |
- |
|
|
0 |
|
|
|
|
|
||
|
|
|
|
|
MUL Y,A |
Y ← Y*A |
90 42 |
4 |
|
|||||||||||
|
|
(unsigned) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NEG |
|
Logical 2’s |
M=$80ifSet |
otherwisecleared |
|
- |
- |
- |
R7ifSetis set |
otherwisecleared |
R=$00ifSet |
otherwisecleared |
|
ifClearedR=$00 |
otherwiseset |
NEG ([$1234.w],X) |
M(M(longmem) + X) ← |
72 60 ww bb |
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|||||||||
|
complement |
|
|
|
|
|
|
|
|
|
|
00 - M(M(longmem) + X) |
|
|||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NEGW |
|
Logical 2’s |
X=$8000ifSet |
otherwisecleared |
|
- |
- |
- |
R15ifSetis set |
otherwisecleared |
R=$0000ifSet |
otherwisecleared |
|
R=$0000ifCleared |
otherwiseset |
NEGW X |
X ← 0000 - X |
50 |
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|||||||||
|
complement |
|
|
|
|
|
|
|
|
|
|
|
||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NOP |
No operation |
|
- |
|
- |
- |
- |
|
- |
- |
|
|
- |
|
NOP |
--------- |
9D |
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OR |
|
Logical OR |
|
- |
|
- |
- |
- |
R7ifSetis set |
otherwisecleared |
R=$00ifSet |
otherwisecleared |
|
- |
|
OR A,($12,SP) |
A ← A OR M(SP+shortoff) |
1A bb |
1 |
|
|
|
|
|
|
|
|
|
|
|
|||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Pop data byte |
|
- |
|
- |
- |
- |
|
- |
- |
|
|
- |
|
POP $1234 |
M(longmem) ← M(++SP) |
32 ww bb |
1 |
|
|
|
|
from stack |
|
|
|
|
|
|
|
|||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
POP |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Pop |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CC ← M(++SP) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
code condition |
|
|
|
|
|
|
|
|
|
|
|
|
|
POP CC |
86 |
1 |
|
||
|
|
register |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Doc ID 13590 Rev 3 |
69/162 |

STM8 instruction set |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PM0044 |
||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||
Table 42. |
Instruction set summary |
(continued) |
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
Mnemo |
|
|
|
Effect on CC register |
|
|
|
|
Example |
(1) |
Pipe |
||||||||
Description |
|
|
|
|
|
|
|
|
|
|
|
Syntax example |
|
Operation |
op- |
Cycles |
|||
|
V |
|
I1 |
H |
I0 |
N |
Z |
|
C |
|
|
|
|||||||
|
|
|
|
|
|
|
|
code(s) |
|
|
|||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Pop index |
|
|
|
|
|
|
|
|
|
|
|
|
XH ← M(++SP) |
|
|
|
|
POPW |
register from |
- |
|
- |
- |
- |
|
- |
|
- |
|
- |
POPW X |
85 |
2 |
|
|||
|
|
|
|
XL ← M(++SP) |
|
||||||||||||||
|
|
stack |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Push |
|
|
|
|
|
|
|
|
|
|
|
PUSH $1234 |
M(SP--) ← M(longmem) |
3B ww bb |
1 |
|
|
PUSH |
data byte onto |
- |
|
- |
- |
- |
|
- |
|
- |
|
- |
|
|
|
|
|
|
|
|
|
|
|
PUSH #$12 |
M(SP--) ← imm.b |
4B bb |
1 |
|
|||||||||||
|
|
stack |
|
|
|
|
|
|
|
|
|
|
|
|
|||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Push index |
|
|
|
|
|
|
|
|
|
|
|
|
M(SP--) ← XL |
|
|
|
|
PUSHW |
register onto |
- |
|
- |
- |
- |
|
- |
|
- |
|
- |
PUSHW X |
89 |
2 |
|
|||
|
|
|
|
M(SP--) ← XH |
|
||||||||||||||
|
|
stack |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
RCF |
Reset carry flag |
- |
|
- |
- |
- |
|
- |
|
- |
|
0 |
RCF |
CC.C ← 0 |
98 |
1 |
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Subroutine |
|
|
|
|
|
|
|
|
|
|
|
|
PCH ← M(++SP) |
|
|
|
|
RET |
|
return |
- |
|
- |
- |
- |
|
- |
|
- |
|
- |
RET |
81 |
4 |
Flush |
||
|
|
|
|
|
PCL ← M(++SP) |
||||||||||||||
|
from section 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Subroutine |
|
|
|
|
|
|
|
|
|
|
|
|
PCE ← M(++SP) |
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
RETF |
|
- |
|
- |
- |
- |
|
- |
|
- |
|
- |
RETF |
PCH ← M(++SP) |
87 |
5 |
Flush |
||
from extended |
|
|
|
|
|||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
PCL ← M(++SP) |
|
|
|
|||
|
|
address |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Reset interrupt |
|
|
|
|
|
|
|
|
|
|
|
|
CC.I1 ← 1 |
|
|
|
||
RIM |
|
mask/ |
- |
|
1 |
- |
0 |
|
- |
|
- |
|
- |
RIM |
9A |
1 |
|
||
|
Interrupt enable |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R7ifSetis set |
otherwisecleared |
R=$00ifSet |
otherwisecleared |
|
bytetheof7before rotation |
|
CC.C ← bit 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R0 |
← CC.C |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R1 |
← bit 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R2 |
← bit 1 |
|
|
|
|
|
Rotate left |
|
|
|
|
|
|
|
|
|
|
|
|
R3 |
← bit 2 |
|
|
|
RLC |
logical through |
- |
|
- |
- |
- |
|
|
|
|
|
|
RLC ([$1234.w],X) |
R4 |
← bit 3 |
72 69 ww bb |
4 |
|
|
|
|
carry |
|
|
|
|
|
|
|
|
|
|
|
|
R5 |
← bit 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R6 ← bit 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R7 ← bit 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bit |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setisR15ifSet |
otherwisecleared |
R=$0000ifSet |
otherwisecleared |
|
rotationbeforebytetheof |
|
R0 |
← CC.C |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R1 |
← bit 0 |
|
|
|
|
Rotate word left |
|
|
|
|
|
|
|
|
|
|
|
|
R2 |
← bit 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
... |
|
|
|
|
||
RLCW |
logical through |
- |
|
- |
- |
- |
|
|
|
|
|
|
RLCW X |
|
59 |
2 |
|
||
|
|
|
|
|
|
|
R13 ← bit 12 |
|
|||||||||||
|
|
carry |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R14 ← bit 13 |
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R15 ← bit 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bit 7 |
|
CC.C ← bit 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Rotate word left |
|
|
|
|
|
R15ifSetis set |
otherwisecleared |
R=$0000ifSet |
otherwisecleared |
|
|
|
A ← XH |
|
|
|
||
RLWA |
|
through |
- |
|
- |
- |
- |
|
|
|
|
|
- |
RLWA X |
XH ← XL |
02 |
1 |
|
|
|
Accumulator |
|
|
|
|
|
|
|
|
|
|
|
|
XL ← A |
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R7ifSetis set |
otherwisecleared |
R=$00ifSet |
otherwisecleared |
|
bytetheof0before rotation |
|
CC.C ← bit 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R7 |
← CC.C |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R6 |
← bit 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R5 |
← bit 6 |
|
|
|
|
|
Rotate right |
|
|
|
|
|
|
|
|
|
|
|
|
R4 |
← bit 5 |
|
|
|
RRC |
logical through |
- |
|
- |
- |
- |
|
|
|
|
|
|
RRC ([$1234.w],X) |
R3 |
← bit 4 |
72 66 ww bb |
4 |
|
|
|
|
carry |
|
|
|
|
|
|
|
|
|
|
|
|
R2 |
← bit 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R1 ← bit 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R0 ← bit 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bit |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70/162 |
Doc ID 13590 Rev 3 |

PM0044 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
STM8 instruction set |
||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||
Table 42. |
Instruction set summary |
(continued) |
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
Mnemo |
|
|
|
Effect on CC register |
|
|
|
|
Example |
(1) |
Pipe |
||||||||
Description |
|
|
|
|
|
|
|
|
|
|
|
Syntax example |
Operation |
|
op- |
Cycles |
|||
|
V |
|
I1 |
H |
I0 |
N |
Z |
|
C |
|
|
|
|||||||
|
|
|
|
|
|
|
|
code(s) |
|
|
|||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setisR7ifSet |
otherwisecleared |
R=$00ifSet |
otherwisecleared |
|
rotationbeforebytetheof |
|
R15 ← CC.C |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R14 ← bit 15 |
|
|
|
|
|
|
Rotate word |
|
|
|
|
|
|
|
|
|
|
|
|
R13 ← bit 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
... |
|
|
|
|
|
RRCW |
|
right logical |
- |
|
- |
- |
- |
|
|
|
|
|
|
RRCW X |
|
56 |
2 |
|
|
|
|
|
|
|
|
|
|
R2 ← bit 3 |
|
|
|||||||||
|
through carry |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
R1 ← bit 2 |
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R0 ← bit 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bit 0 |
|
CC.C ← bit 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Rotate word |
|
|
|
|
|
R15ifSetis set |
otherwisecleared |
R=$0000ifSet |
otherwisecleared |
|
|
|
A ← XL |
|
|
|
|
RRWA |
right through |
- |
|
- |
- |
- |
|
|
|
|
|
- |
RRWA X |
XL ← XH |
|
01 |
1 |
|
|
|
Accumulator |
|
|
|
|
|
|
|
|
|
|
|
|
XH ← A |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RVF |
Reset overflow |
0 |
|
- |
- |
- |
|
- |
|
- |
|
- |
RVF |
CC.V ← 0 |
|
9C |
1 |
|
|
|
flag |
|
|
|
|
|
|
||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SBC |
Subtract with |
subtractionsignedtheif generates clearedoverflow,an otherwise |
|
- |
- |
- |
R7ifSetis set |
otherwisecleared |
R=$00ifSet |
otherwisecleared |
|
carryaisthereifSet from R7 otherwisecleared |
SBC A,($12,SP) |
A ← A -M(SP+shortoff) - |
12 bb |
1 |
|
||
|
|
|
|
|
|
|
|
|
|||||||||||
|
carry |
|
|
|
|
|
|
|
|
CC.C |
|
|
|||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
Set |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCF |
Set Carry Flag |
- |
|
- |
- |
- |
|
- |
|
- |
|
1 |
SCF |
CC.C ← 1 |
|
99 |
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Set interrupt |
|
|
|
|
|
|
|
|
|
|
|
|
CC.I0 ← 1 |
|
|
|
|
SIM |
|
mask/ |
- |
|
1 |
- |
1 |
|
- |
|
- |
|
- |
SIM |
|
9B |
1 |
|
|
|
Disable |
|
|
|
|
CC.I1 ← 1 |
|
|
|||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
interrupts |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R7ifSetis set |
otherwisecleared |
R=$00ifSet |
otherwisecleared |
|
bytetheof7before shifting |
|
CC.C ← bit 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R0 ← 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R1 ← bit 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R2 ← bit 1 |
|
|
|
|
|
|
Shift left |
|
|
|
|
|
|
|
|
|
|
|
|
R3 ← bit 2 |
|
|
|
|
SLA |
|
arithmetic |
- |
|
- |
- |
- |
|
|
|
|
|
|
SLA ([$1234.w],X) |
R4 ← bit 3 |
|
72 68 ww bb |
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R5 ← bit 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R6 ← bit 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R7 ← bit 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bit |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Doc ID 13590 Rev 3 |
71/162 |

STM8 instruction set |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PM0044 |
|||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||||
Table 42. |
Instruction set summary |
(continued) |
|
|
|
|
|
|||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
Mnemo |
|
|
|
|
Effect on CC register |
|
|
|
|
Example |
(1) |
Pipe |
||||||||
Description |
|
|
|
|
|
|
|
|
|
|
|
|
Syntax example |
|
Operation |
op- |
Cycles |
|||
|
V |
|
I1 |
H |
I0 |
N |
Z |
|
C |
|
|
|
||||||||
|
|
|
|
|
|
|
|
code(s) |
|
|
||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setisR15ifSet |
otherwisecleared |
R=$0000ifSet |
otherwisecleared |
|
shiftingbeforebytetheof |
|
R0 |
← 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R1 |
← bit 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R2 |
← bit 1 |
|
|
|
SLAW |
Shift word left |
|
- |
|
- |
- |
- |
|
|
|
|
|
|
SLAW X |
R3 ← bit 2 |
58 |
2 |
|
||
|
arithmetic |
|
|
|
|
|
|
|
|
..... |
|
|
||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R14 ← bit 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R15 ← bit 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bit 15 |
|
CC.C ← bit 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R7ifSetis set |
otherwisecleared |
R=$00ifSet |
otherwisecleared |
|
bytetheof7before shifting |
|
CC.C ← bit 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R0 |
← 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R1 |
← bit 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R2 |
← bit 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R3 |
← bit 2 |
|
|
|
SLL |
Shift left logical |
|
- |
|
- |
- |
- |
|
|
|
|
|
|
SLL ([$1234.w],X) |
R4 ← bit 3 |
72 68 ww bb |
4 |
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R5 |
← bit 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R6 ← bit 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R7 ← bit 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bit |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setisR15ifSet |
otherwisecleared |
R=$0000ifSet |
otherwisecleared |
|
shiftingbeforebytetheof |
|
R0 |
← 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R1 |
← bit 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R2 |
← bit 1 |
|
|
|
SLLW |
Shift word left |
|
- |
|
- |
- |
- |
|
|
|
|
|
|
SLLW X |
R3 ← bit 2 |
58 |
2 |
|
||
|
logical |
|
|
|
|
|
|
|
|
..... |
|
|
||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R14 ← bit 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R15 ← bit 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bit 15 |
|
CC.C ← bit 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R7ifSetis set |
otherwisecleared |
R=$00ifSet |
otherwisecleared |
|
bytetheof0before shifting |
|
R7 ← bit 7 (unchanged) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CC.C ← bit 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R0 ← bit 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R1 ← bit 2 |
|
|
|
|
|
|
Shift right |
|
|
|
|
|
|
|
|
|
|
|
|
|
R2 ← bit 3 |
|
|
|
|
SRA |
|
arithmetic |
|
- |
|
- |
- |
- |
|
|
|
|
|
|
SRA ([$1234.w],X) |
R3 |
← bit 4 |
72 67 ww bb |
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R4 |
← bit 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R5 ← bit 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R6 ← bit 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bit |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R7ifSetset |
otherwisecleared |
|
|
|
|
R15ifSetis set |
otherwisecleared |
R=$0000ifSet |
otherwisecleared |
|
bytetheof0before shifting |
|
R15 ← bit 15 (unchanged) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CC.C ← bit 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R0 ← bit 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R1 ← bit 2 |
|
|
|
|
|
Shift word right |
|
|
|
|
|
|
|
|
|
|
|
|
|
R2 ← bit 3 |
|
|
|
||
SRAW |
|
arithmetic |
|
|
|
- |
- |
- |
|
|
|
|
|
|
SRAW X |
.... |
|
57 |
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R12 ← bit 13 |
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R13 ← bit 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R14 ← bit 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bit |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72/162 |
Doc ID 13590 Rev 3 |

PM0044 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
STM8 instruction set |
||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||||
Table 42. |
Instruction set summary |
(continued) |
|
|
|
|
|
|
|||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
Mnemo |
|
|
|
Effect on CC register |
|
|
|
|
|
|
Example |
(1) |
Pipe |
||||||||
Description |
|
|
|
|
|
|
|
|
|
|
|
|
Syntax example |
|
Operation |
|
op- |
Cycles |
|||
|
V |
I1 |
H |
I0 |
N |
Z |
|
C |
|
|
|
|
|||||||||
|
|
|
|
|
|
|
|
code(s) |
|
|
|||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R7ifSetset |
otherwisecleared |
R=$00ifSet |
otherwisecleared |
|
bytetheof0before shifting |
|
|
R7 |
← 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CC.C ← bit 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R0 ← bit 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R1 |
← bit 2 |
|
|
|
|
|
|
Shift right |
|
|
|
|
|
|
|
|
|
|
|
|
|
R2 |
← bit 3 |
|
|
|
|
SRL |
|
logical |
- |
|
- |
- |
- |
|
|
|
|
|
|
|
SRL ([$1234.w],X) |
R3 |
← bit 4 |
|
72 64 ww bb |
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R4 |
← bit 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R5 |
← bit 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R6 |
← bit 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bit |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R15ifSetset |
otherwisecleared |
R=$0000ifSet |
otherwisecleared |
|
bytetheof0before shifting |
|
|
R15 ← 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CC.C ← bit 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R0 ← bit 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R1 |
← bit 2 |
|
|
|
|
|
Shift word right |
|
|
|
|
|
|
|
|
|
|
|
|
|
R2 |
← bit 3 |
|
|
|
|
|
SRLW |
|
arithmetic |
- |
|
- |
- |
- |
|
|
|
|
|
|
|
SRLW X |
.... |
|
|
54 |
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R12 ← bit 13 |
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R13 ← bit 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R14 ← bit 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bit |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Subtract without |
operationsignedtheifSet generates |
clearedoverflow,an otherwise |
- |
- |
- |
R7ifSetis set |
otherwisecleared |
R=$00ifSet |
otherwisecleared |
|
aisthereifSetcarry from R7 |
otherwisecleared |
SUB A,($12,SP) |
A ← A -M(SP+shortoff) |
|
10 bb |
1 |
|
||
|
|
|
|
|
|
|
|
|
|
|
|
||||||||||
SUB |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
carry |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- |
|
- |
- |
- |
|
- |
|
- |
|
- |
|
SUB SP,#$12 |
SP ← SP + imm.b |
|
52 ii |
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SUBW |
Subtract word |
(unsignedmemX<ifSet 16-bit |
clearedvalues),otherwise |
- |
dst(7:0)<ifSetmem(7:0) clearedvalues)(unsignedotherwise |
- |
R15ifSetis set |
otherwisecleared |
R=$0000ifSet |
otherwisecleared |
|
(unsignedmem<dstifSet values) |
otherwisecleared |
SUBW X,($12,SP) |
X ← X -M(SP+shortoff) |
|
72 F0 bb |
2 |
|
||
|
|
|
|
|
|
|
|
|
|
|
|
||||||||||
without carry |
|
|
|
|
|
|
|
|
|
|
|
|
|||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isR7ifSetset |
otherwisecleared |
R=$00ifSet |
otherwisecleared |
|
|
|
|
R0 |
↔ R4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
SWAP |
Swap nibbles |
- |
|
- |
- |
- |
|
|
|
|
|
- |
|
SWAP ([$1234.w],X) |
R1 |
↔ R5 |
|
72 6E ww bb |
4 |
|
|
|
|
|
|
|
|
|
R2 |
↔ R6 |
|
|
|||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
R3 |
↔ R7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Doc ID 13590 Rev 3 |
73/162 |