mirror of
https://github.com/catseye/SixtyPical.git
synced 2025-01-07 12:29:52 +00:00
Add explicitly-addressed memory locations.
This commit is contained in:
parent
49e42af953
commit
522c771208
@ -26,3 +26,4 @@ in future versions.
|
||||
* Added `repeat` loops to the language, which can repeat until a flag
|
||||
is set (or `not` set), or which can repeat `forever`.
|
||||
* `if not` inverts the sense of the test.
|
||||
* Added explicitly-addressed memory locations.
|
||||
|
@ -31,19 +31,25 @@ Documentation
|
||||
TODO
|
||||
----
|
||||
|
||||
For 0.4:
|
||||
|
||||
* explicitly-addressed memory locations
|
||||
|
||||
For 0.5:
|
||||
|
||||
* add line number (or at least routine name) to error messages.
|
||||
* hexadecimal literals.
|
||||
* 6502-mnemonic aliases (`sec`, `clc`)
|
||||
* other handy aliases (`eq` for `z`, etc.)
|
||||
* source code comments.
|
||||
* `table` type constructor and indirect addressing.
|
||||
|
||||
For 0.6:
|
||||
|
||||
* hexadecimal literals.
|
||||
* source code comments.
|
||||
|
||||
For 0.7:
|
||||
|
||||
* `word` type.
|
||||
* `table` type constructor and indirect addressing.
|
||||
|
||||
For 0.8:
|
||||
|
||||
* `vector` type.
|
||||
|
||||
For 0.9:
|
||||
|
||||
* add line number (or at least routine name) to error messages.
|
||||
* 6502-mnemonic aliases (`sec`, `clc`)
|
||||
* other handy aliases (`eq` for `z`, etc.)
|
||||
|
@ -75,6 +75,10 @@ by giving the type, which must be `byte`, and the name.
|
||||
|
||||
byte pos
|
||||
|
||||
A location in memory may be given explicitly on a user-defined memory location.
|
||||
|
||||
byte screen @ 1024
|
||||
|
||||
Routines
|
||||
--------
|
||||
|
||||
|
8
eg/screen.60p
Normal file
8
eg/screen.60p
Normal file
@ -0,0 +1,8 @@
|
||||
byte screen @ 1024
|
||||
|
||||
routine main
|
||||
trashes a, z, n, screen
|
||||
{
|
||||
ld a, 100
|
||||
st a, screen
|
||||
}
|
@ -33,6 +33,8 @@ class Compiler(object):
|
||||
|
||||
for defn in program.defns:
|
||||
label = Label(defn.name)
|
||||
if defn.addr is not None:
|
||||
label.set_addr(defn.addr)
|
||||
self.labels[defn.name] = label
|
||||
|
||||
for routine in program.routines:
|
||||
@ -48,8 +50,9 @@ class Compiler(object):
|
||||
self.compile_routine(routine)
|
||||
|
||||
for defn in program.defns:
|
||||
label = self.labels[defn.name]
|
||||
self.emitter.resolve_bss_label(label)
|
||||
if defn.addr is None:
|
||||
label = self.labels[defn.name]
|
||||
self.emitter.resolve_bss_label(label)
|
||||
|
||||
def compile_routine(self, routine):
|
||||
assert isinstance(routine, Routine)
|
||||
|
@ -98,13 +98,19 @@ class Parser(object):
|
||||
raise KeyError(name)
|
||||
self.symbols[name] = routine
|
||||
routines.append(routine)
|
||||
self.scanner.check_type('EOF')
|
||||
return Program(defns=defns, routines=routines)
|
||||
|
||||
def defn(self):
|
||||
self.scanner.expect('byte')
|
||||
name = self.scanner.token
|
||||
self.scanner.scan()
|
||||
return Defn(name=name)
|
||||
addr = None
|
||||
if self.scanner.consume('@'):
|
||||
self.scanner.check_type('integer literal')
|
||||
addr = int(self.scanner.token)
|
||||
self.scanner.scan()
|
||||
return Defn(name=name, addr=addr)
|
||||
|
||||
def routine(self):
|
||||
self.scanner.expect('routine')
|
||||
|
@ -77,6 +77,16 @@ Access a defined memory location.
|
||||
| }
|
||||
= 00c0a0008c09c0ad09c060
|
||||
|
||||
| byte screen @ 1024
|
||||
|
|
||||
| routine main
|
||||
| trashes a, z, n, screen
|
||||
| {
|
||||
| ld a, 100
|
||||
| st a, screen
|
||||
| }
|
||||
= 00c0a9648d000460
|
||||
|
||||
Some instructions.
|
||||
|
||||
| byte foo
|
||||
|
@ -27,6 +27,15 @@ Syntax error
|
||||
| )
|
||||
? SyntaxError
|
||||
|
||||
Another syntax error
|
||||
|
||||
| byte glee
|
||||
| {
|
||||
| ld a, 0
|
||||
| add a, 1
|
||||
| }
|
||||
? SyntaxError
|
||||
|
||||
Extern routines
|
||||
|
||||
| routine chrout
|
||||
@ -92,3 +101,13 @@ Repeat with not
|
||||
| } until not z
|
||||
| }
|
||||
= ok
|
||||
|
||||
Extern memory locations
|
||||
|
||||
| byte screen @ 1024
|
||||
|
|
||||
| routine main {
|
||||
| ld a, 100
|
||||
| st a, screen
|
||||
| }
|
||||
= ok
|
||||
|
Loading…
Reference in New Issue
Block a user