Commit Diff


commit - 34149a2174203f148ec1e47ec74ce8eaba14e3bf
commit + b6e626605be30152bc6afbf4ffe799e5ff54fd06
blob - 022659a36ea0b9be8c1f7aeacf5fa224c8066efe
blob + 7a2c00f776abbf5ae59b70913ff94d3ae97fc1e4
--- Makefile
+++ Makefile
@@ -14,8 +14,11 @@ nm: rvforth
 	nm rvforth | sort -n | less
 
 run: rvforth
-	./rvforth
+	rlwrap ./rvforth
 
+test: rvforth
+	./rvforth < test.fs
+
 clean:
 	rm -f rvforth *.core
 
blob - 2232800451f29c868cdb69efa04074b45a10c2bb
blob + a96d078686143b05379984efecc7147528bb97fb
--- rvforth.S
+++ rvforth.S
@@ -353,8 +353,15 @@ defcode "XOR", 3, XOR, OR
 	PUSH t0
 	NEXT
 
-defcode "0=", 2, EQZ, XOR
+defcode "RSHIFT", 6, RSHIFT, XOR
+	POP t1
 	POP t0
+	srl t0, t0, t1
+	PUSH t0
+	NEXT
+
+defcode "0=", 2, EQZ, RSHIFT
+	POP t0
 	beq t0, zero, 1f	
 	PUSH zero
 	NEXT
@@ -378,7 +385,12 @@ defcode "<", 1, LT, EQ
 	PUSH t0
 	NEXT
 
-defcode "KEY", 3, KEY, LT
+defword ">", 1, GT, LT
+	.quad SWAP
+	.quad LT
+	.quad EXIT
+
+defcode "KEY", 3, KEY, GT
 	jal _KEY
 	PUSH a0
 	NEXT
@@ -446,8 +458,15 @@ defword "FIND", 4, FIND, MEMEQ
 	.quad LIT, 8		// ( 8 &word &word -- namelen name )
 	.quad ADD		// ( &flags &word -- namelen name )
 	.quad FETCHBYTE		// ( flags &word -- namelen name )
-	.quad LIT, F_HIDDEN	// ( F_HIDDEN flags &word -- namelen name )
-	.quad AND		// ( hidden &word -- namelen name )
+	.quad DUP		// ( flags flags &word -- namelen name )
+	.quad LIT, F_HIDDEN	// ( F_HIDDEN flags flags &word -- namelen name )
+	.quad AND		// ( hidden flags &word -- namelen name )
+	GOTONZ 4f		// ( flags &word -- namelen name )
+	.quad LIT, F_LENMASK	// ( F_LENMASK flags &word -- namelen name )
+	.quad AND		// ( len &word -- namelen name )
+	.quad RSPFETCH		// ( RSP len &word -- namelen name )
+	.quad FETCH		// ( namelen len &word -- namelen name )
+	.quad SUB		// ( eql &word -- namelen name )
 	GOTONZ 2f		// ( &word -- namelen name )
 
 	.quad DUP		// ( &word &word -- namelen name )
@@ -468,6 +487,9 @@ defword "FIND", 4, FIND, MEMEQ
 	.quad RDROP		// ( &word -- name )
 	.quad RDROP		// ( &word )
 	.quad EXIT		// noreturn
+
+4:	// hidden		// ( flags &word -- namelen name )
+	.quad DROP		// ( &word -- namelen name )
 
 2:	// hidden or not equal	// ( &word -- namelen name )
 	.quad FETCH		// ( &next -- namelen name )
@@ -814,7 +836,13 @@ defcode "'", 1, TICK, COMMA
 	PUSH a0
 	NEXT
 
-defword "[", 1, LBRACK, TICK, F_IMMED
+defword "[']", 3, BTICK, TICK, F_IMMED
+	.quad WORD
+	.quad FIND
+	.quad TCFA
+	.quad EXIT
+
+defword "[", 1, LBRACK, BTICK, F_IMMED
 	.quad LIT, 0
 	.quad STATE
 	.quad STORE