annotate level1/modules/dw3.asm @ 2308:b5f0c5326e7e

Changes made to move ISR to dw3
author boisy
date Sun, 03 Jan 2010 14:35:04 +0000
parents 660cc987e18d
children b2bc1ad04163
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2180
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
1 ********************************************************************
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
2 * DW3 - DriveWire 3 Low Level Subroutine Module
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
3 *
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
4 * $Id$
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
5 *
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
6 * Edt/Rev YYYY/MM/DD Modified by
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
7 * Comment
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
8 * ------------------------------------------------------------------
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
9 * 1 2008/01/26 Boisy G. Pitre
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
10 * Started as a segregated subroutine module.
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
11
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
12 nam DW3
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
13 ttl DriveWire 3 Low Level Subroutine Module
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
14
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
15 ifp1
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
16 use defsfile
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
17 use dwdefs.d
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
18 endc
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
19
2308
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
20 tylg set Sbrtn+Objct
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
21 atrv set ReEnt+rev
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
22 rev set $01
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
23
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
24 mod eom,name,tylg,atrv,start,0
2180
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
25
2308
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
26 * irq
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
27 IRQPckt fcb $00,$01,$0A ;IRQ packet Flip(1),Mask(1),Priority(1) bytes
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
28 * Default time packet
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
29 DefTime dtb
2180
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
30
2308
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
31 name fcs /dw3/
2180
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
32
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
33 * DriveWire subroutine entry table
2308
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
34 start lbra Init
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
35 bra Read
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
36 nop
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
37 lbra Write
2180
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
38
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
39 * Term
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
40 *
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
41 * Entry:
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
42 * U = address of device memory area
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
43 *
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
44 * Exit:
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
45 * CC = carry set on error
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
46 * B = error code
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
47 *
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
48 Term
2308
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
49 clrb clear Carry
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
50 rts
2180
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
51
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
52 * Read
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
53 *
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
54 * ON ENTRY:
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
55 * X = ADDRESS OF THE RECEIVE BUFFER
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
56 * A = TIMEOUT VALUE (182 = APPROX ONE SECOND @ 0.89 MHz)
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
57 *
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
58 * ON EXIT:
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
59 * Y = DATA CHECKSUM
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
60 * D = ACTUAL NUMBER OF BYTES RECEIVED
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
61 * X AND U ARE PRESERVED
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
62 * CC.CARRY IS SET IF A FRAMING ERROR WAS DETECTED
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
63 *
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
64 Read
2308
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
65 use dwread.asm
2180
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
66
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
67 * Write
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
68 *
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
69 * Entry:
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
70 Write
2308
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
71 use dwwrite.asm
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
72
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
73 * Init
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
74 *
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
75 * Entry:
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
76 * Y = address of device descriptor
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
77 * U = address of device memory area
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
78 *
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
79 * Exit:
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
80 * CC = carry set on error
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
81 * B = error code
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
82 *
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
83 * Initialize the serial device
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
84 Init
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
85 clrb clear Carry
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
86 pshs y,x,cc then push CC on stack
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
87 orcc #IntMasks
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
88 ldx #PIA1Base $FF20
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
89 clr 1,x clear CD
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
90 lda #%11111110
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
91 sta ,x
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
92 lda #%00110100
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
93 sta 1,x
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
94 lda ,x
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
95
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
96 ; allocate DW statics page
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
97 pshs u
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
98 ldd #$0100
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
99 os9 F$SRqMem
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
100 tfr u,x
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
101 puls u
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
102 lbcs InitEx
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
103 IFGT Level-1
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
104 stx <D.DWStat
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
105 ELSE
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
106 stx >D.DWStat
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
107 ENDC
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
108 ; clear out 256 byte page at X
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
109 clrb
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
110 loop@ clr ,x+
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
111 decb
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
112 bne loop@
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
113
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
114 * install ISR
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
115 InstIRQ
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
116 IFGT Level-1
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
117 ldx <D.DWStat
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
118 ELSE
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
119 ldx >D.DWStat
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
120 ENDC
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
121 leax DW.VIRQPkt,x
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
122 pshs u
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
123 tfr x,u
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
124 leax Vi.Stat,x ;fake VIRQ status register
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
125 lda #$80 ;VIRQ flag clear, repeated VIRQs
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
126 sta ,x ;set it while we're here...
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
127 tfr x,d ;copy fake VIRQ status register address
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
128 leax IRQPckt,pcr ;IRQ polling packet
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
129 leay IRQSvc,pcr ;IRQ service entry
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
130 os9 F$IRQ ;install
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
131 puls u
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
132 bcs InitEx ;exit with error
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
133 ldd #$0003 ;lets try every 6 ticks (0.1 seconds) -- testing 3, gives better response in interactive things
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
134 IFGT Level-1
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
135 ldx <D.DWStat
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
136 ELSE
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
137 ldx >D.DWStat
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
138 ENDC
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
139 leax DW.VIRQPkt,x
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
140 std Vi.Rst,x ; reset count
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
141 tfr x,y ; move VIRQ software packet to Y
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
142 tryagain
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
143 ldx #$0001 ; code to install new VIRQ
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
144 os9 F$VIRQ ; install
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
145 bcc IRQok ; no error, continue
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
146 cmpb #E$UnkSvc
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
147 bne InitEx
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
148 ; if we get an E$UnkSvc error, then clock has not been initialized, so do it here
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
149 leax DefTime,pcr
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
150 os9 F$STime
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
151 bra tryagain ; note: this has the slim potential of looping forever
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
152 IRQok
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
153 IFGT Level-1
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
154 ldx <D.DWStat
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
155 ELSE
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
156 ldx >D.DWStat
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
157 ENDC
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
158 ; cheat: we know DW.StatTbl is at offset $00 from D.DWStat, do not bother with leax
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
159 leax DW.StatTbl,x
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
160 tfr u,d
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
161 ldb <V.PORT+1,u ; get our port #
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
162 sta b,x ; store in table
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
163
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
164 InitEx
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
165 puls cc,x,y,pc
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
166
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
167
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
168 ; ***********************************************************************
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
169 ; Interrupt handler - Much help from Darren Atkinson
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
170
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
171 IRQMulti3 anda #$1F ; mask first 5 bits, a is now port #+1
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
172 deca ; we pass +1 to use 0 for no data
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
173 pshs a ; save port #
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
174 cmpb RxGrab,u ; compare room in buffer to server's byte
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
175 bhs IRQM06 ; room left >= server's bytes, no problem
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
176
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
177 stb RxGrab,u ; else replace with room left in our buffer
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
178
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
179 ; also limit to end of buffer
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
180 IRQM06 ldd RxBufEnd,u ; end addr of buffer
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
181 subd RxBufPut,u ; subtract current write pointer, result is # bytes left going forward in buff.
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
182
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
183 IRQM05 cmpb RxGrab,u ; compare b (room left) to grab bytes
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
184 bhs IRQM03 ; branch if we have room for grab bytes
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
185
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
186 stb RxGrab,u ; else set grab to room left
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
187
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
188 ; send multiread req
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
189 IRQM03 puls a ; port # is on stack
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
190 ldb RxGrab,u
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
191
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
192 pshs u
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
193
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
194 ; setup DWsub command
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
195 pshs d ; (a port, b bytes)
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
196 lda #OP_SERREADM ; load command
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
197 pshs a ; command store on stack
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
198 leax ,s ; point X to stack
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
199 ldy #3 ; 3 bytes to send
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
200
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
201 IFGT Level-1
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
202 ldu <D.DWSubAddr
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
203 ELSE
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
204 ldu >D.DWSubAddr
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
205 ENDC
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
206 jsr 6,u ; call DWrite
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
207
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
208 leas 3,s ; clean 3 DWsub args from stack
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
209
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
210 ldx ,s ; pointer to this port's area (from U prior), leave it on stack
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
211 ldb RxGrab,x ; set B to grab bytes
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
212 clra ; 0 in high byte
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
213 tfr d,y ; set # bytes for DW
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
214
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
215 ldx RxBufPut,x ; point X to insert position in this port's buffer
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
216 ; receive response
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
217 jsr 3,u ; call DWRead
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
218 ; handle errors?
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
219
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
220
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
221 puls u
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
222 ldb RxGrab,u ; our grab bytes
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
223
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
224 ; set new RxBufPut
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
225 ldx RxBufPut,u ; current write pointer
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
226 abx ; add b (# bytes) to RxBufPut
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
227 cmpx RxBufEnd,u ; end of Rx buffer?
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
228 blo IRQM04 ; no, go keep laydown pointer
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
229 ldx RxBufPtr,u ; get Rx buffer start address
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
230 IRQM04 stx RxBufPut,u ; set new Rx data laydown pointer
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
231
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
232 ; set new RxDatLen
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
233 ldb RxDatLen,u
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
234 addb RxGrab,u
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
235 stb RxDatLen,u ; store new value
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
236
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
237 bra CkSuspnd
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
238
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
239 IRQMulti
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
240 ; initial grab bytes
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
241 stb RxGrab,u
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
242
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
243 ; limit server bytes to bufsize - datlen
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
244 ldb RxBufSiz,u ; size of buffer
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
245 subb RxDatLen,u ; current bytes in buffer
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
246 bne IRQMulti3 ; continue, we have some space in buffer
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
247 ; no room in buffer
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
248 tstb
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
249 bne CkSuspnd
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
250 bra IRQExit
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
251
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
252
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
253 ; **** IRQ ENTRY POINT
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
254 IRQSvc equ *
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
255 pshs cc,dp ; save system cc,DP
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
256 orcc #IntMasks ; mask interrupts
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
257
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
258 ; mark VIRQ handled (note U is pointer to our VIRQ packet in DP)
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
259 lda Vi.Stat,u ; VIRQ status register
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
260 anda #^Vi.IFlag ; clear flag in VIRQ status register
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
261 sta Vi.Stat,u ; save it...
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
262
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
263 ; poll server for incoming serial data
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
264
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
265 ; send request
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
266 lda #OP_SERREAD ; load command
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
267 pshs a ; command store on stack
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
268 leax ,s ; point X to stack
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
269 ldy #1 ; 1 byte to send
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
270
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
271 IFGT Level-1
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
272 ldu <D.DWSubAddr
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
273 ELSE
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
274 ldu >D.DWSubAddr
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
275 ENDC
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
276 jsr 6,u ; call DWrite
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
277
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
278 ; receive response
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
279 leas -1,s ; one more byte to fit response
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
280 leax ,s ; point X to stack head
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
281 ldy #2 ; 2 bytes to retrieve
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
282 jsr 3,u ; call DWRead
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
283 beq IRQSvc2 ; branch if no error
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
284 leas 2,s ; error, cleanup stack 2
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
285 bra IRQExit2 ; don't reset error count on the way out
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
286
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
287 ; process response
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
288 IRQSvc2
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
289 ldd ,s++ ; pull returned status byte into A,data into B (set Z if zero, N if multiread)
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
290 beq IRQExit ; branch if D = 0 (nothing to do)
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
291
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
292 ; save back D on stack and build our U
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
293 pshs d
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
294 anda #$1F ; mask first 5 bits, a is now port #+1
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
295 deca ; we pass +1 to use 0 for no data
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
296 ; here we set U to the static storage area of the device we are working with
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
297 IFGT Level-1
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
298 ldx <D.DWStat
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
299 ELSE
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
300 ldx >D.DWStat
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
301 ENDC
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
302 ; cheat: we know DW.StatTbl is at offset $00 from D.DWStat, do not bother with leax
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
303 ; leax DW.StatTbl,x
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
304 lda a,x
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
305 bne IRQCont ; if A is 0, then this device is not active, so exit
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
306 puls d
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
307 bra IRQExit
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
308 IRQCont
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
309 clrb
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
310 tfr d,u
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
311
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
312 ldd ,s++ ; pull returned status byte into A,data into B (set Z if zero, N if multiread)
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
313
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
314 bmi IRQMulti ; branch for multiread
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
315
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
316 ; put byte B in port As buffer - optimization help from Darren Atkinson
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
317 IRQPutCh ldx RxBufPut,u ; point X to the data buffer
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
318
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
319 ; process interrupt/quit characters here
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
320 ; note we will have to do this in the multiread (ugh)
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
321 tfr b,a ; put byte in A
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
322 ldb #S$Intrpt
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
323 cmpa V.INTR,u
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
324 beq send@
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
325 ldb #S$Abort
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
326 cmpa V.QUIT,u
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
327 bne store
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
328 send@ lda V.LPRC,u
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
329 beq IRQExit
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
330 os9 F$Send
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
331 bra IRQExit
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
332
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
333 store
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
334 ; store our data byte
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
335 sta ,x+ ; store and increment buffer pointer
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
336
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
337 ; adjust RxBufPut
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
338 cmpx RxBufEnd,u ; end of Rx buffer?
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
339 blo IRQSkip1 ; no, go keep laydown pointer
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
340 ldx RxBufPtr,u ; get Rx buffer start address
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
341 IRQSkip1 stx RxBufPut,u ; set new Rx data laydown pointer
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
342
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
343 ; increment RxDatLen
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
344 inc RxDatLen,u
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
345
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
346
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
347 ; check if we have a process waiting for data
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
348 CkSuspnd lda <V.WAKE,u ; V.WAKE?
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
349 beq IRQExit ; no
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
350 clr <V.WAKE,u ; clear V.WAKE
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
351
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
352 ; wake up waiter for read
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
353 IFEQ Level-1
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
354 ldb #S$Wake
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
355 os9 F$Send
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
356 ELSE
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
357 clrb
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
358 tfr d,x ; copy process descriptor pointer
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
359 lda P$State,x ; get state flags
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
360 anda #^Suspend ; clear suspend state
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
361 sta P$State,x ; save state flags
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
362 ENDC
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
363
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
364 IRQExit
b5f0c5326e7e Changes made to move ISR to dw3
boisy
parents: 2180
diff changeset
365 IRQExit2 puls cc,dp,pc ; restore interrupts cc,dp, return
2180
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
366
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
367 emod
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
368 eom equ *
660cc987e18d Added DriveWire 3 modules to distribution
boisy
parents:
diff changeset
369 end