comma = char ','
mnem m = string m
+iLabel :: Dict -> Parser Word32
+-- TODO: save msb (=sign) correctly...
+iLabel d@(aktadr,_) = do {i <- (iLit d); return $ ((i - aktadr)`div`4) .&. 0xffff}
+
iLit :: Dict -> Parser Word32
iLit (_,d) = do
val <- expr d;
iLit5 d = do i <- iLit d; return $ i .&. 0x001f
iLit12 d = do i <- iLit d; return $ i .&. 0x0fff
-iLit15 d = do i <- iLit d; return $ i .&. 0xefff
+iLit15 d = do i <- iLit d; return $ i .&. 0x7fff
iLit16 d = do i <- iLit d; return $ i .&. 0xffff
imm4 :: Parser String
infixl 1 <@>
ins m form e = do {mnem m; form e}
-csv0i_p dict f = f<$>condition<*>branchpred<*>(iLit dict)
+csv0i_p dict f = f<$>condition<*>branchpred<*>(iLabel dict)
csv0i_p' f = f<$>condition<*>branchpred
csv1 f = f<$>condition<%>reg
csv1_p f = f<$>condition<%>reg
where free = 0
bform' opcd typ cond bp = bform opcd typ 0 cond bp 0
-sform opcd typ rd cond = pack [(cond,28),(opcd,23),(rd,19),(typ,17)]
+sform opcd typ cond rd = pack [(cond,28),(opcd,23),(rd,19),(typ,17)]
brrform opcd typ cond ra = pack [(cond,28),(opcd,23),(ra,19),(typ,2)]