Skip to content

Instantly share code, notes, and snippets.

@castleberrysam
Created December 8, 2017 00:50
Show Gist options
  • Save castleberrysam/dd7bbb92b0a1f0e8105f85b018d9df34 to your computer and use it in GitHub Desktop.
Save castleberrysam/dd7bbb92b0a1f0e8105f85b018d9df34 to your computer and use it in GitHub Desktop.
(mov %r4 0) ; zero KEY input buffer count
(mov (@+ %r4 #xffe0) %r4)
(mov (@+ %r4 #x8014) %r4) ; zero end of CONTEXT
(mov %r5 (@+ %r4 |FORTH-PTR|)) ; initialize FORTH dictionary
(mov (@+ %r4 #x8018) %r5)
(mov %r5 (@+ %r4 |ROOT-PTR|)) ; initialize ROOT dictionary
(mov (@+ %r4 #x801a) %r5)
(mov %r1 #x8ffe) ; initialize stack and return stack pointers
(mov %r2 #x9ffe)
(mov %r3 #xa000) ; initialize free space pointer (HERE)
(mov %r15 |COLD|) ; start executing COLD
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |COLD| |FORTH|)
(.word |ENTER|)
(.word |CR| |DISPLAY|)
(.fstring "FORTH start-up initiated...")
(.word |ONLY| |FORTH| |DEFINITIONS|)
(.word |CR| |DISPLAY|)
(.fstring "This system is compliant with a FORTH-83 Standard Sub-set.")
(.word |ABORT|)
(.defword |QUIT| |FORTH|)
(.word |ENTER|)
(.word |LIT| #x9ffe |RP!|)
(.word |DECIMAL| |[|)
(.word |LIT| 0 |BLK| |!|)
(.label |QUIT_loc1|)
(.word |CR| |TIB| |LIT| 80 |EXPECT|)
(.word |SPAN| |@| |#TIB| |!|)
(.word |LIT| 0 |>IN| |!|)
(.label |QUIT_loc0|)
(.word |INTERPRET| |NOT| |0BRANCH| |QUIT_loc0|)
(.word |DISPLAY|)
(.fstring " ok")
(.word |BRANCH| |QUIT_loc1|)
(.defword |ENTER-NATIVE| |FORTH|)
(mov %r4 (@+ %r15 0))
(add %r4 2)
(mov %r0 %r4)
(.defword |ENTER| |FORTH|)
(mov (@+ %r2 0) %r15)
(add %r2 -2)
(mov %r15 (@+ %r15 0))
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |LIT| |FORTH|)
(.word |ENTER-NATIVE|)
(mov %r4 (@+ %r15 2))
(push %r4)
(add %r15 4)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |RP!| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r2)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |@| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(mov %r4 (@+ %r4 0))
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |C!| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(pop %r5)
(mov %r6 (@+ %r4 0))
(lfun #b1000 %r6 #xff00)
(lfun #b1110 %r5 %r6)
(mov (@+ %r4 0) %r5)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |DECIMAL| |FORTH|)
(.word |ENTER-NATIVE|)
(mov %r4 10)
(mov (@+ %r4 #x7ff6) %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |BASE| |FORTH|)
(.word |ENTER-NATIVE|)
(mov %r4 #x8000)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |!| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(pop %r5)
(mov (@+ %r4 0) %r5)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |EXIT| |FORTH|)
(.word |ENTER-NATIVE|)
(add %r2 2)
(mov %r15 (@+ %r2 0))
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |[| |FORTH| :immediate)
(.word |ENTER-NATIVE|)
(mov %r4 0)
(mov (@+ %r4 #x8002) %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |]| |FORTH|)
(.word |ENTER-NATIVE|)
(mov %r4 1)
(mov (@+ %r4 #x8002) %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |STATE| |FORTH|)
(.word |ENTER-NATIVE|)
(mov %r4 #x8002)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |TIB| |FORTH|)
(.word |ENTER-NATIVE|)
(mov %r4 #xff90)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |EXPECT| |FORTH|)
(.word |ENTER|)
(.word |DUP| |>R|)
(.word |LIT| 0 |SPAN| |!|)
(.label |EXPECT_loc1|)
(.word |DUP| |0BRANCH| |EXPECT_loc0|)
(.word |KEY|)
(.word |DUP| |LIT| 13 |=| |0BRANCH| |EXPECT_loc2|)
(.word |DROP| |DROP| |LIT| 1 |LIT| 32)
(.word |LIT| -1 |SPAN| |+!|)
(.label |EXPECT_loc2|)
(.word |DUP| |LIT| 8 |=| |0BRANCH| |EXPECT_loc3|)
(.word |OVER| |R@| |=| |0BRANCH| |EXPECT_loc4|)
(.word |DROP| |BRANCH| |EXPECT_loc1|)
(.label |EXPECT_loc4|)
(.word |ROT| |2-| |ROT| |2+| |ROT|)
(.word |LIT| -2 |SPAN| |+!|)
(.label |EXPECT_loc3|)
(.word |DUP| |>R| |EMIT| |SWAP| |R>| |OVER| |!|)
(.word |1+| |SWAP| |1-| |LIT| 1 |SPAN| |+!|)
(.word |BRANCH| |EXPECT_loc1|)
(.label |EXPECT_loc0|)
(.word |DROP| |DROP| |R>| |DROP|)
(.word |EXIT|)
(.defword |SPAN| |FORTH|)
(.word |ENTER-NATIVE|)
(mov %r4 #x8004)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |DUP| |FORTH|)
(.word |ENTER-NATIVE|)
(mov %r4 (@+ %r1 2))
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |0BRANCH| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(mov %r5 %r15)
(add %r5 4)
(bnez %r4 %r0 (relative |0BRANCH_loc0|))
(mov %r5 (@+ %r15 2))
(.label |0BRANCH_loc0|)
(mov %r15 %r5)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |BRANCH| |FORTH|)
(.word |ENTER-NATIVE|)
(mov %r15 (@+ %r15 2))
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |DROP| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |+| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(pop %r5)
(add %r4 %r5)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |-| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(pop %r5)
(sub %r5 %r4)
(push %r5)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |U<| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(pop %r5)
(mov %r6 %r4)
(mov %r7 %r5)
(lfun #b1000 %r6 32768)
(lfun #b1000 %r7 32768)
(bez %r6 %r0 (relative |Ul_loc0|))
(bez %r7 %r0 (relative |Ul_loc1|))
(mov %r6 %r4)
(mov %r4 %r5)
(mov %r5 %r6)
(lfun #b0001 %r4 0)
(lfun #b0001 %r5 0)
(mov %r0 |Ul_loc2|)
(.label |Ul_loc1|)
(mov %r4 -1)
(mov %r0 |Ul_loc3|)
(.label |Ul_loc0|)
(bez %r7 %r0 (relative |Ul_loc2|))
(mov %r4 0)
(mov %r0 |Ul_loc3|)
(.label |Ul_loc2|)
(sub %r5 %r4)
(mov %r4 0)
(bgez %r5 %r0 (relative |Ul_loc3|))
(mov %r4 -1)
(.label |Ul_loc3|)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |1+| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(add %r4 1)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |1-| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(add %r4 -1)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |+!| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(pop %r5)
(mov %r6 (@+ %r4 0))
(add %r5 %r6)
(mov (@+ %r4 0) %r5)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |KEY| |FORTH|)
(.word |ENTER-NATIVE|)
(mov %r4 #xffe0)
(mov %r5 (@+ %r4 0))
(bez %r5 %r0 (relative |KEY_loc1|))
(add %r5 -1)
(mov (@+ %r4 0) %r5)
(mov %r4 (@+ %r5 #xff88))
(mov %r0 |KEY_loc2|)
(.label |KEY_loc1|)
(mov %r5 #xffe6)
(.label |KEY_loc0|)
(mov %r4 (@+ %r5 0))
(bez %r4 %r0 (relative |KEY_loc0|))
(mov %r5 %r4)
(mov %r7 0)
(.label |KEY_loc4|)
(add %r5 -1)
(mov %r6 (@+ %r5 #xfff0))
(mov (@+ %r7 #xff88) %r6)
(add %r7 1)
(bnez %r5 %r0 (relative |KEY_loc4|))
(mov (@+ %r5 #xffe6) %r5)
(add %r4 -1)
(mov (@+ %r5 #xffe0) %r4)
(mov %r4 (@+ %r4 #xff88))
(.label |KEY_loc2|)
(lfun #b1000 %r4 #x7f)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |>R| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(mov (@+ %r2 0) %r4)
(add %r2 -2)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |R>| |FORTH|)
(.word |ENTER-NATIVE|)
(add %r2 2)
(mov %r4 (@+ %r2 0))
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |=| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(pop %r5)
(sub %r5 %r4)
(mov %r4 0)
(bnez %r5 %r0 (relative |=_loc0|))
(mov %r4 -1)
(.label |=_loc0|)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |SWAP| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(pop %r5)
(push %r4)
(push %r5)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |EMIT| |FORTH|)
(.word |ENTER-NATIVE|)
(.label |EMIT_loc0|)
(mov %r4 #xffe4)
(mov %r4 (@+ %r4 0))
(bnez %r4 %r0 (relative |EMIT_loc0|))
(pop %r4)
(mov %r5 #xffe8)
(mov (@+ %r5 7) %r4)
(mov %r4 1)
(mov %r5 #xffe4)
(mov (@+ %r5 0) %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |OVER| |FORTH|)
(.word |ENTER-NATIVE|)
(mov %r4 (@+ %r1 4))
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |#TIB| |FORTH|)
(.word |ENTER-NATIVE|)
(mov %r4 #x8006)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |>IN| |FORTH|)
(.word |ENTER-NATIVE|)
(mov %r4 #x8008)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |DISPLAY| |FORTH|)
(.word |ENTER-NATIVE|)
(mov %r4 (@+ %r15 2))
(lfun #b1000 %r4 #xff)
(mov %r5 %r15)
(add %r5 3)
(add %r15 %r4)
(mov %r6 %r5)
(add %r6 %r4)
(.label |DISPLAY_loc1|)
(mov %r4 %r6)
(sub %r4 %r5)
(bez %r4 %r0 (relative |DISPLAY_loc0|))
(mov %r4 (@+ %r5 0))
(lfun #b1000 %r4 #xff)
(.label |DISPLAY_loc2|)
(mov %r7 #xffe4)
(mov %r7 (@+ %r7 0))
(bnez %r7 %r0 (relative |DISPLAY_loc2|))
(mov %r7 #xffe8)
(mov (@+ %r7 7) %r4)
(mov %r4 1)
(mov %r7 #xffe4)
(mov (@+ %r7 0) %r4)
(add %r5 1)
(mov %r0 |DISPLAY_loc1|)
(.label |DISPLAY_loc0|)
(add %r15 3)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |CR| |FORTH|)
(.word |ENTER| |LIT| 13 |EMIT| |EXIT|)
(.defword |INTERPRET| |FORTH|)
(.word |ENTER|)
(.word |LIT| 32 |WORD| |DUP| |C@| |LIT| 0 |=| |0BRANCH| |INTERPRET_loc0|)
(.word |DROP| |LIT| 0 |EXIT|)
(.label |INTERPRET_loc0|)
(.word |FIND| |?DUP| |0BRANCH| |INTERPRET_loc1|)
(.word |LIT| 1 |=| |STATE| |@| |LIT| 0 |=| |OR| |0BRANCH| |INTERPRET_loc2|)
(.word |EXECUTE| |LIT| -1 |EXIT|)
(.label |INTERPRET_loc2|)
(.word |>CODE| |,| |LIT| -1 |EXIT|)
(.label |INTERPRET_loc1|)
(.word |NUMBER| |NOT| |0BRANCH| |INTERPRET_loc3|)
(.word |DISPLAY|)
(.fstring " ?")
(.word |ABORT|)
(.label |INTERPRET_loc3|)
(.word |STATE| |@| |0BRANCH| |INTERPRET_loc4|)
(.word |COMPILE| |LIT| |,|)
(.label |INTERPRET_loc4|)
(.word |LIT| -1 |EXIT|)
(.defword |WORD| |FORTH|)
(.word |ENTER|)
(.word |>R|)
(.word |BLK| |@| |?DUP| |0BRANCH| |WORD_loc0|)
(.word |1-| |BLOCK| |LIT| 1024 |BRANCH| |WORD_loc4|)
(.label |WORD_loc0|)
(.word |TIB| |#TIB| |@|)
(.label |WORD_loc4|)
(.word |LIT| 0 |HERE| |!|)
(.label |WORD_loc1|)
(.word |>IN| |@| |OVER| |U<| |0BRANCH| |WORD_loc2|)
(.word |OVER| |>IN| |@| |+| |C@|)
(.word |>IN| |@| |1+| |>IN| |!|)
(.word |DUP| |R@| |=| |HERE| |C@| |AND| |0BRANCH| |WORD_loc3|)
(.word |DROP| |LIT| 32 |HERE| |1+| |C@| |1+| |HERE| |1+| |+| |C!|)
(.word |BRANCH| |WORD_loc2|)
(.label |WORD_loc3|)
(.word |LIT| 1 |HERE| |C!|)
(.word |HERE| |1+| |C@| |1+| |DUP| |HERE| |1+| |C!| |HERE| |1+| |+| |C!|)
(.word |BRANCH| |WORD_loc1|)
(.label |WORD_loc2|)
(.word |DROP| |DROP| |R>| |DROP| |HERE| |1+|)
(.word |EXIT|)
(.defword |>CODE| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(mov %r5 (@+ %r4 0))
(lfun #b1000 %r5 31)
(add %r5 3)
(add %r4 %r5)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |>BODY| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(mov %r5 (@+ %r4 0))
(lfun #b1000 %r5 31)
(add %r5 7)
(add %r4 %r5)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |BLK| |FORTH|)
(.word |ENTER-NATIVE|)
(mov %r4 #x800a)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |?DUP| |FORTH|)
(.word |ENTER-NATIVE|)
(mov %r4 (@+ %r1 2))
(bez %r4 %r0 (relative |?DUP_loc0|))
(push %r4)
(.label |?DUP_loc0|)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |NOT| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(lfun #b0001 %r4 0)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |NEGATE| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(lfun #b0001 %r4 0)
(add %r4 1)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |R@| |FORTH|)
(.word |ENTER-NATIVE|)
(mov %r4 (@+ %r2 2))
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |AND| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(pop %r5)
(lfun #b1000 %r4 %r5)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |C@| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(mov %r4 (@+ %r4 0))
(lfun #b1000 %r4 #xff)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |FIND| |FORTH|)
(.word |ENTER|)
(.word |CONTEXT| |DUP| |>R| |@|)
(.label |FIND_loc0|)
(.word |DUP| |0BRANCH| |FIND_loc1|)
(.word |SWAP| |OVER| |@|)
(.label |FIND_loc2|)
(.word |?DUP| |0BRANCH| |FIND_loc3|)
(.word |OVER| |OVER| |STRCMP| |0BRANCH| |FIND_loc5|)
(.word |SWAP| |DROP| |SWAP| |DROP|)
(.word |DUP| |C@| |LIT| 128 |AND| |0BRANCH| |FIND_loc6|)
(.word |LIT| 1 |BRANCH| |FIND_loc1|)
(.label |FIND_loc6|)
(.word |LIT| -1 |BRANCH| |FIND_loc1|)
(.label |FIND_loc5|)
(.word |DOWN| |BRANCH| |FIND_loc2|)
(.label |FIND_loc4|)
(.word |DROP|)
(.label |FIND_loc3|)
(.word |SWAP|)
(.word |R>| |1+| |DUP| |>R|)
(.word |@| |OVER| |OVER| |=| |NOT| |0BRANCH| |FIND_loc4|)
(.word |SWAP| |DROP|)
(.word |BRANCH| |FIND_loc0|)
(.label |FIND_loc1|)
(.word |R>| |DROP|)
(.word |EXIT|)
(.defword |STRCMP| |FORTH|)
(.word ENTER-NATIVE)
(pop %r4)
(pop %r5)
(mov %r6 (@+ %r4 0))
(lfun #b1000 %r6 #x7f)
(mov %r7 (@+ %r5 0))
(lfun #b1000 %r7 #x7f)
(sub %r7 %r6)
(bnez %r7 %r0 (relative |STRCMP_loc0|))
(mov %r7 %r6)
(lfun #b1000 %r7 1)
(bez %r7 %r0 (relative |STRCMP_loc1|))
(add %r4 1)
(add %r5 1)
(add %r6 -1)
(mov %r7 (@+ %r4 0))
(lfun #b1000 %r7 #xff)
(mov %r8 (@+ %r5 0))
(lfun #b1000 %r8 #xff)
(sub %r7 %r8)
(bnez %r7 %r0 (relative |STRCMP_loc0|))
(.label |STRCMP_loc1|)
(bez %r6 %r0 (relative |STRCMP_loc2|))
(mov %r7 (@+ %r4 1))
(mov %r8 (@+ %r5 1))
(sub %r7 %r8)
(bnez %r7 %r0 (relative |STRCMP_loc0|))
(add %r4 2)
(add %r5 2)
(add %r6 -2)
(mov %r0 |STRCMP_loc1|)
(.label |STRCMP_loc2|)
(mov %r4 -1)
(mov %r0 |STRCMP_loc3|)
(.label |STRCMP_loc0|)
(mov %r4 0)
(.label |STRCMP_loc3|)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |OR| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(pop %r5)
(lfun #b1110 %r4 %r5)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |EXECUTE| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(mov %r5 (@+ %r4 0))
(lfun #b1000 %r5 31)
(add %r5 3)
(add %r4 %r5)
(mov %r5 (@+ %r4 0))
(mov %r6 |ENTER|)
(sub %r6 %r5)
(bnez %r6 %r0 (relative |EXECUTE_loc1|))
(mov (@+ %r2 0) %r15)
(add %r2 -2)
(add %r4 2)
(mov %r15 %r4)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.label |EXECUTE_loc1|)
(mov %r6 |ENTER-CREATE|)
(sub %r6 %r5)
(bnez %r6 %r0 (relative |EXECUTE_loc2|))
(mov (@+ %r2 0) %r15)
(add %r2 -2)
(add %r4 4)
(push %r4)
(mov %r15 (@+ %r4 -2))
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.label |EXECUTE_loc2|)
(add %r4 2)
(mov %r0 %r4)
(.defword |,| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(mov (@+ %r3 0) %r4)
(add %r3 2)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |HERE| |FORTH|)
(.word |ENTER-NATIVE|)
(push %r3)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |HERE!| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r3)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |ALLOT| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(add %r3 %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |NUMBER| |FORTH|)
(.word |ENTER|)
(.word |DUP| |C@| |OVER| |+|)
(.word |LIT| 0 |>R| |LIT| 1 |>R|)
(.label |NUMBER_loc4|)
(.word |OVER| |OVER| |=| |NOT| |0BRANCH| |NUMBER_loc0|)
(.word |DUP| |C@|)
(.word |DUP| |LIT| 45 |=| |0BRANCH| |NUMBER_loc1|)
(.word |R>| |R>| |NEGATE| |>R| |>R| |DROP| |BRANCH| |NUMBER_loc0|)
(.label |NUMBER_loc1|)
(.word |DUP| |LIT| 96 |>| |0BRANCH| |NUMBER_loc2| |LIT| 32 |-|)
(.label |NUMBER_loc2|)
(.word |DUP| |LIT| 64 |>| |0BRANCH| |NUMBER_loc3| |LIT| 7 |-|)
(.label |NUMBER_loc3|)
(.word |LIT| 48 |-|)
(.word |DUP| |BASE| |@| |U<| |NOT| |0BRANCH| |NUMBER_loc5|)
(.word |R>| |DROP| |R>| |DROP| |LIT| 0 |EXIT|)
(.label |NUMBER_loc5|)
(.word |R>| |SWAP| |OVER| |UM*| |R>| |+| |>R| |BASE| |@| |UM*| |>R|)
(.word |1-| |BRANCH| |NUMBER_loc4|)
(.label |NUMBER_loc0|)
(.word |DROP| |DROP| |R>| |DROP| |R>| |LIT| -1)
(.word |EXIT|)
(.defword |>| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(pop %r5)
(sub %r4 %r5)
(mov %r5 -1)
(lfun #b1000 %r4 #x8000)
(bnez %r4 %r0 (relative |>_loc0|))
(mov %r5 0)
(.label |>_loc0|)
(push %r5)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |UM*| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(pop %r5)
(mov %r6 0)
(.label |UM*_loc1|)
(bez %r4 %r0 (relative |UM*_loc0|))
(add %r6 %r5)
(add %r4 -1)
(mov %r0 |UM*_loc1|)
(.label |UM*_loc0|)
(push %r6)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |ABORT| |FORTH|)
(.word |ENTER| |LIT| #x8ffe |SP!| |QUIT|)
(.defword |SP!| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r1)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |'| |FORTH|)
(.word |ENTER|)
(.word |LIT| 32 |WORD| |FIND| |LIT| 0 |=| |0BRANCH| |'_loc0|)
(.word |DISPLAY|)
(.fstring " ?")
(.word |ABORT|)
(.label |'_loc0|)
(.word |EXIT|)
(.defword |<| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(pop %r5)
(sub %r5 %r4)
(mov %r5 0)
(bgez %r4 %r0 (relative |<_loc0|))
(mov %r5 -1)
(.label |<_loc0|)
(push %r5)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |TYPE| |FORTH|)
(.word |ENTER|)
(.label |TYPE_loc0|)
(.word |DUP| |0BRANCH| |TYPE_loc1|)
(.word |SWAP| |DUP| |C@| |EMIT| |1+| |SWAP|)
(.word |1-| |BRANCH| |TYPE_loc0|)
(.label |TYPE_loc1|)
(.word |DROP| |DROP|)
(.word |EXIT|)
(.defword |/| |FORTH|)
(.word |ENTER| |/MOD| |SWAP| |DROP| |EXIT|)
(.defword |MOD| |FORTH|)
(.word |ENTER| |/MOD| |DROP| |EXIT|)
(.defword |/MOD| |FORTH|)
(.word |ENTER|)
(.word |OVER| |0<| |OVER| |0<| |DUP| |>R| |XOR| |>R|)
(.word |ABS| |SWAP| |ABS| |SWAP|)
(.word |UM/MOD|)
(.word |R>| |0BRANCH| |/MOD_loc0| |NEGATE|)
(.label |/MOD_loc0|)
(.word |SWAP| |R>| |0BRANCH| |/MOD_loc1| |NEGATE|)
(.label |/MOD_loc1|)
(.word |SWAP|)
(.word |EXIT|)
(.defword |UM/MOD| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(pop %r5)
(mov %r6 0)
(mov %r7 0)
(bez %r4 %r0 (relative |UM/MOD_loc1|))
(.label |UM/MOD_loc0|)
(sub %r5 %r4)
(subc %r7 %r7)
(add %r6 1)
(bez %r7 %r0 (relative |UM/MOD_loc0|))
(add %r6 -1)
(add %r5 %r4)
(.label |UM/MOD_loc1|)
(push %r5)
(push %r6)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |<#| |FORTH|)
(.word |ENTER-NATIVE|)
(mov %r4 0)
(mov (@+ %r3 0) %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |#| |FORTH|)
(.word |ENTER|)
(.word |BASE| |@| |UM/MOD| |SWAP|)
(.word |DUP| |LIT| 9 |>| |0BRANCH| |#_loc0|)
(.word |LIT| 39 |+|)
(.label |#_loc0|)
(.word |LIT| 48 |+|)
(.word |HOLD|)
(.word |EXIT|)
(.defword |#>| |FORTH|)
(.word |ENTER|)
(.word |DROP| |HERE| |C@| |DUP| |LIT| 8 |SWAP| |-| |HERE| |+| |SWAP|)
(.word |EXIT|)
(.defword |#S| |FORTH|)
(.word |ENTER|)
(.label |#S_loc0|)
(.word |#| |DUP| |LIT| 0 |=| |0BRANCH| |#S_loc0|)
(.word |EXIT|)
(.defword |HOLD| |FORTH|)
(.word |ENTER|)
(.word |HERE| |C@| |DUP| |1+| |HERE| |C!| |LIT| 7 |SWAP| |-| |HERE| |+| |C!|)
(.word |EXIT|)
(.defword |SIGN| |FORTH|)
(.word |ENTER|)
(.word |LIT| 0 |<| |0BRANCH| |SIGN_loc0|)
(.word |LIT| 45 |HOLD|)
(.label |SIGN_loc0|)
(.word |EXIT|)
(.defword |U.| |FORTH|)
(.word |ENTER|)
(.word |<#| |#S| |#>| |TYPE|)
(.word |EXIT|)
(.defword |0<| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(lfun #b1000 %r4 #x8000)
(mov %r5 0)
(bez %r4 %r0 (relative |0<_loc0|))
(mov %r5 -1)
(.label |0<_loc0|)
(push %r5)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |0=| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(mov %r5 0)
(bnez %r4 %r0 (relative |0=_loc0|))
(mov %r5 -1)
(.label |0=_loc0|)
(push %r5)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |0>| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(mov %r5 -1)
(bez %r4 %r0 (relative |0>_loc1|))
(bgez %r4 %r0 (relative |0>_loc0|))
(.label |0>_loc1|)
(mov %r5 0)
(.label |0>_loc0|)
(push %r5)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |2+| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(add %r4 2)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |2-| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(add %r4 -2)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |2/| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(mov %r5 %r4)
(lfun #b1000 %r5 #x8000)
(rot %r4 -1)
(lfun #b1000 %r4 #x7fff)
(lfun #b1110 %r4 %r5)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |ABS| |FORTH|)
(.word |ENTER|)
(.word |DUP| |0<| |0BRANCH| |ABS_loc0| |NEGATE|)
(.label |ABS_loc0|)
(.word |EXIT|)
(.defword |COUNT| |FORTH|)
(.word |ENTER| |DUP| |1+| |SWAP| |C@| |EXIT|)
(.defword |D+| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(pop %r5)
(pop %r6)
(pop %r7)
(add %r4 %r6)
(addc %r5 %r7)
(push %r5)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |D<| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(pop %r5)
(pop %r6)
(pop %r7)
(sub %r5 %r7)
(bgez %r5 %r0 (relative |D<_loc0|))
(mov %r4 0)
(mov %r0 |D<_loc1|)
(.label |D<_loc0|)
(sub %r4 %r6)
(mov %r4 -1)
(bgez %r4 %r0 (relative |D<_loc1|))
(mov %r4 0)
(.label |D<_loc1|)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |DEPTH| |FORTH|)
(.word |ENTER-NATIVE|)
(mov %r4 %r1)
(lfun #b0001 %r4 0)
(add %r4 #x8fff)
(rot %r4 -1)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |RDEPTH| |FORTH|)
(.word |ENTER-NATIVE|)
(mov %r4 %r2)
(lfun #b0001 %r4 0)
(add %r4 #x9fff)
(rot %r4 -1)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |DNEGATE| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(pop %r5)
(lfun #b0001 %r4 0)
(lfun #b0001 %r5 0)
(mov %r6 0)
(add %r4 1)
(addc %r5 %r6)
(push %r5)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |MAX| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(pop %r5)
(mov %r6 %r4)
(sub %r6 %r5)
(mov %r7 %r4)
(bgez %r6 %r0 (relative |MAX_loc0|))
(mov %r7 %r5)
(.label |MAX_loc0|)
(push %r7)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |MIN| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(pop %r5)
(mov %r6 %r5)
(sub %r6 %r4)
(mov %r7 %r4)
(bgez %r6 %r0 (relative |MIN_loc0|))
(mov %r7 %r5)
(.label |MIN_loc0|)
(push %r7)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |PICK| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(rot %r4 1)
(mov %r5 %r1)
(add %r5 %r4)
(mov %r4 (@+ %r5 2))
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |ROT| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(pop %r5)
(pop %r6)
(push %r5)
(push %r4)
(push %r6)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |XOR| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(pop %r5)
(lfun #b0110 %r4 %r5)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |SPACE| |FORTH|)
(.word |ENTER| |LIT| 32 |EMIT| |EXIT|)
(.defword |SPACES| |FORTH|)
(.word |ENTER|)
(.label |SPACES_loc1|)
(.word |DUP| |0BRANCH| |SPACES_loc0| |SPACE| |1-| |BRANCH| |SPACES_loc1|)
(.label |SPACES_loc0|)
(.word |DROP|)
(.word |EXIT|)
(.defword |(| |FORTH| :immediate)
(.word |ENTER| |LIT| 41 |WORD| |DROP| |EXIT|)
(.defword |.(| |FORTH| :immediate)
(.word |ENTER| |LIT| 41 |WORD| |COUNT| |TYPE| |EXIT|)
(.defword |DOWN| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(mov %r5 (@+ %r4 0))
(lfun #b1000 %r5 31)
(add %r5 1)
(add %r4 %r5)
(mov %r4 (@+ %r4 0))
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |FORGET| |FORTH|)
(.word |ENTER|)
(.word |LIT| 32 |WORD| |FIND| |0BRANCH| |FORGET_loc0|)
(.word |LIT| #x7fff |OVER| |U<| |NOT| |0BRANCH| |FORGET_loc0|)
(.word |DUP| |HERE!|)
(.word |LIT| |ROOT| |>BODY| |@| |@|)
(.label |FORGET_loc1|)
(.word |DUP| |LIT| |ROOT-HEADER| |=| |NOT| |0BRANCH| |FORGET_loc2|)
(.word |DUP| |>BODY| |@| |@| |ROT|)
(.label |FORGET_loc4|)
(.word |OVER| |OVER| |U<| |NOT| |0BRANCH| |FORGET_loc3|)
(.word |ROT| |ROT| |DOWN| |OVER| |OVER| |SWAP| |>BODY| |@| |!| |ROT|)
(.word |BRANCH| |FORGET_loc4|)
(.label |FORGET_loc3|)
(.word |SWAP| |DROP| |SWAP|)
(.word |DOWN| |BRANCH| |FORGET_loc1|)
(.label |FORGET_loc2|)
(.word |DROP| |DROP|)
(.word |EXIT|)
(.label |FORGET_loc0|)
(.word |DROP|)
(.word |CR| |DISPLAY|)
(.fstring " !")
(.word |ABORT|)
(.defword |PAD| |FORTH|)
(.word |ENTER-NATIVE|)
(mov %r4 #xff00)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |CMOVE| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(pop %r5)
(pop %r6)
(.label |CMOVE_loc1|)
(bez %r4 %r0 (relative |CMOVE_loc0|))
(mov %r7 (@+ %r5 0))
(mov %r8 (@+ %r6 0))
(lfun #b1000 %r7 #xff00)
(lfun #b1000 %r8 #x00ff)
(lfun #b1110 %r7 %r8)
(mov (@+ %r5 0) %r7)
(add %r4 -1)
(add %r5 1)
(add %r6 1)
(mov %r0 |CMOVE_loc1|)
(.label |CMOVE_loc0|)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |CMOVE>| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(pop %r5)
(pop %r6)
(add %r5 %r4)
(add %r5 -1)
(add %r6 %r4)
(add %r6 -1)
(.label |CMOVE>_loc1|)
(bez %r4 %r0 (relative |CMOVE>_loc0|))
(mov %r7 (@+ %r5 0))
(mov %r8 (@+ %r6 0))
(lfun #b1000 %r7 #xff00)
(lfun #b1000 %r8 #x00ff)
(lfun #b1110 %r7 %r8)
(mov (@+ %r5 0) %r7)
(add %r4 -1)
(add %r5 -1)
(add %r6 -1)
(mov %r0 |CMOVE>_loc1|)
(.label |CMOVE>_loc0|)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |:| |FORTH|)
(.word |ENTER|)
(.word |HERE|)
(.word |LIT| 32 |WORD| |DUP| |C@| |LIT| 0 |=| |0BRANCH| |:_loc0|)
(.word |DROP| |DISPLAY|)
(.fstring " !")
(.word |ABORT|)
(.label |:_loc0|)
(.word |DUP| |C@| |1+| |HERE| |SWAP| |CMOVE|)
(.word |HERE| |DUP| |C@| |1+| |+| |DUP|)
(.word |2+| |HERE| |-| |ALLOT| |]|)
(.word |COMPILE| |ENTER|)
(.word |EXIT|)
(.defword |;| |FORTH| :immediate)
(.word |ENTER|)
(.word |COMPILE| |EXIT| |[| |CURRENT| |@| |@| |SWAP| |!| |CURRENT| |@| |!|)
(.word |EXIT|)
(.defword |WORDS| |FORTH|)
(.word |ENTER|)
(.word |CONTEXT| |@| |@|)
(.label |WORDS_loc0|)
(.word |DUP| |COUNT| |LIT| 127 |AND| |TYPE| |SPACE|)
(.word |DOWN| |DUP| |LIT| 0 |=| |0BRANCH| |WORDS_loc0|)
(.word |DROP|)
(.word |EXIT|)
(.defword |IMMEDIATE| |FORTH|)
(.word |ENTER| |CURRENT| |@| |@| |DUP| |C@| |LIT| 128 |OR| |SWAP| |C!| |EXIT|)
(.defword |IF| |FORTH| :immediate)
(.word |ENTER|)
(.word |COMPILE| |0BRANCH|)
(.word |HERE| |COMPILE| 0)
(.word |EXIT|)
(.defword |ELSE| |FORTH| :immediate)
(.word |ENTER|)
(.word |COMPILE| |BRANCH|)
(.word |HERE| |COMPILE| 0)
(.word |SWAP| |HERE| |SWAP| |!|)
(.word |EXIT|)
(.defword |THEN| |FORTH| :immediate)
(.word |ENTER|)
(.word |HERE| |SWAP| |!|)
(.word |EXIT|)
(.defword |DO| |FORTH| :immediate)
(.word |ENTER|)
(.word |COMPILE| |LIT| |HERE| |COMPILE| 0 |COMPILE| |>R|)
(.word |HERE| |COMPILE| |>R| |COMPILE| |>R|)
(.word |EXIT|)
(.defword |LEAVE| |FORTH| :immediate)
(.word |ENTER|)
(.word |COMPILE| |R>| |COMPILE| |DROP|)
(.word |COMPILE| |R>| |COMPILE| |DROP|)
(.word |COMPILE| |EXIT|)
(.word |EXIT|)
(.defword |UNLOOP| |FORTH|)
(.word |ENTER|)
(.word |R>| |DROP| |R>| |DROP| |R>| |DROP|)
(.word |EXIT|)
(.defword |LOOP| |FORTH| :immediate)
(.word |ENTER|)
(.word |COMPILE| |R>| |COMPILE| |R>|)
(.word |COMPILE| |1+|)
(.word |COMPILE| |OVER| |COMPILE| |OVER|)
(.word |COMPILE| |=|)
(.word |COMPILE| |0BRANCH| |,|)
(.word |COMPILE| |DROP| |COMPILE| |DROP|)
(.word |HERE| |SWAP| |!| |COMPILE| |DROP|)
(.word |EXIT|)
(.defword |I| |FORTH|)
(.word |ENTER-NATIVE|)
(mov %r4 (@+ %r2 4))
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |J| |FORTH|)
(.word |ENTER-NATIVE|)
(mov %r4 (@+ %r2 8))
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |."| |FORTH| :immediate)
(.word |ENTER|)
(.word |COMPILE| |DISPLAY|)
(.word |LIT| 34 |WORD|)
(.word |DUP| |C@| |HERE| |SWAP| |1+| |DUP| |ALLOT| |CMOVE|)
(.word |EXIT|)
(.defword |ABORT"| |FORTH| :immediate)
(.word |ENTER|)
(.word |COMPILE| |0BRANCH|)
(.word |HERE| |COMPILE| 0)
(.word |."|)
(.word |COMPILE| |ABORT|)
(.word |HERE| |SWAP| |!|)
(.word |EXIT|)
(.defword |BEGIN| |FORTH| :immediate)
(.word |ENTER|)
(.word |HERE|)
(.word |EXIT|)
(.defword |UNTIL| |FORTH| :immediate)
(.word |ENTER|)
(.word |COMPILE| |0BRANCH| |,|)
(.word |EXIT|)
(.defword |WHILE| |FORTH| :immediate)
(.word |ENTER|)
(.word |COMPILE| |0BRANCH|)
(.word |HERE| |COMPILE| 0)
(.word |EXIT|)
(.defword |REPEAT| |FORTH| :immediate)
(.word |ENTER|)
(.word |SWAP| |COMPILE| |BRANCH| |,|)
(.word |HERE| |SWAP| |!|)
(.word |EXIT|)
(.defword |*| |FORTH|)
(.word |ENTER|)
(.word |LIT| 0 |>R|)
(.word |DUP| |0<| |0BRANCH| |*_loc0| |NEGATE| |R>| |NOT| |>R|)
(.label |*_loc0|)
(.word |SWAP| |DUP| |0<| |0BRANCH| |*_loc1| |NEGATE| |R>| |NOT| |>R|)
(.label |*_loc1|)
(.word |UM*| |R>| |0BRANCH| |*_loc2| |NEGATE|)
(.label |*_loc2|)
(.word |EXIT|)
(.defword |.| |FORTH|)
(.word |ENTER|)
(.word |DUP| |ABS|)
(.word |<#| |#S| |SWAP| |SIGN| |#>| |TYPE|)
(.word |EXIT|)
(.defword |COMPILE| |FORTH|)
(.word |ENTER-NATIVE|)
(mov %r4 (@+ %r15 2))
(mov (@+ %r3 0) %r4)
(add %r3 2)
(add %r15 4)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |HEX| |FORTH|)
(.word |ENTER-NATIVE|)
(mov %r4 16)
(mov (@+ %r4 #x7ff0) %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |FILL| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(pop %r5)
(pop %r6)
(.label |FILL_loc1|)
(bez %r5 %r0 (relative |FILL_loc0|))
(mov %r7 (@+ %r6 0))
(lfun #b1000 %r7 #xff00)
(lfun #b1110 %r7 %r4)
(mov (@+ %r6 0) %r7)
(add %r5 -1)
(add %r6 1)
(mov %r0 |FILL_loc1|)
(.label |FILL_loc0|)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |LITERAL| |FORTH| :immediate)
(.word |ENTER|)
(.word |COMPILE| |LIT| |,|)
(.word |EXIT|)
(.defword |ROLL| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(rot %r4 1)
(mov %r5 %r4)
(add %r5 %r1)
(mov %r6 (@+ %r5 2))
(.label |ROLL_loc1|)
(bez %r4 %r0 (relative |ROLL_loc0|))
(mov %r7 (@+ %r5 0))
(mov (@+ %r5 2) %r7)
(add %r4 -2)
(add %r5 -2)
(mov %r0 |ROLL_loc1|)
(.label |ROLL_loc0|)
(mov (@+ %r5 2) %r6)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |[']| |FORTH| :immediate)
(.word |ENTER|)
(.word |LIT| 32 |WORD| |DUP| |C@| |LIT| 0 |=| |0BRANCH| |[']_loc0|)
(.word |DISPLAY|)
(.fstring " !")
(.word |ABORT|)
(.label |[']_loc0|)
(.word |FIND| |0BRANCH| |[']_loc1|)
(.word |COMPILE| |LIT| |,|)
(.word |EXIT|)
(.label |[']_loc1|)
(.word |DISPLAY|)
(.fstring " ?")
(.word |ABORT|)
(.defword |[COMPILE]| |FORTH| :immediate)
(.word |ENTER|)
(.word |LIT| 32 |WORD| |DUP| |C@| |LIT| 0 |=| |0BRANCH| |[COMPILE]_loc0|)
(.word |DISPLAY|)
(.fstring " !")
(.word |ABORT|)
(.label |[COMPILE]_loc0|)
(.word |FIND| |0BRANCH| |[COMPILE]_loc1|)
(.word |>CODE| |,|)
(.word |EXIT|)
(.label |[COMPILE]_loc1|)
(.word |DISPLAY|)
(.fstring " ?")
(.word |ABORT|)
(.defword |.S| |FORTH|)
(.word |ENTER|)
(.word |DEPTH| |LIT| 0)
(.label |.S_loc0|)
(.word |OVER| |OVER| |=| |NOT| |0BRANCH| |.S_loc1|)
(.word |DUP| |2+| |PICK| |U.| |SPACE| |1+|)
(.word |BRANCH| |.S_loc0|)
(.label |.S_loc1|)
(.word |DROP| |DROP|)
(.word |EXIT|)
(.defword |*/| |FORTH|)
(.word |ENTER| |*/MOD| |SWAP| |DROP| |EXIT|)
(.defword |*/MOD| |FORTH|)
(.word |ENTER|)
(.word |OVER| |0<| |OVER| |0<| |DUP| |>R| |XOR| |LIT| 3 |PICK| |0<| |XOR| |>R|)
(.word |ABS| |ROT| |ABS| |ROT| |ABS| |ROT|)
(.word |UM*/MOD|)
(.word |R>| |0BRANCH| |*/MOD_loc0| |NEGATE|)
(.label |*/MOD_loc0|)
(.word |SWAP| |R>| |0BRANCH| |*/MOD_loc1| |NEGATE|)
(.label |*/MOD_loc1|)
(.word |SWAP|)
(.word |EXIT|)
(.defword |UM*/MOD| |FORTH|)
(.word |ENTER-NATIVE|)
(pop %r4)
(pop %r5)
(pop %r6)
(mov %r7 0)
(mov %r8 0)
(mov %r9 0)
(.label |UM*/MOD_loc0|)
(bez %r5 %r0 (relative |UM*/MOD_loc1|))
(add %r7 %r6)
(addc %r8 %r9)
(add %r5 -1)
(mov %r0 |UM*/MOD_loc0|)
(.label |UM*/MOD_loc1|)
(mov %r6 0)
(.label |UM*/MOD_loc2|)
(sub %r7 %r4)
(subc %r8 %r9)
(subc %r5 %r5)
(add %r6 1)
(bez %r5 %r0 (relative |UM*/MOD_loc2|))
(add %r7 %r4)
(add %r6 -1)
(push %r7)
(push %r6)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |-TRAILING| |FORTH|)
(.word |ENTER-NATIVE|)
(mov %r4 (@+ %r1 4))
(pop %r5)
(add %r4 %r5)
(.label |-TRAILING_loc0|)
(bez %r5 %r0 (relative |-TRAILING_loc1|))
(mov %r6 (@+ %r4 -1))
(lfun #b1000 %r6 #xff)
(add %r6 -32)
(bnez %r6 %r0 (relative |-TRAILING_loc1|))
(add %r4 -1)
(add %r5 -1)
(mov %r0 |-TRAILING_loc0|)
(.label |-TRAILING_loc1|)
(push %r5)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r15 (@+ %r4 0))
(.defword |CONVERT| |FORTH|)
(.label |CONVERT_loc0|)
(.word |1+| |C@|)
(.word |DUP| |LIT| 96 |>| |0BRANCH| |CONVERT_loc1| |LIT| 32 |-|)
(.label |CONVERT_loc1|)
(.word |DUP| |LIT| 64 |>| |0BRANCH| |CONVERT_loc2| |LIT| 7 |-|)
(.label |CONVERT_loc2|)
(.word |LIT| 48 |-|)
(.word |DUP| |BASE| |@| |U<| |NOT| |0BRANCH| |CONVERT_loc3|)
(.word |DROP| |EXIT|)
(.label |CONVERT_loc3|)
(.word |ROT| |ROT| |BASE| |@| |1-|)
(.label |CONVERT_loc4|)
(.word |DUP| |0BRANCH| |CONVERT_loc5| |1-|)
(.word |ROT| |ROT| |OVER| |OVER| |D+| |ROT|)
(.word |BRANCH| |CONVERT_loc4|)
(.label |CONVERT_loc5|)
(.word |DROP| |ROT| |BRANCH| |CONVERT_loc0|)
(.defword |+LOOP| |FORTH| :immediate)
(.defword |CREATE| |FORTH|)
(.word |ENTER|)
(.word |LIT| 32 |WORD| |DUP| |C@| |LIT| 0 |=| |0BRANCH| |CREATE_loc0|)
(.word |DISPLAY|)
(.fstring " !")
(.word |ABORT|)
(.label |CREATE_loc0|)
(.word |DUP| |C@| |1+| |HERE| |SWAP| |CMOVE|)
(.word |HERE| |DUP| |C@| |1+| |+| |DUP| |CURRENT| |@| |@| |SWAP| |!|)
(.word |HERE| |CURRENT| |@| |!|)
(.word |2+| |HERE| |-| |ALLOT|)
(.word |COMPILE| |ENTER-CREATE| |COMPILE| |CREATE-IMPL|)
(.label |CREATE-IMPL|)
(.word |EXIT|)
(.defword |ENTER-CREATE| |FORTH|)
(mov (@+ %r2 0) %r15)
(add %r2 -2)
(mov %r4 (@+ %r15 0))
(add %r4 4)
(push %r4)
(mov %r15 (@+ %r4 -2))
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |DOES>| |FORTH| :immediate)
(.word |ENTER|)
(.word |COMPILE| |LIT| |HERE| |LIT| 14 |+| |,|)
(.word |COMPILE| |CURRENT| |COMPILE| |@| |COMPILE| |@|)
(.word |COMPILE| |>BODY| |COMPILE| |2-|)
(.word |COMPILE| |!| |COMPILE| |EXIT|)
(.word |EXIT|)
(.defword |VARIABLE| |FORTH|)
(.word |ENTER| |CREATE| |LIT| 0 |,| |EXIT|)
(.defword |CONSTANT| |FORTH|)
(.word |ENTER|)
(.word |CREATE| |,|)
(.word |LIT| |CONSTANT-IMPL| |CURRENT| |@| |@| |>BODY| |2-| |!|)
(.word |EXIT|)
(.label |CONSTANT-IMPL|)
(.word |@|)
(.word |EXIT|)
(.defword |CONTEXT| |ROOT|)
(.word |ENTER-NATIVE|)
(mov %r4 #x800c)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |CURRENT| |ROOT|)
(.word |ENTER-NATIVE|)
(mov %r4 #x8016)
(push %r4)
(add %r15 2)
(mov %r4 (@+ %r15 0))
(mov %r0 (@+ %r4 0))
(.defword |VOCABULARY| |ROOT|)
(.word |ENTER|)
(.word |CONTEXT| |@| |CURRENT| |@| |ROOT| |DEFINITIONS|)
(.word |CREATE| |HERE| |2+| |,| |LIT| 0 |,|)
(.word |LIT| |VOCABULARY-IMPL| |CURRENT| |@| |@| |>BODY| |2-| |!|)
(.word |CURRENT| |!| |CONTEXT| |!|)
(.word |EXIT|)
(.label |VOCABULARY-IMPL|)
(.word |@| |CONTEXT| |!|)
(.word |EXIT|)
(.defword |DEFINITIONS| |ROOT|)
(.word |ENTER| |CONTEXT| |@| |CURRENT| |!| |EXIT|)
(.defword |ALSO| |ROOT|)
(.word |ENTER|)
(.word |CONTEXT| |DUP| |2+| |LIT| 6 |CMOVE>| |EXIT|)
(.word |EXIT|)
(.defword |ONLY| |ROOT|)
(.word |ENTER| |ROOT| |ALSO| |ALSO| |ALSO| |EXIT|)
(.defword |ORDER| |ROOT|)
(.defword |SEAL| |ROOT|)
(.defword |LOAD| |FORTH|)
(.defword |BLOCK| |FORTH|)
(.defword |BUFFER| |FORTH|)
(.defword |FLUSH| |FORTH|)
(.defword |SAVE-BUFFERS| |FORTH|)
(.defword |UPDATE| |FORTH|)
(.defword |FORTH-83| |FORTH|)
(.word |ENTER| |EXIT|)
; The ROOT vocabulary must be the first one defined for FORGET to work properly.
; Also, only additional vocabularies should be defined in ROOT at runtime.
(.label |ROOT-HEADER|)
(.defword |ROOT| |ROOT|)
(.word |ENTER-CREATE|)
(.word |VOCABULARY-IMPL|)
(.word #x801a)
(.defword |FORTH| |ROOT|)
(.word |ENTER-CREATE|)
(.word |VOCABULARY-IMPL|)
(.word #x8018)
; The following code must come at the end of this file for FIND to work properly.
(.label |FORTH-PTR|)
(.vocabptr |FORTH|)
(.label |ROOT-PTR|)
(.vocabptr |ROOT|)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment