OpenCores
URL https://opencores.org/ocsvn/System09/System09/trunk

Subversion Repositories System09

[/] [System09/] [trunk/] [src/] [xrecv/] [XRECV.ASM] - Blame information for rev 164

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 153 davidgb
*
2
** FLEX 9 DISK DRIVERS
3
*
4
* FOR SYS09BUG ON THE DIGILENT SPARTAN 3 STARTER BOARD
5
* WITH I/O MAPPED AT $XE000
6
* AND ROM MAPPED AT $XF000
7
* THE DIGILENT SPARTAN 3 STARTER BOARD HAS 1MBYTE OF SRAM
8
* THE FIRST 64K IS USED BY FLEX,
9
* THE SECOND 128K IS USED AS A ROM DISK
10
* THE REMAINING RAM IS USED FOR A RAM DISK
11
*
12
*
13
CFLAG   EQU $01     CARRY FLAG
14
VFLAG   EQU $02     OVERFLOW FLAG
15
ZFLAG   EQU $04     ZERO FLAG
16
NFLAG   EQU $08     NEGATIVE FLAG
17
IFLAG   EQU $10     IRQ MASK CC
18
HFLAG   EQU $20     HALF CARRY
19
FFLAG   EQU $40     FIRQ MASK CC
20
EFLAG   EQU $80     ENTIRE FLAG
21
*
22
MAPPAG  EQU $00     PAGE $0000 DAT ADDRESS
23
*
24
* Serial Port
25
*
26
ACIAS   EQU $E000
27
ACIAC1  EQU ACIAS
28
ACIAD1  EQU ACIAS+1
29
DELCON  EQU 1250    Delay (Processor clock in MHz * 50)
30
*
31
* XMODEM Control characters
32
*
33
SOH     EQU $01
34
EOT     EQU $04
35
ACK     EQU $06
36
NAK     EQU $15
37
CAN     EQU $18
38
*
39
* ASCII CONTROL CHARACTERS
40
*
41
HT      EQU $09
42
LF      EQU $0A
43
CR      EQU $0D
44
*
45
* Some dummy Constants
46
*
47
RMAXTRK EQU 48
48
RMAXSEC EQU 14
49
RTOTSEC EQU RMAXTRK*RMAXSEC-RMAXSEC
50
*
51
* Start
52
*
53
        ORG $0100
54
START   LBRA  LOAD1
55
*
56
*
57
* RAM SPACE
58
*
59
CHKSUM  FCB  0
60
BLKNUM  FCB  0 Xmodem block number
61
BYTCNT  FCB  0 Xmodem byte count
62
XSTATE  FDB  0 Xmodem State Vector
63
DELCNT  FCB  $00,$00,$00 Xmodem Poll timer
64
BUFPTR  FDB 0
65
TEXTFL  FCB 0
66
LINECT  FCB 0
67
        ORG  $0200
68
*
69
* SECTOR BUFFER
70
*
71
BUFFER  RMB  256
72
*
73
*
74
* ACIA INPUT TEST
75
*
76
INTEST  LDA ACIAC1
77
        BITA #$01
78
        RTS
79
*
80
* RESET ACIA
81
*
82
ACIRST  LDA #$03 master reset
83
        STA  ACIAC1
84
        LDA #$11
85
        STA ACIAC1
86
        RTS
87
*
88
* ACIA INPUT
89
*
90
INTER   LDA  #16
91
        STA  DELCNT+0
92
        CLR  DELCNT+1
93
        CLR  DELCNT+2
94
INTER0  LDA  ACIAC1
95
        BITA #$01
96
        BNE  INTER1
97
        BITA #$78
98
        BEQ  INTER2
99
        BSR  ACIRST
100
        BRA  INTER
101
*
102
INTER1  LDA  ACIAD1
103
        ANDCC #VFLAG
104
        RTS
105
*
106
INTER2  DEC  DELCNT+2
107
        BNE  INTER0
108
        DEC  DELCNT+1
109
        BNE  INTER0
110
        DEC  DELCNT+0
111
        BNE  INTER0
112
        CLRA
113
        ORCC #VFLAG
114
        RTS
