base:launching_long_tasks_from_irq_handler
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
base:launching_long_tasks_from_irq_handler [2016-03-15 12:28] – bitbreaker | base:launching_long_tasks_from_irq_handler [2016-03-15 12:50] – bitbreaker | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Launching long tasks from inside a IRQ handler ====== | ====== Launching long tasks from inside a IRQ handler ====== | ||
+ | |||
+ | by Bitbreaker/ | ||
When executing code within an IRQ handler you have to finish things before the next IRQ occurs. But sometimes tasks just take some more time, for that you can spin off those tasks from inside the handler, and allow then upcoming IRQs to happen. | When executing code within an IRQ handler you have to finish things before the next IRQ occurs. But sometimes tasks just take some more time, for that you can spin off those tasks from inside the handler, and allow then upcoming IRQs to happen. | ||
Line 15: | Line 17: | ||
;... your desired irq handler code goes here | ;... your desired irq handler code goes here | ||
+ | lda some_condition | ||
beq skip_long | beq skip_long | ||
Line 25: | Line 28: | ||
lda #$00 | lda #$00 | ||
pha | pha | ||
- | |||
- | ;copy over the registers | ||
- | lda reg_a | ||
- | sta reg_a_ | ||
- | lda reg_x | ||
- | sta reg_x_ | ||
- | lda reg_y | ||
- | sta reg_y_ | ||
skip_long | skip_long | ||
Line 46: | Line 41: | ||
| | ||
task | task | ||
+ | ; | ||
+ | sta reg_a_ | ||
+ | stx reg_x_ | ||
+ | sty reg_y_ | ||
+ | |||
; | ; | ||
| | ||
- | ; | + | ; |
lda reg_a_ | lda reg_a_ | ||
ldx reg_x_ | ldx reg_x_ | ||
Line 76: | Line 76: | ||
sta $d012 | sta $d012 | ||
| | ||
- | ;now allow irq2 happen on top of this task and return to this task when done | + | ;now allow irq2 to happen on top of this task and return to this task when done |
cli | cli | ||
| |
base/launching_long_tasks_from_irq_handler.txt · Last modified: 2016-11-23 10:54 by bitbreaker