mirror of
https://github.com/catseye/SixtyPical.git
synced 2025-02-16 15:30:26 +00:00
Compile goto's.
This commit is contained in:
parent
bb6ad5d3cf
commit
16450e06d5
15
eg/goto.60p
Normal file
15
eg/goto.60p
Normal 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
|
||||
}
|
@ -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: {
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user