Commit Diff


commit - 2318c26739d68cdccb95c012a116d1cf44153df6
commit + 58a4e61d0f6350f28132a9e5e8a09351f9c0c3e0
blob - d3465c5921e7dfc99b12498cb24fb30f71646101
blob + 307867f6704ca91602381a4850ba4437f4c470ae
--- rvforth.S
+++ rvforth.S
@@ -286,16 +286,6 @@ bs:
 	addi s1, s1, -1
 	j 1b
 .size _WORD, . - _WORD
-
-_TCFA:
-	addi a0, a0, 9
-	lbu t0, -1(a0)
-	andi t0, t0, F_LENMASK
-	add a0, a0, t0
-	addi a0, a0, 7
-	andi a0, a0, ~7
-	jr ra
-.size _TCFA, . - _TCFA
 
 _EMIT:
 	j putchar
@@ -885,11 +875,20 @@ defcode "CHAR", 4, CHAR, EMIT
 	PUSH a0
 	NEXT
 
-defcode "TCFA", 4, TCFA, CHAR
-	POP a0
-	jal _TCFA
-	PUSH a0
-	NEXT
+// ( word -- &cw )
+defword "TCFA", 4, TCFA, CHAR
+	.quad LIT, 8		// ( 8 word )
+	.quad ADD		// ( &flags )
+	.quad DUP		// ( &flags &flags )
+	.quad FETCHBYTE		// ( flags &flags )
+	.quad LIT, F_LENMASK	// ( F_LENMASK flags &flags )
+	.quad AND		// ( len &flags )
+	.quad ADD		// ( ptr )
+	.quad LIT, 8		// ( 8 ptr )
+	.quad ADD		// ( ptr )
+	.quad LIT, ~7		// ( ~7 ptr )
+	.quad AND		// ( &cw )
+	.quad EXIT
 
 defword "RECURSE", 7, RECURSE, TCFA, F_IMMED
 	.quad LATEST, FETCH