From 9bf82558496f37d246ecb73d0c2ee30c17e2453b Mon Sep 17 00:00:00 2001 From: Jeremiah Orians Date: Sun, 21 May 2017 21:13:04 -0400 Subject: [PATCH] Fixing assoc in mixed lexical scope --- CHANGELOG.org | 2 ++ bootstrapping Steps.org | 10 +++++++++- stage2/High_level_prototypes/lisp_eval.c | 2 +- stage2/lisp.s | 4 +++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.org b/CHANGELOG.org index f1a8b3f..7c6f104 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -20,6 +20,8 @@ ** Changed ** Fixed +Fixed failure to lookup symbols that are identical but are in different lexical scopes +Updated Bootstrapping instructions to reflect new checksum and recommendation for most minimal requirements ** Removed diff --git a/bootstrapping Steps.org b/bootstrapping Steps.org index 2a107e1..5789e6f 100644 --- a/bootstrapping Steps.org +++ b/bootstrapping Steps.org @@ -18,6 +18,14 @@ First to get a vm that can run our code: make development +For those of you who don't want to depend upon make, simply run: +gcc -ggdb -Dtty_lib=true vm.h vm.c vm_instructions.c vm_decode.c tty.c -o bin/vm + +However if you are trying to hand convert the source code to your TTL Logic +or relay based computer to ensure complete immunity from the trusting trust attack, +please instead implement the equivelent of: +gcc vm.h vm_minimal.c vm_instructions.c vm_decode.c -o bin/vm + And we probably want a safe place to put the programs we make: mkdir roms @@ -144,7 +152,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/lisp --memory 48K -roms/lisp should have the sha256sum of a99a43cb11fd2889a94d9e2bc65e5487406eb62ae4d0d877d573437cb9d1c107 +roms/lisp should have the sha256sum of d9bb13beced1c98daa4a62512ba35faa137f3ed6f23cdc1cdf724e25e8c6d80a Our lisp will first attempt to evaluate any code in tape_01 and then evaluate any code that the user types in. It is recommended to run with no less than 4MB of Memory diff --git a/stage2/High_level_prototypes/lisp_eval.c b/stage2/High_level_prototypes/lisp_eval.c index 912e3bb..18ece78 100644 --- a/stage2/High_level_prototypes/lisp_eval.c +++ b/stage2/High_level_prototypes/lisp_eval.c @@ -69,7 +69,7 @@ struct cell* assoc(struct cell* key, struct cell* alist) if(nil == alist) return nil; for(; nil != alist; alist = alist->cdr) { - if(alist->car->car == key) return alist->car; + if(alist->car->car->string == key->string) return alist->car; } return nil; } diff --git a/stage2/lisp.s b/stage2/lisp.s index 9978c2f..f617195 100644 --- a/stage2/lisp.s +++ b/stage2/lisp.s @@ -907,13 +907,15 @@ PUSHR R3 R15 ; Protect R3 PUSHR R4 R15 ; Protect R4 LOADUI R4 $NIL ; Using NIL + LOAD32 R0 R0 4 ; Using KEY->CAR :assoc_0 CMPJUMPI.E R1 R4 @assoc_done LOAD32 R2 R1 4 ; ALIST->CAR LOAD32 R3 R2 4 ; ALIST->CAR->CAR + LOAD32 R3 R3 4 ; ALIST->CAR->CAR->CAR LOAD32 R1 R1 8 ; ALIST = ALIST->CDR - CMPSKIP.E R0 R3 ; If ALIST->CAR->CAR != KEY + CMPSKIP.E R0 R3 ; If ALIST->CAR->CAR->CAR != KEY->CAR JUMP @assoc_0 ; Iterate using ALIST->CDR ;; Found KEY