6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Sep 20, 2024 2:38 am

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Polling for interrupts
PostPosted: Sun Jun 30, 2019 2:09 pm 
Offline
User avatar

Joined: Sun Dec 29, 2002 8:56 pm
Posts: 452
Location: Canada
Is there a way to poll for an interrupt on the ‘816? The software needs to poll for an interrupt (running with interrupts masked off) and execute an interrupt routine if there’s an interrupt present, otherwise continue on with the program. I don’t think the wai instruction can be used for this because it’ll wait for an interrupt. The software doesn’t need to wait. The best I could come up with was the following code:
Code:
 PollForIRQ:
   pha
   lda      IRQStatus      ; route all IRQ's to a register at this location
   beq      .0001         ; zero = no IRQ’s
   phx
   phy
   jsr      IRQRout
   ply
   plx
.0001:
   pla
   rtl

It turns the poll into a subroutine call. Seems like a lot of overhead.

_________________
http://www.finitron.ca


Top
 Profile  
Reply with quote  
PostPosted: Sun Jun 30, 2019 2:18 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
Doesn't
PHP
CLI
PLP
do the trick?


Top
 Profile  
Reply with quote  
PostPosted: Sun Jun 30, 2019 5:25 pm 
Offline
User avatar

Joined: Sun Dec 29, 2002 8:56 pm
Posts: 452
Location: Canada
Quote:
Doesn't
PHP
CLI
PLP
do the trick?

Hey thanks, that'll work. Wrapped up in a macro that's ideal.

_________________
http://www.finitron.ca


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 01, 2019 12:17 am 
Offline

Joined: Mon May 21, 2018 8:09 pm
Posts: 1462
Even CLI : SEI should do, and takes only 4 cycles in the no-interrupt case. If I was not already set, then any interrupt would be taken immediately and you wouldn't need to poll for it. The interrupt itself will save and restore P around the ISR.


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 01, 2019 4:14 am 
Offline
User avatar

Joined: Sun Dec 29, 2002 8:56 pm
Posts: 452
Location: Canada
Yup that works too. (I found that one myself after the large hint).
I have it wrapped up in a macro called 'pfi'. Since the system is running with interrupts disabled there's no need to push / pull the status reg.
All the interrupts are still connected to a port so all that's needed in the IRQ routine is to read the port to see who interrupted.
Hopefully I can get a little co-operative multi-tasker going.

_________________
http://www.finitron.ca


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 9 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: