From 41d3ebb643ed468bde8b3aff890379bf49409ffe Mon Sep 17 00:00:00 2001 From: Jeremiah Orians Date: Thu, 15 Jun 2017 06:33:45 -0400 Subject: [PATCH] Fixing forth comparisons thanks to reepca --- CHANGELOG.org | 2 ++ bootstrapping Steps.org | 2 +- stage2/forth.s | 48 ++++++++++++++++++++--------------------- test/SHA256SUMS | 2 +- 4 files changed, 28 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.org b/CHANGELOG.org index 71d995d..a524d49 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -27,6 +27,8 @@ Updated checksum for stage2 forth ** Fixed 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 ** Removed diff --git a/bootstrapping Steps.org b/bootstrapping Steps.org index e9ce627..8bca632 100644 --- a/bootstrapping Steps.org +++ b/bootstrapping Steps.org @@ -174,7 +174,7 @@ Then we use our M0 Line macro assembler to convert our assembly into hex2 format Then we need to assemble that hex into our desired program: ./bin/vm --rom roms/stage1_assembler-2 --tape_01 temp2 --tape_02 roms/forth --memory 48K -roms/forth should with the sha256sum of 110dfd9cf2187ed8bf68a07510f054d96a55ec26377fe9d3a8e1f44ced2313f4 +roms/forth should with the sha256sum of a0d760e98534ec7abea6677e80fac98d2ec42d5bb1f02b1575122831fed46651 Our forth will first attempt to evaluate any code in tape_01 and then evaluate any code that the user types in (Otherwise there is no way for a forth fan to have a chance against the lisp in terms of being able to bootstrap something cool) diff --git a/stage2/forth.s b/stage2/forth.s index c696c89..e5fb670 100644 --- a/stage2/forth.s +++ b/stage2/forth.s @@ -366,11 +366,11 @@ NOP ; Flags &Equal_Code ; Where assembly is Stored :Equal_Code - POPR R1 R14 ; Get top of stack - POPR R2 R14 ; Get second item on Stack - FALSE R0 ; Assume comparision is True + POPR R2 R14 ; Get top of stack + POPR R1 R14 ; Get second item on Stack + TRUE R0 ; Assume comparision is True CMPSKIP.E R1 R2 ; Check if they are equal and skip if they are - TRUE R0 ; Looks like our assumption was wrong + FALSE R0 ; Looks like our assumption was wrong PUSHR R0 R14 ; Store the result JSR_COROUTINE R11 ; NEXT @@ -383,11 +383,11 @@ NOP ; Flags &NEqual_Code ; Where assembly is Stored :NEqual_Code - POPR R1 R14 ; Get top of stack - POPR R2 R14 ; Get second item on Stack - FALSE R0 ; Assume comparision is True + POPR R2 R14 ; Get top of stack + POPR R1 R14 ; Get second item on Stack + TRUE R0 ; Assume comparision is True CMPSKIP.NE R1 R2 ; Check if they are not equal and skip if they are - TRUE R0 ; Looks like our assumption was wrong + FALSE R0 ; Looks like our assumption was wrong PUSHR R0 R14 ; Store the result JSR_COROUTINE R11 ; NEXT @@ -400,11 +400,11 @@ NOP ; Flags &Less_Code ; Where assembly is Stored :Less_Code - POPR R1 R14 ; Get top of stack - POPR R2 R14 ; Get second item on Stack - FALSE R0 ; Assume comparision is True + POPR R2 R14 ; Get top of stack + POPR R1 R14 ; Get second item on Stack + TRUE R0 ; Assume comparision is True CMPSKIP.L R1 R2 ; Check if less than and skip if they are - TRUE R0 ; Looks like our assumption was wrong + FALSE R0 ; Looks like our assumption was wrong PUSHR R0 R14 ; Store the result JSR_COROUTINE R11 ; NEXT @@ -417,11 +417,11 @@ NOP ; Flags &LEqual_Code ; Where assembly is Stored :LEqual_Code - POPR R1 R14 ; Get top of stack - POPR R2 R14 ; Get second item on Stack - FALSE R0 ; Assume comparision is True + POPR R2 R14 ; Get top of stack + POPR R1 R14 ; Get second item on Stack + TRUE R0 ; Assume comparision is True CMPSKIP.LE R1 R2 ; Check if they are less than or equal and skip if they are - TRUE R0 ; Looks like our assumption was wrong + FALSE R0 ; Looks like our assumption was wrong PUSHR R0 R14 ; Store the result JSR_COROUTINE R11 ; NEXT @@ -434,11 +434,11 @@ NOP ; Flags &Greater_Code ; Where assembly is Stored :Greater_Code - POPR R1 R14 ; Get top of stack - POPR R2 R14 ; Get second item on Stack - FALSE R0 ; Assume comparision is True + POPR R2 R14 ; Get top of stack + POPR R1 R14 ; Get second item on Stack + TRUE R0 ; Assume comparision is True CMPSKIP.G R1 R2 ; Check if greater and skip if they are - TRUE R0 ; Looks like our assumption was wrong + FALSE R0 ; Looks like our assumption was wrong PUSHR R0 R14 ; Store the result JSR_COROUTINE R11 ; NEXT @@ -451,11 +451,11 @@ NOP ; Flags &GEqual_Code ; Where assembly is Stored :GEqual_Code - POPR R1 R14 ; Get top of stack - POPR R2 R14 ; Get second item on Stack - FALSE R0 ; Assume comparision is True + POPR R2 R14 ; Get top of stack + POPR R1 R14 ; Get second item on Stack + TRUE R0 ; Assume comparision is True CMPSKIP.GE R1 R2 ; Check if they are equal and skip if they are - TRUE R0 ; Looks like our assumption was wrong + FALSE R0 ; Looks like our assumption was wrong PUSHR R0 R14 ; Store the result JSR_COROUTINE R11 ; NEXT diff --git a/test/SHA256SUMS b/test/SHA256SUMS index 424b722..eef3e2c 100644 --- a/test/SHA256SUMS +++ b/test/SHA256SUMS @@ -1,6 +1,6 @@ 8f465d3ec1cba00a7d024a1964e74bb6d241f86a73c77d95d8ceb10d09c8f7b9 roms/CAT 59f0502748af32e3096e026a95e77216179cccfe803a05803317414643e2fcec roms/DEHEX -110dfd9cf2187ed8bf68a07510f054d96a55ec26377fe9d3a8e1f44ced2313f4 roms/forth +a0d760e98534ec7abea6677e80fac98d2ec42d5bb1f02b1575122831fed46651 roms/forth 4c146297da8c672955698a82207295b28feb389c9856a2c6ea6a60ce7e84260a roms/lisp 2b9727381aec15a504c0898189fbc2344209d8e04451e3fa5d743e08e38f64cf roms/M0 24a4d74eb2eb7a82e68335643855658b27b5a6c3b13db473539f3e08d6f26ceb roms/SET