aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2023-08-28 20:18:47 +0200
committerBad Diode <bd@badd10de.dev>2023-08-28 20:18:47 +0200
commit9afc23da8cda2dd1380e4282ead882375ea3a5ec (patch)
tree5650fc1486ea5061b176c42a89656cc4802c1a6c /src
parentac0bc3913a1a8fdf20d5e3bf3d0631f54ae1fbac (diff)
downloaduxngba-9afc23da8cda2dd1380e4282ead882375ea3a5ec.tar.gz
uxngba-9afc23da8cda2dd1380e4282ead882375ea3a5ec.zip
Add relative store str/str2 ops
Diffstat (limited to 'src')
-rw-r--r--src/main.c8
-rw-r--r--src/uxn-core.s29
2 files changed, 29 insertions, 8 deletions
diff --git a/src/main.c b/src/main.c
index 6c65153..6a7b7cd 100644
--- a/src/main.c
+++ b/src/main.c
@@ -129,7 +129,10 @@ init_uxn() {
129 // LDR / SRT 129 // LDR / SRT
130 0xa0, 0xab, 0xcd, 0x80, 0xfb, 0x12, 130 0xa0, 0xab, 0xcd, 0x80, 0xfb, 0x12,
131 0xa0, 0xab, 0xcd, 0x80, 0xfb, 0x32, 131 0xa0, 0xab, 0xcd, 0x80, 0xfb, 0x32,
132 0x80, 1, 0x12, 0x00, 0xaa, 0xbb, 132 0x80, 1, 0x12, 0xa0, 0xaa, 0xbb,
133 0xa0, 0xff, 0xee, 0x80, 0xfa, 0x33,
134 0x80, 0xff, 0x80, 1, 0x13, 0xa0, 0xaa, 0xbb,
135 0xa0, 0xff, 0xee, 0x80, 1, 0x33, 0xa0, 0xaa, 0xbb,
133 }; 136 };
134 memcpy(uxn_ram + PAGE_PROGRAM, uxn_rom, sizeof(uxn_rom)); 137 memcpy(uxn_ram + PAGE_PROGRAM, uxn_rom, sizeof(uxn_rom));
135} 138}
@@ -186,6 +189,8 @@ main(void) {
186 io_ports[i] = 0; 189 io_ports[i] = 0;
187 } 190 }
188 191
192 uxn_eval_asm(PAGE_PROGRAM);
193
189 txt_printf("ROM"); 194 txt_printf("ROM");
190 for (size_t i = 0; i < 64; i++) { 195 for (size_t i = 0; i < 64; i++) {
191 if (i % 8 == 0) { 196 if (i % 8 == 0) {
@@ -195,7 +200,6 @@ main(void) {
195 } 200 }
196 txt_printf("\n\n"); 201 txt_printf("\n\n");
197 202
198 uxn_eval_asm(PAGE_PROGRAM);
199 txt_printf("WST ("); 203 txt_printf("WST (");
200 txt_printf("SIZE: %d)", wst_ptr - (uintptr_t)wst); 204 txt_printf("SIZE: %d)", wst_ptr - (uintptr_t)wst);
201 for (size_t i = 0; i < 64; i++) { 205 for (size_t i = 0; i < 64; i++) {
diff --git a/src/uxn-core.s b/src/uxn-core.s
index 7d5eb69..0e5cdbc 100644
--- a/src/uxn-core.s
+++ b/src/uxn-core.s
@@ -100,15 +100,15 @@ uxn_ret:
100 strb \a, [r2], #2 100 strb \a, [r2], #2
101.endm 101.endm
102 102
103.macro zsave8 val, off 103.macro zsave8 a, off
104 strb \val, [r7, \off] 104 strb \a, [r7, \off]
105.endm 105.endm
106 106
107.macro zsave16 val, off 107.macro zsave16 a, off
108 add \off, r7 108 add \off, r7
109 strb \val, [\off, #1] 109 strb \a, [\off, #1]
110 lsr \val, #8 110 lsr \a, #8
111 strb \val, [\off] 111 strb \a, [\off]
112.endm 112.endm
113 113
114.macro zload8 dst, off 114.macro zload8 dst, off
@@ -119,6 +119,17 @@ uxn_ret:
119 ldrb \dst, [r0, \off] 119 ldrb \dst, [r0, \off]
120.endm 120.endm
121 121
122.macro rsave8 a, off
123 strb \a, [r0, \off]
124.endm
125
126.macro rsave16 a, off
127 adds \off, r0
128 strb \a, [\off, #1]
129 lsr \a, #8
130 strb \a, [\off]
131.endm
132
122@ OP table 133@ OP table
123op_table: 134op_table:
124 .word brk @ 0x00 135 .word brk @ 0x00
@@ -642,9 +653,15 @@ ldr2:
642 b uxn_decode 653 b uxn_decode
643 654
644str: 655str:
656 wpop8s r4
657 wpop8 r3
658 rsave8 r3, r4
645 b uxn_decode 659 b uxn_decode
646 660
647str2: 661str2:
662 wpop8s r4
663 wpop16 r3, r5
664 rsave16 r3, r4
648 b uxn_decode 665 b uxn_decode
649 666
650lda: 667lda: