aboutsummaryrefslogtreecommitdiff
path: root/amforth-6.5/avr8/drivers/generic-isr.asm
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2017-08-19 12:15:28 +0200
committerDimitri Sokolyuk <demon@dim13.org>2017-08-19 12:15:28 +0200
commit67d25d837ac55f28a366c0a3b262e439a6e75fc3 (patch)
treedf7715c7724c5935ab87c807f3b8b4ef529315e3 /amforth-6.5/avr8/drivers/generic-isr.asm
parente0d6784e89dba33226c0edb815bb974486fa7c48 (diff)
Add AmForth
Diffstat (limited to 'amforth-6.5/avr8/drivers/generic-isr.asm')
-rw-r--r--amforth-6.5/avr8/drivers/generic-isr.asm41
1 files changed, 41 insertions, 0 deletions
diff --git a/amforth-6.5/avr8/drivers/generic-isr.asm b/amforth-6.5/avr8/drivers/generic-isr.asm
new file mode 100644
index 0000000..e0aeaed
--- /dev/null
+++ b/amforth-6.5/avr8/drivers/generic-isr.asm
@@ -0,0 +1,41 @@
+; ISR routines
+.eseg
+intvec: .byte INTVECTORS * CELLSIZE
+.dseg
+intcnt: .byte INTVECTORS
+.cseg
+
+; interrupt routine gets called (again) by rcall! This gives the
+; address of the int-vector on the stack.
+isr:
+ st -Y, r0
+ in r0, SREG
+ st -Y, r0
+.if (pclen==3)
+ pop r0 ; some 128+K Flash devices use 3 cells for call/ret
+.endif
+ pop r0
+ pop r0 ; = intnum * intvectorsize + 1 (address following the rcall)
+ dec r0
+.if intvecsize == 1 ;
+ lsl r0
+.endif
+ mov isrflag, r0
+ push zh
+ push zl
+ ldi zl, low(intcnt)
+ ldi zh, high(intcnt)
+ lsr r0 ; we use byte addresses in the counter array, not words
+ add zl, r0
+ adc zh, zeroh
+ ld r0, Z
+ inc r0
+ st Z, r0
+ pop zl
+ pop zh
+
+ ld r0, Y+
+ out SREG, r0
+ ld r0, Y+
+ ret ; returns the interrupt, the rcall stack frame is removed!
+ ; no reti here, see words/isr-end.asm