mirror of
https://github.com/irmen/prog8.git
synced 2024-11-26 11:49:22 +00:00
fix stack crash in cx16.push_vera_context()
This commit is contained in:
parent
2d600da8b6
commit
4bc65e9ef7
@ -735,49 +735,53 @@ IRQ_SCRATCH_ZPWORD2 .word 0
|
||||
}}
|
||||
}
|
||||
|
||||
inline asmsub push_vera_context() clobbers(A) {
|
||||
asmsub push_vera_context() clobbers(A) {
|
||||
; -- use this at the start of your IRQ handler if it uses Vera registers, to save the state
|
||||
%asm {{
|
||||
; note cannot store this on cpu hardware stack because this gets called as a subroutine
|
||||
lda cx16.VERA_ADDR_L
|
||||
pha
|
||||
sta _vera_storage
|
||||
lda cx16.VERA_ADDR_M
|
||||
pha
|
||||
sta _vera_storage+1
|
||||
lda cx16.VERA_ADDR_H
|
||||
pha
|
||||
sta _vera_storage+2
|
||||
lda cx16.VERA_CTRL
|
||||
pha
|
||||
sta _vera_storage+3
|
||||
eor #1
|
||||
sta cx16.VERA_CTRL
|
||||
lda cx16.VERA_ADDR_L
|
||||
pha
|
||||
sta _vera_storage+4
|
||||
lda cx16.VERA_ADDR_M
|
||||
pha
|
||||
sta _vera_storage+5
|
||||
lda cx16.VERA_ADDR_H
|
||||
pha
|
||||
sta _vera_storage+6
|
||||
lda cx16.VERA_CTRL
|
||||
pha
|
||||
sta _vera_storage+7
|
||||
rts
|
||||
_vera_storage: .byte 0,0,0,0,0,0,0,0
|
||||
}}
|
||||
}
|
||||
|
||||
inline asmsub pop_vera_context() clobbers(A) {
|
||||
asmsub pop_vera_context() clobbers(A) {
|
||||
; -- use this at the end of your IRQ handler if it uses Vera registers, to restore the state
|
||||
%asm {{
|
||||
pla
|
||||
lda cx16.push_vera_context._vera_storage+7
|
||||
sta cx16.VERA_CTRL
|
||||
pla
|
||||
lda cx16.push_vera_context._vera_storage+6
|
||||
sta cx16.VERA_ADDR_H
|
||||
pla
|
||||
lda cx16.push_vera_context._vera_storage+5
|
||||
sta cx16.VERA_ADDR_M
|
||||
pla
|
||||
lda cx16.push_vera_context._vera_storage+4
|
||||
sta cx16.VERA_ADDR_L
|
||||
pla
|
||||
lda cx16.push_vera_context._vera_storage+3
|
||||
sta cx16.VERA_CTRL
|
||||
pla
|
||||
lda cx16.push_vera_context._vera_storage+2
|
||||
sta cx16.VERA_ADDR_H
|
||||
pla
|
||||
lda cx16.push_vera_context._vera_storage+1
|
||||
sta cx16.VERA_ADDR_M
|
||||
pla
|
||||
lda cx16.push_vera_context._vera_storage+0
|
||||
sta cx16.VERA_ADDR_L
|
||||
rts
|
||||
}}
|
||||
}
|
||||
|
||||
|
@ -1 +1 @@
|
||||
8.4-dev
|
||||
8.3.1
|
||||
|
@ -706,7 +706,7 @@ main {
|
||||
}
|
||||
"""
|
||||
val result = compileText(C64Target(), false, text, writeAssembly = true)!!
|
||||
result.program.entrypoint.statements.size shouldBe 13
|
||||
result.program.entrypoint.statements.size shouldBe 15
|
||||
}
|
||||
|
||||
test("invalid typecasts of numbers") {
|
||||
|
@ -495,7 +495,9 @@ Breaking out of a loop prematurely is possible with the ``break`` statement.
|
||||
languages if this is *not* the case! A for loop from ubyte 10 to ubyte 2, for example, will iterate through
|
||||
all values 10, 11, 12, 13, .... 254, 255, 0 (wrapped), 1, 2. In other languages the entire loop will
|
||||
be skipped in such cases. But prog8 omits the overhead of an extra loop range check and/or branch for every for loop
|
||||
by assuming the normal ranges.
|
||||
because the most common case is that it is not needed.
|
||||
You should add an explicit range check yourself if the ending value can be less than the start value and
|
||||
a full wrap-around loop is not what you want!
|
||||
|
||||
|
||||
Conditional Execution
|
||||
|
@ -3,6 +3,10 @@ TODO
|
||||
|
||||
For next release
|
||||
^^^^^^^^^^^^^^^^
|
||||
- cx16: sys.reset_system() doesn't silence the vera psg (kernel bug in reset vector?) use reset vera bit?
|
||||
- see if we can let for loops skip the loop if end<start, without adding a lot of code size/duplicating the loop condition
|
||||
this is documented behiavor to now loop around but it's too easy to forget about
|
||||
|
||||
...
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user