Fix (bodge?) and document my worries.
Cat's Eye Technologies
8 years ago
195 | 195 |
| }
|
196 | 196 |
? routine 'main' does not preserve 'A'
|
197 | 197 |
|
|
198 |
| reserve byte score
|
|
199 |
| routine update_score
|
|
200 |
| {
|
|
201 |
| ldx #4
|
|
202 |
| stx score
|
|
203 |
| }
|
|
204 |
| routine main {
|
|
205 |
| lda #4
|
|
206 |
| if beq {
|
|
207 |
| jsr update_score
|
|
208 |
| } else {
|
|
209 |
| ldx #4
|
|
210 |
| }
|
|
211 |
| sta score
|
|
212 |
| }
|
|
213 |
= main ([])
|
|
214 |
= A: UpdatedWith (Immediate 4)
|
|
215 |
= X: PoisonedWith (Immediate 4)
|
|
216 |
= NamedLocation Nothing "score": UpdatedWith A
|
|
217 |
=
|
|
218 |
= update_score ([])
|
|
219 |
= X: UpdatedWith (Immediate 4)
|
|
220 |
= NamedLocation Nothing "score": UpdatedWith X
|
|
221 |
|
198 | 222 |
Poisoning a high byte or low byte of a word poisons the whole word.
|
199 | 223 |
|
200 | 224 |
| reserve word score
|
|
210 | 234 |
| sta temp
|
211 | 235 |
| }
|
212 | 236 |
? routine 'main' does not preserve 'NamedLocation Nothing "score"'
|
|
237 |
|
|
238 |
| assign vector cinv 788
|
|
239 |
| reserve vector save_cinv
|
|
240 |
|
|
|
241 |
| assign word position $fb
|
|
242 |
|
|
|
243 |
| reserve byte value
|
|
244 |
|
|
|
245 |
| routine reset_position {
|
|
246 |
| lda #$00
|
|
247 |
| sta <position
|
|
248 |
| lda #$04
|
|
249 |
| sta >position
|
|
250 |
| }
|
|
251 |
|
|
|
252 |
| routine our_cinv {
|
|
253 |
| inc value
|
|
254 |
| lda value
|
|
255 |
| ldy #0
|
|
256 |
| sta (position), y
|
|
257 |
| if beq {
|
|
258 |
| jsr reset_position
|
|
259 |
| } else {
|
|
260 |
| }
|
|
261 |
| jmp (save_cinv)
|
|
262 |
| }
|
|
263 |
|
|
|
264 |
| routine main {
|
|
265 |
| jsr reset_position
|
|
266 |
| sei {
|
|
267 |
| copy cinv save_cinv
|
|
268 |
| copy routine our_cinv to cinv
|
|
269 |
| }
|
|
270 |
| clc
|
|
271 |
| repeat bcc { }
|
|
272 |
| }
|
|
273 |
= main ([])
|
|
274 |
= A: PoisonedWith (Immediate 4)
|
|
275 |
= FlagC: UpdatedWith (Immediate 0)
|
|
276 |
= NamedLocation Nothing "cinv": UpdatedWith (Immediate 7)
|
|
277 |
= NamedLocation Nothing "position": PoisonedWith A
|
|
278 |
= NamedLocation Nothing "save_cinv": UpdatedWith (NamedLocation Nothing "cinv")
|
|
279 |
=
|
|
280 |
= our_cinv ([])
|
|
281 |
= A: PoisonedWith (Immediate 4)
|
|
282 |
= Y: UpdatedWith (Immediate 0)
|
|
283 |
= IndirectIndexed (NamedLocation (Just Word) "position") Y: UpdatedWith A
|
|
284 |
= NamedLocation Nothing "position": PoisonedWith A
|
|
285 |
= NamedLocation Nothing "value": UpdatedWith (Immediate 1)
|
|
286 |
=
|
|
287 |
= reset_position ([])
|
|
288 |
= A: UpdatedWith (Immediate 4)
|
|
289 |
= NamedLocation Nothing "position": UpdatedWith A
|
86 | 86 |
sta (position), y
|
87 | 87 |
jsr increment_pos
|
88 | 88 |
jsr compare_pos
|
89 | |
lda vic_border ; WHY DOES THE FOLLOWING NOT ANALUZE
|
90 | 89 |
if beq {
|
91 | 90 |
jsr reset_position
|
92 | 91 |
} else {
|
62 | 62 |
routCtx
|
63 | 63 |
checkInstr nm (IF _ branch b1 b2) progCtx routCtx =
|
64 | 64 |
let
|
|
65 |
-- This works, but I worry about it.
|
|
66 |
-- It doesn't work if we pass routCtx to both blocks,
|
|
67 |
-- because when we go to merge them, there is apparently
|
|
68 |
-- too much information, and we end up checking things
|
|
69 |
-- we don't need to check.
|
|
70 |
-- Leaving the second one empty results in the right amount
|
|
71 |
-- of information.
|
|
72 |
-- But what are we depriving the else block context of?
|
|
73 |
-- More tests are needed.
|
|
74 |
-- Possibly the merge needs to be redone.
|
65 | 75 |
routCtx1 = checkBlock nm b1 progCtx routCtx
|
66 | |
routCtx2 = checkBlock nm b2 progCtx routCtx
|
|
76 |
routCtx2 = checkBlock nm b2 progCtx Map.empty
|
67 | 77 |
in
|
68 | 78 |
mergeAlternateRoutCtxs nm routCtx1 routCtx2
|
69 | 79 |
checkInstr nm (REPEAT _ branch blk) progCtx routCtx =
|
25 | 25 |
|
26 | 26 |
type ProgramContext = Map.Map RoutineName RoutineContext
|
27 | 27 |
|
28 | |
untypedLocation (HighByteOf (NamedLocation _ name)) =
|
29 | |
NamedLocation Nothing name
|
30 | |
untypedLocation (LowByteOf (NamedLocation _ name)) =
|
31 | |
NamedLocation Nothing name
|
|
28 |
untypedLocation (HighByteOf x) =
|
|
29 |
untypedLocation x
|
|
30 |
untypedLocation (LowByteOf x) =
|
|
31 |
untypedLocation x
|
|
32 |
untypedLocation (Indexed table index) =
|
|
33 |
untypedLocation table
|
32 | 34 |
untypedLocation (NamedLocation _ name) =
|
33 | 35 |
NamedLocation Nothing name
|
34 | 36 |
untypedLocation x = x
|