From 3eb04547355c49b986e884e028652ac50762089b Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Sun, 30 Jan 2022 17:16:36 +1100 Subject: minor edits --- Assembler.hs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Assembler.hs') diff --git a/Assembler.hs b/Assembler.hs index ca79a48..47959ea 100644 --- a/Assembler.hs +++ b/Assembler.hs @@ -80,12 +80,15 @@ stripJunk xs = filter (not . null) $ (filter (not . (flip elem " \t")) . head . stripLabels :: [[Char]] -> [[Char]] stripLabels = filter (not . (elem '(')) +-- For labels addLabels :: [[Char]] -> Int -> Map [Char] [Char] -> Map [Char] [Char] addLabels [] _ table = table addLabels ((hd:tl):rest) addr table | hd == '(' = addLabels rest addr (Map.insert (init tl) (int2Bin16 addr) table) | otherwise = addLabels rest (addr + 1) table +-- For variables, addr is the current instruction address, vaddr is the +-- variable memory address (to be assigned) addSyms :: [[Char]] -> Int -> Int -> Map [Char] [Char] -> Map [Char] [Char] addSyms [] _ _ table = table addSyms ((hd:tl):rest) addr vaddr table -- cgit v1.2.3