mirror of
https://github.com/catseye/SixtyPical.git
synced 2025-02-16 15:30:26 +00:00
Hey, passing tests. Cool.
This commit is contained in:
parent
a86738c387
commit
827896cd68
@ -6,6 +6,18 @@ Anayzling SixtyPical Programs
|
|||||||
-> Functionality "Analyze SixtyPical program" is implemented by
|
-> Functionality "Analyze SixtyPical program" is implemented by
|
||||||
-> shell command "bin/sixtypical analyze %(test-file)"
|
-> shell command "bin/sixtypical analyze %(test-file)"
|
||||||
|
|
||||||
|
Analysis determines what storage locations have been modified by a
|
||||||
|
routine.
|
||||||
|
|
||||||
|
| reserve byte score
|
||||||
|
| routine main {
|
||||||
|
| lda #4
|
||||||
|
| sta score
|
||||||
|
| }
|
||||||
|
= main
|
||||||
|
= A: UpdatedWith (Immediate 4)
|
||||||
|
= NamedLocation (Just Byte) "score": UpdatedWith A
|
||||||
|
|
||||||
A routine cannot expect registers which a called routine does not
|
A routine cannot expect registers which a called routine does not
|
||||||
preserve, to be preserved.
|
preserve, to be preserved.
|
||||||
|
|
||||||
@ -21,7 +33,7 @@ preserve, to be preserved.
|
|||||||
| jsr update_score
|
| jsr update_score
|
||||||
| sta border_colour
|
| sta border_colour
|
||||||
| }
|
| }
|
||||||
? routine does not preserve register
|
? routine does not preserve 'A'
|
||||||
|
|
||||||
But if it does it can.
|
But if it does it can.
|
||||||
|
|
||||||
@ -38,4 +50,12 @@ But if it does it can.
|
|||||||
| jsr update_score
|
| jsr update_score
|
||||||
| sta border_colour
|
| sta border_colour
|
||||||
| }
|
| }
|
||||||
= True
|
= main
|
||||||
|
= A: UpdatedWith (Immediate 4)
|
||||||
|
= X: PoisonedWith (Immediate 1)
|
||||||
|
= NamedLocation (Just Byte) "border_colour": UpdatedWith A
|
||||||
|
= NamedLocation (Just Byte) "score": PoisonedWith X
|
||||||
|
=
|
||||||
|
= update_score
|
||||||
|
= X: UpdatedWith (Immediate 1)
|
||||||
|
= NamedLocation (Just Byte) "score": UpdatedWith X
|
||||||
|
@ -32,8 +32,11 @@ checkBlock (instr:instrs) progCtx routCtx =
|
|||||||
checkBlock instrs progCtx routCtx'
|
checkBlock instrs progCtx routCtx'
|
||||||
|
|
||||||
checkInstr (COPY src dst) progCtx routCtx =
|
checkInstr (COPY src dst) progCtx routCtx =
|
||||||
-- TODO check that src is not poisoned
|
case Map.lookup src routCtx of
|
||||||
Map.insert dst (UpdatedWith src) routCtx
|
Just (PoisonedWith _) ->
|
||||||
|
error ("routine does not preserve '" ++ (show src) ++ "'")
|
||||||
|
_ ->
|
||||||
|
Map.insert dst (UpdatedWith src) routCtx
|
||||||
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user