From 40ec859e51a27a1d1e773463ee43bd4290297ce8 Mon Sep 17 00:00:00 2001 From: Jeremiah Orians Date: Sat, 29 Oct 2016 12:05:41 -0400 Subject: [PATCH] Added logical functions and a subroutine EXIT --- stage2/forth.s | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/stage2/forth.s b/stage2/forth.s index d65a149..7efcbaa 100644 --- a/stage2/forth.s +++ b/stage2/forth.s @@ -26,6 +26,12 @@ CALLI R15 @cold_start HALT +;; EXIT function +;; Pops Return stack +;; And jumps to NEXT +:EXIT + POPR R13 R15 + ;; NEXT function ;; increments to next instruction ;; Jumps to updated current @@ -334,5 +340,56 @@ PUSHR R0 R14 JSR_COROUTINE R11 ; NEXT +;; AND +:AND_Text +"AND" +:AND_Entry + &GEqual_Entry ; Pointer to >= + &AND_Text ; Pointer to Name + NOP ; Flags + POPR R0 R14 + POPR R1 R14 + AND R0 R0 R1 + PUSHR R0 R14 + JSR_COROUTINE R11 ; NEXT + +;; OR +:OR_Text +"OR" +:OR_Entry + &AND_Entry ; Pointer to AND + &OR_Text ; Pointer to Name + NOP ; Flags + POPR R0 R14 + POPR R1 R14 + OR R0 R0 R1 + PUSHR R0 R14 + JSR_COROUTINE R11 ; NEXT + +;; XOR +:XOR_Text +"XOR" +:XOR_Entry + &OR_Entry ; Pointer to OR + &XOR_Text ; Pointer to Name + NOP ; Flags + POPR R0 R14 + POPR R1 R14 + XOR R0 R0 R1 + PUSHR R0 R14 + JSR_COROUTINE R11 ; NEXT + +;; NOT +:NOT_Text +"NOT" +:NOT_Entry + &XOR_Entry ; Pointer to XOR + &NOT_Text ; Pointer to Name + NOP ; Flags + POPR R0 R14 + NOT R0 R0 + PUSHR R0 R14 + JSR_COROUTINE R11 ; NEXT + :cold_start ;;