mirror of
https://github.com/irmen/prog8.git
synced 2025-02-04 02:30:19 +00:00
fix startup subroutine linking in VM
This commit is contained in:
parent
e5e63cc5ac
commit
592f74124c
@ -3,9 +3,6 @@ TODO
|
||||
|
||||
For next minor release
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
- fix IR/VM: animals.p8 example is borked, it jumps straight to a suggestion and then somehow doesn't print the animal name correctly in the first question, and exits after 1 animal instead of looping
|
||||
this has happened after v8.7: caused by c21913a6 ir: keep order of children in block 22-11-2022
|
||||
|
||||
...
|
||||
|
||||
|
||||
|
@ -2,6 +2,9 @@
|
||||
%zeropage basicsafe
|
||||
%option no_sysinit
|
||||
|
||||
; The documentation for custom PS2 key handlers can be found here:
|
||||
; https://github.com/X16Community/x16-docs/blob/master/X16%20Reference%20-%2002%20-%20Editor.md#custom-keyboard-scancode-handler
|
||||
|
||||
main {
|
||||
|
||||
sub start() {
|
||||
@ -69,6 +72,9 @@ main {
|
||||
; Unfortunately this also means you cannot decide from that prog8 code
|
||||
; if the keyboard press should be consumed/ignored or put into the keyboard queue
|
||||
; (this is controlled by returning 0 or 1 in register A here)
|
||||
;
|
||||
; see:
|
||||
; https://github.com/X16Community/x16-docs/tree/X16%20Reference%20-%2002%20-%20Editor.md#custom-keyboard-scancode-handler
|
||||
|
||||
%asm {{
|
||||
php
|
||||
|
@ -23,9 +23,11 @@ class VmProgramLoader {
|
||||
// make sure that if there is a "main.start" entrypoint, we jump to it
|
||||
irProgram.blocks.firstOrNull()?.let {
|
||||
if(it.children.any { sub -> sub is IRSubroutine && sub.label=="main.start" }) {
|
||||
val chunk = IRCodeChunk(null, null)
|
||||
val previous = programChunks.lastOrNull()
|
||||
val chunk = IRCodeChunk(null, previous)
|
||||
placeholders[Pair(chunk, 0)] = "main.start"
|
||||
chunk += IRInstruction(Opcode.JUMP, labelSymbol = "main.start")
|
||||
previous?.let { p -> p.next = chunk }
|
||||
programChunks += chunk
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user