1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2025-02-09 01:30:50 +00:00

Don't trash a in copy if a is the dest of the copy, for now.

This commit is contained in:
Chris Pressey 2017-12-13 16:18:36 +00:00
parent f9dc730f88
commit b477c5e786
2 changed files with 17 additions and 12 deletions

View File

@ -237,17 +237,16 @@ routine player_logic
// check collision.
copy [ptr] + y, a
// cmp a, 32
// if z {
// copy new_pos, pos
// copy 81, [ptr] + y
// } else {
// // copy game_state_game_over, dispatch_game_state
// }
copy 81, [ptr] + y
copy new_pos, pos
cmp a, 32
if z {
copy new_pos, pos
copy 81, [ptr] + y
} else {
// copy game_state_game_over, dispatch_game_state
trash n
trash a
trash z
}
// FIXME these trashes, strictly speaking, probably shouldn't be needed,
// but currently the compiler cares too much about values that are

View File

@ -392,6 +392,7 @@ class Analyzer(object):
context.assert_meaningful(src.ref, REG_Y)
# TODO this will need to be more sophisticated. the thing ref points to is touched, as well.
context.set_touched(src.ref) # TODO and REG_Y? if not, why not?
context.set_touched(dest)
context.set_written(dest)
elif isinstance(src, LocationRef) and isinstance(dest, IndexedRef):
context.assert_meaningful(src, dest.ref, dest.index)
@ -409,7 +410,12 @@ class Analyzer(object):
context.set_written(dest)
context.set_touched(REG_A, FLAG_Z, FLAG_N)
context.set_unmeaningful(REG_A, FLAG_Z, FLAG_N)
context.set_unmeaningful(FLAG_Z, FLAG_N)
# FIXME: this is just to support "copy [foo] + y, a". consider disallowing `a` as something
# that can be used in `copy`. should be using `st` or `ld` instead, probably.
if dest != REG_A:
context.set_unmeaningful(REG_A)
elif opcode == 'with-sei':
self.analyze_block(instr.block, context)