115
*
116
* ACIA OUTPUT
117
*
118
OUTTER  PSHS A
119
*
120
OUTTE1  LDA ACIAC1
121
        BITA #$02
122
        BNE  OUTTE2
123
        BITA #$78
124
        BEQ  OUTTE1
125
        BSR  ACIRST
126
        BRA  OUTTE1
127
*
128
OUTTE2  PULS A
129
        STA ACIAD1
130
        RTS
131
*
132
* Print Data
133
*
134
PDATA0  BSR  OUTTER
135
PDATA1  LDA  ,X+
136
        CMPA #$04
137
        BNE  PDATA0
138
        RTS
139
*
140
* Get a Byte using XModem protocol
141
* Carry clear => no errors
142
* Carry set   => errors
143
*
144
XREAD   PSHS U
145
        LDU  XSTATE
146
*
147
XBYTE0  LBSR INTER
148
        BVC  XBYTE1
149
        LDA  #NAK
150
        LBSR OUTTER
151
        LDU  #XSTS
152
        BRA  XBYTE0
153
*
154
XBYTE1  JSR  ,U
155
        BNE  XBYTE0
156
        STU  XSTATE
157
        PULS U,PC
158
*
159
* START - LOOK FOR SOH (START OF HEADER) = $01
160
*
161
XSTS  CMPA #SOH
162
        BNE  XSTS1
163
        LDU  #XSTB
164
        ANDCC #$FF-CFLAG-ZFLAG No abort, no valid data (no exit)
165
        RTS
166
*
167
XSTS1 CMPA #EOT
168
        BNE  XSTS2
169
        LDA  #ACK
170
        LBSR OUTTER
171
        ORCC  #CFLAG+ZFLAG  Set (c)=1 abort & exit
172
        RTS
173
*
174
XSTS2 CMPA #CAN
175
        BNE  XSTS3
176
        ORCC  #CFLAG+ZFLAG  Set (c)=1 abort & exit
177
        RTS
178
*
179
XSTS3 ANDCC #$FF-CFLAG-ZFLAG
180
        RTS
181
*
182
* Got SOH
183
* Now get block number
184
*
185
XSTB  CMPA BLKNUM
186
        BNE  XSTBE
187
        LDU  #XSTCOM
188
        ANDCC #$FF-CFLAG-ZFLAG No abort, No valid data (no exit)
189
        RTS
190
*
191
* Error in block number
192
*
193
XSTBE LDA  #NAK
194
        LBSR OUTTER
195
        LDU  #XSTS
196
        ANDCC #$FF-CFLAG-ZFLAG No abort, No valid data (no exit)
197
        RTS
198
*
199
* Get complement of block number
200
*
201
XSTCOM  COMA
202
        CMPA BLKNUM
203
        BNE  XSTBE
204
        CLR  CHKSUM
205
        LDA  #128
206
        STA  BYTCNT
207
        LDU  #XSTD
208
        ANDCC #$FF-CFLAG-ZFLAG No abort, No valid data (no exit)
209
        RTS
210
*
211
* Get data bytes
212
*
213
XSTD  PSHS A
214
        ADDA CHKSUM
215
        STA  CHKSUM
216
        PULS A
217
        DEC  BYTCNT
218
        BNE  XSTD1
219
        LDU  #XSTC
220
XSTD1 STA  ,X+
221
        ANDCC #$FF-CFLAG-ZFLAG No abort, no valid data (no exit)
222
        RTS
223
*
224
* Byte count reached zero
225
* Check checksum byte
226
*
227
XSTC  CMPA CHKSUM
228
        BNE  XSTC1 retry if wrong checksum
229
*
230
* Checksum OK ...
231
* increment block number
232
* Don't send ACK until data written to CF
233
*
234
        INC  BLKNUM
235
        LDU  #XSTS
236
        ANDCC #$FF-CFLAG No abort
237
        ORCC #ZFLAG      Valid data (exit)
238
        RTS
239
*
240
* Checksum Error detected ...
241
* Reset Sector counter in ACCB to last 128 byte boundary
242
* and send NAK
243
*
244
XSTC1  LDX #BUFFER
245
        LDA  #NAK
246
XSTC2 LBSR OUTTER
247
        LDU  #XSTS
