3a_asm: changed data structure again to calculate relative addresses
[calu.git] / 3a_asm / Main.hs
index 2515674cf1444255fe6604d116ff55cc0ea7aa09..2952e8b53925251ba684962ee0b4455ccfcb0ecc 100644 (file)
@@ -35,12 +35,12 @@ main = do
        sequence_ [printf "%s" (show x) | x <- parsed]
 
 
-parseInstr :: [DictLabel] -> [DTF] -> [DTF]
+parseInstr :: [DictElem] -> [DTF] -> [DTF]
 parseInstr _ [] = []
 parseInstr dict ((DTF_InstrToParse a instr c l s):xs) =
        (DTF_Instr a bytecode c l s):(parseInstr dict xs)
        where
-       bytecode = case (parse (instruction dict) "" (instr++"\n")) of
+       bytecode = case (parse (instruction (a,dict)) "" (instr++"\n")) of
                Left err -> error ("couldn't parse Instruction: " ++ instr ++ "\n" ++ show err)
                Right x -> x
 parseInstr dict (x:xs) = x:(parseInstr dict xs)
@@ -52,7 +52,7 @@ inc :: Counter -> Counter
 inc = ((+) 4)
 
 
-convertDTF :: [(Int,String)] -> DT_State -> Counter -> Counter -> [DictLabel] -> ([DictLabel], [DTF])
+convertDTF :: [(Int,String)] -> DT_State -> Counter -> Counter -> [DictElem] -> ([DictElem], [DTF])
 convertDTF [] _ _ _ d = (d,[])
 convertDTF ((lno,str):xs) state datacnt instrcnt dict = (newdict, (actlist newdtf))
        where
@@ -78,11 +78,11 @@ convertDTF ((lno,str):xs) state datacnt instrcnt dict = (newdict, (actlist newdt
        nstate (DTF_State s) = s
        nstate _ = state
 
-       ndict (DTF_Label l _ a) = dict `add_label` (l,a)
-       ndict (DTF_SectionToDet a _ _ l _) = dict `add_label` (l,a)
-       ndict (DTF_InstrToParse a _ _ l _) = dict `add_label` (l,a)
-       ndict (DTF_Data a _ _ l _) = dict `add_label` (l,a)
-       ndict (DTF_Instr a _ _ l _) = dict `add_label` (l,a)
+       ndict (DTF_Label l _ a) = dict `add_elem` (l,a)
+       ndict (DTF_SectionToDet a _ _ l _) = dict `add_elem` (l,a)
+       ndict (DTF_InstrToParse a _ _ l _) = dict `add_elem` (l,a)
+       ndict (DTF_Data a _ _ l _) = dict `add_elem` (l,a)
+       ndict (DTF_Instr a _ _ l _) = dict `add_elem` (l,a)
        ndict _ = dict
 
        newdtf = case (parse parseDTFLine "" (str++"\n")) of