Kernel User Interrupt

Programming the 6502 microprocessor and its relatives in assembly and other languages.
User avatar
speculatrix
Posts: 151
Joined: 03 Apr 2018
Contact:

Re: Kernel User Interrupt

Post by speculatrix »

Coincidentally, I’ve just been grappling with something similar. Although my skills here are basic, I have documented what I did here: https://mansfield-devine.com/speculatri ... ng-system/
It either works or catches fire. Either way is fun.
Zolatron 64 project (on Medium)
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: Kernel User Interrupt

Post by BigEd »

Ah, thanks, I see now!
Andre
Posts: 21
Joined: 03 May 2021
Location: Brisbane Australia

Re: Kernel User Interrupt

Post by Andre »

Hi

Spotted an error if anybody was looking closely.
Quote:
...yes it was a 10ms timer interrupt
JMP ($04F0) ; jump to vector1 interrupt
_vector1_return:
INC SYSTEM_TIMER
CLC
LDA SYSTEM_TIMER
CMP #$64 ; HAS TIMER REACHED 100 (0x64)
BCC _exit_irq
LDA #$00
STA SYSTEM_TIMER
INC SYSTEM_SECONDS

JMP ($04F2) ; jump to vector2 interrupt
_vector2_return:
_not_via:

JMP ($04F4) ; jump to vector3 interrupt
_vector3_return:
_exit_irq:
PLA
PLX
PLY

_irq_last_byte_address:
RTI ; Return from IRQ interrupt
the line BCC _exit_irq should be a BCC to _not_via
otherwise the JMP(indirect) for vector3 will be missed.

This is still all work in progress so testing is limited.

Regards
Andre
User avatar
BigDumbDinosaur
Posts: 9428
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Kernel User Interrupt

Post by BigDumbDinosaur »

Andre wrote:

Code: Select all

...yes it was a 10ms timer interrupt
JMP ($04F0) ; jump to vector1 interrupt
_vector1_return:
INC SYSTEM_TIMER
CLC
LDA SYSTEM_TIMER
CMP #$64 ; HAS TIMER REACHED 100 (0x64)
BCC _exit_irq
LDA #$00
STA SYSTEM_TIMER
INC SYSTEM_SECONDS

JMP ($04F2) ; jump to vector2 interrupt
_vector2_return:
_not_via:

JMP ($04F4) ; jump to vector3 interrupt
_vector3_return:
_exit_irq:
PLA
PLX
PLY

_irq_last_byte_address:
RTI ; Return from IRQ interrupt

Surrounding your code snippets with code brackets will make it a little easier to read.
x86?  We ain't got no x86.  We don't NEED no stinking x86!
teamtempest
Posts: 443
Joined: 08 Nov 2009
Location: Minnesota
Contact:

Re: Kernel User Interrupt

Post by teamtempest »

Code: Select all

...yes it was a 10ms timer interrupt
JMP ($04F0) ; jump to vector1 interrupt
_vector1_return:
INC SYSTEM_TIMER
CLC
LDA SYSTEM_TIMER
CMP #$64 ; HAS TIMER REACHED 100 (0x64)
BCC _exit_irq
LDA #$00
STA SYSTEM_TIMER
INC SYSTEM_SECONDS
An alternative might be to count down instead of up:

Code: Select all

JMP ($04F0)
_vector1_return:
DEC SYSTEM_TIMER
BNE _exit_irq
INC SYSTEM_SECONDS
LDA #100
STA SYSTEM_TIMER
User avatar
Sheep64
In Memoriam
Posts: 311
Joined: 11 Aug 2020
Location: A magnetic field

Re: Kernel User Interrupt

Post by Sheep64 »

Andre on Fri 22 Apr 2022 wrote:

Code: Select all

_exit_irq:
PLA
PLX
PLY
That is an unusual order. On NMOS 6502, PHA // TXA // PHA // TYA // PHA is traditional. On 65C02, this can be compacted to PHA // PHX // PHY and would be reversed with PLY // PLX // PLA. Unless the IRQ handler begins with PHY // PHX // PHA, the software running outside of interrupt will have its register contents shuffled.
Post Reply