Simply hooking the IRQ. #443
Replies: 3 comments 17 replies
-
Accordingly, this IRQ routine fires after the default vector, rather than before, : irqpeek $dc0e c@ ;
: irqpoke $dc0e c! ;
: irqoff irqpeek $fe and irqpoke ;
: irqon irqpeek 1 or irqpoke ;
: irqsub ( addr -- )
irqoff $314 ! irqon ;
code pstate \ uses SYS register locations
$15 lda, pha, $14 lda, pha,
sr lda, pha, ar lda, pha,
xr lda, pha, yr lda, pha,
$ea31 jmp,
;code
code flashborder
$d020 inc,
$d020 dec,
$ea81 jmp, \ into restore registers, rti
;code
: irqtest
['] flashborder $14 ! \ set SYS address
['] pstate irqsub
;
|
Beta Was this translation helpful? Give feedback.
-
This one leverages the BRK instruction to push the stack frame. : irqpeek $dc0e c@ ;
: irqpoke $dc0e c! ;
: irqoff irqpeek $fe and irqpoke ;
: irqon irqpeek 1 or irqpoke ;
: irqsub ( addr -- )
$314 ! irqon ; \ irq vector
: brksub ( addr -- )
irqoff $316 ! ; \ brk vector
code flashborder \ not so arbitrary asm code
$314 lda, pha, $315 lda, pha, \ flashborder to stack
$31 lda,# $314 sta, $ea lda,# $315 sta, \ restore irq vector
brk, nop, \ stack for me, do irq routine
\ user code
$d020 inc, \ return from irq routine here
$d020 dec, \ then exit
\ end user code
sei, \ cia timer IRQs were held off until reset by irq routine
pla, $315 sta, pla, $314 sta, \ flashborder to irq -mind the stack
$ea81 jmp, \ restore regs, rti
;code
: irqtest
$ea31 brksub \ call irq routine on a brk
['] flashborder irqsub \ call my code on irq
; |
Beta Was this translation helpful? Give feedback.
-
Just a small thing, you can replace : irq! ( flag -- ) $dc0e c@ swap
if 1 or else $fe and then $dc0e c! ; And a pair of more general words for masking bit registers: : bits@ ( mask addr -- bits ) c@ and ;
: bits! ( flag mask addr -- )
rot >r dup c@ rot ( addr val mask ) r>
if or else invert and then swap c! ; Edit: Whoops, |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I was surprised how easy this is.
End your code with $ea31 jmp,
Your code holds off the IRQ routine until your code is finished.
Fixed!
Beta Was this translation helpful? Give feedback.
All reactions