From: Bernhard Urban Date: Fri, 17 Dec 2010 21:48:44 +0000 (+0100) Subject: 3a_asm: 'nicer' fix for ldil vs. ldilt fail X-Git-Tag: bootrom_v1~68 X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=calu.git;a=commitdiff_plain;h=b109e17d767479bb16dd6c639058ac73af70878a 3a_asm: 'nicer' fix for ldil vs. ldilt fail note that sign and highlow are swapped now... --- diff --git a/3a_asm/DT.hs b/3a_asm/DT.hs index 562285b..b5d297b 100644 --- a/3a_asm/DT.hs +++ b/3a_asm/DT.hs @@ -76,6 +76,9 @@ carry = do { char 'c'; return 1} <|> do {string ""; return 0} updateDisable :: Parser Word32 updateDisable = do { char 'd'; return 1} <|> do {string ""; return 0} +highonly :: Parser Word32 +highonly = do { char 'h'; return 1} <|> do {string ""; return 0} + highlow :: Parser Word32 highlow = do { char 'h'; return 1} <|> do {char 'l'; return 0} <|> do {string ""; return 0} @@ -116,7 +119,8 @@ csv2m dict f = f<$>condition<%>reg<.>(iLit15 dict)<@>reg csv2i_cd dict f = f<$>carry<*>updateDisable<*>condition<%>reg<.>reg<.>(iLit5 dict) csv2i_d dict f = f<$>updateDisable<*>condition<%>reg<.>reg<.>(iLit5 dict) csv2i_scd dict f = f<$>sign<*>carry<*>updateDisable<*>condition<%>reg<.>reg<.>(iLit12 dict) -csv2i_sl dict f = f<$>sign<*>highlow<*>condition<%>reg<.>(iLit16 dict) +csv2i_sl dict f = f<$>highonly<*>sign<*>condition<%>reg<.>(iLit16 dict) +csv2i_sl' dict f = f<$>sign<*>condition<%>reg<.>(iLit16 dict) csv2i_lfd dict f = f<$>highlow<*>fill<*>updateDisable<*>condition<%>reg<.>(iLit16 dict) csv3_cd f = f<$>carry<*>updateDisable<*>condition<%>reg<.>reg<.>reg csv3_d f = f<$>updateDisable<*>condition<%>reg<.>reg<.>reg @@ -126,7 +130,7 @@ instructions = [add, addi, mov, sub, subi, lls, lrs, ars, pop, push, disc, fetch, movpf, movsf, movpt, movst, - ldh, ldb, ldw, ldi, + ldh, ldb, ldw, ldi, ldil, stw, sth, stb, ldx, stx, br, ret, call, reti, @@ -164,6 +168,7 @@ ldw dict = ins "ldw" (csv2m dict) $ mformi 0x0e ldh dict = ins "ldh" (csv2m dict) $ mformi 0x10 ldb dict = ins "ldb" (csv2m dict) $ mformi 0x12 ldi dict = ins "ldi" (csv2i_sl dict) $ lformi' 0x1a +ldil dict = ins "ldil" (csv2i_sl' dict) $ lformi' 0x1a 0 stw dict = ins "stw" (csv2m dict) $ mformi 0x0f sth dict = ins "sth" (csv2m dict) $ mformi 0x11 stb dict = ins "stb" (csv2m dict) $ mformi 0x13 @@ -188,7 +193,7 @@ aformi opcd s c d cond rd ra imm = pack [(cond,28),(opcd,23),(rd,19),(ra,15),(im aformi' opcd s c d cond rd ra = aformi opcd s c d cond rd ra 0 lformi opcd hl f d cond rd imm = pack [(cond,28),(opcd,23),(rd,19),(imm,3),(hl,2),(f,1),(d,0)] -lformi' opcd s hl cond rd imm = lformi opcd s hl 0 cond rd imm +lformi' opcd hl s cond rd imm = lformi opcd s hl 0 cond rd imm lformi'not opcd cond rd = lformi opcd 0 1 0 cond rd 0xefffffff mformi opcd cond rd disp ra = pack [(cond,28),(opcd,23),(rd,19),(ra,15),(disp,0)] diff --git a/3a_asm/Main.hs b/3a_asm/Main.hs index d62fe17..8160012 100644 --- a/3a_asm/Main.hs +++ b/3a_asm/Main.hs @@ -173,9 +173,12 @@ lf_data d = do repeat <- try (do {size <- many1 $ noneOf "\n;,"; char ','; return $ size}) <|> return "1" -- TODO: atm 32bit imm only code <- many1 $ noneOf "\n;" - -- TODO: this is quite ugly here :/ - let (Right val) = parse (parseConst d) "" code - let (Right r) = parse (parseConst d) "" repeat + let val = case parse (parseConst d) "" code of + Right v -> v + Left err -> error $ show err + let r = case parse (parseConst d) "" repeat of + Right v -> v + Left err -> error $ show err comment <- try(parseComment) <|> parseMySpaces return $ DTF_Fill r val (fill ++ (if repeat == "1" then "" else repeat) ++ code) l comment