| ... | ... |
@@ -12,18 +12,19 @@ cc uxn.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -o uxn |
| 12 | 12 |
|
| 13 | 13 |
### Write |
| 14 | 14 |
|
| 15 |
-- `;variable`, set a name to address on the zero-page |
|
| 16 |
-- `:label`, set a name to an address |
|
| 15 |
+- `;variable`, set a label to an assigned address |
|
| 16 |
+- `:const`, set a label to a constant short |
|
| 17 |
+- `@label`, set a label to an address |
|
| 17 | 18 |
|
| 18 | 19 |
### Read |
| 19 | 20 |
|
| 20 |
-- `,literal`, get a literal pointer |
|
| 21 |
-- `.pointer`, get a raw pointer |
|
| 21 |
+- `,literal`, push label value to stack |
|
| 22 |
+- `.pointer`, read label value |
|
| 22 | 23 |
|
| 23 | 24 |
### Special |
| 24 | 25 |
|
| 25 |
-- `@0010`, move to position in the program |
|
| 26 |
-- `( comment )` |
|
| 26 |
+- `( comment )`, toggle parsing on/off |
|
| 27 |
+- `|0010`, move to position in the program |
|
| 27 | 28 |
|
| 28 | 29 |
``` |
| 29 | 30 |
;value ( alloc a zero-page variable ) |
| ... | ... |
@@ -49,7 +50,6 @@ cc uxn.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -o uxn |
| 49 | 50 |
### Assembler |
| 50 | 51 |
|
| 51 | 52 |
- Catch overflow/underflow |
| 52 |
-- Constants |
|
| 53 | 53 |
- Jumps should be relative |
| 54 | 54 |
|
| 55 | 55 |
### CPU |
| ... | ... |
@@ -63,6 +63,10 @@ cc uxn.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -o uxn |
| 63 | 63 |
- Build PPU |
| 64 | 64 |
- Add flags.. |
| 65 | 65 |
|
| 66 |
+### Devices |
|
| 67 |
+ |
|
| 68 |
+- Devices each have an input byte, an output byte and two request bytes. |
|
| 69 |
+ |
|
| 66 | 70 |
## Refs |
| 67 | 71 |
|
| 68 | 72 |
https://code.9front.org/hg/plan9front/file/a7f9946e238f/sys/src/games/nes/cpu.c |
| 69 | 73 |
similarity index 89% |
| 70 | 74 |
rename from extras/usm.sublime-syntax |
| 71 | 75 |
rename to etc/usm.sublime-syntax |
| ... | ... |
@@ -18,7 +18,7 @@ contexts: |
| 18 | 18 |
- include: strings |
| 19 | 19 |
|
| 20 | 20 |
numbers: |
| 21 |
- - match: '\@(\S+)\s?' |
|
| 21 |
+ - match: '\|(\S+)\s?' |
|
| 22 | 22 |
scope: punctuation.definition |
| 23 | 23 |
pop: true |
| 24 | 24 |
|
| ... | ... |
@@ -29,6 +29,9 @@ contexts: |
| 29 | 29 |
- match: '\;(\S+)\s?' |
| 30 | 30 |
scope: string.control |
| 31 | 31 |
pop: true |
| 32 |
+ - match: '\_(\S+)\s?' |
|
| 33 |
+ scope: string.control |
|
| 34 |
+ pop: true |
|
| 32 | 35 |
- match: '\,(\S+)\s?' |
| 33 | 36 |
scope: keyword.control |
| 34 | 37 |
pop: true |
| 35 | 38 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,27 @@ |
| 1 |
+( blank project ) |
|
| 2 |
+ |
|
| 3 |
+;variable1 |
|
| 4 |
+;variable2 |
|
| 5 |
+_constant1 abcd |
|
| 6 |
+ |
|
| 7 |
+|0100 ( -------------------------------- ) |
|
| 8 |
+ |
|
| 9 |
+:RESET BRK |
|
| 10 |
+ |
|
| 11 |
+|c000 ( -------------------------------- ) |
|
| 12 |
+ |
|
| 13 |
+:FRAME ( FRAME-START ) |
|
| 14 |
+ |
|
| 15 |
+ |
|
| 16 |
+ |
|
| 17 |
+BRK ( FRAME-END ) |
|
| 18 |
+ |
|
| 19 |
+|d000 ( -------------------------------- ) |
|
| 20 |
+ |
|
| 21 |
+:ERROR BRK |
|
| 22 |
+ |
|
| 23 |
+|FFFA ( -------------------------------- ) |
|
| 24 |
+ |
|
| 25 |
+.RESET |
|
| 26 |
+.FRAME |
|
| 27 |
+.ERROR |
| ... | ... |
@@ -1,27 +1,29 @@ |
| 1 |
-( define some variables in the zero-page ) |
|
| 1 |
+( blank project ) |
|
| 2 | 2 |
|
| 3 |
-;var1 |
|
| 4 |
-;var2 |
|
| 3 |
+;variable1 |
|
| 4 |
+:constant1 9abc |
|
| 5 | 5 |
|
| 6 |
-@0100 |
|
| 6 |
+|0100 ( -------------------------------- ) |
|
| 7 | 7 |
|
| 8 |
-:RESET ( --- ) |
|
| 9 |
- ,1234 |
|
| 10 |
- BRK |
|
| 8 |
+@RESET |
|
| 11 | 9 |
|
| 12 |
-@c000 ( much further.. ) |
|
| 10 |
+,abcd |
|
| 13 | 11 |
|
| 14 |
-:FRAME ( --- ) |
|
| 15 |
- ,ab ,0008 str |
|
| 16 |
- BRK |
|
| 12 |
+BRK ( RESET-END ) |
|
| 17 | 13 |
|
| 18 |
-@d000 ( further still.. ) |
|
| 14 |
+|c000 ( -------------------------------- ) |
|
| 19 | 15 |
|
| 20 |
-:ERROR ( --- ) |
|
| 21 |
- ,cdef |
|
| 22 |
- BRK |
|
| 16 |
+@FRAME ( FRAME-START ) |
|
| 23 | 17 |
|
| 24 |
-@FFFA ( vectors, last 3 shorts ) |
|
| 18 |
+,abcd |
|
| 19 |
+ |
|
| 20 |
+BRK ( FRAME-END ) |
|
| 21 |
+ |
|
| 22 |
+|d000 ( -------------------------------- ) |
|
| 23 |
+ |
|
| 24 |
+@ERROR BRK |
|
| 25 |
+ |
|
| 26 |
+|FFFA ( -------------------------------- ) |
|
| 25 | 27 |
|
| 26 | 28 |
.RESET |
| 27 | 29 |
.FRAME |
| ... | ... |
@@ -103,7 +103,7 @@ shex(char *s) /* string to num */ |
| 103 | 103 |
else if(c >= 'A' && c <= 'F') |
| 104 | 104 |
n = n * 16 + 10 + (c - 'A'); |
| 105 | 105 |
else if(c >= 'a' && c <= 'f') |
| 106 |
- n = n * 16 + 10 + (c - 'f'); |
|
| 106 |
+ n = n * 16 + 10 + (c - 'a'); |
|
| 107 | 107 |
return n; |
| 108 | 108 |
} |
| 109 | 109 |
|
| ... | ... |
@@ -190,6 +190,14 @@ makelabel(char *id, Uint16 addr) |
| 190 | 190 |
return 1; |
| 191 | 191 |
} |
| 192 | 192 |
|
| 193 |
+int |
|
| 194 |
+makeconst(char *id, FILE *f) |
|
| 195 |
+{
|
|
| 196 |
+ char wv[64]; |
|
| 197 |
+ fscanf(f, "%s", wv); |
|
| 198 |
+ return makelabel(id, shex(wv)); |
|
| 199 |
+} |
|
| 200 |
+ |
|
| 193 | 201 |
int |
| 194 | 202 |
pass1(FILE *f) |
| 195 | 203 |
{
|
| ... | ... |
@@ -199,16 +207,22 @@ pass1(FILE *f) |
| 199 | 207 |
while(fscanf(f, "%s", w) == 1) {
|
| 200 | 208 |
if(iscomment(w, &skip)) continue; |
| 201 | 209 |
suca(w); |
| 202 |
- if(w[0] == ':' && !makelabel(w + 1, addr)) |
|
| 210 |
+ if(w[0] == '@' && !makelabel(w + 1, addr)) |
|
| 203 | 211 |
return error("Pass1 failed", w);
|
| 204 | 212 |
if(w[0] == ';' && !makelabel(w + 1, vars++)) |
| 205 | 213 |
return error("Pass1 failed", w);
|
| 214 |
+ if(w[0] == ':') {
|
|
| 215 |
+ if(!makeconst(w + 1, f)) |
|
| 216 |
+ return error("Pass1 failed", w);
|
|
| 217 |
+ else |
|
| 218 |
+ continue; |
|
| 219 |
+ } |
|
| 206 | 220 |
/* move addr ptr */ |
| 207 | 221 |
if(findop(w) || scmp(w, "BRK")) |
| 208 | 222 |
addr += 1; |
| 209 |
- else if(w[0] == '@') {
|
|
| 223 |
+ else if(w[0] == '|') |
|
| 210 | 224 |
addr = shex(w + 1); |
| 211 |
- } else if(w[0] == ':') |
|
| 225 |
+ else if(w[0] == '@') |
|
| 212 | 226 |
addr += 0; |
| 213 | 227 |
else if(w[0] == ';') |
| 214 | 228 |
addr += 0; |
| ... | ... |
@@ -233,12 +247,14 @@ pass2(FILE *f) |
| 233 | 247 |
while(fscanf(f, "%s", w) == 1) {
|
| 234 | 248 |
Uint8 op = 0; |
| 235 | 249 |
Label *l; |
| 236 |
- if(w[0] == ':') continue; |
|
| 250 |
+ if(w[0] == '@') continue; |
|
| 237 | 251 |
if(w[0] == ';') continue; |
| 238 | 252 |
suca(w); |
| 239 | 253 |
if(iscomment(w, &skip) || ismarker(w)) continue; |
| 240 |
- if(w[0] == '@') |
|
| 254 |
+ if(w[0] == '|') |
|
| 241 | 255 |
p.ptr = shex(w + 1); |
| 256 |
+ else if(w[0] == ':') |
|
| 257 |
+ fscanf(f, "%s", w); |
|
| 242 | 258 |
else if((op = findop(w)) || scmp(w, "BRK")) |
| 243 | 259 |
pushbyte(op, 0); |
| 244 | 260 |
else if((l = findlabel(w + 1))) |