- let (dict,formatedsrc) = convertDTF src NoState 0x00 0x00 []
- printf "\nlabels:\n"
- sequence_ [printf "%10s @ 0x%08x\n" l a | (l,a) <- (reverse dict)]
- printf "\nparsed asm:\n"
- sequence_ [printf "%s" (show x) | x <- formatedsrc]
+ let (dict,formatedsrc) = convertDTF src NoState 0x00 0x00 [("start_",0x00)]
+ 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
+ sequence_ [printf "%s" (showsDTFBase x base "") | x <- parsed]
+
+
+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 (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)