diff options
author | Bad Diode <bd@badd10de.dev> | 2023-08-28 20:04:12 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2023-08-28 20:04:12 +0200 |
commit | ac0bc3913a1a8fdf20d5e3bf3d0631f54ae1fbac (patch) | |
tree | f5d876bd5a27e1c3dea21a40d014d033cb9964b9 /src | |
parent | d1f218fdaa8ab08508e565b8169a904d47dda1b3 (diff) | |
download | uxngba-ac0bc3913a1a8fdf20d5e3bf3d0631f54ae1fbac.tar.gz uxngba-ac0bc3913a1a8fdf20d5e3bf3d0631f54ae1fbac.zip |
Add load operations ldr/ldr2
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 46 | ||||
-rw-r--r-- | src/uxn-core.s | 17 |
2 files changed, 42 insertions, 21 deletions
@@ -121,11 +121,15 @@ init_uxn() { | |||
121 | // 0xa0, 0x34, 0x01, 0x1f, // -> ( 1a ) | 121 | // 0xa0, 0x34, 0x01, 0x1f, // -> ( 1a ) |
122 | // 0xa0, 0x34, 0x33, 0x1f, // -> ( 30 ) | 122 | // 0xa0, 0x34, 0x33, 0x1f, // -> ( 30 ) |
123 | // 0xa0, 0x12, 0x48, 0x80, 0x34, 0x3f, // -> ( 09 20 ) | 123 | // 0xa0, 0x12, 0x48, 0x80, 0x34, 0x3f, // -> ( 09 20 ) |
124 | // STZ / LDZ. | 124 | // // STZ / LDZ. |
125 | 0xa0, 0x34, 0x00, 0x11, // STZ (u8*)uxn_ram[1] = 0x34 | 125 | // 0xa0, 0x34, 0x00, 0x11, // STZ (u8*)uxn_ram[1] = 0x34 |
126 | 0xa0, 0xaa, 0xbb, 0x80, 0x01, 0x31, // STZ2 (u16*)uxn_ram[1] = 0x34 | 126 | // 0xa0, 0xaa, 0xbb, 0x80, 0x01, 0x31, // STZ2 (u16*)uxn_ram[1] = 0x34 |
127 | 0x80, 0x00, 0x10, // LDZ -> ( 34 ) | 127 | // 0x80, 0x00, 0x10, // LDZ -> ( 34 ) |
128 | 0x80, 0x01, 0x30, // LDZ2 -> ( aa bb ) | 128 | // 0x80, 0x01, 0x30, // LDZ2 -> ( aa bb ) |
129 | // LDR / SRT | ||
130 | 0xa0, 0xab, 0xcd, 0x80, 0xfb, 0x12, | ||
131 | 0xa0, 0xab, 0xcd, 0x80, 0xfb, 0x32, | ||
132 | 0x80, 1, 0x12, 0x00, 0xaa, 0xbb, | ||
129 | }; | 133 | }; |
130 | memcpy(uxn_ram + PAGE_PROGRAM, uxn_rom, sizeof(uxn_rom)); | 134 | memcpy(uxn_ram + PAGE_PROGRAM, uxn_rom, sizeof(uxn_rom)); |
131 | } | 135 | } |
@@ -182,14 +186,14 @@ main(void) { | |||
182 | io_ports[i] = 0; | 186 | io_ports[i] = 0; |
183 | } | 187 | } |
184 | 188 | ||
185 | // txt_printf("ROM"); | 189 | txt_printf("ROM"); |
186 | // for (size_t i = 0; i < 64; i++) { | 190 | for (size_t i = 0; i < 64; i++) { |
187 | // if (i % 8 == 0) { | 191 | if (i % 8 == 0) { |
188 | // txt_printf("\n"); | 192 | txt_printf("\n"); |
189 | // } | 193 | } |
190 | // txt_printf("%02x ", uxn_ram[i + PAGE_PROGRAM]); | 194 | txt_printf("%02x ", uxn_ram[i + PAGE_PROGRAM]); |
191 | // } | 195 | } |
192 | // txt_printf("\n\n"); | 196 | txt_printf("\n\n"); |
193 | 197 | ||
194 | uxn_eval_asm(PAGE_PROGRAM); | 198 | uxn_eval_asm(PAGE_PROGRAM); |
195 | txt_printf("WST ("); | 199 | txt_printf("WST ("); |
@@ -217,14 +221,14 @@ main(void) { | |||
217 | // txt_printf("%02x ", rst[i]); | 221 | // txt_printf("%02x ", rst[i]); |
218 | // } | 222 | // } |
219 | // } | 223 | // } |
220 | txt_printf("\n\n"); | 224 | // txt_printf("\n\n"); |
221 | txt_printf("RAM (ZP)\n"); | 225 | // txt_printf("RAM (ZP)\n"); |
222 | for (size_t i = 0; i < 64; i++) { | 226 | // for (size_t i = 0; i < 64; i++) { |
223 | if (i % 8 == 0) { | 227 | // if (i % 8 == 0) { |
224 | txt_printf("\n"); | 228 | // txt_printf("\n"); |
225 | } | 229 | // } |
226 | txt_printf("%02x ", uxn_ram[i]); | 230 | // txt_printf("%02x ", uxn_ram[i]); |
227 | } | 231 | // } |
228 | 232 | ||
229 | uintptr_t stack_size = wst_ptr - (uintptr_t)wst; | 233 | uintptr_t stack_size = wst_ptr - (uintptr_t)wst; |
230 | while(true) { | 234 | while(true) { |
diff --git a/src/uxn-core.s b/src/uxn-core.s index ed860d6..7d5eb69 100644 --- a/src/uxn-core.s +++ b/src/uxn-core.s | |||
@@ -66,6 +66,10 @@ uxn_ret: | |||
66 | ldrb \a, [r1, #-1]! | 66 | ldrb \a, [r1, #-1]! |
67 | .endm | 67 | .endm |
68 | 68 | ||
69 | .macro wpop8s a | ||
70 | ldrsb \a, [r1, #-1]! | ||
71 | .endm | ||
72 | |||
69 | .macro wpop16 a, b | 73 | .macro wpop16 a, b |
70 | ldrb \a, [r1, #-1]! | 74 | ldrb \a, [r1, #-1]! |
71 | ldrb \b, [r1, #-1]! | 75 | ldrb \b, [r1, #-1]! |
@@ -111,6 +115,10 @@ uxn_ret: | |||
111 | ldrb \dst, [r7, \off] | 115 | ldrb \dst, [r7, \off] |
112 | .endm | 116 | .endm |
113 | 117 | ||
118 | .macro rload8 dst, off | ||
119 | ldrb \dst, [r0, \off] | ||
120 | .endm | ||
121 | |||
114 | @ OP table | 122 | @ OP table |
115 | op_table: | 123 | op_table: |
116 | .word brk @ 0x00 | 124 | .word brk @ 0x00 |
@@ -619,9 +627,18 @@ stz2: | |||
619 | b uxn_decode | 627 | b uxn_decode |
620 | 628 | ||
621 | ldr: | 629 | ldr: |
630 | wpop8s r4 | ||
631 | rload8 r3, r4 | ||
632 | wpush8 r3 | ||
622 | b uxn_decode | 633 | b uxn_decode |
623 | 634 | ||
624 | ldr2: | 635 | ldr2: |
636 | wpop8s r4 | ||
637 | rload8 r3, r4 | ||
638 | wpush8 r3 | ||
639 | add r4, #1 | ||
640 | rload8 r3, r4 | ||
641 | wpush8 r3 | ||
625 | b uxn_decode | 642 | b uxn_decode |
626 | 643 | ||
627 | str: | 644 | str: |