6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun May 12, 2024 11:39 pm

All times are UTC




Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Fri Apr 22, 2022 7:13 am 
Offline
User avatar

Joined: Tue Apr 03, 2018 2:10 pm
Posts: 125
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/

_________________
I like it when things smoke.
BlogZolatron 64 project


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 22, 2022 7:36 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10800
Location: England
Ah, thanks, I see now!


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 22, 2022 11:45 am 
Offline

Joined: Mon May 03, 2021 12:07 am
Posts: 21
Location: Brisbane Australia
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


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 22, 2022 3:45 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8182
Location: Midwestern USA
Andre wrote:
Code:
...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!


Top
 Profile  
Reply with quote  
PostPosted: Sat Apr 23, 2022 2:35 pm 
Offline

Joined: Sun Nov 08, 2009 1:56 am
Posts: 388
Location: Minnesota
Code:
...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:
JMP ($04F0)
_vector1_return:
DEC SYSTEM_TIMER
BNE _exit_irq
INC SYSTEM_SECONDS
LDA #100
STA SYSTEM_TIMER


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 14, 2022 11:55 am 
Offline
User avatar

Joined: Tue Aug 11, 2020 3:45 am
Posts: 311
Location: A magnetic field
Andre on Fri 22 Apr 2022 wrote:
Code:
_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.

_________________
Modules | Processors | Boards | Boxes | Beep, Beep! I'm a sheep!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: