-- parsing --
-instruction :: Dict -> Parser Word32
-instruction dict = foldl1 (<|>) (fmap (\x -> try (x dict)) instructions) <* char '\n'
+instruction :: LineNo -> Dict -> Parser Word32
+instruction lno dict = foldl1 (<|>) (fmap (\x -> try (x dict)) instructions) <* char '\n' <?> (". something at line " ++ show lno ++ " is wrong (ignore line 1 hint above, but pay attention for possible line offset due to #include).")
testins :: String -> IO ()
testins input =
- case (parse (instruction dict) "" (input++"\n")) of
+ case (parse (instruction 0 dict) "" (input++"\n")) of
Left err -> do { putStr "fail :/\n"; print err}
Right x -> do { printf "0x%08X\n" x }
where
iLit :: Dict -> Parser Word32
iLit (_,d) = do
+ parseMySpaces
val <- expr d;
try (do {
string "@hi"; parseMySpaces;
csv0i_p dict f = f<$>condition<*>branchpred<*>(iLabel dict)
csv0i_p' f = f<$>condition<*>branchpred
csv1 f = f<$>condition<%>reg
+csv1' f = f<$>condition
csv1_p f = f<$>condition<%>reg
csv2 f = f<$>condition<%>reg<.>reg
csv2i dict f = f<$>condition<%>reg<.>(iLit16 dict)
ars dict = ins "ars" (csv2i_d dict) $ shiform 0x0a 1 1 0
-- memory
pop _ = ins "pop" csv1 $ sform 0x0b 0x0
-disc _ = ins "disc" csv1 $ sform 0x0b 0x1
+disc _ = ins "disc" csv1' $ sform' 0x0b 0x1 0
fetch _ = ins "fetch" csv1 $ sform 0x0b 0x2
push _ = ins "push" csv1 $ sform 0x0b 0x3
movpf _ = ins "movpf" csv1 $ sform 0x0c 0x2
bform' opcd typ cond bp = bform opcd typ 0 cond bp 0
sform opcd typ cond rd = pack [(cond,28),(opcd,23),(rd,19),(typ,17)]
+sform' opcd typ rd cond = sform opcd typ cond rd
brrform opcd typ cond ra = pack [(cond,28),(opcd,23),(ra,19),(typ,2)]