diff options
author | Bad Diode <bd@badd10de.dev> | 2023-08-28 14:02:59 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2023-08-28 14:02:59 +0200 |
commit | ba6ed32d1732218f152daae2356f8b0281f5f7b8 (patch) | |
tree | 096c1c0ce87ad35c7f8a30eb6076a5ed02c75890 | |
parent | ee7f1d32a4ded99745a5886eb9839157d5e6ea57 (diff) | |
download | uxngba-ba6ed32d1732218f152daae2356f8b0281f5f7b8.tar.gz uxngba-ba6ed32d1732218f152daae2356f8b0281f5f7b8.zip |
Add swp, rot, dup, ovr instructions
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | src/main.c | 18 | ||||
-rw-r--r-- | src/uxn-core.s | 52 |
3 files changed, 68 insertions, 4 deletions
@@ -38,7 +38,7 @@ OBJCOPY := $(DEVKITBIN)/arm-none-eabi-objcopy | |||
38 | ARCH := -mthumb -mthumb-interwork | 38 | ARCH := -mthumb -mthumb-interwork |
39 | SPECS := -specs=gba.specs | 39 | SPECS := -specs=gba.specs |
40 | CONFIG := | 40 | CONFIG := |
41 | CFLAGS := -Wall -Wextra -pedantic -Wno-incompatible-pointer-types | 41 | CFLAGS := -Wall -Wextra -pedantic -Wno-incompatible-pointer-types -Wno-unused-variable -Wno-unused-function -Wno-unused-parameter |
42 | CFLAGS += -fno-strict-aliasing | 42 | CFLAGS += -fno-strict-aliasing |
43 | CFLAGS += -mcpu=arm7tdmi -mtune=arm7tdmi $(ARCH) | 43 | CFLAGS += -mcpu=arm7tdmi -mtune=arm7tdmi $(ARCH) |
44 | CFLAGS += $(INC_FLAGS) | 44 | CFLAGS += $(INC_FLAGS) |
@@ -70,9 +70,21 @@ init_uxn() { | |||
70 | // 0xa0, 0x12, 0x34, 0x02, | 70 | // 0xa0, 0x12, 0x34, 0x02, |
71 | // 0xa0, 0x12, 0x34, 0x22, | 71 | // 0xa0, 0x12, 0x34, 0x22, |
72 | // 0xa0, 0x00, 0x00, | 72 | // 0xa0, 0x00, 0x00, |
73 | // NIP. | 73 | // // NIP. |
74 | 0xa0, 0x12, 0x34, 0x03, // -> ( 34 ) | 74 | // 0xa0, 0x12, 0x34, 0x03, // -> ( 34 ) |
75 | 0xa0, 0x12, 0x34, 0xa0, 0x56, 0x78, 0x23, // -> ( 56 78 ) | 75 | // 0xa0, 0x12, 0x34, 0xa0, 0x56, 0x78, 0x23, // -> ( 56 78 ) |
76 | // SWP. | ||
77 | 0xa0, 0x12, 0x34, 0x04, // -> ( 34 12 ) | ||
78 | 0xa0, 0x12, 0x34, 0xa0, 0x56, 0x78, 0x24, // -> ( 56 78 12 34 ) | ||
79 | // ROT. | ||
80 | 0xa0, 0x12, 0x34, 0x80, 0x56, 0x05, // -> ( 34 56 12 ) | ||
81 | 0xa0, 0x12, 0x34, 0xa0, 0x56, 0x78, 0xa0, 0x9a, 0xbc, 0x25, // -> ( 56 78 9a bc 12 34 ) | ||
82 | // DUP. | ||
83 | 0xa0, 0x12, 0x34, 0x06, // -> ( 12 34 34 ) | ||
84 | 0xa0, 0x12, 0x34, 0x26, // -> ( 12 34 12 34 ) | ||
85 | // OVR. | ||
86 | 0xa0, 0x12, 0x34, 0x07, // -> ( 12 34 12 ) | ||
87 | 0xa0, 0x12, 0x34, 0xa0, 0x56, 0x78, 0x27, // -> ( 12 34 56 78 12 34 ) | ||
76 | 88 | ||
77 | }; | 89 | }; |
78 | memcpy(uxn_ram + PAGE_PROGRAM, uxn_rom, sizeof(uxn_rom)); | 90 | memcpy(uxn_ram + PAGE_PROGRAM, uxn_rom, sizeof(uxn_rom)); |
diff --git a/src/uxn-core.s b/src/uxn-core.s index 730da32..7e6ad8a 100644 --- a/src/uxn-core.s +++ b/src/uxn-core.s | |||
@@ -117,27 +117,79 @@ nip2: | |||
117 | b uxn_decode | 117 | b uxn_decode |
118 | 118 | ||
119 | swp: | 119 | swp: |
120 | ldrb r3, [r1, #-1]! | ||
121 | ldrb r4, [r1, #-1]! | ||
122 | strb r3, [r1], #1 | ||
123 | strb r4, [r1], #1 | ||
120 | b uxn_decode | 124 | b uxn_decode |
121 | 125 | ||
122 | swp2: | 126 | swp2: |
127 | ldrb r3, [r1, #-1]! | ||
128 | ldrb r5, [r1, #-1]! | ||
129 | orr r3, r3, r5, lsl #8 | ||
130 | ldrb r4, [r1, #-1]! | ||
131 | ldrb r5, [r1, #-1]! | ||
132 | orr r4, r4, r5, lsl #8 | ||
133 | strb r3, [r1, #1] | ||
134 | lsr r3, #8 | ||
135 | strb r3, [r1], #2 | ||
136 | strb r4, [r1, #1] | ||
137 | lsr r4, #8 | ||
138 | strb r4, [r1], #2 | ||
123 | b uxn_decode | 139 | b uxn_decode |
124 | 140 | ||
125 | rot: | 141 | rot: |
142 | ldrb r5, [r1, #-1]! | ||
143 | ldrb r4, [r1, #-1]! | ||
144 | ldrb r3, [r1, #-1]! | ||
145 | strb r4, [r1], #1 | ||
146 | strb r5, [r1], #1 | ||
147 | strb r3, [r1], #1 | ||
126 | b uxn_decode | 148 | b uxn_decode |
127 | 149 | ||
128 | rot2: | 150 | rot2: |
151 | ldrb r5, [r1, #-1]! | ||
152 | ldrb r6, [r1, #-1]! | ||
153 | orr r5, r5, r6, lsl #8 | ||
154 | ldrb r4, [r1, #-1]! | ||
155 | ldrb r6, [r1, #-1]! | ||
156 | orr r4, r4, r6, lsl #8 | ||
157 | ldrb r3, [r1, #-1]! | ||
158 | ldrb r6, [r1, #-1]! | ||
159 | orr r3, r3, r6, lsl #8 | ||
160 | strb r4, [r1, #1] | ||
161 | lsr r4, #8 | ||
162 | strb r4, [r1], #2 | ||
163 | strb r5, [r1, #1] | ||
164 | lsr r5, #8 | ||
165 | strb r5, [r1], #2 | ||
166 | strb r3, [r1, #1] | ||
167 | lsr r3, #8 | ||
168 | strb r3, [r1], #2 | ||
129 | b uxn_decode | 169 | b uxn_decode |
130 | 170 | ||
131 | dup: | 171 | dup: |
172 | ldrb r3, [r1, #-1] | ||
173 | strb r3, [r1], #1 | ||
132 | b uxn_decode | 174 | b uxn_decode |
133 | 175 | ||
134 | dup2: | 176 | dup2: |
177 | ldrb r3, [r1, #-2] | ||
178 | ldrb r4, [r1, #-1] | ||
179 | strb r3, [r1], #1 | ||
180 | strb r4, [r1], #1 | ||
135 | b uxn_decode | 181 | b uxn_decode |
136 | 182 | ||
137 | ovr: | 183 | ovr: |
184 | ldrb r3, [r1, #-2] | ||
185 | strb r3, [r1], #1 | ||
138 | b uxn_decode | 186 | b uxn_decode |
139 | 187 | ||
140 | ovr2: | 188 | ovr2: |
189 | ldrb r3, [r1, #-4] | ||
190 | ldrb r4, [r1, #-3] | ||
191 | strb r3, [r1], #1 | ||
192 | strb r4, [r1], #1 | ||
141 | b uxn_decode | 193 | b uxn_decode |
142 | 194 | ||
143 | equ: | 195 | equ: |