mirror of
https://github.com/catseye/SixtyPical.git
synced 2024-11-29 18:49:22 +00:00
Analyze bfore mitting
This commit is contained in:
parent
c66b339181
commit
b455709ef1
@ -1,4 +1,4 @@
|
|||||||
assign byte table screen $0400
|
assign byte table screen $0400
|
||||||
assign byte table screen2 1274
|
assign byte table screen2 1274
|
||||||
assign byte table screen3 1524
|
assign byte table screen3 1524
|
||||||
assign byte table screen4 1774
|
assign byte table screen4 1774
|
||||||
@ -29,7 +29,7 @@ routine main {
|
|||||||
jsr reset_position
|
jsr reset_position
|
||||||
jsr clear_screen
|
jsr clear_screen
|
||||||
sei {
|
sei {
|
||||||
copy vector cinv to save_cinv
|
copy cinv save_cinv
|
||||||
copy routine our_cinv to cinv
|
copy routine our_cinv to cinv
|
||||||
}
|
}
|
||||||
clc
|
clc
|
||||||
|
@ -38,8 +38,8 @@ main = do
|
|||||||
("emit", Right program) ->
|
("emit", Right program) ->
|
||||||
case checkAndTransformProgram program of
|
case checkAndTransformProgram program of
|
||||||
Just newprog ->
|
Just newprog ->
|
||||||
case analyzeProgram newprog of
|
case (length (show (analyzeProgram newprog)) < 9999999) of
|
||||||
_ ->
|
True ->
|
||||||
putStr $ emitProgram newprog
|
putStr $ emitProgram newprog
|
||||||
(_, Left problem) -> do
|
(_, Left problem) -> do
|
||||||
hPutStrLn stderr (show problem)
|
hPutStrLn stderr (show problem)
|
||||||
|
@ -31,6 +31,8 @@ analyzeProgram program@(Program decls routines) =
|
|||||||
in
|
in
|
||||||
checkBlock instrs progCtx routCtx'
|
checkBlock instrs progCtx routCtx'
|
||||||
|
|
||||||
|
-- -- -- -- -- -- -- -- -- -- -- --
|
||||||
|
|
||||||
checkInstr (COPY src dst) progCtx routCtx =
|
checkInstr (COPY src dst) progCtx routCtx =
|
||||||
case Map.lookup src routCtx of
|
case Map.lookup src routCtx of
|
||||||
Just (PoisonedWith _) ->
|
Just (PoisonedWith _) ->
|
||||||
@ -40,6 +42,24 @@ analyzeProgram program@(Program decls routines) =
|
|||||||
checkInstr (DELTA dst val) progCtx routCtx =
|
checkInstr (DELTA dst val) progCtx routCtx =
|
||||||
-- TODO check that dst is not poisoned
|
-- TODO check that dst is not poisoned
|
||||||
Map.insert dst (UpdatedWith (Immediate val)) routCtx
|
Map.insert dst (UpdatedWith (Immediate val)) routCtx
|
||||||
|
|
||||||
|
checkInstr (ADD dst src) progCtx routCtx =
|
||||||
|
-- TODO check that dst is not poisoned
|
||||||
|
Map.insert dst (UpdatedWith src) routCtx
|
||||||
|
checkInstr (SUB dst src) progCtx routCtx =
|
||||||
|
-- TODO check that dst is not poisoned
|
||||||
|
Map.insert dst (UpdatedWith src) routCtx
|
||||||
|
|
||||||
|
checkInstr (AND dst src) progCtx routCtx =
|
||||||
|
-- TODO check that dst is not poisoned
|
||||||
|
Map.insert dst (UpdatedWith src) routCtx
|
||||||
|
checkInstr (OR dst src) progCtx routCtx =
|
||||||
|
-- TODO check that dst is not poisoned
|
||||||
|
Map.insert dst (UpdatedWith src) routCtx
|
||||||
|
checkInstr (XOR dst src) progCtx routCtx =
|
||||||
|
-- TODO check that dst is not poisoned
|
||||||
|
Map.insert dst (UpdatedWith src) routCtx
|
||||||
|
|
||||||
checkInstr (JSR name) progCtx routCtx =
|
checkInstr (JSR name) progCtx routCtx =
|
||||||
let
|
let
|
||||||
Just calledRout = lookupRoutine program name
|
Just calledRout = lookupRoutine program name
|
||||||
@ -61,12 +81,39 @@ analyzeProgram program@(Program decls routines) =
|
|||||||
-- TODO: oooh, this one's gonna be fun too
|
-- TODO: oooh, this one's gonna be fun too
|
||||||
--checkBlock blk progCtx routCtx
|
--checkBlock blk progCtx routCtx
|
||||||
routCtx
|
routCtx
|
||||||
|
|
||||||
|
-- TODO -- THESE ARE WEAK --
|
||||||
|
checkInstr (SEI blk) progCtx routCtx =
|
||||||
|
checkBlock blk progCtx routCtx
|
||||||
|
checkInstr (PUSH _ blk) progCtx routCtx =
|
||||||
|
checkBlock blk progCtx routCtx
|
||||||
|
|
||||||
|
checkInstr (BIT dst) progCtx routCtx =
|
||||||
|
-- TODO check that dst is not poisoned
|
||||||
|
Map.insert dst (UpdatedWith (Immediate 0)) routCtx
|
||||||
|
|
||||||
|
checkInstr (SHR dst flg) progCtx routCtx =
|
||||||
|
-- TODO check that dst is not poisoned
|
||||||
|
Map.insert dst (UpdatedWith flg) routCtx
|
||||||
|
checkInstr (SHL dst flg) progCtx routCtx =
|
||||||
|
-- TODO check that dst is not poisoned
|
||||||
|
Map.insert dst (UpdatedWith flg) routCtx
|
||||||
|
|
||||||
|
checkInstr (COPYROUTINE name dst) progCtx routCtx =
|
||||||
|
-- TODO check that dst is not poisoned
|
||||||
|
Map.insert dst (UpdatedWith (Immediate 7)) routCtx
|
||||||
|
|
||||||
|
checkInstr (JMPVECTOR dst) progCtx routCtx =
|
||||||
|
routCtx
|
||||||
|
|
||||||
checkInstr NOP progCtx routCtx =
|
checkInstr NOP progCtx routCtx =
|
||||||
routCtx
|
routCtx
|
||||||
|
|
||||||
|
{-
|
||||||
checkInstr instr _ _ = error (
|
checkInstr instr _ _ = error (
|
||||||
"Internal error: sixtypical doesn't know how to " ++
|
"Internal error: sixtypical doesn't know how to " ++
|
||||||
"analyze '" ++ (show instr) ++ "'")
|
"analyze '" ++ (show instr) ++ "'")
|
||||||
|
-}
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Utility function:
|
-- Utility function:
|
||||||
|
Loading…
Reference in New Issue
Block a user