diff options
author | Bad Diode <bd@badd10de.dev> | 2023-08-28 13:31:33 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2023-08-28 13:31:33 +0200 |
commit | ee7f1d32a4ded99745a5886eb9839157d5e6ea57 (patch) | |
tree | 3a9987f21aada34e82ecdfe47e116cd4bba9aa2f /src | |
parent | 8ea88188b604f42e77ab9e929587f80601e5da85 (diff) | |
download | uxngba-ee7f1d32a4ded99745a5886eb9839157d5e6ea57.tar.gz uxngba-ee7f1d32a4ded99745a5886eb9839157d5e6ea57.zip |
Add nip instructions
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 40 | ||||
-rw-r--r-- | src/uxn-core.s | 12 |
2 files changed, 35 insertions, 17 deletions
@@ -50,22 +50,30 @@ init_uxn() { | |||
50 | u8 uxn_rom[] = { | 50 | u8 uxn_rom[] = { |
51 | // | 51 | // |
52 | // ADD test. | 52 | // ADD test. |
53 | 0x80, 0x04, 0x80, 0x08, 0x18, // #04 #08 ADD -> 0c | 53 | // 0x80, 0x04, 0x80, 0x08, 0x18, // #04 #08 ADD -> 0c |
54 | 0xa0, 0x00, 0x04, 0xa0, 0x00, 0x08, 0x38, // #0004 #0008 ADD2 -> 000c | 54 | // 0xa0, 0x00, 0x04, 0xa0, 0x00, 0x08, 0x38, // #0004 #0008 ADD2 -> 000c |
55 | 0xa0, 0x00, 0xff, 0xa0, 0x00, 0x02, 0x38, // #00ff #0002 ADD2 -> 0101 | 55 | // 0xa0, 0x00, 0xff, 0xa0, 0x00, 0x02, 0x38, // #00ff #0002 ADD2 -> 0101 |
56 | // SUB test. | 56 | // // SUB test. |
57 | 0x80, 0x08, 0x80, 0x03, 0x19, // #08 #03 SUB -> 05 | 57 | // 0x80, 0x08, 0x80, 0x03, 0x19, // #08 #03 SUB -> 05 |
58 | 0xa0, 0x00, 0x08, 0xa0, 0x00, 0x03, 0x39, // #0008 #0003 SUB2 -> 0005 | 58 | // 0xa0, 0x00, 0x08, 0xa0, 0x00, 0x03, 0x39, // #0008 #0003 SUB2 -> 0005 |
59 | 0xa0, 0x01, 0x01, 0xa0, 0x00, 0x02, 0x39, // #0008 #0003 SUB2 -> 00ff | 59 | // 0xa0, 0x01, 0x01, 0xa0, 0x00, 0x02, 0x39, // #0008 #0003 SUB2 -> 00ff |
60 | // MUL test. | 60 | // // MUL test. |
61 | 0x80, 0x03, 0x80, 0x04, 0x1a, // #03 #04 MUL -> 0c | 61 | // 0x80, 0x03, 0x80, 0x04, 0x1a, // #03 #04 MUL -> 0c |
62 | 0xa0, 0x00, 0x03, 0xa0, 0x00, 0x04, 0x3a, // #0003 #0004 MUL2 -> 000c | 62 | // 0xa0, 0x00, 0x03, 0xa0, 0x00, 0x04, 0x3a, // #0003 #0004 MUL2 -> 000c |
63 | 0xa0, 0x00, 0xff, 0xa0, 0x00, 0x02, 0x3a, // #00ff #0002 MUL2 -> 01fe | 63 | // 0xa0, 0x00, 0xff, 0xa0, 0x00, 0x02, 0x3a, // #00ff #0002 MUL2 -> 01fe |
64 | // INC test. | 64 | // // INC test. |
65 | 0x80, 0x09, 0x01, // #09 INC -> 0a | 65 | // 0x80, 0x09, 0x01, // #09 INC -> 0a |
66 | 0xa0, 0x00, 0x09, 0x21, // #0009 INC2 -> 000a | 66 | // 0xa0, 0x00, 0x09, 0x21, // #0009 INC2 -> 000a |
67 | 0xa0, 0x00, 0xff, 0x21, // #0009 INC2 -> 0100 | 67 | // 0xa0, 0x00, 0xff, 0x21, // #0009 INC2 -> 0100 |
68 | 0xa0, 0x00, 0xff, 0x21, 0x21 // #0009 INC2 INC2 -> 0101 | 68 | // 0xa0, 0x00, 0xff, 0x21, 0x21, // #0009 INC2 INC2 -> 0101 |
69 | // // POP. | ||
70 | // 0xa0, 0x12, 0x34, 0x02, | ||
71 | // 0xa0, 0x12, 0x34, 0x22, | ||
72 | // 0xa0, 0x00, 0x00, | ||
73 | // NIP. | ||
74 | 0xa0, 0x12, 0x34, 0x03, // -> ( 34 ) | ||
75 | 0xa0, 0x12, 0x34, 0xa0, 0x56, 0x78, 0x23, // -> ( 56 78 ) | ||
76 | |||
69 | }; | 77 | }; |
70 | memcpy(uxn_ram + PAGE_PROGRAM, uxn_rom, sizeof(uxn_rom)); | 78 | memcpy(uxn_ram + PAGE_PROGRAM, uxn_rom, sizeof(uxn_rom)); |
71 | } | 79 | } |
diff --git a/src/uxn-core.s b/src/uxn-core.s index 95afc1a..730da32 100644 --- a/src/uxn-core.s +++ b/src/uxn-core.s | |||
@@ -95,15 +95,25 @@ inc2: | |||
95 | b uxn_decode | 95 | b uxn_decode |
96 | 96 | ||
97 | pop: | 97 | pop: |
98 | sub r1, #1 | ||
98 | b uxn_decode | 99 | b uxn_decode |
99 | 100 | ||
100 | pop2: | 101 | pop2: |
102 | sub r1, #2 | ||
101 | b uxn_decode | 103 | b uxn_decode |
102 | 104 | ||
103 | nip: | 105 | nip: |
106 | ldrb r3, [r1, #-1]! | ||
107 | strb r3, [r1, #-1] | ||
104 | b uxn_decode | 108 | b uxn_decode |
105 | 109 | ||
106 | nip2: | 110 | nip2: |
111 | ldrb r3, [r1, #-1]! | ||
112 | ldrb r5, [r1, #-1]! | ||
113 | orr r3, r3, r5, lsl #8 | ||
114 | strb r3, [r1, #-1] | ||
115 | lsr r3, #8 | ||
116 | strb r3, [r1, #-2] | ||
107 | b uxn_decode | 117 | b uxn_decode |
108 | 118 | ||
109 | swp: | 119 | swp: |
@@ -280,7 +290,7 @@ mul2: | |||
280 | ldrb r4, [r1, #-1]! | 290 | ldrb r4, [r1, #-1]! |
281 | ldrb r5, [r1, #-1]! | 291 | ldrb r5, [r1, #-1]! |
282 | orr r4, r4, r5, lsl #8 | 292 | orr r4, r4, r5, lsl #8 |
283 | mul r3, r3, r4 | 293 | mul r3, r4, r3 |
284 | strb r3, [r1, #1] | 294 | strb r3, [r1, #1] |
285 | lsr r3, #8 | 295 | lsr r3, #8 |
286 | strb r3, [r1], #2 | 296 | strb r3, [r1], #2 |