... | ... |
@@ -22,35 +22,34 @@ To build the Uxn emulator, you must have [SDL2](https://wiki.libsdl.org/). |
22 | 22 |
Read more in the [Uxambly Guide](https://wiki.xxiivv.com/site/uxambly.html). |
23 | 23 |
|
24 | 24 |
``` |
25 |
+( Dev/Console ) |
|
26 |
+ |
|
25 | 27 |
%RTN { JMP2r } |
26 | 28 |
|
27 | 29 |
( devices ) |
28 | 30 |
|
29 |
-|0110 ;Console { vector 2 pad 6 char 1 byte 1 short 2 } |
|
31 |
+|0110 @Console [ &pad $8 &char $1 ] |
|
30 | 32 |
|
31 | 33 |
( program ) |
32 | 34 |
|
33 | 35 |
|0200 |
34 | 36 |
|
35 |
- ,text1 ,print-label JSR2 |
|
36 |
- ,text2 ,print-label JSR2 |
|
37 |
- #ab =Console.byte |
|
38 |
- #cdef =Console.short |
|
39 |
- |
|
37 |
+ ;hello-word ;print JSR2 |
|
38 |
+ |
|
40 | 39 |
BRK |
41 | 40 |
|
42 |
-@print-label ( text ) |
|
41 |
+@print ( addr -- ) |
|
43 | 42 |
|
44 |
- $loop |
|
45 |
- ( send ) DUP2 PEK2 =Console.char |
|
43 |
+ &loop |
|
44 |
+ ( send ) DUP2 PEK2 .Console/char IOW |
|
46 | 45 |
( incr ) #0001 ADD2 |
47 |
- ( loop ) DUP2 PEK2 #00 NEQ ^$loop JNZ |
|
46 |
+ ( loop ) DUP2 PEK2 #00 NEQ ,&loop JNZ |
|
48 | 47 |
POP2 |
49 | 48 |
|
50 |
-RTN |
|
49 |
+RTN |
|
50 |
+ |
|
51 |
+@hello-word [ 48 65 6c 6c 6f 20 57 6f 72 6c 64 21 ] |
|
51 | 52 |
|
52 |
-@text1 [ Welcome 20 to 20 UxnVM 0a00 ] |
|
53 |
-@text2 [ Hello 20 World 0a00 ] |
|
54 | 53 |
``` |
55 | 54 |
|
56 | 55 |
## TODOs |
... | ... |
@@ -4,28 +4,24 @@ |
4 | 4 |
|
5 | 5 |
( devices ) |
6 | 6 |
|
7 |
-|0110 ;Console { vector 2 pad 6 char 1 byte 1 short 2 string 2 } |
|
7 |
+|0110 @Console [ &pad $8 &char $1 ] |
|
8 | 8 |
|
9 | 9 |
( program ) |
10 | 10 |
|
11 | 11 |
|0200 |
12 | 12 |
|
13 |
- ,text1 ,print-label JSR2 |
|
14 |
- ,text2 ,print-label JSR2 |
|
15 |
- #ab =Console.byte |
|
16 |
- #cdef =Console.short |
|
17 |
- |
|
13 |
+ ;hello-word ;print JSR2 |
|
14 |
+ |
|
18 | 15 |
BRK |
19 | 16 |
|
20 |
-@print-label ( text ) |
|
17 |
+@print ( addr -- ) |
|
21 | 18 |
|
22 |
- $loop |
|
23 |
- ( send ) DUP2 PEK2 =Console.char |
|
19 |
+ &loop |
|
20 |
+ ( send ) DUP2 PEK2 .Console/char IOW |
|
24 | 21 |
( incr ) #0001 ADD2 |
25 |
- ( loop ) DUP2 PEK2 #00 NEQ ^$loop JNZ |
|
22 |
+ ( loop ) DUP2 PEK2 #00 NEQ ,&loop JNZ |
|
26 | 23 |
POP2 |
27 | 24 |
|
28 |
-RTN |
|
25 |
+RTN |
|
29 | 26 |
|
30 |
-@text1 [ Welcome 20 to 20 UxnVM 0a00 ] |
|
31 |
-@text2 [ Hello 20 World 0a00 ] |
|
27 |
+@hello-word [ 48 65 6c 6c 6f 20 57 6f 72 6c 64 21 ] |
... | ... |
@@ -49,8 +49,8 @@ char ops[][4] = { |
49 | 49 |
int scin(char *s, char c) { int i = 0; while(s[i]) if(s[i++] == c) return i - 1; return -1; } /* string char index */ |
50 | 50 |
int scmp(char *a, char *b, int len) { int i = 0; while(a[i] == b[i] && i < len) if(!a[i++]) return 1; return 0; } /* string compare */ |
51 | 51 |
int slen(char *s) { int i = 0; while(s[i] && s[++i]) ; return i; } /* string length */ |
52 |
-int sihx(char *s) { int i = 0; char c; while((c = s[i++])) if(!(c >= '0' && c <= '9') && !(c >= 'a' && c <= 'f') && !(c >= 'A' && c <= 'F')) return 0; return 1; } /* string is hexadecimal */ |
|
53 |
-int shex(char *s) { int n = 0, i = 0; char c; while((c = s[i++])) if(c >= '0' && c <= '9') n = n * 16 + (c - '0'); else if(c >= 'A' && c <= 'F') n = n * 16 + 10 + (c - 'A'); else if(c >= 'a' && c <= 'f') n = n * 16 + 10 + (c - 'a'); return n; } /* string to num */ |
|
52 |
+int sihx(char *s) { int i = 0; char c; while((c = s[i++])) if(!(c >= '0' && c <= '9') && !(c >= 'a' && c <= 'f')) return 0; return 1; } /* string is hexadecimal */ |
|
53 |
+int shex(char *s) { int n = 0, i = 0; char c; while((c = s[i++])) if(c >= '0' && c <= '9') n = n * 16 + (c - '0'); else if(c >= 'a' && c <= 'f') n = n * 16 + 10 + (c - 'a'); return n; } /* string to num */ |
|
54 | 54 |
char *scpy(char *src, char *dst, int len) { int i = 0; while((dst[i] = src[i]) && i < len - 2) i++; dst[i + 1] = '\0'; return dst; } /* string copy */ |
55 | 55 |
|
56 | 56 |
#pragma mark - Helpers |
... | ... |
@@ -338,7 +338,7 @@ void |
338 | 338 |
cleanup(char *filename) |
339 | 339 |
{ |
340 | 340 |
int i; |
341 |
- printf("Assembled %s(%0.2fkb), %d labels, %d macros.\n\n", filename, (p.ptr - TRIM) / 1000.0, p.llen, p.mlen); |
|
341 |
+ printf("Assembled %s(%d bytes), %d labels, %d macros.\n\n", filename, (p.ptr - TRIM), p.llen, p.mlen); |
|
342 | 342 |
for(i = 0; i < p.llen; ++i) |
343 | 343 |
if(!p.labels[i].refs) |
344 | 344 |
printf("--- Unused label: %s\n", p.labels[i].name); |