commit 30a6b72e55f6e1770617f479d47c039e9495eb85
parent ce6f238534c8707be70a3f66e61b2d1c099141d5
Author: Henry Wilson <m3henry@googlemail.com>
Date: Wed, 21 Jun 2017 14:51:09 +0100
escape sequences, new test
Diffstat:
3 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/macros.i b/macros.i
@@ -53,6 +53,10 @@
say "\msg\()\n"
.endm
+.macro escape val
+ say "\x1B[\val\()m"
+.endm
+
.macro scratch length
const 8f
goto 9f
diff --git a/main.s b/main.s
@@ -4,7 +4,9 @@
verb forth COLD "COLD" end
_cold: do RESETDATA
- saycr "\x1B[1m\x1B[96maFORTH alpha\x1B[0m"
+ escape 0
+ escape 96
+ saycr "aFORTH alpha"
set numtib 0
do QUIT
@@ -16,14 +18,17 @@ verb forth QUIT
# do RESETRETURN
2: do TIB
const 80
- say "\x1B[93m➤ "
+ escape 93
+ say "➤ "
do ACCEPT
- say "\x1B[0m"
+ escape 0
test equal 0 1f
set numtib
do INTERPRET
goto 2b
-1: saycr "\x1B[1m\x1B[96mDone.\x1B[0m"
+1: escape 96
+ saycr "Done."
+ escape 0
do HALT
verb forth INTERPRET
@@ -48,7 +53,8 @@ verb forth INTERPRET
test greater 0 2f
do DROP
do PAD
- say "\x1B[91mUnknown token: "
+ escape 91
+ say "Unknown token: "
do PRINT
do CR
do ABORT
@@ -58,9 +64,10 @@ verb forth INTERPRET
get numtib
do less
if 3b
+ escape 92
do DEPTH
test equal 0 4f
- say "\x1B[92m ⏎ "
+ say " ⏎ "
test equal 1 5f
do DUP
do dot
@@ -71,7 +78,7 @@ verb forth INTERPRET
saycr "]"
endword
4: do DROP
- saycr "\x1B[92m 🗸"
+ saycr " 🗸"
endword
verb forth CONVERT
diff --git a/makefile b/makefile
@@ -1,6 +1,6 @@
all: bin/aFORTH
@echo Testing...
- @/bin/echo -ne "+ . CR WORDY GREET" | bin/aFORTH
+ @/bin/echo -ne "12 DUP * . CR 10 4 FLAG" | bin/aFORTH
interactive: bin/aFORTH
@bin/aFORTH