1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2024-06-02 03:41:28 +00:00

Compile goto's.

This commit is contained in:
Chris Pressey 2015-10-21 15:51:52 +01:00
parent bb6ad5d3cf
commit 16450e06d5
3 changed files with 37 additions and 1 deletions

15
eg/goto.60p Normal file
View File

@ -0,0 +1,15 @@
routine chrout
inputs a
trashes a
@ 65490
routine bar trashes a, z, n {
ld a, 66
call chrout
}
routine main trashes a, z, n {
ld a, 65
call chrout
goto bar
}

View File

@ -203,6 +203,15 @@ class Compiler(object):
self.emitter.emit(JMP(Indirect(label)))
else:
raise NotImplementedError
elif opcode == 'goto':
location = instr.location
label = self.labels[instr.location.name]
if isinstance(location.type, RoutineType):
self.emitter.emit(JMP(Absolute(label)))
elif isinstance(location.type, VectorType):
self.emitter.emit(JMP(Indirect(label)))
else:
raise NotImplementedError
elif opcode == 'if':
cls = {
False: {

View File

@ -274,4 +274,16 @@ Indirect call.
| copy bar, foo
| call foo
| }
= 00c0
= 00c0wewillfixthislater
goto.
| routine bar outputs x trashes z, n {
| ld x, 200
| }
|
| routine main outputs x trashes a, z, n {
| ld y, 200
| goto bar
| }
= 00c0a0c84c06c060a2c860