From fa8b99969d7a6966c1cd309d41384051599070fb Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Sun, 3 Jul 2016 19:57:27 +0200 Subject: Fix RTS; working example --- ABC/Assembler.icl | 8 ++++---- ABC/Code/RTS.icl | 5 +++-- ABC/Driver.icl | 3 +-- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'ABC') diff --git a/ABC/Assembler.icl b/ABC/Assembler.icl index 9de0708..e5e3a9a 100644 --- a/ABC/Assembler.icl +++ b/ABC/Assembler.icl @@ -29,12 +29,12 @@ where collect :: Assembler Int Int -> SymTable collect [] _ _ = [] -collect [Label l :r] lc dc = [(l,lc,LabSym) :collect r lc dc] -collect [Descriptor dl rl _ _:r] lc dc = [(dl,dc,DescSym):collect r lc (dc+1)] -collect [_ :r] lc dc = collect r (lc+1) dc +collect [Label l :r] lc dc = [(l,lc,LabSym) :collect r lc dc] +collect [Descriptor dl _ _ _:r] lc dc = [(dl,dc,DescSym):collect r lc (dc+1)] +collect [_ :r] lc dc = collect r (lc+1) dc lookup :: Label SymType SymTable -> Int -lookup l t [] = abortn ("label " <+ l <+ " not defined as " <+ t) +lookup l t [] = abortn (l <+ " not defined as " <+ t) lookup l t [(name,n,type):r] | l == name && t == type = n | otherwise = lookup l t r diff --git a/ABC/Code/RTS.icl b/ABC/Code/RTS.icl index f28f4d8..89032f3 100644 --- a/ABC/Code/RTS.icl +++ b/ABC/Code/RTS.icl @@ -7,6 +7,8 @@ rts = [ Descriptor "INT" "_rnf" 0 "integer" , Descriptor "BOOL" "_rnf" 0 "boolean" , Jmp "init_graph" + , Label "_rnf" + , Rtn , Label "init_graph" , Create , Fill "Start" 0 "n_Start" 0 @@ -31,6 +33,7 @@ rts , DecI , Jmp "_brackets" , Label "_exit" + , Pop_b 1 , Rtn , Label "_args" , Print "(" @@ -49,8 +52,6 @@ rts , Jsr "_driver" , DecI , Jmp "_arg_loop" - , Label "_rnf" - , Rtn , Label "_cycle" , Print "cycle in spine\n" , Halt diff --git a/ABC/Driver.icl b/ABC/Driver.icl index aa89ae1..633d248 100644 --- a/ABC/Driver.icl +++ b/ABC/Driver.icl @@ -1,6 +1,6 @@ implementation module ABC.Driver -import StdEnv, StdDebug +import StdEnv import ABC.Machine @@ -18,7 +18,6 @@ boot (prog,descs) fetch_cycle :: State -> State fetch_cycle st=:{pc,program} -//# pc = trace_n pc pc | pc_end pc = st | otherwise = fetch_cycle (currinstr {st & pc=pc`}) where -- cgit v1.2.3