mirror of
https://github.com/catseye/SixtyPical.git
synced 2025-02-09 01:30:50 +00:00
Initialized word
type memory locations.
This commit is contained in:
parent
4854077cce
commit
63f75a26b4
@ -7,6 +7,7 @@ History of SixtyPical
|
||||
* Can `call` and `goto` routines that are defined further down in the source code.
|
||||
* The `forward` modifier can also be used to indicate that the symbol being copied
|
||||
in a `copy` to a vector is a routine that is defined further down in the source.
|
||||
* Initialized `word` memory locations.
|
||||
* Fixed bug which was preventing `if` branches to diverge in what they initialized,
|
||||
if it was already initialized when going into the `if`.
|
||||
* Fixed a bug which was making it crash when trying to analyze `repeat forever` loops.
|
||||
|
@ -76,7 +76,6 @@ This should be tracked in the abstract interpretation.
|
||||
* always analyze before executing or compiling, unless told not to
|
||||
* `trash` instruction.
|
||||
* `interrupt` routines -- to indicate that "the supervisor" has stored values on the stack, so we can trash them.
|
||||
* pre-initialized `word` variables
|
||||
* error messages that include the line number of the source code
|
||||
* have `copy` instruction able to copy a byte to a user-def mem loc, etc.
|
||||
* add absolute addressing in shl/shr, absolute-indexed for add, sub, etc.
|
||||
|
@ -6,7 +6,7 @@ from sixtypical.model import (
|
||||
TYPE_BIT, TYPE_BYTE, TYPE_BYTE_TABLE, TYPE_WORD, TYPE_WORD_TABLE, BufferType, PointerType, RoutineType, VectorType,
|
||||
REG_A, REG_X, REG_Y, FLAG_C
|
||||
)
|
||||
from sixtypical.emitter import Byte, Label, Offset, LowAddressByte, HighAddressByte
|
||||
from sixtypical.emitter import Byte, Word, Label, Offset, LowAddressByte, HighAddressByte
|
||||
from sixtypical.gen6502 import (
|
||||
Immediate, Absolute, AbsoluteX, AbsoluteY, ZeroPage, Indirect, IndirectY, Relative,
|
||||
LDA, LDX, LDY, STA, STX, STY,
|
||||
@ -72,7 +72,14 @@ class Compiler(object):
|
||||
for defn in program.defns:
|
||||
if defn.initial is not None:
|
||||
label = self.labels[defn.name]
|
||||
initial_data = Byte(defn.initial) # TODO: support other types than Byte
|
||||
initial_data = None
|
||||
type_ = defn.location.type
|
||||
if type_ == TYPE_BYTE:
|
||||
initial_data = Byte(defn.initial)
|
||||
elif type_ == TYPE_WORD:
|
||||
initial_data = Word(defn.initial)
|
||||
else:
|
||||
raise NotImplementedError(type_)
|
||||
label.set_length(initial_data.size())
|
||||
self.emitter.resolve_label(label)
|
||||
self.emitter.emit(initial_data)
|
||||
|
@ -89,6 +89,24 @@ If a routine modifies a location, it needs to either output it or trash it.
|
||||
| }
|
||||
= ok
|
||||
|
||||
If a routine reads or writes a user-define memory location, it needs to declare that too.
|
||||
|
||||
| byte b1 @ 60000
|
||||
| byte b2 : 3
|
||||
| word w1 @ 60001
|
||||
| word w2 : 2000
|
||||
|
|
||||
| routine main
|
||||
| inputs b1, w1
|
||||
| outputs b2, w2
|
||||
| trashes a, z, n
|
||||
| {
|
||||
| ld a, b1
|
||||
| st a, b2
|
||||
| copy w1, w2
|
||||
| }
|
||||
= ok
|
||||
|
||||
### ld ###
|
||||
|
||||
Can't `ld` from a memory location that isn't initialized.
|
||||
|
@ -117,6 +117,26 @@ Memory location with initial value.
|
||||
= $0810 RTS
|
||||
= $0811 .byte $03
|
||||
|
||||
Word memory locations with explicit address, initial value.
|
||||
|
||||
| word w1 @ 60001
|
||||
| word w2 : 3003
|
||||
|
|
||||
| routine main
|
||||
| inputs w1
|
||||
| outputs w2
|
||||
| trashes a, z, n
|
||||
| {
|
||||
| copy w1, w2
|
||||
| }
|
||||
= $080D LDA $EA61
|
||||
= $0810 STA $081A
|
||||
= $0813 LDA $EA62
|
||||
= $0816 STA $081B
|
||||
= $0819 RTS
|
||||
= $081A .byte $BB
|
||||
= $081B .byte $0B
|
||||
|
||||
Some instructions.
|
||||
|
||||
| byte foo
|
||||
|
Loading…
x
Reference in New Issue
Block a user