fix variable init order mistake in program startup

reset multiply bit at end of verafx.muls
This commit is contained in:
Irmen de Jong 2024-09-28 18:12:21 +02:00
parent c78b7b1a24
commit 1541ad2160
10 changed files with 32 additions and 34 deletions

View File

@ -470,6 +470,9 @@ internal class ProgramAndVarsGen(
}
private fun entrypointInitialization() {
// zero out the BSS area first, before setting the variable init values
asmgen.out(" jsr prog8_lib.program_startup_clear_bss")
// initialize block-level (global) variables at program start
blockVariableInitializers.forEach {
if (it.value.isNotEmpty())
@ -521,8 +524,7 @@ internal class ProgramAndVarsGen(
arrayVariable2asm(varname, it.alloc.dt, it.value, null)
}
// zero out the BSS area
asmgen.out("+ jsr prog8_lib.program_startup_clear_bss")
asmgen.out("+")
}
private class ZpStringWithInitial(

View File

@ -29,10 +29,7 @@ sys {
; TODO
%asm {{
sei
cld
clc
; TODO reset screen mode etc etc
clv
cli
rts
}}
@ -40,7 +37,10 @@ sys {
asmsub init_system_phase2() {
%asm {{
rts ; no phase 2 steps on the Atari
cld
clc
clv
rts
}}
}

View File

@ -360,7 +360,6 @@ asmsub init_system() {
; Uppercase charset is activated.
%asm {{
sei
cld
lda #0
sta $ff00 ; select default bank 15
jsr cbm.IOINIT
@ -373,8 +372,6 @@ asmsub init_system() {
lda #0
sta c64.BGCOL0
jsr disable_runstop_and_charsetswitch
clc
clv
cli
rts
}}
@ -382,7 +379,10 @@ asmsub init_system() {
asmsub init_system_phase2() {
%asm {{
rts ; no phase 2 steps on the C128
cld
clc
clv
rts
}}
}

View File

@ -357,7 +357,6 @@ asmsub init_system() {
; Uppercase charset is activated.
%asm {{
sei
cld
lda #%00101111
sta $00
lda #%00100111
@ -372,8 +371,6 @@ asmsub init_system() {
lda #0
sta c64.BGCOL0
jsr disable_runstop_and_charsetswitch
clc
clv
cli
rts
}}
@ -381,7 +378,10 @@ asmsub init_system() {
asmsub init_system_phase2() {
%asm {{
rts ; no phase 2 steps on the C64
cld
clc
clv
rts
}}
}

View File

@ -1370,7 +1370,6 @@ asmsub init_system() {
tax
tay
jsr cx16.mouse_config ; disable mouse
cld
lda cx16.VERA_DC_VIDEO
and #%00000111 ; retain chroma + output mode
sta P8ZP_SCRATCH_REG
@ -1400,8 +1399,6 @@ asmsub init_system() {
lda #0
tax
tay
clc
clv
cli
rts
}}
@ -1417,6 +1414,9 @@ asmsub init_system_phase2() {
lda #PROG8_VARSHIGH_RAMBANK
sta $00 ; select ram bank
cli
cld
clc
clv
rts
}}
}

View File

@ -179,6 +179,7 @@ verafx {
ldx cx16.VERA_DATA0
stx cx16.r0s+1
stz cx16.VERA_FX_CTRL ; Cache write disable
stz cx16.VERA_FX_MULT ; $9F2C reset multiply bit
stz cx16.VERA_CTRL ; reset DCSEL
rts
}}

View File

@ -104,13 +104,10 @@ asmsub init_system() {
; Uppercase charset is activated.
%asm {{
sei
cld
lda #142
jsr cbm.CHROUT ; uppercase
lda #147
jsr cbm.CHROUT ; clear screen
clc
clv
cli
rts
}}
@ -118,7 +115,10 @@ asmsub init_system() {
asmsub init_system_phase2() {
%asm {{
rts ; no phase 2 steps on the PET
cld
clc
clv
rts
}}
}

View File

@ -18,8 +18,6 @@ program_startup_clear_bss .proc
lda #0
jsr prog8_lib.memset
.endif
clv
clc
rts
.pend

View File

@ -1,6 +1,9 @@
TODO
====
Commit "tweak program start initialization and fix cleanup at exit for atari and pet compiler targets #04cb684f" causing programs to crash (assem, rockrunner)
Improve register load order in subroutine call args assignments:
in certain situations, the "wrong" order of evaluation of function call arguments is done which results
in overwriting registers that already got their value, which requires a lot of stack juggling (especially on plain 6502 cpu!)

View File

@ -1,20 +1,14 @@
%import textio
%import verafx
%zeropage basicsafe
%option no_sysinit
main {
word @shared w1 = -30
word @shared w2 = -40
uword @shared uw1 = 9999
uword @shared uw2 = 4
ubyte @shared @nozp value1 = 99
ubyte @shared @requirezp value2 = 42
sub start() {
cx16.r0 = 12345
txt.print_uw(verafx.mult16(uw1, uw2))
txt.spc()
txt.print_uw(uw1 * uw2)
txt.print_ub(value1)
txt.nl()
txt.print_ub(value2)
txt.nl()
}
}