diff --git a/codeGenCpu6502/src/prog8/codegen/cpu6502/ProgramAndVarsGen.kt b/codeGenCpu6502/src/prog8/codegen/cpu6502/ProgramAndVarsGen.kt index ce0729530..3af893a74 100644 --- a/codeGenCpu6502/src/prog8/codegen/cpu6502/ProgramAndVarsGen.kt +++ b/codeGenCpu6502/src/prog8/codegen/cpu6502/ProgramAndVarsGen.kt @@ -127,11 +127,8 @@ internal class ProgramAndVarsGen( "cx16" -> { if(options.floats) asmgen.out(" lda #4 | sta $01") // to use floats, make sure Basic rom is banked in - asmgen.out(" jsr main.start | lda #4 | sta $01") - if(!options.noSysInit) - asmgen.out(" jmp ${compTarget.name}.cleanup_at_exit") - else - asmgen.out(" rts") + asmgen.out(" jsr main.start") + asmgen.out(" jmp ${compTarget.name}.cleanup_at_exit") } "c64" -> { asmgen.out(" jsr main.start | lda #31 | sta $01") diff --git a/compiler/res/prog8lib/cx16/syslib.p8 b/compiler/res/prog8lib/cx16/syslib.p8 index 3fea49281..4fb8f9362 100644 --- a/compiler/res/prog8lib/cx16/syslib.p8 +++ b/compiler/res/prog8lib/cx16/syslib.p8 @@ -639,8 +639,12 @@ asmsub init_system_phase2() { asmsub cleanup_at_exit() { ; executed when the main subroutine does rts - ; just an rts here, nothing special to clean up on cx16 %asm {{ + lda #1 + sta $00 ; ram bank 1 + lda #4 + sta $01 ; rom bank 4 (kernal) + stz $2d ; hack to reset machine code monitor bank to 0 rts }} } diff --git a/docs/source/todo.rst b/docs/source/todo.rst index ebffa6a1b..aff9a6c2b 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -3,9 +3,6 @@ TODO For next release ^^^^^^^^^^^^^^^^ -- cx16 programs seem to poke 0, 56 at exit? -- assembling hello4.asm prints stray characters in the string - - petaxian roller.p8 line 49 (also see test.p8) generates large code compared to 8.2 - code gen for if statements has become inefficient? vm/6502?