Updated markdown in Instruction Reference to display as separate paragraphs.
[ned1] / docs / instruction_reference.md
CommitLineData
bc5b63cf
AT
1NED - Instruction Reference
2===========================
3
4Overview
5--------
6
418f3fc7 7Version: 2
bc5b63cf
AT
8
9Format A - Word
10---------------
11
12 +----------+----+-------+
13 | | 31 | 30..0 |
14 +----------+----+-------+
15 | WORD_x | 1 | x..x |
16 +----------+----+-------+
17
18Operation: TOS = x
ec3f5f9c 19
bc5b63cf 20Indicators: None
ec3f5f9c 21
bc5b63cf
AT
22Description: Pushes bits 30-0 on to TOS after left shift by one position and
23 padding with zero bit.
24
25Format C - Syllables
26--------------------
27
28 +----------+---+---+---+---+---+---+
29 | | 5 | 4 | 3 | 2 | 1 | 0 |
30 +----------+---+---+---+---+---+---+
31 | IM_x | 1 | x | x | x | x | x |
32 +----------+---+---+---+---+---+---+
33
34Operation: TOS = x
ec3f5f9c 35
bc5b63cf 36Indicators: None
ec3f5f9c 37
bc5b63cf
AT
38Description: Pushes bits 4-0 on to TOS while padding bits 31-5 with zeroes.
39
40--------------------------------------------------------------------------------
41
42 +----------+---+---+---+---+---+---+
43 | | 5 | 4 | 3 | 2 | 1 | 0 |
44 +----------+---+---+---+---+---+---+
45 | LDSP+x | 0 | 1 | 1 | x | x | x |
46 +----------+---+---+---+---+---+---+
47
48Operation: TOS = TOS[x]
ec3f5f9c 49
bc5b63cf 50Indicators: Sets PSW_N and PSW_Z flags.
ec3f5f9c 51
bc5b63cf
AT
52Description: Pushes a copy of the x'th entry on the stack to the TOS. Indexing
53 begins at 0. Thus, LDSP+0 duplicates the top stack entry and
54 LDSP+1 pushes a copy of the NOS to the TOS.
55
56--------------------------------------------------------------------------------
57
58 +----------+---+---+---+---+---+---+
59 | | 5 | 4 | 3 | 2 | 1 | 0 |
60 +----------+---+---+---+---+---+---+
61 | STSP+x | 0 | 1 | 0 | x | x | x |
62 +----------+---+---+---+---+---+---+
63
64Operation: TOS[x] = TOS
ec3f5f9c 65
bc5b63cf 66Indicators: None
ec3f5f9c 67
bc5b63cf
AT
68Description: Pops TOS and stores it x positions deep, overwriting the
69 pre-existing stack entry. Indexing begins at 0 and is counted
70 after popping the TOS. Thus, STSP+0 deletes the NOS, equivalent
71 to SWAP, DROP if such instructions existed.
72
73--------------------------------------------------------------------------------
74
75 +----------+---+---+---+---+---+---+
76 | | 5 | 4 | 3 | 2 | 1 | 0 |
77 +----------+---+---+---+---+---+---+
78 | AND | 0 | 0 | 1 | 0 | 0 | 0 |
79 +----------+---+---+---+---+---+---+
80
81Operation: TOS = TOS ^ NOS
ec3f5f9c 82
bc5b63cf 83Indicators: Sets PSW_N and PSW_Z flags.
ec3f5f9c 84
bc5b63cf
AT
85Description: Pops TOS and NOS, performs bitwise Boolean AND and pushes result
86 to TOS.
87
88--------------------------------------------------------------------------------
89
90 +----------+---+---+---+---+---+---+
91 | | 5 | 4 | 3 | 2 | 1 | 0 |
92 +----------+---+---+---+---+---+---+
93 | OR | 0 | 0 | 1 | 0 | 0 | 1 |
94 +----------+---+---+---+---+---+---+
95
96Operation: TOS = TOS V NOS
ec3f5f9c 97
bc5b63cf 98Indicators: Sets PSW_N and PSW_Z flags.
ec3f5f9c 99
bc5b63cf
AT
100Description: Pops TOS and NOS, performs bitwise Boolean OR and pushes result
101 to TOS.
102
103--------------------------------------------------------------------------------
104
105 +----------+---+---+---+---+---+---+
106 | | 5 | 4 | 3 | 2 | 1 | 0 |
107 +----------+---+---+---+---+---+---+
108 | NOT | 0 | 0 | 1 | 0 | 1 | 0 |
109 +----------+---+---+---+---+---+---+
110
111Operation: TOS = ~TOS
ec3f5f9c 112
bc5b63cf 113Indicators: Sets PSW_N and PSW_Z flags.
ec3f5f9c 114
bc5b63cf
AT
115Description: Pops TOS, performs bitwise Boolean NOT and pushes result to TOS.
116
117--------------------------------------------------------------------------------
118
119 +----------+---+---+---+---+---+---+
120 | | 5 | 4 | 3 | 2 | 1 | 0 |
121 +----------+---+---+---+---+---+---+
122 | XOR | 0 | 0 | 1 | 0 | 1 | 1 |
123 +----------+---+---+---+---+---+---+
124
125Operation: TOS = TOS >< NOS
ec3f5f9c 126
bc5b63cf 127Indicators: Sets PSW_N and PSW_Z flags.
ec3f5f9c 128
bc5b63cf
AT
129Description: Pops TOS and NOS, performs bitwise Boolean XOR and pushes result
130 to TOS.
131
132--------------------------------------------------------------------------------
133
134 +----------+---+---+---+---+---+---+
135 | | 5 | 4 | 3 | 2 | 1 | 0 |
136 +----------+---+---+---+---+---+---+
137 | ADD | 0 | 0 | 1 | 1 | 0 | 0 |
138 +----------+---+---+---+---+---+---+
139
140Operation: TOS = TOS + NOS
ec3f5f9c 141
bc5b63cf 142Indicators: Sets PSW_N and PSW_Z flags.
ec3f5f9c 143
bc5b63cf
AT
144Description: Pops TOS and NOS, performs signed, twos-complement addition and
145 pushes result to TOS.
146
147--------------------------------------------------------------------------------
148
149 +----------+---+---+---+---+---+---+
150 | | 5 | 4 | 3 | 2 | 1 | 0 |
151 +----------+---+---+---+---+---+---+
152 | SWAP | 0 | 0 | 1 | 1 | 0 | 1 |
153 +----------+---+---+---+---+---+---+
154
155Operation: TOS = NOS; NOS = TOS
ec3f5f9c 156
bc5b63cf 157Indicators: Sets PSW_N and PSW_Z flags.
ec3f5f9c 158
bc5b63cf
AT
159Description: Swaps the TOS and NOS entries on the stack. Sets PSW flags based
160 on new TOS entry.
161
162--------------------------------------------------------------------------------
163
164 +----------+---+---+---+---+---+---+
165 | | 5 | 4 | 3 | 2 | 1 | 0 |
166 +----------+---+---+---+---+---+---+
167 | JMP | 0 | 0 | 1 | 1 | 1 | 0 |
168 +----------+---+---+---+---+---+---+
169
170Operation: PC = TOS
ec3f5f9c 171
bc5b63cf 172Indicators: None
ec3f5f9c 173
bc5b63cf
AT
174Description: Pops TOS and loads value in to PC, overwriting existing PC. Resets
175 SC to zero.
176
177--------------------------------------------------------------------------------
178
179 +----------+---+---+---+---+---+---+
180 | | 5 | 4 | 3 | 2 | 1 | 0 |
181 +----------+---+---+---+---+---+---+
182 | MVSTCK | 0 | 0 | 1 | 1 | 1 | 1 |
183 +----------+---+---+---+---+---+---+
184
185Operation: SID = TOS
ec3f5f9c 186
bc5b63cf 187Indicators: None
ec3f5f9c 188
bc5b63cf
AT
189Description: Pops TOS and loads value in to SID, overwriting existing SID.
190
191--------------------------------------------------------------------------------
192
193 +----------+---+---+---+---+---+---+
194 | | 5 | 4 | 3 | 2 | 1 | 0 |
195 +----------+---+---+---+---+---+---+
196 | SHIFT | 0 | 0 | 0 | 1 | 0 | 0 |
197 +----------+---+---+---+---+---+---+
198
199Operation: TOS = NOS (<< or >>) TOS
ec3f5f9c 200
bc5b63cf 201Indicators: Sets PSW_N and PSW_Z flags.
ec3f5f9c 202
bc5b63cf
AT
203Description: Pops TOS and NOS, shifts NOS according to TOS and pushes back to
204 TOS. Direction of shift is left if bit 31 of TOS is set, otherwise
205 shift is right. Magnitude of shift is controlled by bits 30-0 of
206 TOS. Note that this is sign-magnitude, not twos-complement.
207
208--------------------------------------------------------------------------------
209
210 +----------+---+---+---+---+---+---+
211 | | 5 | 4 | 3 | 2 | 1 | 0 |
212 +----------+---+---+---+---+---+---+
213 | CMPSWP | 0 | 0 | 0 | 1 | 0 | 1 |
214 +----------+---+---+---+---+---+---+
215
216Operation:
ec3f5f9c 217
bc5b63cf 218Indicators:
ec3f5f9c 219
bc5b63cf
AT
220Description: Not yet implemented.
221
222--------------------------------------------------------------------------------
223
224 +----------+---+---+---+---+---+---+
225 | | 5 | 4 | 3 | 2 | 1 | 0 |
226 +----------+---+---+---+---+---+---+
227 | TEST | 0 | 0 | 0 | 1 | 1 | 0 |
228 +----------+---+---+---+---+---+---+
229
230Operation: None
ec3f5f9c 231
bc5b63cf 232Indicators: Sets PSW_N and PSW_Z flags.
ec3f5f9c 233
bc5b63cf
AT
234Description: Pops TOS and sets PSW flags accordingly.
235
236--------------------------------------------------------------------------------
237
238 +----------+---+---+---+---+---+---+
239 | | 5 | 4 | 3 | 2 | 1 | 0 |
240 +----------+---+---+---+---+---+---+
241 | BRZ | 0 | 0 | 0 | 1 | 1 | 1 |
242 +----------+---+---+---+---+---+---+
243
418f3fc7 244Operation: PC = TOS if NOS = 0
ec3f5f9c 245
bc5b63cf 246Indicators: None
ec3f5f9c 247
418f3fc7 248Description: Pops TOS and NOS. If NOS = 0, loads TOS value in to PC.
bc5b63cf
AT
249
250--------------------------------------------------------------------------------
251
252 +----------+---+---+---+---+---+---+
253 | | 5 | 4 | 3 | 2 | 1 | 0 |
254 +----------+---+---+---+---+---+---+
255 | LOAD | 0 | 0 | 0 | 0 | 1 | 0 |
256 +----------+---+---+---+---+---+---+
257
258Operation: TOS = (TOS)
ec3f5f9c 259
bc5b63cf 260Indicators: Sets PSW_N and PSW_Z flags.
ec3f5f9c 261
bc5b63cf
AT
262Description: Pops TOS, treating it as a pointer in to RAM and pushing the
263 corresponding value from RAM on to TOS.
264
265--------------------------------------------------------------------------------
266
267 +----------+---+---+---+---+---+---+
268 | | 5 | 4 | 3 | 2 | 1 | 0 |
269 +----------+---+---+---+---+---+---+
270 | STORE | 0 | 0 | 0 | 0 | 1 | 1 |
271 +----------+---+---+---+---+---+---+
272
273Operation: (TOS) = NOS
ec3f5f9c 274
bc5b63cf 275Indicators: None
ec3f5f9c 276
bc5b63cf
AT
277Description: Pops TOS and NOS, treating TOS as a pointer in to RAM and storing
278 NOS at that address.
279
280--------------------------------------------------------------------------------
281
282 +----------+---+---+---+---+---+---+
283 | | 5 | 4 | 3 | 2 | 1 | 0 |
284 +----------+---+---+---+---+---+---+
285 | NOP | 0 | 0 | 0 | 0 | 0 | 1 |
286 +----------+---+---+---+---+---+---+
287
288Operation: None
ec3f5f9c 289
bc5b63cf 290Indicators: None
ec3f5f9c 291
bc5b63cf
AT
292Description: Does nothing for one CPU cycle.
293
294--------------------------------------------------------------------------------
295
296 +----------+---+---+---+---+---+---+
297 | | 5 | 4 | 3 | 2 | 1 | 0 |
298 +----------+---+---+---+---+---+---+
299 | HALT | 0 | 0 | 0 | 0 | 0 | 0 |
300 +----------+---+---+---+---+---+---+
301
302Operation: None
ec3f5f9c 303
bc5b63cf 304Indicators: None
ec3f5f9c 305
bc5b63cf 306Description: Halts the CPU.