3a_asm: parse a comment \o/
[calu.git] / 3a_asm / DTFormat.hs
1 module DTFormat where
2
3 import Data.Word
4 import Text.Printf
5
6 type Address = Word32
7 type Value = Word32
8 type ValueToParse = String
9 type Code = String
10 type Label = String
11 type Comment = String
12
13 data DTF =
14         DTF_Data Address Value Code Label Comment |
15         DTF_Instr Address Value Code Label Comment |
16         DTF_Comment Comment |
17         DTF_Label Label |
18         -- types for intern processing
19         DTF_ToParse Address ValueToParse Code Label Comment |
20         DTF_Org Address
21
22 instance Show (DTF) where
23         showsPrec n = showsDTF
24
25 showsDTF :: DTF -> ShowS
26 showsDTF (DTF_Data a v c l s) = (++) (datins "0" a v c l s)
27 showsDTF (DTF_Instr a v c l s) = (++) (datins "1" a v c l s)
28 showsDTF (DTF_Comment c) = (++) (printf "2;%s\n" c)
29 showsDTF (DTF_Label l) = (++) (printf "3;%s\n" l)
30 showsDTF (DTF_ToParse a v c l s) = (++) (printf "lulz\n")
31
32
33 datins :: String -> Address -> Value -> Code -> Label -> Comment -> String
34 datins = printf "%s;%08x;%08x;%s;%s;%s\n"
35