uart: swap status with config half word
[calu.git] / 3a_asm / DTFormat.hs
index 3a43eb8b854487ca6b4c18dbd13af4c44b0f5566..8b85ca1cca9c0656e4155bd0b6c391b4600b6db6 100644 (file)
@@ -1,6 +1,8 @@
 module DTFormat where
 
+import Numeric
 import Data.Word
+import Data.Char
 import Text.Printf
 import Text.Parsec
 import Text.Parsec.String
@@ -51,6 +53,16 @@ showsDTF (DTF_State s) = (++) (printf "sta;%s\n" (show s))
 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])