commit eeb85bdcb1c45530bb928b498a760d8d04e5237c
parent a7060c15ca4c1e68381c94d68ca9eb207b0bacb3
Author: neauoire <aliceffekt@gmail.com>
Date: Sat, 3 Jul 2021 20:24:36 -0700
Modified assembler errors
Diffstat:
2 files changed, 66 insertions(+), 16 deletions(-)
diff --git a/projects/examples/blank.tal b/projects/examples/blank.tal
@@ -5,8 +5,10 @@
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
-%DEBUG { .Console/byte DEO #0a .Console/char DEO }
-%DEBUG2 { .Console/short DEO2 #0a .Console/char DEO }
+%DEBUG { ;print-hex JSR2 #0a .Console/write DEO }
+%DEBUG2 { SWP ;print-hex JSR2 ;print-hex JSR2 #0a .Console/write DEO }
+
+%RTN { JMP2r }
( devices )
@@ -27,20 +29,68 @@
|0000
+@lista $3
+@listb $3
+@listc $3
+
( program )
|0100 ( -> )
- ;deferred
- ,relative
- .zero-page
- :immediate
+ ( theme )
+ #0fe5 .System/r DEO2
+ #0fc5 .System/g DEO2
+ #0f25 .System/b DEO2
+
+ #01 .lista #00 + STZ
+ #02 .lista #01 + STZ
+ #03 .lista #02 + STZ
+
+ #10 .listb #00 + STZ
+ #20 .listb #01 + STZ
+ #30 .listb #02 + STZ
+
+ .lista .listb .listc ;add-lists-loop JSR2
+
+ .listc LDZ DEBUG
+ .listc #01 + LDZ DEBUG
+ .listc #02 + LDZ DEBUG
+
+BRK
+
+( Write a Forth word to add together two integer
+vectors (a.k.a. arrays) of three elements each. )
+
+@add-lists-linear ( a b c -- )
+
+ STH
+ ( a[0] b[0] + ) LDZk STH SWP LDZk STHr + STHkr STZ
+ ( a[1] b[1] + ) #01 + LDZk STH SWP #01 + LDZk STHr + STHkr #01 + STZ
+ ( a[2] b[2] + ) #01 + LDZ SWP #01 + LDZ + STHr #02 + STZ
+
+RTN
+
+@add-lists-loop ( a b c -- )
+
+ STH
+ #00 #03
+ &loop
+ ( get incr ) OVR STH
+ ( get a[x] ) OVR2 STHkr ADD LDZ
+ ( get b[x] ) SWP STHkr ADD LDZ
+ ( set c[x] ) ADD STHr STHkr ADD STZ
+ ( incr ) SWP #01 ADD SWP
+ LTHk ,&loop JCN
+ POP2 POP2 POPr
- |goto
- $padding
+JMP2r
- @label
- &sublabel
+@print-hex ( value -- )
+
+ STHk #04 SFT ,&parse JSR .Console/write DEO
+ STHr #0f AND ,&parse JSR .Console/write DEO
+ RTN
+ &parse ( value -- char )
+ DUP #09 GTH ,&above JCN #30 ADD RTN &above #09 SUB #60 ADD RTN
- #value
- "string
-\ No newline at end of file
+RTN
+\ No newline at end of file
diff --git a/src/uxnasm.c b/src/uxnasm.c
@@ -221,7 +221,7 @@ walktoken(char *w)
res += walktoken(m->items[i]);
return res;
}
- return error("Unknown label in first pass", w);
+ return error("Invalid token", w);
}
static int
@@ -328,7 +328,7 @@ pass2(FILE *f)
if(skipblock(w, &cmacr, '{', '}')) continue;
if(w[0] == '|') {
if(p.length && shex(w + 1) < p.ptr)
- return error("Pass 2 - Memory Overwrite", w);
+ return error("Pass 2 - Memory overwrite", w);
p.ptr = shex(w + 1);
continue;
} else if(w[0] == '$') {
@@ -366,7 +366,7 @@ main(int argc, char *argv[])
{
FILE *f;
if(argc < 3)
- return !error("Input", "Missing");
+ return !error("Usage", "input.tal output.rom");
if(!(f = fopen(argv[1], "r")))
return !error("Open", "Failed");
if(!pass1(f) || !pass2(f))