kleinigkeiten
[calu.git] / 3a_asm / Main.hs
index f3a6fc11d0681aac60ad2bb9bb8d05a8d82df96a..d62fe17360220692b8defa51d7e7495b49dd2a71 100644 (file)
@@ -1,6 +1,6 @@
 -- as for deep thoughts ISA
 -----------------------------------------------------------------------------
-import DT
+import DT hiding (not)
 import DTFormat
 import Expr_eval
 
@@ -25,13 +25,18 @@ main = do
        content <- getContents
        let src = (filter (((/=) "") . snd) $ (zip [1..] (lines content)))
        let (dict,formatedsrc) = convertDTF src NoState 0x00 0x00 [("start_",0x00)]
-       printf "\nlabels:\n"
-       sequence_ [printf "%20s @ 0x%08x\n" l a | (l,a) <- (reverse dict)]
-       printf "\nparsed asm:\n"
-       sequence_ [printf "%s" (show x) | x <- formatedsrc]
+       if (not $ null args) && ("-d" `elem` args)
+               then do
+                       printf "\nlabels:\n"
+                       sequence_ [printf "%20s @ 0x%08x\n" l a | (l,a) <- (reverse dict)]
+                       printf "\nparsed asm:\n"
+                       sequence_ [printf "%s" (show x) | x <- formatedsrc]
+                       printf "\nafter parsing the instructions:\n"
+               else do
+                       printf ""
+       let base = if "-b" `elem` args then 2 else 16
        let parsed = parseInstr dict formatedsrc
-       printf "\nafter parsing the instructions:\n"
-       sequence_ [printf "%s" (show x) | x <- parsed]
+       sequence_ [printf "%s" (showsDTFBase x base "") | x <- parsed]
 
 
 parseInstr :: [DictElem] -> [DTF] -> [DTF]