From 77795c669c9606da9f9c5d4fe20b150436b49c3f Mon Sep 17 00:00:00 2001 From: Jeremiah Orians Date: Fri, 16 Jun 2017 16:19:45 -0400 Subject: [PATCH] Fixed Forth's Stack Leak --- CHANGELOG.org | 1 + stage2/forth.s | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.org b/CHANGELOG.org index cdbf923..bee282b 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -32,6 +32,7 @@ Stack offset bug in stage2 forth was found and fixed by reepca in record time Fixed 2DUP and ?DUP in stage2 forth Swapped TRUE and FALSE values in stage2 forth to match http://lars.nocrew.org/dpans/dpans3.htm#3.1.3 Adjusted order of comparisions to better match ans +Stack leak in stage2 forth found and corrected ** Removed Removed need for sponge to be used to run webIDE diff --git a/stage2/forth.s b/stage2/forth.s index 7f3c30c..1de5cda 100644 --- a/stage2/forth.s +++ b/stage2/forth.s @@ -1250,6 +1250,8 @@ :Interpret_Code CALLI R15 @Word_Direct ; Get the Word POPR R0 R14 ; Remove Length + CMPSKIPI.NE R0 0 ; If Nothing read + JUMP @Interpret_Cleanup ; Cleanup POPR R0 R14 ; Remove Pointer PUSHR R0 R14 ; Protect Pointer PUSHR R0 R14 ; Put Pointer @@ -1288,6 +1290,10 @@ PUSHR R0 R8 ; Append Immediate to HEAP JSR_COROUTINE R11 ; NEXT +:Interpret_Cleanup + POPR R0 R14 ; Remove Pointer + JSR_COROUTINE R11 ; NEXT + ;; Cold done function ;; Reads Tape_01 until EOF ;; Then switches into TTY Mode