248
        ANDCC #$FF-CFLAG-ZFLAG No abort, no valid data (no exit)
249
        RTS
250
*
251
* Acknowledge Data Received
252
*
253
XACK    PSHS A
254
        LDA  #ACK
255
        LBSR OUTTER
256
        PULS A,PC
257
*
258
** FLEX CALLS
259
*
260
SYSFCB EQU $C840
261
WARMS  EQU $CD03
262
OUTCH  EQU $CD0F
263
OUTCH2 EQU $CD12
264
GETCHR EQU $CD15
265
PUTCHR EQU $CD18
266
PSTRNG EQU $CD1E
267
GETFIL EQU $CD2D
268
SETEXT EQU $CD33
269
RPTERR EQU $CD3F
270
GETHEX EQU $CD42
271
NXTCH  EQU $CD27
272
FMSCLS EQU $D403
273
FMS    EQU $D406
274
*
275
** MAIN ENTRY POINT
276
*
277
LOAD1  LDX #SYSFCB
278
       JSR >GETFIL
279
       BCC LOAD2
280
       LDB #$15
281
       STB $01,X
282
       JMP >FMSERR
283
LOAD2  JSR NXTCH
284
       ANDA #$5F
285
       CMPA #'T
286
       BNE LOAD3
287
       STA  TEXTFL
288
       LDX #TXTMSG
289
       JSR PDATA1
290
       BRA OPENWR
291
LOAD3  CMPA #$20
292
       BEQ LOAD2
293
*
294
** OPEN FILE FOR WRITE
295
*
296
OPENWR  LDX #SYSFCB
297
        LDA #$02
298
        STA ,X
299
        JSR >FMS
300
        LBNE DSKERR
301
        TST TEXTFL
302
        BEQ OPENW1
303
        LDA #$01
304
        JSR SETEXT
305
        BRA OPENW2
306
OPENW1  LDA #$FF
307
        STA $3B,X
308
OPENW2  EQU *
309
*
310
        LDU  #XSTS
311
        STU  XSTATE
312
        LDA  #1
313
        STA  BLKNUM
314
*
315
** WRITE BYTE TO DISK
316
*
317
WRLOOP LDX #BUFFER
318
       LBSR XREAD
319
       LBCS ABORT
320
       LDX #BUFFER
321
       LDB #128
322
       STX  BUFPTR
323
       STB  BYTCNT
324
WRLP1  LDX BUFPTR
325
       LDA ,X+
326
       STX BUFPTR
327
       TST  TEXTFL
328
       BEQ  WRLP2
329
       CMPA #HT
330
       BNE WRLP3
331
WRLP4  LDA  #$20
332
       LDX #SYSFCB
333
       JSR FMS
334
       INC LINECT
335
       LDA LINECT
336
       ANDA #$07
337
       BNE WRLP4
338
       BRA WRLP5
339
WRLP3  CMPA #LF
340
       BNE  WRLP2
341
       LDX  #SYSFCB
342
       JSR  FMS
343
       BNE DSKERR
344
       LDA  #CR
345
       CLR LINECT
346
       DEC LINECT
347
WRLP2  LDX #SYSFCB
348
       JSR >FMS
349
       BNE DSKERR
350
       INC LINECT
351
WRLP5  DEC  BYTCNT
352
       BNE  WRLP1
353
       LBSR XACK
354
       BRA  WRLOOP
355
*
356
** FINISHED LOAD
357
*
358
ABORT  LDX #ENDMSG
359
       JSR PSTRNG
360
       LBSR XACK
361
*
362
*
363
** CLOSE FILE
364
*
365
CLOSE  LDA #$04
366
       LDX #SYSFCB
367
       STA ,X
368
       JSR >FMS
369
       BEQ EXIT
370
*
371
** ERROR IN CLOSING
372
*
373
DSKERR LDA $01,X
374
FMSERR JSR >RPTERR
375
       JSR >FMSCLS
376
EXIT   JMP >WARMS
377
*
378
** MESSAGES
379
*
380
ENDMSG FCC "FILE LOADED"
381
       FCB $04
382
TXTMSG FCB $0D,$0A
383
       FCC "TEXT FILE"
384
       FCB $04
385
       END START

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.