diff options
author | Bad Diode <bd@badd10de.dev> | 2023-08-29 13:28:47 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2023-08-29 13:28:47 +0200 |
commit | b1b6d258cd8b2dae16815ff239bc9db353e170aa (patch) | |
tree | 24ba54f363ce699e40beeba2da1b36ac71f12905 | |
parent | 3473765c5bcf2dde8b22998d6dac7a3873c6f7d3 (diff) | |
download | uxngba-b1b6d258cd8b2dae16815ff239bc9db353e170aa.tar.gz uxngba-b1b6d258cd8b2dae16815ff239bc9db353e170aa.zip |
Add immediate jump operations jci/jmi/jsi
-rw-r--r-- | src/main.c | 16 | ||||
-rw-r--r-- | src/uxn-core.s | 40 |
2 files changed, 46 insertions, 10 deletions
@@ -60,9 +60,9 @@ init_uxn() { | |||
60 | // 0x80, 0x03, 0x80, 0x04, 0x1a, // #03 #04 MUL -> 0c | 60 | // 0x80, 0x03, 0x80, 0x04, 0x1a, // #03 #04 MUL -> 0c |
61 | // 0xa0, 0x00, 0x03, 0xa0, 0x00, 0x04, 0x3a, // #0003 #0004 MUL2 -> 000c | 61 | // 0xa0, 0x00, 0x03, 0xa0, 0x00, 0x04, 0x3a, // #0003 #0004 MUL2 -> 000c |
62 | // 0xa0, 0x00, 0xff, 0xa0, 0x00, 0x02, 0x3a, // #00ff #0002 MUL2 -> 01fe | 62 | // 0xa0, 0x00, 0xff, 0xa0, 0x00, 0x02, 0x3a, // #00ff #0002 MUL2 -> 01fe |
63 | // DIV test. | 63 | // // DIV test. |
64 | 0x80, 0x08, 0x80, 0x04, 0x1b, // #08 #04 DIV -> 02 | 64 | // 0x80, 0x08, 0x80, 0x04, 0x1b, // #08 #04 DIV -> 02 |
65 | 0xa0, 0x00, 0x08, 0xa0, 0x00, 0x04, 0x3b, // #0008 #0004 DIV2 -> 0002 | 65 | // 0xa0, 0x00, 0x08, 0xa0, 0x00, 0x04, 0x3b, // #0008 #0004 DIV2 -> 0002 |
66 | // // INC test. | 66 | // // INC test. |
67 | // 0x80, 0x09, 0x01, // #09 INC -> 0a | 67 | // 0x80, 0x09, 0x01, // #09 INC -> 0a |
68 | // 0xa0, 0x00, 0x09, 0x21, // #0009 INC2 -> 000a | 68 | // 0xa0, 0x00, 0x09, 0x21, // #0009 INC2 -> 000a |
@@ -152,13 +152,21 @@ init_uxn() { | |||
152 | // JSR | 152 | // JSR |
153 | // 0x80, 0x03, 0x0e, 0x80, 0x01, 0x00, 0x80, 0x02, 0x6c, | 153 | // 0x80, 0x03, 0x0e, 0x80, 0x01, 0x00, 0x80, 0x02, 0x6c, |
154 | // 0x80, 0x03, 0x0e, 0x80, 0x01, 0x00, 0x80, 0x02, 0x6c, | 154 | // 0x80, 0x03, 0x0e, 0x80, 0x01, 0x00, 0x80, 0x02, 0x6c, |
155 | // JMI/JSI/JCI | ||
156 | // 0x40, 0x00, 0x01, 0x00, 0xa0, 0xaa, 0xbb, 0xa0, 0xcc, 0xdd, | ||
157 | // 0x40, 0x00, 0x03, 0x80, 0xff, 0x00, 0xa0, 0xaa, 0xbb, 0xa0, 0xcc, 0xdd, | ||
158 | // 0x40, 0x00, 0x03, 0x80, 0xff, 0x00, 0xa0, 0xaa, 0xbb, 0xa0, 0xcc, 0xdd, 0x40, 0xff, 0xf7, | ||
159 | // 0x40, 0x00, 0x04, 0x00, 0xa0, 0xaa, 0xbb, 0xa0, 0xcc, 0xdd, | ||
160 | // 0x40, 0x00, 0x03, 0x80, 0xff, 0x00, 0xa0, 0xaa, 0xbb, 0xa0, 0xcc, 0xdd, | ||
161 | // 0x60, 0x00, 0x03, 0x80, 0xff, 0x00, 0xa0, 0xaa, 0xbb, 0xa0, 0xcc, 0xdd, | ||
162 | // 0x60, 0x00, 0x03, 0x80, 0xff, 0x00, 0xa0, 0xaa, 0xbb, 0xa0, 0xcc, 0xdd, 0x6c | ||
163 | 0x80, 0x01, 0x20, 0x00, 0x03, 0x80, 0xff, 0x00, 0xa0, 0xaa, 0xbb, 0xa0, 0xcc, 0xdd, | ||
155 | }; | 164 | }; |
156 | memcpy(uxn_ram + PAGE_PROGRAM, uxn_rom, sizeof(uxn_rom)); | 165 | memcpy(uxn_ram + PAGE_PROGRAM, uxn_rom, sizeof(uxn_rom)); |
157 | } | 166 | } |
158 | 167 | ||
159 | // TODO: | 168 | // TODO: |
160 | // - DEI/DEO | 169 | // - DEI/DEO |
161 | // - Jump instructions (JCI/JMI/JSI) | ||
162 | // - OPr modes | 170 | // - OPr modes |
163 | // - OPk modes | 171 | // - OPk modes |
164 | // - OPrk modes | 172 | // - OPrk modes |
diff --git a/src/uxn-core.s b/src/uxn-core.s index ec7537f..d32f303 100644 --- a/src/uxn-core.s +++ b/src/uxn-core.s | |||
@@ -94,6 +94,16 @@ uxn_ret: | |||
94 | strb \a, [r2], #1 | 94 | strb \a, [r2], #1 |
95 | .endm | 95 | .endm |
96 | 96 | ||
97 | .macro rpop8s a | ||
98 | ldrsb \a, [r2, #-1]! | ||
99 | .endm | ||
100 | |||
101 | .macro rpop16 a, b | ||
102 | ldrb \a, [r2, #-1]! | ||
103 | ldrb \b, [r2, #-1]! | ||
104 | orr \a, \a, \b, lsl #8 | ||
105 | .endm | ||
106 | |||
97 | .macro rpush16 a | 107 | .macro rpush16 a |
98 | strb \a, [r2, #1] | 108 | strb \a, [r2, #1] |
99 | lsr \a, #8 | 109 | lsr \a, #8 |
@@ -255,7 +265,7 @@ op_table: | |||
255 | .word brk @ 0x69 | 265 | .word brk @ 0x69 |
256 | .word brk @ 0x6a | 266 | .word brk @ 0x6a |
257 | .word brk @ 0x6b | 267 | .word brk @ 0x6b |
258 | .word brk @ 0x6c | 268 | .word jmp2r @ 0x6c |
259 | .word brk @ 0x6d | 269 | .word brk @ 0x6d |
260 | .word brk @ 0x6e | 270 | .word brk @ 0x6e |
261 | .word brk @ 0x6f | 271 | .word brk @ 0x6f |
@@ -412,17 +422,29 @@ brk: | |||
412 | b uxn_ret | 422 | b uxn_ret |
413 | 423 | ||
414 | jci: | 424 | jci: |
415 | wpop8 r3 | 425 | ldrb r5, [r0], #1 |
416 | cmp r3, #0 | 426 | ldrsb r3, [r0], #1 |
417 | @ TODO: What to do here? Reference not fully clear. | 427 | orr r3, r3, r5, lsl #8 |
428 | wpop8 r4 | ||
429 | cmp r4, #0 | ||
430 | addne r0, r3 | ||
431 | addeq r0, #2 | ||
418 | b uxn_decode | 432 | b uxn_decode |
419 | 433 | ||
420 | jmi: | 434 | jmi: |
421 | @ TODO: What to do here? Reference not fully clear. | 435 | ldrb r5, [r0], #1 |
436 | ldrsb r3, [r0], #1 | ||
437 | orr r3, r3, r5, lsl #8 | ||
438 | add r0, r3 | ||
422 | b uxn_decode | 439 | b uxn_decode |
423 | 440 | ||
424 | jsi: | 441 | jsi: |
425 | @ TODO: What to do here? Reference not fully clear. | 442 | ldrb r5, [r0], #1 |
443 | ldrsb r3, [r0], #1 | ||
444 | orr r3, r3, r5, lsl #8 | ||
445 | mov r4, r0 | ||
446 | rpush16 r4 | ||
447 | add r0, r3 | ||
426 | b uxn_decode | 448 | b uxn_decode |
427 | 449 | ||
428 | lit: | 450 | lit: |
@@ -618,6 +640,12 @@ jmp2: | |||
618 | add r0, r0, r3 | 640 | add r0, r0, r3 |
619 | b uxn_decode | 641 | b uxn_decode |
620 | 642 | ||
643 | jmp2r: | ||
644 | rpop16 r3, r5 | ||
645 | mov r0, r7 | ||
646 | add r0, r0, r3 | ||
647 | b uxn_decode | ||
648 | |||
621 | jcn: | 649 | jcn: |
622 | wpop8s r3 | 650 | wpop8s r3 |
623 | wpop8 r4 | 651 | wpop8 r4 |