| ... | ... |
@@ -25,6 +25,7 @@ cc uxn.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -o uxn |
| 25 | 25 |
|
| 26 | 26 |
- `( comment )`, toggle parsing on/off |
| 27 | 27 |
- `|0010`, move to position in the program |
| 28 |
+- `"hello`, push literal bytes for word "hello" |
|
| 28 | 29 |
|
| 29 | 30 |
``` |
| 30 | 31 |
;value ( alloc a zero-page variable ) |
| ... | ... |
@@ -29,7 +29,7 @@ contexts: |
| 29 | 29 |
- match: '\;(\S+)\s?' |
| 30 | 30 |
scope: string.control |
| 31 | 31 |
pop: true |
| 32 |
- - match: '\_(\S+)\s?' |
|
| 32 |
+ - match: '\@(\S+)\s?' |
|
| 33 | 33 |
scope: string.control |
| 34 | 34 |
pop: true |
| 35 | 35 |
- match: '\,(\S+)\s?' |
| ... | ... |
@@ -38,6 +38,9 @@ contexts: |
| 38 | 38 |
- match: '\.(\S+)\s?' |
| 39 | 39 |
scope: keyword.control |
| 40 | 40 |
pop: true |
| 41 |
+ - match: '\"(\S+)\s?' |
|
| 42 |
+ scope: keyword.control |
|
| 43 |
+ pop: true |
|
| 41 | 44 |
|
| 42 | 45 |
comments: |
| 43 | 46 |
- match: '\('
|
| ... | ... |
@@ -1,24 +1,27 @@ |
| 1 | 1 |
( blank project ) |
| 2 | 2 |
|
| 3 | 3 |
;variable1 |
| 4 |
-;variable2 |
|
| 5 |
-_constant1 abcd |
|
| 4 |
+:constant1 9abc |
|
| 6 | 5 |
|
| 7 | 6 |
|0100 ( -------------------------------- ) |
| 8 | 7 |
|
| 9 |
-:RESET BRK |
|
| 8 |
+@RESET |
|
| 10 | 9 |
|
| 11 |
-|c000 ( -------------------------------- ) |
|
| 10 |
+,abcd |
|
| 11 |
+ |
|
| 12 |
+BRK ( RESET-END ) |
|
| 12 | 13 |
|
| 13 |
-:FRAME ( FRAME-START ) |
|
| 14 |
+|c000 ( -------------------------------- ) |
|
| 14 | 15 |
|
| 16 |
+@FRAME ( FRAME-START ) |
|
| 15 | 17 |
|
| 18 |
+,abcd |
|
| 16 | 19 |
|
| 17 | 20 |
BRK ( FRAME-END ) |
| 18 | 21 |
|
| 19 | 22 |
|d000 ( -------------------------------- ) |
| 20 | 23 |
|
| 21 |
-:ERROR BRK |
|
| 24 |
+@ERROR BRK |
|
| 22 | 25 |
|
| 23 | 26 |
|FFFA ( -------------------------------- ) |
| 24 | 27 |
|
| ... | ... |
@@ -1,30 +1,21 @@ |
| 1 | 1 |
( blank project ) |
| 2 | 2 |
|
| 3 | 3 |
;variable1 |
| 4 |
-:constant1 9abc |
|
| 4 |
+:dev1r FFF0 |
|
| 5 |
+:dev1w FFF1 |
|
| 5 | 6 |
|
| 6 |
-|0100 ( -------------------------------- ) |
|
| 7 |
+|0100 @RESET |
|
| 7 | 8 |
|
| 8 |
-@RESET |
|
| 9 |
+"hello |
|
| 9 | 10 |
|
| 10 |
-,abcd |
|
| 11 |
+,dev1w STR |
|
| 12 |
+,dev1w STR |
|
| 13 |
+,dev1w STR |
|
| 14 |
+,dev1w STR |
|
| 15 |
+,dev1w STR |
|
| 11 | 16 |
|
| 12 |
-BRK ( RESET-END ) |
|
| 17 |
+BRK ( RESET ) |
|
| 13 | 18 |
|
| 14 |
-|c000 ( -------------------------------- ) |
|
| 15 |
- |
|
| 16 |
-@FRAME ( FRAME-START ) |
|
| 17 |
- |
|
| 18 |
-,abcd |
|
| 19 |
- |
|
| 20 |
-BRK ( FRAME-END ) |
|
| 21 |
- |
|
| 22 |
-|d000 ( -------------------------------- ) |
|
| 23 |
- |
|
| 24 |
-@ERROR BRK |
|
| 25 |
- |
|
| 26 |
-|FFFA ( -------------------------------- ) |
|
| 27 |
- |
|
| 28 |
-.RESET |
|
| 29 |
-.FRAME |
|
| 30 |
-.ERROR |
|
| 19 |
+|c000 @FRAME BRK |
|
| 20 |
+|d000 @ERROR BRK |
|
| 21 |
+|FFFA .RESET .FRAME .ERROR |
| ... | ... |
@@ -85,7 +85,7 @@ echom(Memory *m, Uint8 len, char *name) |
| 85 | 85 |
|
| 86 | 86 |
/* clang-format off */ |
| 87 | 87 |
|
| 88 |
-Uint8 mempeek8(Uint16 s) { return cpu.rom.dat[s] & 0xff; }
|
|
| 88 |
+Uint8 rampeek8(Uint16 s) { return cpu.ram.dat[s] & 0xff; }
|
|
| 89 | 89 |
Uint16 mempeek16(Uint16 s) { return (cpu.rom.dat[s] << 8) + (cpu.rom.dat[s+1] & 0xff); }
|
| 90 | 90 |
void wspush8(Uint8 b) { cpu.wst.dat[cpu.wst.ptr++] = b; }
|
| 91 | 91 |
Uint8 wspop8(void) { return cpu.wst.dat[--cpu.wst.ptr]; }
|
| ... | ... |
@@ -158,6 +158,14 @@ error(char *name) |
| 158 | 158 |
return 0; |
| 159 | 159 |
} |
| 160 | 160 |
|
| 161 |
+int |
|
| 162 |
+device1(Uint8 *read, Uint8 *write) |
|
| 163 |
+{
|
|
| 164 |
+ printf("%c", *write);
|
|
| 165 |
+ *write = 0; |
|
| 166 |
+ return 0; |
|
| 167 |
+} |
|
| 168 |
+ |
|
| 161 | 169 |
int |
| 162 | 170 |
eval(void) |
| 163 | 171 |
{
|
| ... | ... |
@@ -192,12 +200,15 @@ start(FILE *f) |
| 192 | 200 |
cpu.vframe = mempeek16(0xfffc); |
| 193 | 201 |
cpu.verror = mempeek16(0xfffe); |
| 194 | 202 |
/* eval reset */ |
| 195 |
- printf("Phase: reset\n");
|
|
| 203 |
+ printf("\nPhase: reset\n");
|
|
| 196 | 204 |
cpu.rom.ptr = cpu.vreset; |
| 197 |
- while(!(cpu.status & FLAG_HALT) && eval()) |
|
| 198 |
- ; |
|
| 205 |
+ while(!(cpu.status & FLAG_HALT) && eval()) {
|
|
| 206 |
+ /* experimental */ |
|
| 207 |
+ if(cpu.ram.dat[0xfff1]) |
|
| 208 |
+ device1(&cpu.ram.dat[0xfff0], &cpu.ram.dat[0xfff1]); |
|
| 209 |
+ } |
|
| 199 | 210 |
/*eval frame */ |
| 200 |
- printf("Phase: frame\n");
|
|
| 211 |
+ printf("\nPhase: frame\n");
|
|
| 201 | 212 |
setflag(FLAG_HALT, 0); |
| 202 | 213 |
cpu.rom.ptr = cpu.vframe; |
| 203 | 214 |
while(!(cpu.status & FLAG_HALT) && eval()) |
| ... | ... |
@@ -148,6 +148,16 @@ pushshort(Uint16 s, int lit) |
| 148 | 148 |
pushbyte(s & 0xff, 0); |
| 149 | 149 |
} |
| 150 | 150 |
|
| 151 |
+void |
|
| 152 |
+pushword(char *w) |
|
| 153 |
+{
|
|
| 154 |
+ int i = slen(w); |
|
| 155 |
+ pushbyte(0x02, 0); |
|
| 156 |
+ pushbyte(slen(w), 0); |
|
| 157 |
+ while(i > 0) |
|
| 158 |
+ pushbyte(w[--i], 0); |
|
| 159 |
+} |
|
| 160 |
+ |
|
| 151 | 161 |
Label * |
| 152 | 162 |
findlabel(char *s) |
| 153 | 163 |
{
|
| ... | ... |
@@ -228,6 +238,8 @@ pass1(FILE *f) |
| 228 | 238 |
addr += 0; |
| 229 | 239 |
else if(w[0] == '.') |
| 230 | 240 |
addr += 2; |
| 241 |
+ else if(w[0] == '"') |
|
| 242 |
+ addr += slen(w + 1); |
|
| 231 | 243 |
else if(w[0] == ',') |
| 232 | 244 |
addr += 4; |
| 233 | 245 |
else if(ismarker(w)) |
| ... | ... |
@@ -255,6 +267,8 @@ pass2(FILE *f) |
| 255 | 267 |
p.ptr = shex(w + 1); |
| 256 | 268 |
else if(w[0] == ':') |
| 257 | 269 |
fscanf(f, "%s", w); |
| 270 |
+ else if(w[0] == '"') |
|
| 271 |
+ pushword(w + 1); |
|
| 258 | 272 |
else if((op = findop(w)) || scmp(w, "BRK")) |
| 259 | 273 |
pushbyte(op, 0); |
| 260 | 274 |
else if((l = findlabel(w + 1))) |