mirror of
https://github.com/catseye/SixtyPical.git
synced 2025-02-16 15:30:26 +00:00
Initial work on adding 16-bit constants to a 16-bit location.
This commit is contained in:
parent
031e4338ad
commit
97d00637d2
@ -2,7 +2,7 @@
|
||||
|
||||
from sixtypical.ast import Program, Routine, Block, Instr
|
||||
from sixtypical.model import (
|
||||
TYPE_BYTE, TYPE_BYTE_TABLE, BufferType, PointerType, VectorType, ExecutableType,
|
||||
TYPE_BYTE, TYPE_WORD, TYPE_BYTE_TABLE, BufferType, PointerType, VectorType, ExecutableType,
|
||||
ConstantRef, LocationRef, IndirectRef, AddressRef,
|
||||
REG_A, REG_Y, FLAG_Z, FLAG_N, FLAG_V, FLAG_C
|
||||
)
|
||||
@ -233,7 +233,17 @@ class Analyzer(object):
|
||||
)
|
||||
context.assert_meaningful(src)
|
||||
context.set_written(dest)
|
||||
elif opcode in ('add', 'sub'):
|
||||
elif opcode == 'add':
|
||||
if src.type == TYPE_BYTE:
|
||||
self.assert_type(TYPE_BYTE, src, dest)
|
||||
context.assert_meaningful(src, dest, FLAG_C)
|
||||
context.set_written(dest, FLAG_Z, FLAG_N, FLAG_C, FLAG_V)
|
||||
else:
|
||||
self.assert_type(TYPE_WORD, src, dest)
|
||||
context.assert_meaningful(src, dest, FLAG_C)
|
||||
context.set_written(dest, FLAG_Z, FLAG_N, FLAG_C, FLAG_V)
|
||||
context.set_unmeaningful(REG_A)
|
||||
elif opcode == 'sub':
|
||||
self.assert_type(TYPE_BYTE, src, dest)
|
||||
context.assert_meaningful(src, dest, FLAG_C)
|
||||
context.set_written(dest, FLAG_Z, FLAG_N, FLAG_C, FLAG_V)
|
||||
|
@ -373,6 +373,45 @@ Can't `add` to a memory location that isn't writeable.
|
||||
| }
|
||||
? ForbiddenWriteError: a in main
|
||||
|
||||
You can `add` a word constant to a word memory location.
|
||||
|
||||
| word score
|
||||
| routine main
|
||||
| inputs a, score
|
||||
| outputs score
|
||||
| trashes a, c, z, v, n
|
||||
| {
|
||||
| st off, c
|
||||
| add score, 1999
|
||||
| }
|
||||
= ok
|
||||
|
||||
`add`ing a word constant to a word memory location trashes `a`.
|
||||
|
||||
| word score
|
||||
| routine main
|
||||
| inputs a, score
|
||||
| outputs score, a
|
||||
| trashes c, z, v, n
|
||||
| {
|
||||
| st off, c
|
||||
| add score, 1999
|
||||
| }
|
||||
? UnmeaningfulOutputError: a in main
|
||||
|
||||
Not sure why this doesn't also raise an error? `a` is trashed...
|
||||
|
||||
| word score
|
||||
| routine main
|
||||
| inputs score
|
||||
| outputs score
|
||||
| trashes c, z, v, n
|
||||
| {
|
||||
| st off, c
|
||||
| add score, 1999
|
||||
| }
|
||||
? UnmeaningfulOutputError: a in main
|
||||
|
||||
### sub ###
|
||||
|
||||
Can't `sub` from or to a memory location that isn't initialized.
|
||||
|
Loading…
x
Reference in New Issue
Block a user