diff options
author | Bad Diode <bd@badd10de.dev> | 2023-08-28 20:35:18 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2023-08-28 20:35:18 +0200 |
commit | 6c2da62e1a5cc88dae68f0dfe3305974fb5d4467 (patch) | |
tree | 96de33a83b0b7f6b81af995893fab5551acf80e9 | |
parent | 9afc23da8cda2dd1380e4282ead882375ea3a5ec (diff) | |
download | uxngba-6c2da62e1a5cc88dae68f0dfe3305974fb5d4467.tar.gz uxngba-6c2da62e1a5cc88dae68f0dfe3305974fb5d4467.zip |
Add absolute load instructions lda/lda2
-rw-r--r-- | src/main.c | 18 | ||||
-rw-r--r-- | src/uxn-core.s | 13 |
2 files changed, 23 insertions, 8 deletions
@@ -126,13 +126,16 @@ init_uxn() { | |||
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 | 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, 0xa0, 0xaa, 0xbb, | 132 | // 0x80, 1, 0x12, 0xa0, 0xaa, 0xbb, |
133 | 0xa0, 0xff, 0xee, 0x80, 0xfa, 0x33, | 133 | // 0xa0, 0xff, 0xee, 0x80, 0xfa, 0x33, |
134 | 0x80, 0xff, 0x80, 1, 0x13, 0xa0, 0xaa, 0xbb, | 134 | // 0x80, 0xff, 0x80, 1, 0x13, 0xa0, 0xaa, 0xbb, |
135 | 0xa0, 0xff, 0xee, 0x80, 1, 0x33, 0xa0, 0xaa, 0xbb, | 135 | // 0xa0, 0xff, 0xee, 0x80, 1, 0x33, 0xa0, 0xaa, 0xbb, |
136 | // LDA /STA | ||
137 | 0xa0, 0x01, 0x05, 0x14, 0xa0, 0xaa, 0xbb, | ||
138 | 0xa0, 0x01, 0x05, 0x34, 0xa0, 0xcc, 0xdd, | ||
136 | }; | 139 | }; |
137 | memcpy(uxn_ram + PAGE_PROGRAM, uxn_rom, sizeof(uxn_rom)); | 140 | memcpy(uxn_ram + PAGE_PROGRAM, uxn_rom, sizeof(uxn_rom)); |
138 | } | 141 | } |
@@ -140,7 +143,6 @@ init_uxn() { | |||
140 | // TODO: | 143 | // TODO: |
141 | // - Division | 144 | // - Division |
142 | // - DEI/DEO | 145 | // - DEI/DEO |
143 | // - Relative load/store | ||
144 | // - Absolute load/store | 146 | // - Absolute load/store |
145 | // - Jump instructions (JMP/JCN/JCI/JMI/JSI/JSR) | 147 | // - Jump instructions (JMP/JCN/JCI/JMI/JSI/JSR) |
146 | // - OPr modes | 148 | // - OPr modes |
diff --git a/src/uxn-core.s b/src/uxn-core.s index 0e5cdbc..7307dce 100644 --- a/src/uxn-core.s +++ b/src/uxn-core.s | |||
@@ -119,6 +119,10 @@ uxn_ret: | |||
119 | ldrb \dst, [r0, \off] | 119 | ldrb \dst, [r0, \off] |
120 | .endm | 120 | .endm |
121 | 121 | ||
122 | .macro aload8 dst, off | ||
123 | ldrb \dst, [r7, \off] | ||
124 | .endm | ||
125 | |||
122 | .macro rsave8 a, off | 126 | .macro rsave8 a, off |
123 | strb \a, [r0, \off] | 127 | strb \a, [r0, \off] |
124 | .endm | 128 | .endm |
@@ -665,9 +669,18 @@ str2: | |||
665 | b uxn_decode | 669 | b uxn_decode |
666 | 670 | ||
667 | lda: | 671 | lda: |
672 | wpop16 r4, r5 | ||
673 | aload8 r3, r4 | ||
674 | wpush8 r3 | ||
668 | b uxn_decode | 675 | b uxn_decode |
669 | 676 | ||
670 | lda2: | 677 | lda2: |
678 | wpop16 r4, r5 | ||
679 | aload8 r3, r4 | ||
680 | wpush8 r3 | ||
681 | add r4, #1 | ||
682 | aload8 r3, r4 | ||
683 | wpush8 r3 | ||
671 | b uxn_decode | 684 | b uxn_decode |
672 | 685 | ||
673 | sta: | 686 | sta: |