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