module DTFormat where
+import Numeric
import Data.Word
+import Data.Char
import Text.Printf
import Text.Parsec
import Text.Parsec.String
datins :: String -> Address -> Value -> Code -> Label -> Comment -> String
datins = printf "%s;%08x;%08x;%s;%s;%s\n"
+tobin :: Value -> String
+tobin v = reverse $ take 32 $ reverse $ (['0' | _<-[0..32]]) ++ (showIntAtBase 2 (chr. ((+)0x30)) v "")
+
+showsDTFBase :: DTF -> Int -> ShowS
+showsDTFBase (DTF_Data a v c l s) 2 = (++) (datinsBin "0" a (tobin v) c l s)
+showsDTFBase (DTF_Instr a v c l s) 2 = (++) (datinsBin "1" a (tobin v) c l s)
+showsDTFBase d _ = showsDTF d
+
+datinsBin :: String -> Address -> String -> Code -> Label -> Comment -> String
+datinsBin = printf "%s;%08x;%s;%s;%s;%s\n"
-- datastructure for managing labels and defines
type Dict = (Address,[DictElem])