aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2023-08-29 09:14:45 +0200
committerBad Diode <bd@badd10de.dev>2023-08-29 09:14:45 +0200
commit4c73a0d430651ef416682dc32b9365ed0a17424d (patch)
treea99545a8dd33c524ae9de0c6b5922e1f7ce59cad /src
parentb3d77b2986e59fec41eaa611d6933d7caac24d92 (diff)
downloaduxngba-4c73a0d430651ef416682dc32b9365ed0a17424d.tar.gz
uxngba-4c73a0d430651ef416682dc32b9365ed0a17424d.zip
Add jsr/jsr2 instructions
Diffstat (limited to 'src')
-rw-r--r--src/main.c48
-rw-r--r--src/uxn-core.s10
2 files changed, 36 insertions, 22 deletions
diff --git a/src/main.c b/src/main.c
index 93a6187..7468b50 100644
--- a/src/main.c
+++ b/src/main.c
@@ -141,10 +141,14 @@ init_uxn() {
141 // JMP 141 // JMP
142 // 0x80, 0x01, 0x0c, 0x00, 0x80, 0xaa, 142 // 0x80, 0x01, 0x0c, 0x00, 0x80, 0xaa,
143 // 0xa0, 0x01, 0x05, 0x2c, 0x00, 0x80, 0xbb, 143 // 0xa0, 0x01, 0x05, 0x2c, 0x00, 0x80, 0xbb,
144 // JCN
144 // 0xa0, 0xab, 0xcd, 0x80, 0x01, 0x80, 0x01, 0x0d, 0x04, 0x02, 145 // 0xa0, 0xab, 0xcd, 0x80, 0x01, 0x80, 0x01, 0x0d, 0x04, 0x02,
145 // 0xa0, 0xab, 0xcd, 0x80, 0x00, 0x80, 0x01, 0x0d, 0x04, 0x02, 146 // 0xa0, 0xab, 0xcd, 0x80, 0x00, 0x80, 0x01, 0x0d, 0x04, 0x02,
146 0xa0, 0xab, 0xcd, 0x80, 0x01, 0xa0, 0x01, 0x0a, 0x2d, 0x04, 0x02, 147 // 0xa0, 0xab, 0xcd, 0x80, 0x01, 0xa0, 0x01, 0x0a, 0x2d, 0x04, 0x02,
147 0xa0, 0xab, 0xcd, 0x80, 0x00, 0xa0, 0x01, 0x15, 0x2d, 0x04, 0x02, 148 // 0xa0, 0xab, 0xcd, 0x80, 0x00, 0xa0, 0x01, 0x15, 0x2d, 0x04, 0x02,
149 // JSR
150 // 0x80, 0x03, 0x0e, 0x80, 0x01, 0x00, 0x80, 0x02, 0x6c,
151 0x80, 0x03, 0x0e, 0x80, 0x01, 0x00, 0x80, 0x02, 0x6c,
148 }; 152 };
149 memcpy(uxn_ram + PAGE_PROGRAM, uxn_rom, sizeof(uxn_rom)); 153 memcpy(uxn_ram + PAGE_PROGRAM, uxn_rom, sizeof(uxn_rom));
150} 154}
@@ -200,41 +204,41 @@ main(void) {
200 204
201 uxn_eval_asm(PAGE_PROGRAM); 205 uxn_eval_asm(PAGE_PROGRAM);
202 206
203 txt_printf("ROM"); 207 // txt_printf("ROM");
208 // for (size_t i = 0; i < 64; i++) {
209 // if (i % 8 == 0) {
210 // txt_printf("\n");
211 // }
212 // txt_printf("%02x ", uxn_ram[i + PAGE_PROGRAM]);
213 // }
214 // txt_printf("\n\n");
215
216 txt_printf("WST (");
217 txt_printf("SIZE: %d)", wst_ptr - (uintptr_t)wst);
204 for (size_t i = 0; i < 64; i++) { 218 for (size_t i = 0; i < 64; i++) {
205 if (i % 8 == 0) { 219 if (i % 8 == 0) {
206 txt_printf("\n"); 220 txt_printf("\n");
207 } 221 }
208 txt_printf("%02x ", uxn_ram[i + PAGE_PROGRAM]); 222 if (i >= (wst_ptr - (uintptr_t)wst)) {
223 txt_printf("%02x ", 0);
224 } else {
225 txt_printf("%02x ", wst[i]);
226 }
209 } 227 }
210 txt_printf("\n\n"); 228 txt_printf("\n\n");
211 229 txt_printf("RST (");
212 txt_printf("WST ("); 230 txt_printf("SIZE: %d)", rst_ptr - (uintptr_t)rst);
213 txt_printf("SIZE: %d)", wst_ptr - (uintptr_t)wst);
214 for (size_t i = 0; i < 64; i++) { 231 for (size_t i = 0; i < 64; i++) {
215 if (i % 8 == 0) { 232 if (i % 8 == 0) {
216 txt_printf("\n"); 233 txt_printf("\n");
217 } 234 }
218 if (i >= (wst_ptr - (uintptr_t)wst)) { 235 if (i >= (rst_ptr - (uintptr_t)rst)) {
219 txt_printf("%02x ", 0); 236 txt_printf("%02x ", 0);
220 } else { 237 } else {
221 txt_printf("%02x ", wst[i]); 238 txt_printf("%02x ", rst[i]);
222 } 239 }
223 } 240 }
224 // txt_printf("\n\n"); 241 // txt_printf("\n\n");
225 // txt_printf("RST (");
226 // txt_printf("SIZE: %d)", rst_ptr - (uintptr_t)rst);
227 // for (size_t i = 0; i < 64; i++) {
228 // if (i % 8 == 0) {
229 // txt_printf("\n");
230 // }
231 // if (i >= (rst_ptr - (uintptr_t)rst)) {
232 // txt_printf("%02x ", 0);
233 // } else {
234 // txt_printf("%02x ", rst[i]);
235 // }
236 // }
237 // txt_printf("\n\n");
238 // txt_printf("RAM (ZP)\n"); 242 // txt_printf("RAM (ZP)\n");
239 // for (size_t i = 0; i < 64; i++) { 243 // for (size_t i = 0; i < 64; i++) {
240 // if (i % 8 == 0) { 244 // if (i % 8 == 0) {
diff --git a/src/uxn-core.s b/src/uxn-core.s
index 71f7c5e..99c5b1c 100644
--- a/src/uxn-core.s
+++ b/src/uxn-core.s
@@ -625,9 +625,19 @@ jcn2:
625 b uxn_decode 625 b uxn_decode
626 626
627jsr: 627jsr:
628 mov r3, r0
629 sub r3, r3, r7
630 rpush16 r3
631 wpop8s r3
632 add r0, r3
628 b uxn_decode 633 b uxn_decode
629 634
630jsr2: 635jsr2:
636 mov r3, r0
637 sub r3, r3, r7
638 wpop16 r3, r5
639 mov r0, r7
640 add r0, r0, r3
631 b uxn_decode 641 b uxn_decode
632 642
633sth: 643sth: