cd00004608 st9 Family Programming Manual Stmicroelectronics
cd00004608 st9 Family Programming Manual Stmicroelectronics
PROGRAMMING MANUAL
INTRODUCTION
The ST9 8/16 bit microcontroller family introduces a new generation of single-chip architecture. It offers
fast program execution, efficient use of memory, sophisticated interrupt handling, input/output (I/O) flexi-
bility and bit-manipulation capabilities, with easy system expansion. Virtually all of the ST9 configuration
can be tailored to the needs of the user under program control. This enables the ST9 to serve as an I/O
intensive microcontroller, as an intelligent peripheral controller within a larger system, or as a memory in-
tensive microprocessor.
Programming of the ST9 is made easy in both high level languages such as C, or directly in assembler
language, by the versatility of the 14 addressing modes coupled with the comprehensive instruction set
operating on bits, BCD, 8-bit bytes and 16-bit words. The availability of the Register File, giving the pro-
grammer multiple 8- and 16-bit accumulators and index pointers, the fast interrupt response time, on-chip
DMA and on-chip and external memory access capabilities, give the ST9 a high efficiency for real-time
control applications.
The ST9 has a range of family devices made up from various memory combinations (RAM, ROM/
EPROM, FLASH, EEPROM), powerful peripherals such as Multifunction Timers, Analog to Digital Con-
verters, Serial Communications Interfaces and a standard Core.
Section 1 describes in more detail the ST9 features of primary interest to assembly language program-
mers.
Please refer to the datasheet of the ST9 device you are using for detailed architectural and configuration
information.
For a detailed technical introduction to the capabilities of the ST9, refer to the ST9+ User Guide available
on the STMicroelectronics website (www.st.com).
Note: This Programming Manual follows the syntax of the ST9 Software Tools (High-level Macro Assem-
bler running under MS-DOS or Windows). Register and bit names follow the recommendations of the In-
clude files in the Include.ST9 directory supplied with the development tools. The ST9 uses 2’s comple-
ment arithmetic on 8-bit and 16-bit values. It does not support any floating point types or BCD.
The ST9 is byte big endian, i.e. the most significant byte of a 16-bit word has the low address. There is no
alignment constraint, i.e. a 16-bit word can be loaded from an odd or even memory address.
The ST9 is bit little endian, i.e. the least significant bit of a byte has number 0.
1
Table of Contents
INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . 1 ANDW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
1 SOFTWARE DESCRIPTION . . . . . . . . . . . . 5 BAND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
1.1 ADDRESSING MODES . . . . . . . . . . . 5 BCPL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
BLD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
1.2 INSTRUCTION SET . . . . . . . . . . . . . 19
BOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
1.3 INSTRUCTION SUMMARY . . . . . . . 26 BRES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
2 OPCODE MAP . . . . . . . . . . . . . . . . . . . . . 59 BSET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
3 INSTRUCTIONS . . . . . . . . . . . . . . . . . . . . 67 BTJF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
ADC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 BTJT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
ADC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 BTSET . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
ADC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 BXOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
ADC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 CALL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
ADC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 CALLS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
ADC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 CCF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
ADC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 CLR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
ADCW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 CP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
ADCW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 CP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
ADCW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 CP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
ADCW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 CP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
ADCW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 CP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
ADCW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 CP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
ADCW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 CP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
ADD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 CPJFI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
ADD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 CPJTI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
ADD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 CPL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
ADD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 CPW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
ADD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 CPW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
ADD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 CPW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
ADD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 CPW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
ADDW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 CPW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
ADDW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 CPW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
ADDW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 CPW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
ADDW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 DA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
ADDW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 DA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
ADDW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 DEC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
ADDW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 DECW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
AND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 DI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
AND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 DIV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
AND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 DIV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
AND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 DIVWS . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
AND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 DIVWS . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
AND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 DJNZ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
AND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 DWJNZ . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
ANDW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 EI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
ANDW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 EXT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
ANDW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 HALT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
ANDW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 INC . . . . . . . . . . . . . . . . . . . . . . . . . . 303. . . . . 159
ANDW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 INCW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
ANDW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 IRET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
2/303
1
Table of Contents
JP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 RLC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
JPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 RLCW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
JPcc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 ROL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
JRcc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 ROR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
LD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 RRC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
LD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 RRCW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
LD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 SBC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
LD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 SBC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
LD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 SBC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
LD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 SBC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
LD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 SBC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
LDPP LDDP LDPD LDDD . . . . . . . . . . . . . . 173 SBC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
LDW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 SBC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
LDW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 SBCW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
LDW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 SBCW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
LDW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 SBCW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
LDW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 SBCW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
LDW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 SBCW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
LINK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 SBCW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
LINKU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 SBCW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
MUL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 SCF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
NOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 SDM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
OR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 SLA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
OR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 SLAW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
OR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 SPM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
OR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 SPP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
OR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 SRA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
OR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 SRAW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
OR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 SRP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
ORW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 SRP0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
ORW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 SRP1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
ORW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 SUB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
ORW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194 SUB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
ORW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 SUB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
ORW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 SUB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
ORW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 SUB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
PEA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 SUB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
PEAU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 SUB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
POP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 SUBW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
POPU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 SUBW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
POPUW . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 SUBW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
POPW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 SUBW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
PUSH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 SUBW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
PUSHU . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 SUBW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
PUSHUW . . . . . . . . . . . . . . . . . . . . . . . . . . 206 SUBW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
PUSHW . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 SWAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
RCF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 TCM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
RET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 TCM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
RETS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 TCM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
3/303
1
Table of Contents
TCM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260 TMW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
TCM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 TMW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
TCM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 UNLINK . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
TCM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 UNLINKU . . . . . . . . . . . . . . . . . . . . . . . . . . 286
TCMW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264 WFI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
TCMW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265 XCH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
TCMW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266 XOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
TCMW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267 XOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
TCMW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268 XOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
TCMW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269 XOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
TCMW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270 XOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
TM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271 XOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294
TM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272 XOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
TM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 XORW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
TM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274 XORW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
TM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275 XORW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
TM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 XORW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
TM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277 XORW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
TMW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278 XORW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
TMW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279 XORW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
TMW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
TMW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
TMW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
303
4/303
1
ST9+ Programming Manual
1 SOFTWARE DESCRIPTION
5/303
ST9+ Programming Manual
6/303
ST9+ Programming Manual
Notes:
1. Word Instructions Only
2. Load Byte Only
7/303
ST9+ Programming Manual
DATA
REGISTER
ADDRESS DATA
REGISTER
ADDRESS DATA
8/303
ST9+ Programming Manual
REGISTER
ADDRESS DATA
ADDRESS
REGISTER
ADDRESS + DATA
ADDRESS
OFFSET
9/303
ST9+ Programming Manual
REGISTER
ADDRESS ADDRESS DATA
+1
10/303
ST9+ Programming Manual
ADDRESS DATA
HIGH
ADDRESS
LOW
11/303
ST9+ Programming Manual
REGISTER ADDRESS
ADDRESS HIGH DATA
ADDRESS
LOW
12/303
ST9+ Programming Manual
+1
13/303
ST9+ Programming Manual
14/303
ST9+ Programming Manual
INDEX
REGISTER LOW
ADDRESS
OFFSET
Figure 11. Memory Indexed Addressing Mode with Immediate Long Offset
INDEX
HIGH + DATA
INDEX
REGISTER LOW
ADDRESS
OFFSET
HIGH
OFFSET
LOW
15/303
ST9+ Programming Manual
REGISTER INDEX
ADDRESS LOW
REGISTER OFFSET
ADDRESS HIGH
OFFSET
LOW
16/303
ST9+ Programming Manual
ADDRESS NEXT
HIGH INSTRUCTION
ADDRESS
LOW
+ NEXT
OFFSET
INSTRUCTION
PROGRAM
COUNTER
17/303
ST9+ Programming Manual
Figure 16. Program Memory Indirect Addressing Mode using Absolute Register
18/303
ST9+ Programming Manual
19/303
ST9+ Programming Manual
20/303
ST9+ Programming Manual
21/303
ST9+ Programming Manual
22/303
ST9+ Programming Manual
23/303
ST9+ Programming Manual
24/303
ST9+ Programming Manual
25/303
ST9+ Programming Manual
TIMING INFORMATION:
The number of clock cycles given is valid when no wait states are added to memory accesses. In order to
facilitate the evaluation of timings when wait states are added to memory access, two additional columns
are given: P and D.
P gives the number of accesses to program memory for instruction fetch: if wait states are added when ac-
cessing the memory containing the code, the number of these wait states, multiplied by the value of col-
umn P, must be added to the instruction duration.
The same applies to column D, which gives the number of accesses needed for operands; these are typ-
ically in data memory, unless (except for stack operations, which are always performed with data memory)
bit 0 of the FLAGS register is 0 (e.g. after executing the SPM instruction).
26/303
ST9+ Programming Manual
27/303
ST9+ Programming Manual
28/303
ST9+ Programming Manual
29/303
ST9+ Programming Manual
30/303
ST9+ Programming Manual
31/303
ST9+ Programming Manual
32/303
ST9+ Programming Manual
33/303
ST9+ Programming Manual
- - - - - -
CALL (rr) 2 12 3 2(1) SSP⇐SSP-2,(SSP)⇐PC, PC⇐dst
- - - - - -
CALL (RR) 2 12 3 2(1) SSP⇐SSP-2,(SSP)⇐ PC, PC⇐dst
Note 1. No data memory accesses are performed if the system stack is kept in the Register File.
34/303
ST9+ Programming Manual
35/303
ST9+ Programming Manual
36/303
ST9+ Programming Manual
Note 1. Refer to the desciption of the DIV instruction on page 150 for detailed information.
Note 2. Registers in groups E and F are not allowed, either directly or as working registers.
Note 3. Additional fetch when the jump is taken.
37/303
ST9+ Programming Manual
Note 1. All flags are restored to original setting (before interrupt occured).
Note 2. Performed only if register file is not used.
Note 3. Additional fetch when the jump is taken.
38/303
ST9+ Programming Manual
39/303
ST9+ Programming Manual
40/303
ST9+ Programming Manual
Note 1. Refer to the description of the MUL instruction on page 182 for detailed information.
Note 2. The value inside [ ] is valid for external memory stack
41/303
ST9+ Programming Manual
42/303
ST9+ Programming Manual
43/303
ST9+ Programming Manual
44/303
ST9+ Programming Manual
RLC (r) 2 6 2 0 “ ” ^ ^ ^ ^ - -
RLC (R) 2 6 2 0 “ ” ^ ^ ^ ^ - -
RLCW : Rotate word left through carry
RLCW rr 2 8 2 0 dst(0)⇐C, C⇐dst(15)
^ ? ^ ^ - -
dst(n+1)⇐dst(n) n=0-14
^ ? ^ ^ - -
RLCW RR 2 8 2 0 “ ”
ROL : Rotate left
ROL r 2 4 2 0 C⇐dst(7), dst(0)⇐dst(7) ^ ^ ^ ^ - -
dst(n+1)⇐dst(n) n=0-6
ROL R 2 4 2 0 “ ” ^ ^ ^ ^ - -
ROL (r) 2 6 2 0 “ ” ^ ^ ^ ^ - -
ROL (R) 2 6 2 0 “ ” ^ ^ ^ ^ - -
ROR : Rotate right
ROR r 2 4 2 0 C⇐dst(0), dst(7)⇐dst(0) ^ ^ ^ ^ - -
dst(n)⇐dst(n+1) n=0-6
ROR R 2 4 2 0 “ ” ^ ^ ^ ^ - -
ROR (r) 2 6 2 0 “ ” ^ ^ ^ ^ - -
ROR (R) 2 6 2 0 “ ” ^ ^ ^ ^ - -
RRC : Rotate right through carry
RRC r 2 4 2 0 dst(7)⇐C, C⇐dst(0) ^ ^ ^ ^ - -
dst(n)⇐dst(n+1) n=0-6
RRC R 2 4 2 0 “ ” ^ ^ ^ ^ - -
RRC (r) 2 6 2 0 “ ” ^ ^ ^ ^ - -
RRC (R) 2 6 2 0 “ ” ^ ^ ^ ^ - -
RRCW : Rotate word right through carry
RRCW rr 2 8 2 0 dst(15)⇐C, C⇐dst(0) ^ ^ ^ ^ - -
dst(n)⇐dst(n+1) n=0-14
RRCW RR 2 8 2 0 “ ” ^ ^ ^ ^ - -
Note 1. No data memory accesses are done if the stack is kept in the Register File.
45/303
ST9+ Programming Manual
46/303
ST9+ Programming Manual
47/303
ST9+ Programming Manual
Note 1. Following this instruction, all addressing modes referring to address spaces will use DPRx registers.
Note 2. Following this instruction, all addressing modes referring to address spaces will use CSR register,
except for the following instructions which operate with DPRx registers independently of the set-
ting of the DP flag :CALLS, RETS, LINK/LINKU, UNLINK/UNLINKU, PUSH(W)/PUSHU(W),
POP(W)/POPU(W), PEA/PEAU, and CALL, RET, IRET and interrupt execution (assuming the
Stack Pointers are not pointing to the Register File).
48/303
ST9+ Programming Manual
49/303
ST9+ Programming Manual
50/303
ST9+ Programming Manual
51/303
ST9+ Programming Manual
52/303
ST9+ Programming Manual
53/303
ST9+ Programming Manual
54/303
ST9+ Programming Manual
55/303
ST9+ Programming Manual
56/303
ST9+ Programming Manual
57/303
ST9+ Programming Manual
58/303
ST9+ Programming Manual
2 OPCODE MAP
For the following symbols, suffix d means destination and suffix s means source.
R, Rd, Rs: general registers (8 bits), if the 4 Most Significant Bits (MSB) are Dh then the 4 Least Signifi-
cant Bits (LSB) specify a working register.
rr,rrd,rrs: working register pair (3 bits), a single bit (0 or 1) follows.
RR,RRd,RRs: general register pair (7 bits), if the 4 Most Significant Bits (MSB) are Dh then the 3 Least
Significant Bits (LSB) specify a working register; a single bit (0 or 1) follows.
bd,bs: destination and source bit numbers (3 bits followed by a 0 or 1), associated with rd and rs for r.b
bit addressing modes.
N: 8-bit quantity.
NN: 16-bit quantity (divided in Nh & Nl) nnnnnn: 6-bit segment number.
wwwww: 5-bit register window number (for SRP...) pppppp: 6-bit register page number (for SPP).
K: ALU parametrization, 4 bits (corresponding instruction is ALD or ALDW, value of K gives instruction to
be substituted for "ALD":
K= 0 1 2 3 4 5 6 8 9 A F
ALD= OR AND SBC ADC ADD SUB XOR CP CP TM LD
59/303
ST9+ Programming Manual
OPCODE ADDRESSING
OPCODE BYTE1 BYTE2 BYTE3 BYTE4 BYTE5
MNEMONIC MODE
15 Rd N AND Rd,#N
16 Rs Rd XCH Rs,Rd
17 RRs0 RRd0 ANDW RRd,RRs
17 RRd1 Nhs Nls ANDW RRd,#NN
18 Rs LD r1,Rs
19 Rd LD Rd,r1
1A N DJNZ r1,N
1B N JR LT,N
1C N LD r1,#N
1D Nh Nl JP LT,NN
1E rrd0,rrs0 ANDW rrd,rrs
1E rrd1,rrs0 ANDW (rrd),rrs
1E rrd0,rrs1 ANDW rrd,(rrs)
1E rrd1,rrs1 ANDW (rrd),(rrs)
1F bd1,rd bs0,rs BAND rd.b,rs.b
1F bd1,rd bs1,rs BAND rd.b,rs.b
1F bd0,rd BRES rd.b
20 Rd POPU Rd
21 Rd POPU (Rd)
22 rd,rs SBC rd,rs
23 rd,rs SBC rd,(rs)
24 Rs Rd SBC Rd,Rs
25 Rd N SBC Rd,#N
26 K,rr1 N R ALD N(rr),R
26 K,rr0 N N R ALD NN(rr),R
27 RRs0 RRd0 SBCW RRd,RRs
27 RRd1 Nhs Nls SBCW RRd,#NN
28 Rs LD r2,Rs
29 Rd LD Rd,r2
2A N DJNZ r2,N
2B N JR LE,N
2C N LD r2,#N
2D Nh Nl JP LE,NN
2E rrd0,rrs0 SBCW rrd,rrs
2E rrd1,rrs0 SBCW (rrd),rrs
2E rrd0,rrs1 SBCW rrd,(rrs)
2E rrd1,rrs1 SBCW (rrd),(rrs)
2F RR0 SRAW RR
2F K,0001 Ns Ndh Ndl ALD NNd,#Ns
30 Rd PUSHU Rd
31 Rd PUSHU (Rd)
32 rd,rs ADC rd,rs
33 rd,rs ADC rd,(rs)
34 Rs Rd ADC Rd,Rs
35 Rd N ADC Rd,#N
36 RR0 RRCW RR
36 K,0001 Nsh Nsl Ndh Ndl ALDW NNd,#NNs
60/303
ST9+ Programming Manual
OPCODE ADDRESSING
OPCODE BYTE1 BYTE2 BYTE3 BYTE4 BYTE5
MNEMONIC MODE
37 RRs0 RRd0 ADCW RRd,RRs
37 RRd1 Nhs Nls ADCW RRd,#NN
38 Rs LD r3,Rs
39 Rd LD Rd,r3
3A N DJNZ r3,N
3B N JR ULE,N
3C N LD r3,#N
3D Nh Nl JP ULE,NN
3E rrd0,rrs0 ADCW rrd,rrs
3E rrd1,rrs0 ADCW (rrd),rrs
3E rrd0,rrs1 ADCW rrd,(rrs)
3E rrd1,rrs1 ADCW (rrd),(rrs)
3F 01nnnnnn Nh Nl CALLS nnnnnn,NN
3F 11nnnnnn Nh Nl JPS nnnnnn,NN
40 Rd DEC Rd
41 Rd DEC (Rd)
42 rd,rs ADD rd,rs
43 rd,rs ADD rd,(rs)
44 Rs Rd ADD Rd,Rs
45 Rd N ADD Rd,#N
46 RET
47 RRs0 RRd0 ADDW RRd,RRs
47 RRd1 Nhs Nls ADDW RRd,#NN
48 Rs LD r4,Rs
49 Rd LD Rd,r4
4A N DJNZ r4,N
4B N JR OV,N
4C N LD r4,#N
4D Nh Nl JP OV,NN
4E rrd0,rrs0 ADDW rrd,rrs
4E rrd1,rrs0 ADDW (rrd),rrs
4E rrd0,rrs1 ADDW rrd,(rrs)
4E rrd1,rrs1 ADDW (rrd),(rrs)
4F rrd0,rs MUL rrd,rs
50 Rd INC Rd
51 Rd INC (Rd)
52 rd,rs SUB rd,rs
53 rd,rs SUB rd,(rs)
54 Rs Rd SUB Rd,Rs
55 Rd N SUB Rd,#N
56 RRs0 rrh0,rrl0 DIVWS rrh,rrl,RRs
57 RRs0 RRd0 SUBW RRd,RRs
57 RRd1 Nhs Nls SUBW RRd,#NN
58 Rs LD r5,Rs
59 Rd LD Rd,r5
5A N DJNZ r5,N
5B N JR MI,N
61/303
ST9+ Programming Manual
OPCODE ADDRESSING
OPCODE BYTE1 BYTE2 BYTE3 BYTE4 BYTE5
MNEMONIC MODE
5C N LD r5,#N
5D Nh Nl JP MI,NN
5E rrd0,rrs0 SUBW rrd,rrs
5E rrd1,rrs0 SUBW (rrd),rrs
5E rrd0,rrs1 SUBW rrd,(rrs)
5E rrd1,rrs1 SUBW (rrd),(rrs)
5F rrd0,rs DIV rrd,rs
60 rrs1,rrx0 K,rd ALD rd,rrs(rrx)
60 rrd1,rrx1 K,rs ALD rrd(rrx),rs
60 rrs0,rrx0 K,rrde ALDW rrd,rrs(rrx)
60 rrd0,rrx1 K,rrse ALDW rrd(rrx),rrs
61 CCF
62 rd,rs XOR rd,rs
63 rd,rs XOR rd,(rs)
64 Rs Rd XOR Rd,Rs
65 Rd N XOR Rd,#N
66 Rs PUSH Rs
67 RRs0 RRd0 XORW RRd,RRs
67 RRd1 Nhs Nls XORW RRd,#NN
68 Rs LD r6,Rs
69 Rd LD Rd,r6
6A N DJNZ r6,N
6B N JR EQ,N
6C N LD r6,#N
6D Nh Nl JP EQ,NN
6E rrd0,rrs0 XORW rrd,rrs
6E rrd1,rrs0 XORW (rrd),rrs
6E rrd0,rrs1 XORW rrd,(rrs)
6E rrd1,rrs1 XORW (rrd),(rrs)
6F bd1,rd bs0,rs BXOR rd.bd,rs.bs
6F bd1,rd bs1,rs BXOR rd.bd, rs.bs
6F bd0,rd BCPL rd.bd
70 Rd DA Rd
71 Rd DA (Rd)
72 K,rrs1 Rd ALD Rd,(rrs)
72 K,rrd0 Rs ALD (rrd),Rs
73 K,rrs0 RRd0 ALD (RRd),(rrs)
73 0100,rr1 R CALLS (R),(rr)
73 1100,rr1 R JPS (R),(rr)
74 RRd1 CALL (RRd)
74 RRs0 PUSHW RRs
75 RRd0 POPW RRd
75 RRd1 UNLINK RRd
76 Rd POP Rd
77 Rd POP (Rd)
78 Rs LD r7,Rs
79 Rd LD Rd,r7
62/303
ST9+ Programming Manual
OPCODE ADDRESSING
OPCODE BYTE1 BYTE2 BYTE3 BYTE4 BYTE5
MNEMONIC MODE
7A N DJNZ r7,N
7B N JR UL,N
7C N LD r7,#N
7D Nh Nl JP UL,NN
7E K,rrs0 RRd0 ALDW RRd,(rrs)
7F K,rrx1 N Rd ALD Rd,N(rrx)
7F K,rrx0 Nh Nl Rd ALD Rd,NN(rrx)
80 Rd CPL Rd
81 Rd CPL (Rd)
82 rd,rs CP rd,rs
83 rd,rs CP rd,(rs)
84 Rs Rd CP Rd,Rs
85 Rd N CP Rd,#N
86 K,rrx1 N RRs1 ALDW N(rrx),RRs
86 K,rrx1 N RRd0 ALDW RRd,N(rrx)
86 K,rrx0 Nh Nl RRs1 ALDW NN(rrx),RRs
86 K,rrx0 Nh Nl RRd0 ALDW RRd,NN(rrx)
87 RRs0 RRd0 CPW RRd,RRs
87 RRd1 Nhs Nls CPW RRd,#NN
88 Rs LD r8,Rs
89 Rd LD Rd,r8
8A N DJNZ r8,N
8B N JR T,N
8C N LD r8,#N
8D Nh Nl JP T,NN
8E rrd0,rrs0 CPW rrd,rrs
8E rrd1,rrs0 CPW (rrd),rrs
8E rrd0,rrs1 CPW rrd,(rrs)
8E rrd1,rrs1 CPW (rrd),(rrs)
8F RRd0 RLCW RRd
8F F1 N PUSH N
8F F3 N PUSHU N
8F C1 Nh Nl PUSH NN
8F C3 Nh Nl PUSHU NN
8F 01 RRx0 N PEA N(RRx)
8F 01 RRx1 Nl Nh PEA NN(RRx)
8F 03 RRx0 N PEAU N(RRx)
8F 03 RRx1 Nl Nh PEAU NN(RRx)
90 Rd CLR Rd
91 Rd CLR (Rd)
92 rd,rs CP rd,rs
93 rd,rs CP rd,(rs)
94 Rs Rd CP Rd,Rs
95 Rd N CP Rd,#N
96 RRs0 K,rd ALDW (rd),RRs
97 RRs0 RRd0 CPW RRd,RRs
97 RRd1 Nhs Nls CPW RRd,#NN
63/303
ST9+ Programming Manual
OPCODE ADDRESSING
OPCODE BYTE1 BYTE2 BYTE3 BYTE4 BYTE5
MNEMONIC MODE
98 Rs LD r9,Rs
99 Rd LD Rd,r9
9A N DJNZ r9,N
9B N JR GE,N
9C N LD r9,#N
9D Nh Nl JP GE,NN
9E rrd0,rrs0 CPW rrd,rrs
9E rrd1,rrs0 CPW (rrd),rrs
9E rrd0,rrs1 CPW rrd,(rrs)
9E rrd1,rrs1 CPW (rrd),(rrs)
9F rrs0,rd N CPJF rd,(rrs),N
9F rrs1,rd N CPJT rd,(rrs),N
A0 Rd ROL Rd
A1 Rd ROL (Rd)
A2 rd,rs TM rd,rs
A3 rd,rs TM rd,(rs)
A4 Rs Rd TM Rd,Rs
A5 Rd N TM Rd,#N
A6 K,rs RRd0 ALDW RRd,(rs)
A7 RRs0 RRd0 TMW RRd,RRs
A7 RRd1 Nhs Nls TMW RRd,#NN
A8 Rs LD r10,Rs
A9 Rd LD Rd,r10
AA N DJNZ r10,N
AB N JR GT,N
AC N LD r10,#N
AD Nh Nl JP GT,NN
AE rrd0,rrs0 TMW rrd,rrs
AE rrd1,rrs0 TMW (rrd),rrs
AE rrd0,rrs1 TMW rrd,(rrs)
AE rrd1,rrs1 TMW (rrd),(rrs)
AF b0,rd N BTJT b.rd,N
AF b1,rd N BTJF b.rd,N
B0 Rd RLC Rd
B1 Rd RLC (Rd)
B2 rs,rx N LD N(rx),rs
B3 rd,rx N LD rd,N(rx)
B4 K,rrs1 Rd ALD Rd,(rrs)+
B4 K,rrd0 Rs ALD (rrd)+,Rs
B5 rd,rrs0 LD rd,(rrs)
B5 rs,rrd1 LD (rrd),rs
B6 RR0 PUSHUW RR
B6 RR1 N LINKU RR,#N
B7 RR0 POPUW RR
B7 RR1 UNLINKU RR
B8 Rs LD r11,Rs
B9 Rd LD Rd,r11
64/303
ST9+ Programming Manual
OPCODE ADDRESSING
OPCODE BYTE1 BYTE2 BYTE3 BYTE4 BYTE5
MNEMONIC MODE
BA N DJNZ r11,N
BB N JR UGT,N
BC N LD r11,#N
BD Nh Nl JP UGT,NN
BE K,rrd1 RRs0 ALDW (rr),RR
BE K,rrd0 Nh Nl ALDW (rr),#NN
BF RRd0 Nh Nl LDW RRd,#NN
BF 01 HALT
C0 Rd ROR Rd
C1 Rd ROR (Rd)
C2 K,rrs1 Rd ALD Rd,-(rrs)
C2 K,rrd0 Rs ALD -(rrd),Rs
C3 K,rrs1 RRd ALDW
C3 K,rrd0 RRs ALDW RRd,-(rrs)
C4 K,rd Nh Nl ALD -(rrd),RRs
C5 K,rs Nh Nl ALD NN,rs
C6 RR0 N DWJNZ RR,N
C6 RR1 EXT RR
C7 wwwww000 SRP wwwww
C7 wwwww100 SRP0 wwwww
C7 wwwww101 SRP1 wwwww
C7 pppppp10 SPP pppppp
C8 Rs LD r12,Rs
C9 Rd LD Rd,r12
CA N DJNZ r12,N
CB N JR NOV,N
CC N LD r12,#N
CD Nh Nl JP NOV,NN
CE ETRAP
CF RRd0 DECW RRd
D0 Rd RRC Rd
D1 Rd RRC (Rd)
D2 Nh Nl CALL NN
D3 IRET
D4 RR0 JP (RR)
D4 RR1 N LINK RR,#N
D5 K,rrs1 RRd0 ALDW RRd,(rrd)+
D5 K,rrd0 RRs0 ALDW (rrd)+,RRs
D6 rrd0,rrs0 LDPP (rrd)+,(rrs)+
D6 rrd1,rrs0 LDDP (rrd)+,(rrs)+
D6 rrd0,rrs1 LDPD (rrd)+,(rrs)+
D6 rrd1,rrs1 LDDD (rrd)+,(rrs)+
D7 rd,rrs1 LD (rd)+,(rrs)+
D7 rs,rrd0 LD (rrd)+,(rs)+
D8 Rs LD r13,Rs
D9 Rd LD Rd,r13
DA N DJNZ r13,N
65/303
ST9+ Programming Manual
OPCODE ADDRESSING
OPCODE BYTE1 BYTE2 BYTE3 BYTE4 BYTE5
MNEMONIC MODE
DB N JR PL,N
DC N LD r13,#N
DD Nh Nl JP PL,NN
DE rrs1,rx N LDW N(rx),rrs
DE rrd0,rx N LDW rrd,N(rx)
DF RRd0 INCW RRd
E0 Rd SRA Rd
E1 Rd SRA (Rd)
E2 K,rrd0 Nh Nl ALDW rrd,NN
E2 K,rrs1 Nh Nl ALDW NN,rrs
E3 rrd0,rrs0 LDW rrd,rrs
E3 rrd1,rrs0 LDW (rrd),rrs
E3 rrd0,rrs1 LDW rrd,(rrs)
E3 rrd1,rrs1 LDW (rrd),(rrs)
E4 rd,rs LD rd,(rs)
E5 rd,rs LD (rd),rs
E6 Rs K,rd ALD (rd),Rs
E7 K,rs Rd ALD Rd,(rs)
E8 Rs LD r14,Rs
E9 Rd LD Rd,r14
EA N DJNZ r14,N
EB N JR NE,N
EC N LD r14,#N
ED Nh Nl JP NE,NN
EE SPM
EF RRs0 RRd0 LDW RRd,RRs
EF 01 WFI
EF 31 ERET
F0 Rd SWAP Rd
F1 Rd SWAP (Rd)
F2 bs1,rs bd0,rd BLD rd.bd,rs.bs
F2 bs1,rs bd1,rd BLD rd.bd,rs.bs
F2 bd0,rd BTSET rd.bd
F3 K,rrd0 N ALD (rrd),#N
F4 Rs Rd LD Rd,Rs
F5 Rd N LD Rd,#N
F6 bd0,rr0 BTSET (rr).bd
F6 01 RETS
F7 Rs PUSH (Rs)
F8 Rs LD r15,Rs
F9 Rd LD Rd,r15
FA N DJNZ r15,N
FB N JR NC,N
FC N LD r15,#N
FD Nh Nl JP NC,NN
FE SDM
FF NOP
66/303
INSTRUCTIONS
ST9+ Programming Manual
INTRODUCTION
Instruction Format Description (See Notes below)
ADC 1 2 3
4 1
ADC
Add with carry (byte) Register, Register
5
7 8 9 10 11 14
ADC dst,src
INSTRUCTION FORMAT: No. No. OPC OPC Addr Mode
Oper
Bytes Cycl (HEX) XTN dst src
[ OPC ] [ XTN |src,1] [ dst ] 3 8 72 3 R (rr) a
3 8 72 3 r (rr) a
3 12 B4 3 R (rr)+ b
3 12 B4 3 r (rr)+ b
3 12 C2 3 R -(rr) c
3 12 C2 3 r -(rr) c
6
[ OPC ] [ofs,1|src,0] [ XTN | dst ] 3 12 60 3 r rr(rrx) a
[ OPC ] [ XTN |src,1] [ ofs ] 4 12 7F 3 R N(rr) a
[ dst ] 4 12 7F 3 r N(rr) a
[ OPC ] [ XTN | dst ] [ src h ] 4 10 C4 3 r NN a
[ src l ]
[ OPC ] [ XTN |src,0] [ ofs h ] 5 14 7F 3 R NN(rr) a
[ ofs l ] [ dst ] 5 14 7F 3 r NN(rr) a
12 13
1) Mnemonic Code
The assembly language name of an instruction.
3) Operand Size
4) Addressing Mode
Instructions are grouped by Addressing Mode families. For example, all instructions doing an “add with
carry on byte dealing between two operands expressed as register expressions” fall into the family: “Add
with carry (byte) Register, Register”. Add with carry is the “Shorthand Descriptive Name”, “byte” is the
size of the instruction family and “Register, Register” is the generic addressing mode
68/303
1
ST9+ Programming Manual
INTRODUCTION (Cont’d)
5) Assembly syntax
The assembly syntax gives the general form of the instruction, e.g.
ADC dst, src
has to be interpreted with all pairs of destination (dst) and source (src) operands as available in the cor-
responding columns of the instruction table.
6) Encoding patterns
Within a given instruction family, several encoding patterns are possible, depending on which combination
of operands is involved in the instruction. The instruction table contains a line for each possible encoding
pattern.
The nomenclature used in these encoding patterns is listed below:
[ a ] represents the byte whose value is a. In this case, value a is encoded on 8 bits.
[ a ] [ b ] represents the encoding of two consecutive bytes (the number of square brackets corre-
sponds to the number of consecutive bytes).
[ a | b ] represents the byte obtained by concatenating tetrad a to tetrad b. In this case, values a and
b are encoded on 4 bits. A tetrad is four bits and can also be called a nibble.
[ a | b,0 ] In this case, b is encoded on three bits and a 0 bit is added to complete the tetrad.
src h represents the high-order byte of a 16-bit immediate value, noted NN in the src column.
src l represents the low-order byte of a 16-bit immediate value, noted NN in the src column.
dst h represents the high-order byte of a 16-bit immediate value, noted NN in the dst column.
dst l represents the low-order byte of a 16-bit immediate value, noted NN in the dst column.
ofs represents either a single-byte immediate value offset, noted N in the src column, or the encod-
ing of the first rr register in case of a source rr(rr) operand.
ofd represents either a single-byte immediate value offset, noted N in the dst column, or the encod-
ing of the first rr register in case of a destination rr (rr) operand.
ofs h represents the high-order byte of a 16-bit immediate value, noted NN in the src column.
ofs l represents the low-order byte of a 16-bit immediate value, noted NN in the src column.
ofd h represents the high-order byte of a 16-bit immediate value, noted NN in the dst column.
ofd l represents the low-order byte of a 16-bit immediate value, noted NN in the dst column.
69/303
1
ST9+ Programming Manual
INTRODUCTION (Cont’d)
bts represents the encoding of bit number b of notation r.b in the source column.
btd represents the encoding of bit number b of notation r.b in the destination column.
cc represents the 4-bit encoding of the condition code, as described in Table 11 on page 23.
7) Number of bytes
The number of bytes needed to encode the full instruction.
8) Number of cycles
The number of cycles needed to perform the complete instruction.
9) Operation Code
An 8-bit value expressed in hexadecimal notation.
12) Destination
The encoding of the destination operand. It can be 3, 4 or 8 bits depending on the encoding context.
13) Source
The encoding of the source operand. It can be 3, 4 or 8 bits depending on the context.
14) Operation
A letter (a, b, etc.) which refers to a particular operation (OPERATION a, OPERATION b, etc.) described
below the table.
IMPORTANT:
The use of the DPRx or CSR registers is required for all virtual memory addresses (16 bits)
given in the following instruction examples. For simplicity in these examples, the virtual ad-
dresses are equal to their physical addresses (22 bits) and the selection of the DPRx or CSR
registers is not taken into account, although this takes place in normal conditions.
70/303
1
ST9+ Programming Manual
ADC ADC
Add with carry (byte) Register, Register
ADC dst,src
If the carry flag is set, working register 8 contains 35 (decimal) and register 64
contains 22 (decimal), after this instruction working register 8 will contain 58.
71/303
1
ST9+ Programming Manual
ADC ADC
Add with carry (byte) Register, Memory
ADC dst,src
72/303
1
ST9+ Programming Manual
ADC ADC
Add with carry (byte) Register, Memory
If the carry flag is reset, working register 8 contains 11 (decimal), working register pair
4 contains 4200 (decimal) and memory location 4200 contains 11 (decimal), after this
instruction working register 8 will contain 22 and working register pair 4 will contain
4201
73/303
1
ST9+ Programming Manual
ADC ADC
Add with carry (byte) Memory, Register
ADC dst,src
74/303
1
ST9+ Programming Manual
ADC ADC
Add with carry (byte) Memory, Register
If the carry flag is set, memory location 4028 contains 200 (decimal) and working
register 8 contains 32 (decimal), after this instruction memory location 4028 will
contain 233.
75/303
1
ST9+ Programming Manual
ADC ADC
Add with carry (byte) Memory, Memory
ADC dst,src
If the carry flag is set, working register pair 4 contains 2800 (decimal), memory
location 2800 contains 46 (decimal), working register pair 8 contains 4200 (decimal)
and memory location 4200 contains 45 (decimal), after this instruction memory
location 2800 will contain 92.
76/303
1
ST9+ Programming Manual
ADC ADC
Add with carry (byte) All, Immediate
ADC dst,src
If the carry flag is set, working register pair 8 contains 4028 (decimal) and memory
location 4028 contains 74 (decimal), after this instruction memory location 4028 will
contain 107.
77/303
1
ST9+ Programming Manual
ADCW ADCW
Add With Carry (Word) - Register, Register
ADCW dst,src
If the carry flag is zero, register pair 64 contains 1102 (decimal), working register 8
contains 200 (decimal), and register pair 200 contains 2550 (decimal), after this
instruction register pair 200 will hold 3652.
78/303
1
ST9+ Programming Manual
ADCW ADCW
Add With Carry (Word) - Register, Memory
ADCW dst,src
79/303
1
ST9+ Programming Manual
ADCW ADCW
Add With Carry (Word) - Register, Memory
If the carry flag is set, working register pair 4 contains 1184 (decimal), register pair 64
contains 5000 (decimal) and memory location 1182 contains 1100 (decimal), after this
instruction working register pair 64 will contain 6101 and register pair 4 will contain
1182.
80/303
1
ST9+ Programming Manual
ADCW ADCW
Add With Carry (Word) - Memory, Register
ADCW dst,src
81/303
1
ST9+ Programming Manual
ADCW ADCW
Add With Carry (Word) - Memory, Register
If the carry flag is set, register pair 64 contains 1250 (decimal), working register pair
4 contains 1064 (decimal), and memory location 1064 contains 1750, after this
instruction is carried out memory pair 1064 will contain 3001 and working register pair
4 will contain 1066.
82/303
1
ST9+ Programming Manual
ADCW ADCW
Add With Carry (Word) - Memory, Memory
ADCW dst,src
If the carry flag is set, working register pair 6 contains 1002 (decimal), memory pair
1002 contains 2300 (decimal), working register pair 4 contains 1060 (decimal) and
memory pair 1060 contains 2700 (decimal), after this instruction memory pair 1060
will contain 5001.
83/303
1
ST9+ Programming Manual
ADCW ADCW
Add With Carry (Word) - All, Immediate
ADCW dst,src
If the carry flag is zero and register pair 64 contains 2000 (decimal), after this
instruction has been carried out register pair 64 will contain the decimal value 6268.
84/303
1
ST9+ Programming Manual
ADD ADD
Add (byte) Register, Register
ADD dst,src
85/303
1
ST9+ Programming Manual
ADD ADD
Add (byte) Register, Memory
ADD dst,src
86/303
1
ST9+ Programming Manual
ADD ADD
Add (byte) Register, Memory
If register 32 contains 207 (decimal), working register pair 4 contains 4200 (decimal)
and memory location 4199 contains 27 (decimal), after this instruction register 32 will
contain 234 and working register pair 4 will contain 4199.
87/303
1
ST9+ Programming Manual
ADD ADD
Add (byte) Memory, Register
ADD dst,src
88/303
1
ST9+ Programming Manual
ADD ADD
Add (byte) Memory, Register
If working register pair 8 contains 4028 (decimal), memory location 4034 contains 110
(decimal) and register 255 contains 100 (decimal), after this instruction memory
location 4034 will contain 210.
89/303
1
ST9+ Programming Manual
ADD ADD
Add (byte) Memory, Memory
ADD dst,src
If working register pair 4 contains 2800 (decimal) and memory location 2800 contains
46 (decimal), working register pair 8 contains 4200 (decimal) and memory location
4200 contains 45 (decimal), after this instruction memory location 2800 will contain
91.
90/303
1
ST9+ Programming Manual
ADD ADD
Add (byte) All, Immediate
ADD dst,src
If working register pair 8 contains 4028 (decimal) and memory location 4028 contains
74 (decimal), after this instruction memory location 4028 will contain 106.
91/303
1
ST9+ Programming Manual
ADDW ADDW
Add (Word) - Register, Register
ADDW dst,src
If working register 8 contains 124, register pair 124 contains 1300 (decimal) and
register pair 64 contains 800 (decimal) after this instruction register pair 64 will contain
2100.
92/303
1
ST9+ Programming Manual
ADDW ADDW
Add (Word) - Register, Memory
ADDW dst,src
93/303
1
ST9+ Programming Manual
ADDW ADDW
Add (Word) - Register, Memory
If working register pair 8 contains 1240 (decimal), memory pair 1240 contains 3000
(decimal) and register pair 64 contains 1000 (decimal), after this instruction working
register pair 64 will contain 4000.
94/303
1
ST9+ Programming Manual
ADDW ADDW
Add (Word) - Memory, Register
ADDW dst,src
95/303
1
ST9+ Programming Manual
ADDW ADDW
Add (Word) - Memory, Register
If register pair 64 contains 1250 (decimal), working register pair 4 contains 1064
(decimal), and memory pair 1064 contains 1750, after this instruction is carried out
memory pair 1064 will contain 3000 and working register pair 4 will contain 1066.
96/303
1
ST9+ Programming Manual
ADDW ADDW
Add (Word) - Memory, Memory
ADDW dst,src
If working register pair 6 contains 1002 (decimal), memory pair 1002 contains 2300
(decimal), working register pair 4 contains 1060 (decimal) and memory pair 1060
contains 2700 (decimal), after this instruction memory pair 1060 will contain 5000.
97/303
1
ST9+ Programming Manual
ADDW ADDW
Add (Word) - All, Immediate
ADDW dst,src
If register pair 64 contains 2000 (decimal), after this instruction has been carried out
register pair 64 will contain the decimal value 6268.
98/303
1
ST9+ Programming Manual
AND AND
AND (byte) Register, Register
AND dst,src
If working register 8 contains 11001100 and register 64 contains 10000101, after this
instruction working register 8 will contain 10000100.
99/303
1
ST9+ Programming Manual
AND AND
AND (byte) Register, Memory
AND dst,src
100/303
1
ST9+ Programming Manual
AND AND
AND (byte) Register, Memory
101/303
1
ST9+ Programming Manual
AND AND
AND (byte) Memory, Register
AND dst,src
102/303
1
ST9+ Programming Manual
AND AND
AND (byte) Memory, Register
103/303
1
ST9+ Programming Manual
AND AND
AND (byte) Memory, Memory
AND dst,src
If working register pair 4 contains 2800 (decimal), memory location 2800 contains
11001100, working register pair 8 contains 4200 (decimal) and memory location 4200
contains 11000011, after this instruction memory location 2800 will contain
11000000.
104/303
1
ST9+ Programming Manual
AND AND
AND (byte) All, Immediate
AND dst,src
If working register pair 8 contains 4028 (decimal) and memory location 4028 contains
11101100, after this instruction memory location 4028 will contain 00100000.
105/303
1
ST9+ Programming Manual
ANDW ANDW
AND (Word) - Register, Register
ANDW dst,src
106/303
1
ST9+ Programming Manual
ANDW ANDW
AND (Word) - Register, Memory
ANDW dst,src
107/303
1
ST9+ Programming Manual
ANDW ANDW
AND (Word) - Register, Memory
FLAGS: C: Unaffected.
Z: Set if the result is zero, otherwise cleared.
S: Set if result bit 15 is set, otherwise cleared.
V: Always reset to zero.
D: Undefined.
H: Undefined.
If working register pair 4 contains 1184 (decimal), register pair 64 contains 10101010/
10101010B and memory pair 1184 contains 11001100/11001100B, after this
instruction register pair 64 will contain 10001000/10001000B and register pair 4 will
contain 1186.
108/303
1
ST9+ Programming Manual
ANDW ANDW
AND (Word) - Memory, Register
ANDW dst,src
109/303
1
ST9+ Programming Manual
ANDW ANDW
AND (Word) - Memory, Register
110/303
1
ST9+ Programming Manual
ANDW ANDW
AND (Word) - Memory, Memory
ANDW dst,src
If working register pair 6 contains register 1002 (decimal), memory pair 1002 contains
11001100/11001100B, working register pair 4 contains 1060 (decimal), and memory
pair 1060 contains 10101010/10101010B, after this instruction memory pair 1060 will
contain 10001000/10001000B.
111/303
1
ST9+ Programming Manual
ANDW ANDW
AND (Word) - All, Immediate
ANDW dst,src
112/303
1
ST9+ Programming Manual
BAND BAND
Bit AND
BAND dst.b,src.b
If bit 2 of working register 8 is 0 and bit 5 of working register 4 is 1, after this instruction
bit 5 of working register 4 will be 0.
NOTE: A bit AND can use the same or different nibbles of the same register as both source
and destination.
113/303
1
ST9+ Programming Manual
BCPL BCPL
Bit Complement
BCPL dst.b
114/303
1
ST9+ Programming Manual
BLD BLD
Bit Load
BLD dst.b,src.b
If bit 2 of working register 8 is 1, after this instruction bit 5 of working register 4 will be
0.
NOTE: A bit load can use the same or different nibbles of the same register as both source
and destination.
115/303
1
ST9+ Programming Manual
BOR BOR
Bit OR
BOR dst.b,src.b
If bit 2 of working register 8 is 1 and bit 5 of working register 4 is 0, after this instruction
bit 5 of working register 4 will be 1.
NOTE: A bit OR can use the same or different nibbles of the same register as both source
and destination.
116/303
1
ST9+ Programming Manual
BRES BRES
Bit Reset
BRES dst.b
117/303
1
ST9+ Programming Manual
BSET BSET
Bit Set
BSET dst.b
118/303
1
ST9+ Programming Manual
BTJF BTJF
Bit Test And Jump If False
BTJF dst,src
If bit 2 of working register 10 is zero and the program counter holds 200, after this
instruction the program counter will jump to address 160.
119/303
1
ST9+ Programming Manual
BTJT BTJT
Bit Test And Jump If True
BTJT dst,src
If bit 2 of working register 10 is a one and the program counter holds 200, after this
instruction the program counter will jump to address 240.
120/303
1
ST9+ Programming Manual
BTSET BTSET
Bit Test and Set
BTSET dst.b
If bit 5 of working register 4 is 0, after this instruction it is set to 1 and the zero flag is
also set to 1.
121/303
1
ST9+ Programming Manual
BXOR BXOR
Bit XOR
BXOR dst.b,src.b
If bit 2 of working register 8 is 1 and bit 5 of working register 4 is 0, after this instruction
bit 5 of working register 4 will be 1.
NOTE: A bit XOR can use the same or different nibbles of the same register as both source
and destination.
122/303
1
ST9+ Programming Manual
CALL CALL
Unconditional Call
CALL dst
The current contents of the program counter (PC) are pushed onto the top of the
system stack. (The program counter value used is the address of the first instruction
byte following the CALL instruction). The specified destination address is then loaded
into the PC and points to the first instruction of the CALL procedure.
In direct memory addressing mode the destination is in the memory location
addressed by the absolute value in the operand.
In the indirect memory addressing mode the destination is in the memory location
addressed by the contents of the destination register pair.
FLAGS: No flags affected.
If the content of the program counter is 1A47 (hex) and the content of the system stack
pointer is 3002 (hex) the above instruction will cause the stack pointer to be
decremented to 3000 (hex), 1A4A (the address following the instruction) is stored in
external data memory 3000 (hex) and 3001 (hex), and the program counter is loaded
with 3521 (hex). The program counter now points to the address of the first statement
in the procedure to be executed.
123/303
1
ST9+ Programming Manual
CALLS CALLS
Unconditional Call Segment
This instruction uses a different stack frame, saving both the PC and the CSR on the
stack.
The current content of the program counter (PC) and then, the content of the CSR are
pushed onto the top of the system stack. (The program counter value used is the
address of the first instruction byte following the CALLS instruction). The specified
destination address is then loaded into the CSR and PC and points to the first
instruction of the CALLS procedure.
In direct memory addressing mode the destination is in the memory location
addressed by the absolute value in the operands.
In the indirect memory addressing mode the destination is in the memory location
addressed by the contents of the destination registers.
FLAGS: No flags affected.
124/303
1
ST9+ Programming Manual
If the content of the PC is 1A47 (hex), the content of CSR is 6 and the content of the
system stack pointer is 3003 (hex) the above instruction will cause the stack pointer
to be decremented to 3000 (hex), 1A4B (the address following the instruction) is
stored in external data memory 3000 (hex) and 3001 (hex), the value 6 (CSR) is
stored in 3002 (hex), CSR and PC are loaded with 12, 3521 (hex). The program
counter now points to the address of the first statement in the procedure to be
executed.
Stack
3003h
PCL
PCH
CSR 3000h
125/303
1
ST9+ Programming Manual
CCF CCF
Complement Carry Flag
CCF
OPERATION: C ⇐ NOT C
The carry flag is complemented; if C=1 it is changed to C=0 and vice-versa.
FLAGS: C: Complemented.
No other flags affected.
If the carry flag is set to one, after this instruction it will be reset to zero.
126/303
1
ST9+ Programming Manual
CLR CLR
Clear Register
CLR dst
OPERATION: dst ⇐ 0
The contents of destination register, directly or indirectly addressed, is cleared to
zero.
FLAGS: No flags affected.
If register 32 holds 142, after this instruction register 142 will contain 0.
127/303
1
ST9+ Programming Manual
CP CP
Compare (byte) Register, Register
CP dst,src
128/303
1
ST9+ Programming Manual
CP CP
Compare (byte) Register, Memory
CP dst,src
129/303
1
ST9+ Programming Manual
CP CP
Compare (byte) Register, Memory
CP dst,src (Cont’d)
If register 32 contains 11001100, working register pair 4 contains 4200 (decimal) and
memory location 4199 contains 11001100, after this instruction, C, S, V flags will be
reset to zero, the zero flag will be set to one and working register pair 4 will contain
4199.
130/303
1
ST9+ Programming Manual
CP CP
Compare (byte) Memory, Register
CP dst,src
131/303
1
ST9+ Programming Manual
CP CP
Compare (byte) Memory, Register
CP dst,src (Cont’d)
132/303
1
ST9+ Programming Manual
CP CP
Compare (byte) Memory, Memory
CP dst,src
If working register pair 4 contains 2800 (decimal), memory location 2800 contains
11001100, working register pair 8 contains 4200 (decimal) and memory location 4200
contains 11001100, after this instruction the zero flag will be set to one.
133/303
1
ST9+ Programming Manual
CP CP
Compare (byte) All, Immediate
CP dst,src
If working register pair 8 contains 4028 (decimal) and memory location 4028 contains
11101100, after this instruction the zero flag will be reset to zero.
134/303
1
ST9+ Programming Manual
CPJFI CPJFI
Compare And Jump If False Otherwise Post-Increment
CPJFI dst,src,N
OPERATION: If compare not verified jump, otherwise increment source register pair.
The source operand is compared to (subtracted from) the destination operand. If the
result is different from zero the offset N (where N is in the range -128/+127) is added
to the program counter and control passes to the statement whose address is now in
the PC, otherwise the source pointer is incremented by one and the instruction
following the CPJFI is executed.
FLAGS: No flags affected.
If the current value of the program counter is 340 (decimal) and working register 2
contains 11001100B, working register pair 14 contains 3000 (decimal) and memory
location 3000 holds 10000100B the program counter will now point at program
location 440 (decimal).
NOTE: The source value must exist within the destination area (or limit checks must be
included).
135/303
1
ST9+ Programming Manual
CPJTI CPJTI
Compare And Jump If True Otherwise Post-Increment
CPJTI dst,src,N
If the current value of the program counter is 340 (decimal) and working register 2
contains 11001100B, working register pair 14 contains 3000 (decimal) and memory
location 3000 holds 11001100B the program counter will now point at program
location 440 (decimal).
NOTE: The source value must exist within the destination area (or limit checks must be
included).
136/303
1
ST9+ Programming Manual
CPL CPL
Complement Register
CPL dst
If register 32 contains 142 and register 142 holds 10101010B, after this instruction the
contents of register 142 become 01010101B.
137/303
1
ST9+ Programming Manual
CPW CPW
Compare (Word) - Register, Register
CPW dst,src
138/303
1
ST9+ Programming Manual
CPW CPW
Compare (Word) - Register, Memory
CPW dst,src
139/303
1
ST9+ Programming Manual
CPW CPW
Compare (Word) - Register, Memory
If working register pair 4 contains 1184 (decimal), register pair 64 contains 11001100/
11001100B and memory pair 1182 contains 11001100/11001100B, after this
instruction has been carried out the zero flag will be set and register pair 4 will contain
1182.
140/303
1
ST9+ Programming Manual
CPW CPW
Compare (Word) - Memory, Register
CPW dst,src
141/303
1
ST9+ Programming Manual
CPW CPW
Compare (Word) - Memory, Register
142/303
1
ST9+ Programming Manual
CPW CPW
Compare (Word) - Memory, Memory
CPW dst,src
If working register pair 6 contains 1002 (decimal), memory pair 1002 contains
11001100/11001100B, working register pair 4 contains 1060 (decimal) and memory
pair 1060 contains 11001100/11001100B, after this instruction the zero flag will be
set.
143/303
1
ST9+ Programming Manual
CPW CPW
Compare (word) - All, Immediate
CPW dst,src
144/303
1
ST9+ Programming Manual
DA DA
Decimal Adjust
DA dst
145/303
1
ST9+ Programming Manual
DA DA
Decimal Adjust
DA dst (Cont’d)
If addition is performed using the BCD values 15 and 27, the result should be 42. The
sum is incorrect, however, in the destination location when using standard binary
arithmetic.
The DA statement adjusts this result so that the correct BCD representation is
obtained.
146/303
1
ST9+ Programming Manual
DEC DEC
Decrement Register
DEC dst
If working register 2 holds 122 and register 122 contains 100 (decimal), after this
instruction is executed register 122 will contain 99.
147/303
1
ST9+ Programming Manual
DECW DECW
Decrement Word Register
DECW dst
If working register pair 2 holds 2000 (decimal), after this instruction is executed it will
contain 1999 (decimal).
148/303
1
ST9+ Programming Manual
DI DI
Disable Interrupts
DI
OPERATION: CIC.4 ⇐ 0
Bit 4 of the Central Interrupt Control register (R230) is reset to zero. All interrupts
except NMI are then disabled.
FLAGS: No flags affected.
149/303
1
ST9+ Programming Manual
DIV DIV
Divide (16/8)
DIV dst,src
If working register 6 contains 30 (decimal) and working register pair 8 contains 500
(decimal), after this instruction working register 9 will contain 16 (decimal) and
working register 8 will contain 20 (decimal).
150/303
1
ST9+ Programming Manual
DIV DIV
Divide (16/8)
NOTE 1: If the dividend high is greater than or equal to the divisor the instruction is not carried
out, the carry flag is reset to zero (D flag is always set to one), all other flags are
undefined. This control takes 20 clock cycles and both destination and source register
remain unmodified.
NOTE 2: If the divisor is zero, a trap is generated simulating a subroutine call. The current
Program Counter is saved on the system stack and then the PC is set to the
contents of memory locations 0002 and 0003 of the Program memory which
contains the Divide-by-zero trap vector. This procedure takes 38 clock cycles.
151/303
1
ST9+ Programming Manual
DIVWS DIVWS
Divide Word Stepped (32/16)
OPERATION:
When executed 16 times and then followed by a RLCW on the destination low working
register pair, this instruction carries out a 32 bit by 16 bit divide and leaves the result
in the destination low working register pair and the remainder in the destination high
working register pair. No automatic controls are carried out on the relationship
between divisor and dividend before this instruction is carried out, nor is the divisor
checked for zero, these should be supplied by the user.
FLAGS: C: Unaffected.
Z: Set to one.
S: Reset to zero.
V: Reset to zero.
D: Unaffected.
H: Reset to zero.
.
Working register pair 6 will contain the 16 high order bits of the dividend, working
register pair 8 will contain the 16 low order bits of the dividend and register pair 10 will
contain the 16 bit divisor. After this instruction working register pair 8 will contain the
result and working register pair 6 the remainder. See subroutine example.
NOTE: A typical example of a subroutine using the DIVWS instruction is shown below.
152/303
1
ST9+ Programming Manual
DIVWS DIVWS
Divide Word Stepped (32/16)
d_len = r0
dvsr = RR10
dvd_hi = rr6
dvd_low = rr8
;
;inputs: RR10 = 16 bit divisor
; rr6 = 32 bit dividend high
; rr8 = 32 bit dividend low
;outputs: RR10 = unmodified divisor
; rr6 = remainder
; rr8 = result
;
DIVSTEP:
cpw dvd_hi,dvsr ;check dividend higher than divisor
jrug Out ;if not leave subroutine
cpw dvsr,#0000h ;check divisor zero
jrnz Defloop ;if true start divide
Out: ret
Defloop:
pushu d_len ;set 16 bit step divide loop
ld d_len,#16
Loop: divws dvd_hi,dvd_low,dvsr
;carry out divws
djnz d_len,Loop ;16 times
rlcw dvd_low
popu d_len
ret
153/303
1
ST9+ Programming Manual
DJNZ DJNZ
Decrement And Jump If Not Zero
DJNZ dst,N
NOTE : Due to the ST9 architecture, the DJNZ instruction cannot be used with registers in
group E or F accessed through working registers pointing to such groups, as the result
of this test is undefined.
154/303
1
ST9+ Programming Manual
DWJNZ DWJNZ
Decrement Word And Jump If Not Zero
DWJNZ dst,N
EXAMPLE: DWJNZ is typically used to control a “loop” of instructions. In the following example
300 bytes are moved from one area in the register file to another. The steps involved
are:
NOTE : Due to the ST9 architecture, the DWJNZ instruction cannot be used with registers in
group E or F accessed through working registers pointing to such groups, as the result
of this test is undefined.
155/303
1
ST9+ Programming Manual
EI EI
Enable Global Interrupts
EI
OPERATION: CIC.4 ⇐ 1
Bit 4 of the Central Interrupt Control register (R230) is set to one. All interrupts except
NMI are then enabled.
FLAGS: No flag affected.
NOTE: The NMI (Not Maskable Interrupt) must be separately enabled (see Technical
Manual).
156/303
1
ST9+ Programming Manual
EXT EXT
Sign Extend
EXT dst
If bit 7 of register R11 is 1, after this instruction all bits in register R10 will be 1.
157/303
1
ST9+ Programming Manual
HALT HALT
Halt
HALT
When the program encounters this instruction it is halted until a reset is executed.
158/303
1
ST9+ Programming Manual
INC INC
Increment Register
INC dst
If register 32 holds 142 and register 142 contains 95 (decimal), after this instruction
register 142 will contain 96.
159/303
1
ST9+ Programming Manual
INCW INCW
Register Increment Word
INCW dst
If register pair 32 contains 4000 (decimal) after this instruction it will contain 4001
(decimal).
160/303
1
ST9+ Programming Manual
IRET IRET
Interrupt Return
IRET
This instruction causes the program to resume execution exactly at the point it left
when an interrupt service routine was initiated. All flags are set to the status they had
when the interrupt service routine was started.
EMR2.EMCSV = 0 (ISR used): EMR2.EMCSV = 1 (CSR used):
2002h 2002h
PCL PCL
PCH 2000h PCH 2000h
FLAGS CSR
FLAGS
161/303
1
ST9+ Programming Manual
JP JP
Unconditional Jump
JP dst
OPERATION: PC ⇐ dst
The unconditional jump simply replaces the contents of the program counter with the
destination contents. Control then passes to the statement addressed by the program
counter.
The destination operand can be in a directly or indirectly addressed program memory
location.
FLAGS: No flags affected.
The instruction replaces the content of the program counter with 1024 (decimal) and
transfers program control to that location.
162/303
1
ST9+ Programming Manual
JPS JPS
Unconditional Jump Segment
The instruction replaces the content of the program counter with 1024 (decimal) and
transfers program control to that location.
163/303
1
ST9+ Programming Manual
JPcc JPcc
Conditional Jump
JPcc dst
If the result of the last mathematic or logic operation left the zero flag set, then the
program counter is loaded with 1024 (decimal) and control is transferred to that
location.
164/303
1
ST9+ Programming Manual
JRcc JRcc
Conditional Jump Relative
JRcc dst
If the result of the last mathematic or logic operation left the zero flag set then the
program counter is loaded with the present value plus 24 and control is transferred to
that location.
165/303
1
ST9+ Programming Manual
LD LD
Load (byte) Register, Register
LD dst,src
If register 5 contains 183 (decimal) and register 255 (i.e. 183+72) contains 131
(decimal), after this instruction working register 8 will contain 131.
166/303
1
ST9+ Programming Manual
LD LD
Load (byte) Register, Memory
LD dst,src
167/303
1
ST9+ Programming Manual
LD LD
Load (byte) Register, Memory
LD dst,src (Cont’d)
If working register 4 contains 100 (decimal), working register pair 6 contains 1242
(decimal) and memory location 1242 contains 132, after this instruction register 100
will contain 132, working register 4 will contain 101 and working register 6 will contain
1243.
168/303
1
ST9+ Programming Manual
LD LD
Load (byte) Memory, Register
LD dst,src
169/303
1
ST9+ Programming Manual
LD LD
Load (byte) Memory, Register
LD dst,src (Cont’d)
If working register pair 4 contains 1000 (decimal), working register 6 contains 242
(decimal) and register 242 contains 132, after this instruction memory location 1000
will contain 132, working register pair 4 will contain 1001 and working register 6 will
contain 243.
170/303
1
ST9+ Programming Manual
LD LD
Load (Byte) Memory, Memory
LD dst,src
If working register pair 4 contains 1000 (decimal), working register pair 6 contains
1242 (decimal) and memory location 1242 contains 132, after this instruction memory
location 1000 will contain 132.
171/303
1
ST9+ Programming Manual
LD LD
Load (Byte) All, Immediate
LD dst,src
After this instruction has been carried out working register 8 contains the decimal
value 242.
172/303
1
ST9+ Programming Manual
If working register pair 8 contains 1131 (decimal), working register pair 12 contains
2400 (decimal) and the memory location 2400 contains 100 (decimal), after this
instruction memory location 1131 will contain 100, working register pair 8 will contain
1132 and working register pair 12 will contain 2401.
173/303
1
ST9+ Programming Manual
LDW LDW
Load (Word) Register, Register
LDW dst,src
If register pair 254 contains 3F C1 (hex), after this instruction the working register pair
8 will contains 3F C1 (hex).
174/303
1
ST9+ Programming Manual
LDW LDW
Load (Word) Register, Memory
LDW dst,src
If working register 4 contains 2400 (decimal) and memory pair 2400 contains 56 ED
(Hex), after this instruction working register pair 8 will contain 56 ED and working
register pair 4 will contain 2402.
175/303
1
ST9+ Programming Manual
LDW LDW
Load (Word) Memory, Register
LDW dst,src
176/303
1
ST9+ Programming Manual
LDW LDW
Load (Word) Memory, Register
If working register pair 4 contains 1024 (decimal) and register pair 64 contains 8F E3
(Hex), after this instruction memory pair 1024 will contain 8F E3 and register pair 4 will
contain 1026.
177/303
1
ST9+ Programming Manual
LDW LDW
Load (Word) Memory, Memory
LDW dst,src
If working register pair 4 contains 1024 (decimal), working register pair 6 contains
2042 (decimal) and memory pair 2042 contains CB ED (Hex), after this instruction
memory pair 1024 will contain CB ED.
178/303
1
ST9+ Programming Manual
LDW LDW
Load (Word) All, Immediate
LDW dst,src
After this instruction has been carried out, register pair 100 contains the decimal value
4268 (10 AC Hex.). With 16-bit words, the Most Significant Bit is in the lower byte of
the memory. Therefore, R100 = 0x10 and R101 = 0xAC.
179/303
1
ST9+ Programming Manual
LINK LINK
Link code
LINK
OPERATION: Stack in memory (16 cycles) Stack in the register file (12 cycles)
SSP = SSP - 2 SSP(low) = SSP(low) - 1
(SSP) = RR (SSP(low)) = RR(low)
RR = SSP RR(low) = SSP(low)
SSP = SSP - N SSP(low) = SSP(low) - N
SSP(high) = undefined
In C functions, the compiler needs to push variables in the system stack and to keep
the return address location of the function inside the stack.
Therefore, a frame pointer is used, and 2 pieces of code named prologue and
epilogue need to be added at the beginning and at the end of the function.
The "Link" instruction is used to reduce the code overhead generated by the compiler
inside the function.
Stack in memory (16 cycles) Stack in the register file (12 cycles)
SSP
SSP
RR4(high) RR4_new
RR4(low) RR4(low) RR4_new
After the instruction, RR4 points to the location where previous RR4 has been stored.
180/303
1
ST9+ Programming Manual
LINKU LINKU
Link code
LINKU
OPERATION: Stack in memory(16 cycles) Stack in the register file (12 cycles)
USP = USP - 2 USP(low) = USP(low) - 1
(USP) = RR (USP(low)) = RR(low)
RR = USP RR(low) = USP(low)
USP = USP - N USP(low) = USP(low) - N
USP(high) = undefined
In C functions, the compiler needs to push variables in the user stack and to keep the
return address location of the function inside the stack.
Therefore, a frame pointer is used, and 2 pieces of code named prologue and
epilogue need to be added at the beginning and at the end of the function.
The "Linku" instruction is used to reduce the code overhead generated by the
compiler inside the function.
Stack in memory (16 cycles) Stack in the register file (12 cycles)
USP
USP
RR4(high) RR4_new
RR4(low) RR4(low) RR4_new
After the instruction, RR4 points to the location where previous RR4 has been stored.
181/303
1
ST9+ Programming Manual
MUL MUL
Multiply (8x8)
MUL dst,src
If working register 7 contains 35 and working register 8 contains 220, after this
instruction working register pair 6 will contain 7700 (decimal), i.e. working register 6
will contain 1E (Hex) and register 7 will contain 14 (Hex).
182/303
1
ST9+ Programming Manual
NOP NOP
No Operation
NOP
OPERATION: No Operation is carried out. This instruction is often used in timing or delay loops.
183/303
1
ST9+ Programming Manual
OR OR
OR (byte) Register, Register
OR dst,src
If working register 8 contains 11001100 and register 64 contains 10000101, after this
instruction working register 8 will contain 11001101.
184/303
1
ST9+ Programming Manual
OR OR
OR (byte) Register, Memory
OR dst,src
185/303
1
ST9+ Programming Manual
OR OR
OR (byte) Register, Memory
OR dst,src (Cont’d)
FLAGS: C: Unaffected.
Z: Set if the result is zero, otherwise cleared.
S: Set if result bit 7 is set, otherwise cleared.
V: Always reset to zero.
D: Unaffected.
H: Unaffected.
186/303
1
ST9+ Programming Manual
OR OR
OR (byte) Memory, Register
OR dst,src
187/303
1
ST9+ Programming Manual
OR OR
OR (byte) Memory, Register
OR dst,src (Cont’d)
FLAGS: C: Unaffected.
Z: Set if the result is zero, otherwise cleared.
S: Set if result bit 7 is set, otherwise cleared.
V: Always reset to zero.
D: Unaffected.
H: Unaffected.
188/303
1
ST9+ Programming Manual
OR OR
OR (byte) Memory, Memory
OR dst,src
If working register pair 4 contains 2800 (decimal), memory location 2800 contains
11001100, working register pair 8 contains 4200 (decimal) and memory location 4200
contains 00001100, after this instruction memory location 2800 will contain
11001100.
189/303
1
ST9+ Programming Manual
OR OR
OR (byte) All, Immediate
OR dst,src
If working register pair 8 contains 4028 (decimal) and memory location 4028 contains
11101101, after this instruction memory location 4028 will contain 11101101.
190/303
1
ST9+ Programming Manual
ORW ORW
OR (Word) - Register, Register
ORW dst,src
191/303
1
ST9+ Programming Manual
ORW ORW
OR (Word) - Register, Memory
ORW dst,src
192/303
1
ST9+ Programming Manual
ORW ORW
OR (Word) - Register, Memory
FLAGS: C: Unaffected.
Z: Set if the result is zero, otherwise cleared.
S: Set if result bit 15 is set, otherwise cleared.
V: Always reset to zero.
D: Unaffected.
H: Unaffected.
If working register pair 4 contains 1184 (decimal), register pair 64 contains 10101010/
10101010B and memory pair 1182 contains 11001100/11001100B, after this
instruction register pair 64 will contain 11101110/11101110B and register pair 4 will
contain 1182.
193/303
1
ST9+ Programming Manual
ORW ORW
OR (Word) - Memory, Register
ORW dst,src
194/303
1
ST9+ Programming Manual
ORW ORW
OR (Word) - Memory, Register
FLAGS: C: Unaffected.
Z: Set if the result is zero, otherwise cleared.
S: Set if result bit 15 is set, otherwise cleared.
V: Always reset to zero.
D: Unaffected.
H: Unaffected.
195/303
1
ST9+ Programming Manual
ORW ORW
OR (Word) - Memory, Memory
ORW dst,src
If working register pair 6 contains 1002 (decimal), memory pair 1002 contains
11001100/11001100B, working register pair 4 contains 1060 (decimal) and memory
pair 1060 contains 10101010/10101010B, after this instruction memory pair 1060 will
contain 11101110/11101110B.
196/303
1
ST9+ Programming Manual
ORW ORW
OR (Word) - All, Immediate
ORW dst,src
197/303
1
ST9+ Programming Manual
PEA PEA
Push Effective Address on System Stack
PEA src
The content of register pair RR32 is 1024, to this value is added the immediate value
16 and the result is pushed into the stack location pointed by the pre-decremented
system stack pointer.
198/303
1
ST9+ Programming Manual
PEAU PEAU
Push Effective Address on User Stack
PEAU src
The content of register pair RR32 is 1024, to this value is added the immediate value
16 and the result is pushed into the stack location pointed by the pre-decremented
user stack pointer.
199/303
1
ST9+ Programming Manual
POP POP
Pop Byte from System Stack
POP dst
If the system stack pointer contains 2000 (decimal), working register 2 contains 52
(decimal) and system stack location 2000 contains 124 (decimal), after this instruction
register 52 will contain 124 and the system stack pointer will contain 2001.
200/303
1
ST9+ Programming Manual
POPU POPU
Pop Byte from User Stack
POPU dst
If the user stack pointer contains 2000 (decimal), working register 2 contains 52
(decimal) and user stack location 2000 contains 124 (decimal), after this instruction
register 52 will contain 124 and the user stack pointer will contain 2001.
201/303
1
ST9+ Programming Manual
POPUW POPUW
Pop Word from User Stack
POPUW dst
If the user stack pointer contains 2000 (decimal), user stack location 2000 contains 11
(hex) and user stack location 2001 contains 24 (hex), after this instruction working
register 2 will contain 11 (hex), working register 3 will contain 24 (hex) and the user
stack pointer will contain 2002.
202/303
1
ST9+ Programming Manual
POPW POPW
Pop Word from System Stack
POPW dst
If the system stack pointer contains 2000 (decimal), system stack location 2000
contains 11 (hex), system stack location 2001 contains 24 (hex), after this instruction
working register 2 will contain 11 (hex), working register 3 will contain 24 (hex) and the
system stack pointer will contain 2002.
203/303
1
ST9+ Programming Manual
PUSH PUSH
Push Byte on System Stack
PUSH src
If the system stack pointer contains 2000 (decimal), register 32 contains 100 and
register 100 contains 60 (decimal), after this instruction system stack pointer location
1999 will contain 60.
204/303
1
ST9+ Programming Manual
PUSHU PUSHU
Push Byte on User Stack
PUSHU src
If the user stack pointer contains 2000 (decimal), after this instruction user stack
pointer location 1999 will contain 20.
205/303
1
ST9+ Programming Manual
PUSHUW PUSHUW
Push Word on User Stack
PUSHUW src
If the stack pointer contains 2000 (decimal) and register pair 32 contains 6000 (hex),
after this instruction the user stack pointer will contain 1998, user stack location 1999
will contain 00 (hex) and user stack location 1998 will contain 60 (hex).
206/303
1
ST9+ Programming Manual
PUSHW PUSHW
Push Word on System Stack
PUSHW src
If the system stack pointer contains 2000 (decimal) and register pair 32 contains 6000
(hex), after this instruction the system stack pointer will contain 1998, system stack
location 1999 will contain 00 (hex) and system stack location 1998 will contain 60
(hex).
207/303
1
ST9+ Programming Manual
RCF RCF
Reset Carry Flag
RCF
OPERATION: C⇐0
The carry flag is reset to zero, regardless of its previous content.
FLAGS: C: reset to zero.
No other flags affected.
Regardless of its prior condition, after this instruction the carry flag will be reset to
zero.
208/303
1
ST9+ Programming Manual
RET RET
Return From Subroutine
RET
OPERATION: PC ⇐ (SSP)
SSP ⇐ SSP + 2
This instruction is normally used to return to the previously executed procedure at the
end of procedure entered by a CALL statement. The contents of the location
addressed by the system stack pointer are popped into the program counter. The next
statement executed is that addressed by the new content of the PC.
FLAGS: No flags affected.
EXAMPLE: If the program counter contains 35B4 (hex), the system stack pointer contains 2000
(hex), external data memory location 2000 (hex) contains 18 (hex), and location 2001
(hex) contains 85 (hex), then the instruction:
RET
leaves the value 2002 (hex) in the system stack pointer and 1885 (hex), the
addressed of the next instruction, in the program counter.
Stack
2002h
PCL
PCH 2000h
209/303
1
ST9+ Programming Manual
RETS RETS
Return From Far Subroutine
RETS
Stack
2003h
PCL
PCH
CSR 2000h
210/303
1
ST9+ Programming Manual
RLC RLC
Rotate Left Through Carry
RLC dst
OPERATION: dst(0) ⇐ C
C ⇐ dst(7)
dst(n+1) ⇐ dst(n) Where n=0-6
The contents of the destination register are shifted one place to the left with bit 7
shifted into the carry flag and the carry flag shifted into bit 0. The destination register
can be directly or indirectly addressed.
b7 b0
If the carry flag is zero, working register 2 contains 155 (decimal) and register 155
contains 11001100B, after this instruction register 155 will contain 10011000B and
the carry flag will be set to 1.
211/303
1
ST9+ Programming Manual
RLCW RLCW
Rotate Left Through Carry Word
RLCW dst
OPERATION: dst(0) ⇐ C
C ⇐ dst(15)
dst(n+1) ⇐ dst(n) where n=0-14
The contents of the destination register pair are shifted one place to the left with bit 15
shifted into the carry flag and the carry flag shifted into bit 0.
b15 b0
If the carry flag is zero, and working register pair 2 contains 11001100/11001100B,
after this instruction it will 10011001/10011000B and the carry flag will be set to 1.
212/303
1
ST9+ Programming Manual
ROL ROL
Rotate Left Byte
ROL dst
OPERATION: C ⇐ dst(7)
dst(0) ⇐ dst(7)
dst(n+1) ⇐ dst(n) Where n=0-6
The contents of the destination register are shifted one place to the left with bit 7
shifted into bit 1 and into the carry flag. The destination register can be directly or
indirectly addressed.
b7 b0
If working register 2 contains 146 (decimal) and register 146 contains 11001100B,
after this instruction register 146 will contain 10011001B and the carry flag will be set
to 1.
213/303
1
ST9+ Programming Manual
ROR ROR
Rotate Right Byte
ROR dst
OPERATION: C ⇐ dst(0)
dst(7) ⇐ dst(0)
dst(n) ⇐ dst(n+1) Where n=0-6
The contents of the destination register are shifted one place to the right with bit 0
shifted into bit 7 and into the carry flag. The destination register can be directly or
indirectly addressed.
b7 b0
If the carry flag is set to one and register 32 contains 11001100B, after this instruction
register 32 will contain 01100110B and the carry flag will be reset to zero.
214/303
1
ST9+ Programming Manual
RRC RRC
Rotate Right Through Carry Byte
RRC dst
OPERATION: dst(7) ⇐ C
C ⇐ dst(0)
dst(n) ⇐ dst(n+1) Where n=0-6
The contents of the destination register are shifted one place to the right with bit 0
shifted into the carry flag and the carry flag shifted into bit 7. The destination register
can be directly or indirectly addressed.
b7 b0
If the carry flag is zero, register 32 contains 155 and register 155 contains
00110011B, after this instruction register 155 will contain 00011001B and the carry
flag will be set to 1.
215/303
1
ST9+ Programming Manual
RRCW RRCW
Rotate Right Through Carry Word
RRCW dst
OPERATION: dst(15) ⇐ C
C ⇐ dst(0)
dst(n) ⇐ dst(n+1) where n=0-14
The contents of the destination register pair are shifted one place to the right with bit
0 shifted into the carry flag and the carry flag shifted into bit 15.
FLAGS: C: Set if carry from LSB (bit 0 was 1).
b15 b0
Z: Undefined.
S: Set if the result bit 15 is set, otherwise cleared.
V: Set if result bit 15 is changed, cleared otherwise.
D: Unaffected.
H: Unaffected.
If the carry flag is set and register 32 pair contains 11001100/11001100B, after this
instruction register 32 will contain 11100110/01100110B and the zero flag will be
reset to 0.
216/303
1
ST9+ Programming Manual
SBC SBC
Subtract with carry (byte) Register, Register
SBC dst,src
If the carry flag is reset, working register 8 contains 100 (decimal), working register 4
contains 200 (decimal) and register 200 contains 25 (decimal), after this instruction
working register 8 will contain 75.
217/303
1
ST9+ Programming Manual
SBC SBC
Subtract with carry (byte) Register, Memory
SBC dst,src
218/303
1
ST9+ Programming Manual
SBC SBC
Subtract with carry (byte) Register, Memory
FLAGS: C: Cleared if carry from MSB of result, set otherwise indicating a borrow.
Z: Set if the result is zero, otherwise cleared.
S: Set if the result is less than zero, otherwise cleared.
V: Set if arithmetic overflow occurred, cleared otherwise.
D: Always reset to one.
H: Cleared if carry from low-order nibble occurred.
If the carry flag is set, working register 8 contains 110 (decimal), working register pair
4 contain 4200 (decimal) and memory address 4204 (decimal) contains 10 (decimal),
after this instruction working register 8 contains 99 (decimal).
219/303
ST9+ Programming Manual
SBC SBC
Subtract with carry (byte) Memory, Register
SBC dst,src
220/303
ST9+ Programming Manual
SBC SBC
Subtract with carry (byte) Memory, Register
FLAGS: C: Cleared if carry from MSB of result, set otherwise indicating a borrow.
Z: Set if the result is zero, otherwise cleared.
S: Set if the result is less than zero, otherwise cleared.
V: Set if arithmetic overflow occurred, cleared otherwise.
D: Always reset to one.
H: Cleared if carry from low-order nibble occurred.
If the carry flag is set, working register pair 8 contains 4028 (decimal) memory location
4028 contains 110 (decimal) and register 255 contains 101 (decimal), after this
instruction memory location 4028 will contain 8 and working register pair 8 will contain
4029.
221/303
ST9+ Programming Manual
SBC SBC
Subtract with carry (byte) Memory, Memory
SBC dst,src
If the carry flag is set, working register pair 4 contains 2800 (decimal), memory
location 2800 contains 46 (decimal), working register pair 8 contains 4200 (decimal)
and memory location 4200 contains 45 (decimal), after this instruction memory
location 2800 will contain 0.
222/303
ST9+ Programming Manual
SBC SBC
Subtract with carry (byte) All, Immediate
SBC dst,src
If the carry flag is set, working register pair 8 contains 4028 (decimal) and memory
location 4028 contains 74 (decimal), after this instruction memory location 4028 will
contain 41.
223/303
ST9+ Programming Manual
SBCW SBCW
Subtract With Carry (Word) - Register, Register
SBCW dst,src
If the carry flag is set, register pair 64 contains 1102 (decimal), working register 8
contains 200 (decimal) and register pair 200 contains 2550 (decimal), after this
instruction register pair 200 will hold 1447.
224/303
ST9+ Programming Manual
SBCW SBCW
Subtract With Carry (Word) - Register, Memory
SBCW dst,src
225/303
ST9+ Programming Manual
SBCW SBCW
Subtract With Carry (Word) - Register, Memory
FLAGS: C: Cleared if carry from MSB of result, otherwise set indicating borrow.
Z: Set if the result is zero, otherwise cleared.
S: Set if the result is less than zero, otherwise cleared.
V: Set if arithmetic overflow occurred, cleared otherwise.
D: Undefined.
H: Undefined.
If the carry flag is set, working register pair 8 contains 1184 (decimal), register pair 64
contains 5000 (decimal) and memory pair 1182 contains 1100 (decimal), after this
instruction register pair 64 will contain 3899 and register pair 4 will contain 1182.
226/303
ST9+ Programming Manual
SBCW SBCW
Subtract With Carry (Word) - Memory, Register
SBCW dst,src
227/303
ST9+ Programming Manual
SBCW SBCW
Subtract With Carry (Word) - Memory, Register
FLAGS: C: Cleared if carry from MSB of result, otherwise set indicating borrow.
Z: Set if the result is zero, otherwise cleared.
S: Set if the result is less than zero, otherwise cleared.
V: Set if arithmetic overflow occurred, cleared otherwise.
D: Undefined.
H: Undefined.
If the carry flag is set, register pair 64 contains 1250 (decimal), working register pair
4 contains 1064 (decimal) and memory pair 1064 contains 1750, after this instruction
has been carried out memory pair 1064 will contain 499 and working register pair 4 will
contain 1066.
228/303
ST9+ Programming Manual
SBCW SBCW
Subtract With Carry (Word) - Memory, Memory
SBCW dst,src
If the carry flag is zero, working register pair 6 contains 1002 (decimal), memory pair
1002 contains 2300 (decimal), working register pair 4 contains 1060 (decimal) and
memory pair 1060 contains 2700 (decimal), after this instruction memory pair 1060
will contain 400.
229/303
ST9+ Programming Manual
SBCW SBCW
Subtract With Carry (Word) - All, Immediate
SBCW dst,src
If the carry flag is zero, register pair 64 contains 5000 (decimal), after this instruction
has been carried out register pair 64 will contain the decimal value 732.
230/303
ST9+ Programming Manual
SCF SCF
Set Carry Flag
SCF
OPERATION: C⇐1
The carry flag is set to 1.
FLAGS: C: Set to one.
No other flags affected.
Regardless of its prior condition, after this instruction the carry flag will be set to one.
231/303
ST9+ Programming Manual
SDM SDM
Set Data Memory
SDM
232/303
ST9+ Programming Manual
SLA SLA
Shift Left Arithmetic (Byte)
SLA dst
If working register 6 contains A4 hex, after this instruction the carry bit will be set and
working register 8 will contain 48 hex.
NOTE: This instruction is logically and functionally equivalent to the ADD dst, dst operation
and is recognized and translated into the corresponding ADD instruction by the ST9
assembler.
233/303
ST9+ Programming Manual
SLAW SLAW
Shift Left Arithmetic Word
SLAW dst
If working register pair 4 contains A438 hex, after this instruction the carry bit will be
set and working register pair 4 will contain 4870 hex.
NOTE: This instruction is logically and functionally equivalent to the ADD dst, dst operation
and is recognized and translated into the corresponding ADDW instruction by the ST9
assembler.
234/303
ST9+ Programming Manual
SPM SPM
Set Program Memory
SPM
235/303
ST9+ Programming Manual
SPP SPP
Set Page Pointer
SPP src
This instruction will select page 5 of paged registers. Then operations addressing
group F of the register file are related to page 5.
The page pointer register (R234) contains 0x14.
236/303
ST9+ Programming Manual
SRA SRA
Shift Right Arithmetic Byte
SRA dst
If the carry flag is one, working register 2 contains 137 (decimal) and register 137
contains 11001100, after this instruction register 137 will contain 11100110 and the
carry flag will be zero.
237/303
ST9+ Programming Manual
SRAW SRAW
Shift Right Arithmetic Word
SRAW dst
If the carry flag is one, working register pair 2 contains 11001100/11001100B, after
this instruction working register pair 2 will contain 11100110/01100110B and the carry
flag will be zero.
238/303
ST9+ Programming Manual
SRP SRP
Set Register Pointer
SRP src
SRP #3
LD r3, #10
LD R21, #20
The first instruction will select the second pair of register (R16-R31) as working
register window. The second instruction therefore will load the value 10 (decimal) in
working register 3 which is R19. The register R21 in the third instruction is equivalent
to r5. After this instruction register R21 will contain 20 (decimal).
239/303
ST9+ Programming Manual
SRP0 SRP0
Set Register Pointer 0
SRP0 src
SRP0#3
LD r3, #10
LD r5, #20
This instruction will select the window R24-R31. The second instruction will therefore
load in the third register of the selected window the immediate data, that is register
R27 will contain 10 (decimal). The third instruction will load in the sixth working
register, that is R29, the value 20 (decimal).
240/303
ST9+ Programming Manual
SRP1 SRP1
Set Register Pointer 1
SRP1 src
SRP#3
SRP1#2
LD r3, #10
LD r10, #20
The first instruction will select the window pair R16-R31. With the second instruction
the mode will be changed to the twin register groups and register RP0 will point to
R24-R31 while register RP1 will point to R16-R23. The first load instruction will
therefore refer to register pointer zero since the value of the short register is between
0-7 and will place the value 10 (decimal) into R19. The second load refers to register
pointer one since the value of the short register is between 8-15 and will place 20
(decimal) into R26.
241/303
ST9+ Programming Manual
SUB SUB
Subtract (byte) Register, Register
SUB dst,src
242/303
ST9+ Programming Manual
SUB SUB
Subtract (byte) Register, Memory
SUB dst,src
243/303
ST9+ Programming Manual
SUB SUB
Subtract (byte) Register, Memory
FLAGS: C: Cleared if carry from MSB of result, set otherwise indicating a borrow.
Z: Set if the result is zero, otherwise cleared.
S: Set if the result is less than zero, otherwise cleared.
V: Set if arithmetic overflow occurred, cleared otherwise.
D: Always reset to one.
H: Cleared if carry from low-order nibble occurred.
If working register 8 contains 213 (decimal), working register pair 4 contain 4200
(decimal) and memory location 4200 contains 25 (decimal), after this instruction
register 8 will contain 188.
244/303
ST9+ Programming Manual
SUB SUB
Subtract (byte) Memory, Register
SUB dst,src
245/303
ST9+ Programming Manual
SUB SUB
Subtract (byte) Memory, Register
FLAGS: C: Cleared if carry from MSB of result, set otherwise indicating a borrow.
Z: Set if the result is zero, otherwise cleared.
S: Set if the result is less than zero, otherwise cleared.
V: Set if arithmetic overflow occurred, cleared otherwise.
D: Always reset to one.
H: Cleared if carry from low-order nibble occurred.
If working register pair 8 contains 4028 (decimal) memory location 4028 contains 144
(decimal) and register 255 contains 22 (decimal), after this instruction memory
location 4028 will contain 122.
246/303
ST9+ Programming Manual
SUB SUB
Subtract (byte) Memory, Memory
SUB dst,src
If working register pair 4 contains 2800 (decimal), memory location 2800 contains 46
(decimal), working register pair 8 contains 4200 (decimal) and memory location 4200
contains 45 (decimal), after this instruction memory location 2800 will contain 1.
247/303
ST9+ Programming Manual
SUB SUB
Subtract (byte) All, Immediate
SUB dst,src
If working register pair 8 contains 4028 (decimal) and memory location 4028 contains
74 (decimal), after this instruction memory location 4028 will contain 42.
248/303
ST9+ Programming Manual
SUBW SUBW
Subtract (Word) - Register, Register
SUBW dst,src
If register pair 64 contains 1102 (decimal), working register 8 contains 200 (decimal)
and register pair 200 contains 2550 (decimal), after this instruction register pair 200
will hold 1448.
249/303
ST9+ Programming Manual
SUBW SUBW
Subtract (Word) - Register, Memory
SUBW dst,src
250/303
ST9+ Programming Manual
SUBW SUBW
Subtract (Word) - Register, Memory
FLAGS: C: Cleared if carry from MSB of result, otherwise set indicating borrow.
Z: Set if the result is zero, otherwise cleared.
S: Set if the result is less than zero, otherwise cleared.
V: Set if arithmetic overflow occurred, cleared otherwise.
D: Undefined.
H: Undefined.
If working register pair 8 contains 1184 (decimal), register pair 64 contains 5000
(decimal) and memory location 1182 contains 1100 (decimal), after this instruction
register pair 64 will contain 3900 and register pair 4 will contain 1182.
251/303
ST9+ Programming Manual
SUBW SUBW
Subtract (Word) - Memory, Register
SUBW dst,src
252/303
ST9+ Programming Manual
SUBW SUBW
Subtract (Word) - Memory, Register
FLAGS: C: Cleared if carry from MSB of result, otherwise set indicating a borrow.
Z: Set if the result is zero, otherwise cleared.
S: Set if the result is less than zero, otherwise cleared.
V: Set if arithmetic overflow occurred, cleared otherwise.
D: Undefined.
H: Undefined.
If register location 64 contains 1250 (decimal), working register pair 4 contains 1064
(decimal) and memory pair 1064 contains 11750, after this instruction has been
carried out memory pair 1064 will contain 500 and working register pair 4 will contain
1066.
253/303
ST9+ Programming Manual
SUBW SUBW
Subtract (Word) - Memory, Memory
SUBW dst,src
If working register pair 6 contains 1002 (decimal), memory pair 1002 contains 2300
(decimal), working register pair 4 contains 1060 (decimal) and memory pair 1060
contains 2700 (decimal), after this instruction memory pair 1060 will contain 400.
254/303
ST9+ Programming Manual
SUBW SUBW
Subtract (Word) - All, Immediate
SUBW dst,src
If register pair 64 contains 5000 (decimal), after this instruction has been carried out
register pair 64 will contain the decimal value 732.
255/303
ST9+ Programming Manual
SWAP SWAP
Swap Nibbles
SWAP dst
FLAGS: C: Undefined.
Z: Set if the result is zero, otherwise cleared.
S: Set if the result bit 7 is set, otherwise cleared.
V: Undefined.
D: Unaffected.
H: Unaffected.
If register 32 contains 1110 0111B, after this instruction the contents become
01111110B.
256/303
ST9+ Programming Manual
TCM TCM
Test complement under mask (byte) Register, Register
TCM dst,src
If working register 8 contains 11001100 and register 64 contains 1000 0100, after this
instruction the zero flag will be reset to zero.
257/303
ST9+ Programming Manual
TCM TCM
Test complement under mask (byte) Register, Memory
TCM dst,src
258/303
ST9+ Programming Manual
TCM TCM
Test complement under mask (byte) Register, Memory
FLAGS: C: Unaffected.
Z: Set if the result is zero, otherwise cleared.
S: Set if result bit 7 is set, otherwise cleared.
V: Always reset to zero.
D: Unaffected.
H: Unaffected.
259/303
ST9+ Programming Manual
TCM TCM
Test complement under mask (byte) Memory, Register
TCM dst,src
260/303
ST9+ Programming Manual
TCM TCM
Test complement under mask (byte) Memory, Register
FLAGS: C: Unaffected.
Z: Set if the result is zero, otherwise cleared.
S: Set if result bit 7 is set, otherwise cleared.
V: Always reset to zero.
D: Unaffected.
H: Unaffected.
261/303
ST9+ Programming Manual
TCM TCM
Test complement under mask (byte) Memory, Memory
TCM dst,src
If working register pair 4 contains 2800 (decimal), memory location 2800 contains
11001100, working register pair 8 contain 4200 (decimal) and memory location 4200
contains 11001100, after this instruction the zero flag will be set to one.
262/303
ST9+ Programming Manual
TCM TCM
Test complement under mask (byte) All, Immediate
TCM dst,src
If working register pair 8 contains 4028 (decimal) and memory location 4028 contains
11101100, after this instruction the zero flag will be set to one.
263/303
ST9+ Programming Manual
TCMW TCMW
Test Complement Under Mask (Word) - Register,
Register
TCMW dst,src
264/303
ST9+ Programming Manual
TCMW TCMW
Test Complement Under Mask (Word) - Register,
Memory
TCMW dst,src
The source word is held in the source memory location and the destination word in the
destination register pair. The destination register pair is addressed directly, the
memory location is addressed either directly, indirectly or by indexing.
OPERATION b: NOT dst AND src
rr ⇐ rr + 2
As operation ’a’ (indirect memory addressing only), but the contents of the destination
register pair are incremented after the TCMW has been carried out.
OPERATION c: rr ⇐ rr - 2
NOT dst AND src
As operation ’a’ (indirect memory addressing only), but the contents of the destination
register pair are decremented before the TCMW is carried out.
265/303
ST9+ Programming Manual
TCMW TCMW
Test Complement Under Mask (Word) - Register,
Memory
FLAGS: C: Unaffected.
Z: Set if the result is zero, otherwise cleared.
S: Set if result bit 15 is set, otherwise cleared.
V: Always reset to zero.
D: Unaffected.
H: Unaffected.
If working register pair 4 contains 1184 (decimal), register pair 64 contains 11001100/
11001100B and memory location 1182 contains 11001100/11001100B, after this
instruction the zero flag will be set and register pair 4 will contain 1182.
266/303
ST9+ Programming Manual
TCMW TCMW
Test Complement Under Mask (Word) - Memory,
Register
TCMW dst,src
267/303
ST9+ Programming Manual
TCMW TCMW
Test Complement Under Mask (Word) - Memory,
Register
FLAGS: C: Unaffected.
Z: Set if the result is zero, otherwise cleared.
S: Set if result bit 15 is set, otherwise cleared.
V: Always reset to zero.
D: Unaffected.
H: Unaffected.
268/303
ST9+ Programming Manual
TCMW TCMW
Test Complement Under Mask (Word) - Memory,
Memory
TCMW dst,src
If working register pair 6 contains 1002 (decimal), memory location pair 1002 contains
11001100/11001100B, working register pair 4 contains 1060 (decimal) and memory
location 1060 contains 11001100/11001100B, after this instruction the zero flag will
be set.
269/303
ST9+ Programming Manual
TCMW TCMW
Test Complement Under Mask (Word) - All, Immediate
TCMW dst,src
270/303
ST9+ Programming Manual
TM TM
Test under mask (byte) Register, Register
TM dst,src
If working register 8 contains 01001100 and register 64 contains 00110011, after this
instruction the zero flag will be set to one.
271/303
ST9+ Programming Manual
TM TM
Test under mask (byte) Register, Memory
TM dst,src
272/303
ST9+ Programming Manual
TM TM
Test under mask (byte) Register, Memory
TM dst,src (Cont’d)
FLAGS: C: Unaffected.
Z: Set if the result is zero, otherwise cleared.
S: Set if result bit 7 is set, otherwise cleared.
V: Always reset
D: Unaffected.
H: Unaffected.
273/303
ST9+ Programming Manual
TM TM
Test under mask (byte) Memory, Register
TM dst,src
274/303
ST9+ Programming Manual
TM TM
Test under mask (byte) Memory, Register
TM dst,src (Cont’d)
FLAGS: C: Unaffected.
Z: Set if the result is zero, otherwise cleared.
S: Set if result bit 7 is set, otherwise cleared.
V: Always reset
D: Unaffected.
H: Unaffected.
275/303
ST9+ Programming Manual
TM TM
Test under mask (byte) Memory, Memory
TM dst,src
If working register pair 4 contains 2800 (decimal), memory location 2800 contains
11001100, working register pair 8 contains 4200 (decimal) and memory location
4200contains 00110011, after this instruction the zero flag will be set to one.
276/303
ST9+ Programming Manual
TM TM
Test under mask (byte) All, Immediate
TM dst,src
If working register pair 8 contains 4028 (decimal) and memory location 4028 contains
11101100, after this instruction the zero flag will be reset to zero.
277/303
ST9+ Programming Manual
TMW TMW
Test Under Mask (Word) - Register, Register
TMW dst,src
278/303
ST9+ Programming Manual
TMW TMW
Test Under Mask (Word) - Register, Memory
TMW dst,src
279/303
ST9+ Programming Manual
TMW TMW
Test Under Mask (Word) - Register, Memory
FLAGS: C: Unaffected.
Z: Set if the result is zero, otherwise cleared.
S: Set if result bit 15 is set, otherwise cleared.
V: Always reset to zero.
D: Unaffected.
H: Unaffected.
If working register pair 4 contains 1184 (decimal), register pair 64 contains 11001100/
11001100B and memory location 1182 contains 11001100/11001100B, after this
instruction the zero flag will be reset and register pair 4 will contain 1182.
280/303
ST9+ Programming Manual
TMW TMW
Test Under Mask (Word) - Memory, Register
TMW dst,src
281/303
ST9+ Programming Manual
TMW TMW
Test Under Mask (Word) - Memory, Register
FLAGS: C: Unaffected.
Z: Set if the result is zero, otherwise cleared.
S: Set if result bit 15 is set, otherwise cleared.
V: Always reset to zero.
D: Unaffected.
H: Unaffected.
282/303
ST9+ Programming Manual
TMW TMW
Test Under Mask (Word) - Memory, Memory
TMW dst,src
If working register pair 6 contains 1002 (decimal), memory location pair 1002 contains
11001100/11001100B, working register pair 4 contains 1060 (decimal) and memory
location 1060 contains 11001100/11001100B, after this instruction the zero flag will
be reset.
283/303
ST9+ Programming Manual
TMW TMW
Test Under Mask (Word) - All, Immediate
TMW dst,src
284/303
ST9+ Programming Manual
UNLINK UNLINK
Unlink code
UNLINK dst
In C functions, the compiler needs to push variables in the user/system stacks and to
keep the return address location of the function inside the stack.
Therefore, a frame pointer is used, and 2 pieces of code named prologue and
epilogue need to be added at the beginning and at the end of the function.
The "Unlink" instruction is used to get the shortest size in the epilogue of a C function.
Stack in memory (16 cycles) Stack in the register file (12 cycles)
RR4(high)
RR4(low) RR4(low)
SSP SSP
After the instruction, RR4 register will have the value taken in the stack as indicated
in the above scheme.
285/303
ST9+ Programming Manual
UNLINKU UNLINKU
Unlink code
UNLINKU
In C functions, the compiler needs to push variables in the user/system stacks and to
keep the return address location of the function inside the stack.
Therefore, a frame pointer is used, and 2 pieces of code named prologue and
epilogue need to be added at the beginning and at the end of the function.
The "Unlinku" instruction is used to get the shortest size in the epilogue of a C
function.
FLAGS: No flags affected.
Stack in memory (16 cycles) Stack in the register file (12 cycles)
RR4(high)
RR4(low) RR4(low)
USP USP
After the instruction, RR4 register will have the value taken in the stack as indicated
in the above scheme.
286/303
ST9+ Programming Manual
WFI WFI
Wait For Interrupt
WFI
287/303
ST9+ Programming Manual
XCH XCH
Exchange Registers
XCH dst,src
288/303
ST9+ Programming Manual
XOR XOR
Exclusive OR (byte) Register, Register
XOR dst,src
If working register 8 contains 11001100 and register 64 contains 10000101, after this
instruction working register 8 will contain 01001001.
289/303
ST9+ Programming Manual
XOR XOR
Exclusive OR (byte) Register, Memory
XOR dst,src
290/303
ST9+ Programming Manual
XOR XOR
Exclusive OR (byte) Register, Memory
FLAGS: C: Unaffected.
Z: Set if the result is zero, otherwise cleared.
S: Set if result bit 7 is set, otherwise cleared.
V: Always reset to zero.
D: Unaffected.
H: Unaffected.
291/303
ST9+ Programming Manual
XOR XOR
Exclusive OR (byte) Memory, Register
XOR dst,src
292/303
ST9+ Programming Manual
XOR XOR
Exclusive OR (byte) Memory, Register
FLAGS: C: Unaffected.
Z: Set if the result is zero, otherwise cleared.
S: Set if result bit 7 is set, otherwise cleared.
V: Always reset to zero.
D: Unaffected.
H: Unaffected.
293/303
ST9+ Programming Manual
XOR XOR
Exclusive OR (byte) Memory, Memory
XOR dst,src
If working register pair 4 contains 2800 (decimal), memory location 2800 contains
11001100, working register pair 8 contains 4200 (decimal) and memory location 4200
contains 1100011, after this instruction memory location 2800 will contain 00001111.
294/303
ST9+ Programming Manual
XOR XOR
Exclusive OR (byte) All, Immediate
XOR dst,src
If working register pair 8 contains 4028 (decimal) and memory location 4028 contains
11001100, after this instruction memory location 4028 will contain 11101100.
295/303
ST9+ Programming Manual
XORW XORW
Exclusive OR (Word) - Register, Register
XORW dst,src
296/303
ST9+ Programming Manual
XORW XORW
Exclusive OR (Word) - Register, Memory
XORW dst,src
297/303
ST9+ Programming Manual
XORW XORW
Exclusive OR (Word) - Register, Memory
FLAGS: C: Unaffected.
Z: Set if the result is zero, otherwise cleared.
S: Set if result bit 15 is set, otherwise cleared.
V: Always reset to zero.
D: Unaffected.
H: Unaffected.
If working register pair 4 contains 1184 (decimal), register pair 64 contains 10101010/
10101010B and memory location 1182 contains 11001100/11001100B, after this
instruction register pair 64 will contain 01100110/01100110B and register pair 4 will
contain 1182.
298/303
ST9+ Programming Manual
XORW XORW
Exclusive OR (Word) - Memory, Register
XORW dst,src
299/303
ST9+ Programming Manual
XORW XORW
Exclusive OR (Word) - Memory, Register
FLAGS: C: Unaffected.
Z: Set if the result is zero, otherwise cleared.
S: Set if result bit 15 is set, otherwise cleared.
V: Always reset to zero.
D: Unaffected.
H: Unaffected.
300/303
ST9+ Programming Manual
XORW XORW
Exclusive OR (Word) - Memory, Memory
XORW dst,src
If working register pair 6 contains 1002 (decimal), memory location 1002 contains
11001100/11001100B, working register pair 4 contains 1060 (decimal) and memory
location 1060 contains 10101010/10101010B, after this instruction memory location
1060 will contains 01100110/01100110B.
301/303
ST9+ Programming Manual
XORW XORW
Exclusive OR (Word) - All, Immediate
XORW dst,src
302/303
ST9+ Programming Manual
Notes:
Information furnished is believed to be accurate and reliable. However, STMicroelectronics assumes no responsibility for the consequences
of use of such information nor for any infringement of patents or other rights of third parties which may result from its use. No license is granted
by implication or otherwise under any patent or patent rights of STMicroelectronics. Specifications mentioned in this publication are subject
to change without notice. This publication supersedes and replaces all information previously supplied. STMicroelectronics products are not
authorized for use as critical components in life support devices or systems without the express written approval of STMicroelectronics.
The ST logo is a registered trademark of STMicroelectronics
2001 STMicroelectronics - All Rights Reserved.
Purchase of I2C Components by STMicroelectronics conveys a license under the Philips I2C Patent. Rights to use these components in an
I2C system is granted provided that the system conforms to the I2C Standard Specification as defined by Philips.
STMicroelectronics Group of Companies
Australia - Brazil - China - Finland - France - Germany - Hong Kong - India - Italy - Japan - Malaysia - Malta - Morocco - Singapore - Spain
Sweden - Switzerland - United Kingdom - U.S.A.
http://www.st.com
303/303