diff options
author | Bad Diode <bd@badd10de.dev> | 2023-08-28 14:23:35 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2023-08-28 14:23:35 +0200 |
commit | aaff9e5fbcb0ff3939750429de9b9900feb17178 (patch) | |
tree | 4733be45809e41950b52b4d05d70cdbce8d75490 /src | |
parent | ba6ed32d1732218f152daae2356f8b0281f5f7b8 (diff) | |
download | uxngba-aaff9e5fbcb0ff3939750429de9b9900feb17178.tar.gz uxngba-aaff9e5fbcb0ff3939750429de9b9900feb17178.zip |
Add equ, neq, gth, lth instructions
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 44 | ||||
-rw-r--r-- | src/uxn-core.s | 62 |
2 files changed, 94 insertions, 12 deletions
@@ -73,18 +73,38 @@ init_uxn() { | |||
73 | // // NIP. | 73 | // // NIP. |
74 | // 0xa0, 0x12, 0x34, 0x03, // -> ( 34 ) | 74 | // 0xa0, 0x12, 0x34, 0x03, // -> ( 34 ) |
75 | // 0xa0, 0x12, 0x34, 0xa0, 0x56, 0x78, 0x23, // -> ( 56 78 ) | 75 | // 0xa0, 0x12, 0x34, 0xa0, 0x56, 0x78, 0x23, // -> ( 56 78 ) |
76 | // SWP. | 76 | // // SWP. |
77 | 0xa0, 0x12, 0x34, 0x04, // -> ( 34 12 ) | 77 | // 0xa0, 0x12, 0x34, 0x04, // -> ( 34 12 ) |
78 | 0xa0, 0x12, 0x34, 0xa0, 0x56, 0x78, 0x24, // -> ( 56 78 12 34 ) | 78 | // 0xa0, 0x12, 0x34, 0xa0, 0x56, 0x78, 0x24, // -> ( 56 78 12 34 ) |
79 | // ROT. | 79 | // // ROT. |
80 | 0xa0, 0x12, 0x34, 0x80, 0x56, 0x05, // -> ( 34 56 12 ) | 80 | // 0xa0, 0x12, 0x34, 0x80, 0x56, 0x05, // -> ( 34 56 12 ) |
81 | 0xa0, 0x12, 0x34, 0xa0, 0x56, 0x78, 0xa0, 0x9a, 0xbc, 0x25, // -> ( 56 78 9a bc 12 34 ) | 81 | // 0xa0, 0x12, 0x34, 0xa0, 0x56, 0x78, 0xa0, 0x9a, 0xbc, 0x25, // -> ( 56 78 9a bc 12 34 ) |
82 | // DUP. | 82 | // // DUP. |
83 | 0xa0, 0x12, 0x34, 0x06, // -> ( 12 34 34 ) | 83 | // 0xa0, 0x12, 0x34, 0x06, // -> ( 12 34 34 ) |
84 | 0xa0, 0x12, 0x34, 0x26, // -> ( 12 34 12 34 ) | 84 | // 0xa0, 0x12, 0x34, 0x26, // -> ( 12 34 12 34 ) |
85 | // OVR. | 85 | // // OVR. |
86 | 0xa0, 0x12, 0x34, 0x07, // -> ( 12 34 12 ) | 86 | // 0xa0, 0x12, 0x34, 0x07, // -> ( 12 34 12 ) |
87 | 0xa0, 0x12, 0x34, 0xa0, 0x56, 0x78, 0x27, // -> ( 12 34 56 78 12 34 ) | 87 | // 0xa0, 0x12, 0x34, 0xa0, 0x56, 0x78, 0x27, // -> ( 12 34 56 78 12 34 ) |
88 | // EQU. | ||
89 | 0xa0, 0x12, 0x12, 0x08, // -> ( 01 ) | ||
90 | 0xa0, 0x12, 0x34, 0x08, // -> ( 00 ) | ||
91 | 0xa0, 0x12, 0x34, 0xa0, 0x12, 0x34, 0x28, // -> ( 01 ) | ||
92 | 0xa0, 0x12, 0x34, 0xa0, 0x56, 0x78, 0x28, // -> ( 00 ) | ||
93 | // NEQ. | ||
94 | 0xa0, 0x12, 0x12, 0x09, // -> ( 00 ) | ||
95 | 0xa0, 0x12, 0x34, 0x09, // -> ( 01 ) | ||
96 | 0xa0, 0x12, 0x34, 0xa0, 0x12, 0x34, 0x29, // -> ( 00 ) | ||
97 | 0xa0, 0x12, 0x34, 0xa0, 0x56, 0x78, 0x29, // -> ( 01 ) | ||
98 | // GTH. | ||
99 | 0xa0, 0x12, 0x34, 0x0a, // -> ( 00 ) | ||
100 | 0xa0, 0x34, 0x12, 0x0a, // -> ( 01 ) | ||
101 | 0xa0, 0x12, 0x34, 0xa0, 0x34, 0x56, 0x2a, // -> ( 00 ) | ||
102 | 0xa0, 0x34, 0x56, 0xa0, 0x12, 0x34, 0x2a, // -> ( 01 ) | ||
103 | // LTH. | ||
104 | 0xa0, 0x12, 0x34, 0x0b, // -> ( 01 ) | ||
105 | 0xa0, 0x34, 0x12, 0x0b, // -> ( 00 ) | ||
106 | 0xa0, 0x12, 0x34, 0xa0, 0x34, 0x56, 0x2b, // -> ( 01 ) | ||
107 | 0xa0, 0x34, 0x56, 0xa0, 0x12, 0x34, 0x2b, // -> ( 00 ) | ||
88 | 108 | ||
89 | }; | 109 | }; |
90 | memcpy(uxn_ram + PAGE_PROGRAM, uxn_rom, sizeof(uxn_rom)); | 110 | memcpy(uxn_ram + PAGE_PROGRAM, uxn_rom, sizeof(uxn_rom)); |
diff --git a/src/uxn-core.s b/src/uxn-core.s index 7e6ad8a..6a4b84d 100644 --- a/src/uxn-core.s +++ b/src/uxn-core.s | |||
@@ -193,27 +193,89 @@ ovr2: | |||
193 | b uxn_decode | 193 | b uxn_decode |
194 | 194 | ||
195 | equ: | 195 | equ: |
196 | ldrb r3, [r1, #-1]! | ||
197 | ldrb r4, [r1, #-1]! | ||
198 | sub r3, r4, r3 | ||
199 | rsbs r4, r3, #0 | ||
200 | adc r4, r4, r3 | ||
201 | strb r4, [r1], #1 | ||
196 | b uxn_decode | 202 | b uxn_decode |
197 | 203 | ||
198 | equ2: | 204 | equ2: |
205 | ldrb r3, [r1, #-1]! | ||
206 | ldrb r5, [r1, #-1]! | ||
207 | orr r3, r3, r5, lsl #8 | ||
208 | ldrb r4, [r1, #-1]! | ||
209 | ldrb r5, [r1, #-1]! | ||
210 | orr r4, r4, r5, lsl #8 | ||
211 | sub r3, r4, r3 | ||
212 | rsbs r4, r3, #0 | ||
213 | adc r4, r4, r3 | ||
214 | strb r4, [r1], #1 | ||
199 | b uxn_decode | 215 | b uxn_decode |
200 | 216 | ||
201 | neq: | 217 | neq: |
218 | ldrb r3, [r1, #-1]! | ||
219 | ldrb r4, [r1, #-1]! | ||
220 | subs r3, r4, r3 | ||
221 | movne r3, #1 | ||
222 | strb r3, [r1], #1 | ||
202 | b uxn_decode | 223 | b uxn_decode |
203 | 224 | ||
204 | neq2: | 225 | neq2: |
226 | ldrb r3, [r1, #-1]! | ||
227 | ldrb r5, [r1, #-1]! | ||
228 | orr r3, r3, r5, lsl #8 | ||
229 | ldrb r4, [r1, #-1]! | ||
230 | ldrb r5, [r1, #-1]! | ||
231 | orr r4, r4, r5, lsl #8 | ||
232 | subs r3, r4, r3 | ||
233 | movne r3, #1 | ||
234 | strb r3, [r1], #1 | ||
205 | b uxn_decode | 235 | b uxn_decode |
206 | 236 | ||
207 | gth: | 237 | gth: |
238 | ldrb r3, [r1, #-1]! | ||
239 | ldrb r4, [r1, #-1]! | ||
240 | cmp r4, r3 | ||
241 | movls r3, #0 | ||
242 | movhi r3, #1 | ||
243 | strb r3, [r1], #1 | ||
208 | b uxn_decode | 244 | b uxn_decode |
209 | 245 | ||
210 | gth2: | 246 | gth2: |
247 | ldrb r3, [r1, #-1]! | ||
248 | ldrb r5, [r1, #-1]! | ||
249 | orr r3, r3, r5, lsl #8 | ||
250 | ldrb r4, [r1, #-1]! | ||
251 | ldrb r5, [r1, #-1]! | ||
252 | orr r4, r4, r5, lsl #8 | ||
253 | cmp r4, r3 | ||
254 | movls r3, #0 | ||
255 | movhi r3, #1 | ||
256 | strb r3, [r1], #1 | ||
211 | b uxn_decode | 257 | b uxn_decode |
212 | 258 | ||
213 | lth: | 259 | lth: |
260 | ldrb r3, [r1, #-1]! | ||
261 | ldrb r4, [r1, #-1]! | ||
262 | cmp r4, r3 | ||
263 | movcs r3, #0 | ||
264 | movcc r3, #1 | ||
265 | strb r3, [r1], #1 | ||
214 | b uxn_decode | 266 | b uxn_decode |
215 | 267 | ||
216 | lth2: | 268 | lth2: |
269 | ldrb r3, [r1, #-1]! | ||
270 | ldrb r5, [r1, #-1]! | ||
271 | orr r3, r3, r5, lsl #8 | ||
272 | ldrb r4, [r1, #-1]! | ||
273 | ldrb r5, [r1, #-1]! | ||
274 | orr r4, r4, r5, lsl #8 | ||
275 | cmp r4, r3 | ||
276 | movcs r3, #0 | ||
277 | movcc r3, #1 | ||
278 | strb r3, [r1], #1 | ||
217 | b uxn_decode | 279 | b uxn_decode |
218 | 280 | ||
219 | jmp: | 281 | jmp: |