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

Subversion Repositories System09

[/] [System09/] [trunk/] [src/] [sys09bug/] [sys09nul.asm] - Blame information for rev 211

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

Line No. Rev Author Line
1 133 davidgb
*
2
** SYS09BUG MONITOR EXTENSIONS
3
*
4
* FOR GENERIC SYS09BUG
5
* WITH I/O MAPPED AT $XE000
6
* AND ROM MAPPED AT $XF000
7
* (JUST A COPY OF SYS09IDE.ASM
8
* TO FILL THE MEMORY AT F000)
9
*
10
*
11
 PAGE
12
*
13
***************************************************
14
* Serial PROM register
15
***************************************************
16
*
17
** CONFIGURATION PROM DEFINITIONS
18
*
19
PROMREG EQU MONIO+$C0
20
PCLKHI  EQU $01     Toggle PROM Clock High
21
PCLKLO  EQU $00     Toggle PROM Clock Low
22
PRSTHI  EQU $02     Toggle PROM Reset High
23
PRSTLO  EQU $00     Toggle PROM Reset Low
24
SYNCHI  EQU $AA55   Synch Pattern High Word
25
SYNCLO  EQU $FF00   Synch Pattern Low Word
26
*
27
*
28
***************************************************
29
*   START OF ROM                                  *
30
***************************************************
31
*
32
MONITV EQU MONROM+0  FDB MONITOR
33
NXTCMV EQU MONROM+2  FDB NEXTCMD
34
INCHV  EQU MONROM+4  FDB INCH
35
INCHEV EQU MONROM+6  FDB INCHE
36
INCHKV EQU MONROM+8  FDB INCHEK
37
OUTCHV EQU MONROM+10 FDB OUTCH
38
PDATAV EQU MONROM+12 FDB PDATA
39
PCRLFV EQU MONROM+14 FDB PCRLF
40
PSTRGV EQU MONROM+16 FDB PSTRNG
41
LRAV   EQU MONROM+18 FDB LRA
42
*
43
* Condition code flags
44
*
45
CFLAG   EQU $01     CARRY FLAG
46
VFLAG   EQU $02     OVERFLOW FLAG
47
ZFLAG   EQU $04     ZERO FLAG
48
NFLAG   EQU $08     NEGATIVE FLAG
49
IFLAG   EQU $10     IRQ MASK CC
50
HFLAG   EQU $20     HALF CARRY
51
FFLAG   EQU $40     FIRQ MASK CC
52
EFLAG   EQU $80     ENTIRE FLAG
53
*
54
* Serial Port
55
*
56
ACIAC1  EQU ACIAS
57
ACIAD1  EQU ACIAS+1
58
DELCON  EQU 1250    Delay (Processor clock in MHz * 50)
59
*
60
* XMODEM Control characters
61
*
62
SOH     EQU $01
63
EOT     EQU $04
64
ACK     EQU $06
65
NAK     EQU $15
66
CAN     EQU $18
67
*
68
* Some Disk Constants
69
*
70
RMAXTRK EQU 256
71
RMAXSEC EQU 255
72
RTOTSEC EQU RMAXTRK*RMAXSEC-RMAXSEC
73
*
74
* RAM SPACE
75
*
76
* PUT THIS DOWN THE BOTTOM OF MEMORY
77
*
78
        ORG  $0100
79
DRVNUM  RMB 1
80
TRACK   RMB 1
81
SECTOR  RMB 1
82
CHKSUM  RMB 1
83
BLKNUM  RMB 1 Xmodem block number
84
BYTCNT  RMB 1 Xmodem byte count
85
XSTATE  RMB 2 Xmodem State Vector
86
DELCNT  RMB 3  $00,$00,$00 Xmodem Poll timer
87
MAXTRK  RMB 1
88
MAXSEC  RMB 1
89
        ORG  $0200
90
*
91
* SECTOR BUFFER
92
*
93
BUFFER  RMB  256
94
*
95
****************************************
96
*
97
* START OF EXTENSION COMMANDS
98
*
99
****************************************
100
*
101
        ORG MONEXT
102
        FDB NEXTEXT   Jump to next extended command
103
*
104
***** NEXTCMD *****
105
*
106
NEXTEXT JSR [INCHEV]  GET ONE CHAR. FROM TERMINAL
107
        ANDA #$7F STRIP PARITY FROM CHAR.
108
        TFR  A,B
109
        LDA  #$20
110
        JSR [OUTCHV] PRNT SPACE
111
        CMPB #$60
112
        BLE NXTEX0
113
        SUBB #$20
114
*
115
***** DO TABLE LOOKUP *****
116
*   FOR COMMAND FUNCTIONS
117
*
118
NXTEX0  LDX #EXTTAB    POINT TO JUMP TABLE
119
NXTEX1  CMPB ,X+       DOES COMMAND MATCH TABLE ENTRY ?
120
        BEQ  JMPEXT    BRANCH IF MATCH FOUND
121
        LEAX 2,X       POINT TO NEXT ENTRY IN TABLE
122
        CMPX #EXTEND   REACHED END OF TABLE YET ?
123
        BNE  NXTEX1    IF NOT END, CHECK NEXT ENTRY
124
        LDX  #MSGWHAT  POINT TO MSG "WHAT?"
125
        LBRA PDATA1    PRINT MSG AND RETURN
126
JMPEXT  JMP  [,X]      JUMP TO COMMAND ROUTINE
127
*
128
* EXTENDED COMMAND JUMP TABLE
129
*
130
EXTTAB EQU *
131
       FCC 'B'   BOOT FLEX
132
       FDB UBSUB
133
       FCC 'F'   FORMAT IDE DISK
134
       FDB UFSUB
135
       FCC 'X'   XMODEM ROM DISK UPLOAD
136
       FDB UXSUB
137
*
138
EXTEND EQU *
139
*
140
MSGWHAT FCC "WHAT ?"
141
        FCB $0A,$0D,$04
142
*
143
* GO TO FLEX RESIDENT IN MEMORY
144
*
145
UBSUB   LDX #$CD00
146
        STX 10,U
147
        TFR  U,S
148
        RTI
149
*
150
* recieve char from remote drive.
151
* timeout if no response for approx 1s.
152
* Entry: no parameters
153
* Exit:  (A) = recieved char, (C)=1 if valid char, (C)=0 if timeout.
154
*
155
RCHAR   PSHS    X,Y
156
*
157
        LDX     #1000         1000x inner loop
158
RCHAR1  LDY     #DELCON       delay constant for inner loop (approx 1ms).
159
RCHAR2  LDA     ACIAC1        test for recieved char
160
        ASRA
161
        BCS     RCHAR3        get character
162
        LEAY    -1,Y          else, continue to count delay
163
        BNE     RCHAR2
164
        LEAX    -1,X
165
        BNE     RCHAR1
166
        PULS    X,Y,PC        return with error if timed out
167
*
168
RCHAR3  LDA     ACIAD1        return data (carry bit still set)
169
        PULS    X,Y,PC
170
*
171
*
172
* transmit char to remote drive.
173
* timeout if no response for approx 1s. (allows for use of hardware flow control)
174
* Entry: (A) = char to transmit
175
* Exit:  (A) = recieved char, (C)=1 if valid char, (C)=0 if timeout.
176
*
177
SCHAR   PSHS    X,Y
178
        PSHS    A
179
*
180
        LDX     #1000         1000x inner loop
181
SCHAR1  LDY     #DELCON       delay constant for inner loop (approx 1ms).
182
SCHAR2  LDA     ACIAC1        test for space in transmit FIFO
183
        ASRA
184
        ASRA
185
        BCS     SCHAR3        send character
186
        LEAY    -1,Y          else, continue to count delay
187
        BNE     SCHAR2
188
        LEAX    -1,X
189
        BNE     SCHAR1
190
        PULS    A
191
        PULS    X,Y,PC        return with error if timed out
192
*
193
SCHAR3  PULS    A
194
        STA     ACIAD1        send data (carry bit still set)
195
        PULS    X,Y,PC
196
*
197
** 'UF' Format IDE Drive to FLEX standard.
198
*
199
DISFOS  FCB $0A,$0D
200
        FCC 'Formating IDE disk... '
201
        FCB $0A,$0D
202
        FCC 'Drive Number ?'
203
        FCB 4
204
MESS6   FCB $0A,$0D,4
205
        FCC 'IDE drive not allocated! '
206
        FCB 4
207
UFMSG1  FCB $0A,$0D
208
        FCC 'Format Complete'
209
        FCB 4
210
VOLMSG  FCC 'IDEDISK '
211
        FCB 4
212
*
213
UFSUB   JSR  INITDR
214
        LDX #DISFOS
215
        JSR PDATA1
216
UFSUB1  LBSR RCHAR
217
        BCC  UFSUB1
218
        LBSR SCHAR
219
        CMPA #'0'
220
        LBLO UFEXIT
221
        CMPA #'3'
222
        LBHI  UFEXIT
223
        SUBA #'0'
224
        TFR  A,B
225
        STB DRVNUM
226
        LDX #DRVNUM-3
227
        JSR DRVSEL
228
*
229
* set up free chain
230
*
231
        LDX #BUFFER clear out buffer
232
        CLRA
233
        CLRB
234
DFL1    STA 0,X+
235
        DECB
236
        BNE DFL1
237
*
238
        CLR TRACK
239
        LDA #1
240
        STA SECTOR
241
DFL2    LDX #BUFFER
242
        LDA TRACK
243
        STA 0,X
244
        LDA SECTOR
245
        INCA
246
        CMPA #RMAXSEC+1 last sector on track?
247
        BNE DFL3
248
        INC 0,X
249
        LDA #1
250
DFL3    STA 1,X
251
        LDA TRACK
252
        LDB SECTOR
253
        JSR WRITSC
254
        INC SECTOR
255
        LDA SECTOR
256
        CMPA #RMAXSEC+1
257
        BNE DFL2
258
        LDA #1
259
        STA  SECTOR
260
        INC TRACK
261
        LDA TRACK
262
        CMPA #RMAXTRK
263
        BNE DFL2
264
* break free chain at last track/sector
265
        LDX  #BUFFER
266
        LDA  #RMAXTRK-1
267
        LDB  #RMAXSEC
268
        JSR  READSC
269
        LDX  #BUFFER
270
        CLR  0,X
271
        CLR  1,X
272
        LDA  #RMAXTRK-1
273
        LDB  #RMAXSEC
274
        JSR  WRITSC
275
* set up sector structure, SIR, directory etc
276
        LDX  #BUFFER
277
        CLRA
278
        LDB  #RMAXSEC
279
        JSR  READSC
280
        LDX  #BUFFER
281
        CLR  0,X break end of directory chain
282
        CLR  1,X
283
        CLRA
284
        LDB  #RMAXSEC
285
        JSR  WRITSC
286
*
287
        LDX  #BUFFER
288
        CLRA
289
        LDB  #3 set up SIR
290
        JSR  READSC
291
        LDX  #BUFFER
292
        CLR  0,X break forward link
293
        CLR  1,X
294
*
295
        PSHS Y
296
        LDY  #VOLMSG
297
        LDB  #16
298
DFL4    LDA  ,Y+
299
        STA  B,X
300
        INCB
301
        CMPB #24
302
        BNE  DFL4
303
        PULS Y
304
*
305
        CLRA
306
        LDB  DRVNUM volume number
307
        STD  27,X
308
*
309
        LDD  #$0101 first trk/sec  01-01
310
        STD  29,X
311
        LDA  #RMAXTRK-1
312
        LDB  #RMAXSEC
313
        STD  31,X
314
        STD  38,X
315
        LDD  #RTOTSEC total DATA sectors (2912-14)
316
        STD  33,X
317
*
318
        LDA #01 month   set default creation date (SYS09's birthday!)
319
        STA 35,X
320
        LDA #07 day
321
        STA 36,X
322
        LDA #07 year
323
        STA 37,X
324
*
325
RF3     CLRA
326
        LDB  #3
327
        JSR  WRITSC
328
*
329
* Not sure what this is about
330
* put bootstrap on track 0 sector 1
331
*
332
*        LDX #BUFFER
333
*        CLRA
334
*        LDB #1
335
*        JSR READSC
336
*        LDX #BUFFER
337
*        LDA #$AA set the init flag
338
*        STA 0,X
339
*        LDA  #$55
340
*        STA 1,X
341
*        CLRA
342
*        LDB #1
343
*        JSR WRITSC
344
*
345
*  Write Boot sector
346
*
347
        LDX  #BOOT
348
        CLRA         TRACK 0
349
        LDB  #$01    SECTOR 1
350
        STA  TRACK
351
        STB  SECTOR
352
        LBSR WRITSC
353
*
354
UFEXIT  LDX #UFMSG1
355
        JMP PDATA1
356
*
357
* ACIA INPUT TEST
358
*
359
INTEST  LDA ACIAC1
360
        BITA #$01
361
        RTS
362
*
363
* RESET ACIA
364
*
365
ACIRST  LDA #$03 master reset
366
        STA  ACIAC1
367
        LDA #$11
368
        STA ACIAC1
369
        RTS
370
*
371
* ACIA INPUT
372
*
373
INTER   LDA  #16
374
        STA  DELCNT+0
375
        CLR  DELCNT+1
376
        CLR  DELCNT+2
377
INTER0  LDA  ACIAC1
378
        BITA #$01
379
        BNE  INTER1
380
        BITA #$78
381
        BEQ  INTER2
382
        BSR  ACIRST
383
        BRA  INTER
384
*
385
INTER1  LDA  ACIAD1
386
        ANDCC #$FF-VFLAG
387
        RTS
388
*
389
INTER2  DEC  DELCNT+2
390
        BNE  INTER0
391
        DEC  DELCNT+1
392
        BNE  INTER0
393
        DEC  DELCNT+0
394
        BNE  INTER0
395
        CLRA
396
        ORCC #VFLAG
397
        RTS
398
*
399
* ACIA OUTPUT
400
*
401
OUTTER  PSHS A
402
*
403
OUTTE1  LDA ACIAC1
404
        BITA #$02
405
        BNE  OUTTE2
406
        BITA #$78
407
        BEQ  OUTTE1
408
        BSR  ACIRST
409
        BRA  OUTTE1
410
*
411
OUTTE2  PULS A
412
        STA ACIAD1
413
        RTS
414
*
415
* Print Data
416
*
417
PDATA0  BSR  OUTTER
418
PDATA1  LDA  ,X+
419
        CMPA #$04
420
        BNE  PDATA0
421
        RTS
422
*
423
*
424
** 'UX' Xmodem IDE Disk upload
425
*
426
UXMES0  FCB $0D,$0A
427
        FCC 'Xmodem IDE Disk Upload'
428
        FCB 4
429
UXMES1  FCB $0D,$0A
430
        FCC 'Upload Complete'
431
        FCB 4
432
UXMES2  FCB $0D,$0A
433
        FCC 'Upload Error'
434
        FCB 4
435
UXMSG3  FCB $0D,$0A
436
        FCC 'Drive Number :'
437
        FCB 4
438
UXMSG4  FCB $0D,$0A
439
        FCC 'Are You Sure ? (Y/N)'
440
        FCB 4
441
*
442
* Print Banner
443
*
444
UXSUB   LDX #UXMES0
445
        LBSR PDATA1
446
*
447
* Prompt for Disk drive number (0 to 3)
448
*
449
        LDX #UXMSG3
450
        LBSR PDATA1
451
UXSUB1  LBSR INTER
452
        BVS  UXSUB1
453
        LBSR OUTTER
454
        CMPA #'0
455
        LBLO UXEXIT
456
        CMPA #'3
457
        LBHI UXEXIT
458
        SUBA #'0
459
        STA  DRVNUM
460
*
461
* Report selected drive
462
*
463
        LDX #UXMSG3
464
        LBSR PDATA1
465
        LDA  DRVNUM
466
        ADDA #'0
467
        LBSR OUTTER
468
*
469
* Ask for confirmation (Y/N)
470
*
471
        LDX #UXMSG4
472
        LBSR PDATA1
473
UXSUB2  LBSR INTER
474
        BVS  UXSUB2
475
        LBSR OUTTER
476
        ANDA #$5F
477
        CMPA #'N
478
        LBEQ UXEXIT
479
        CMPA #'Y
480
        BNE  UXSUB
481
*
482
* We have confirmation ... now load the disk image
483
*
484
        LBSR INITDR
485
        LDU  #XSTST
486
        STU  XSTATE
487
        LDA  #1
488
        STA  BLKNUM
489
*
490
* Sector1
491
*
492
        LDX  #BUFFER
493
*
494
        CLRA         TRACK 0
495
        LDB  #$01    SECTOR 1
496
        STA  TRACK
497
        STB  SECTOR
498
*
499
        LBSR XREAD
500
        LBCS UXERR
501
        LBSR XACK
502
        LBSR XREAD
503
        LBCS UXERR
504
*
505
        LDX  #BUFFER
506
        LDA  TRACK
507
        LDB  SECTOR
508
        LBSR WRITSC
509
        LBSR XACK
510
*
511
* Sector 2
512
*
513
        LDX  #BUFFER
514
*
515
        LDA  TRACK
516
        LDB  SECTOR
517
        INCB
518
        STA  TRACK
519
        STB  SECTOR
520
*
521
        LBSR XREAD
522
        LBCS UXERR
523
        LBSR XACK
524
        LBSR XREAD
525
        LBCS UXERR
526
*
527
        LDX  #BUFFER
528
        LDA  TRACK
529
        LDB  SECTOR
530
        LBSR WRITSC
531
*
532
        LBSR XACK
533
*
534
* Sector 3 - SIR
535
*
536
        LDX  #BUFFER
537
*
538
        LDA  TRACK
539
        LDB  SECTOR
540
        INCB
541
        STA  TRACK
542
        STB  SECTOR
543
*
544
        LBSR XREAD
545
        LBCS UXERR
546
        LBSR XACK
547
        LBSR XREAD
548
        LBCS UXERR
549
*
550
        LDX  #BUFFER
551
        LDA  38,X
552
        INCA
553
        STA  MAXTRK
554
        LDB  39,X
555
        INCB
556
        STB  MAXSEC
557
        LDA  TRACK
558
        LDB  SECTOR
559
        LBSR WRITSC
560
*
561
        LBSR XACK
562
*
563
* Sector 4 to Last Track & Sector
564
*
565
*
566
        LDA  TRACK
567
        LDB  SECTOR
568
        INCB
569
*
570
UXLOOP  LDX  #BUFFER
571
        STA  TRACK
572
        STB  SECTOR
573
*
574
        LBSR XREAD
575
        LBCS UXERR
576
        LBSR XACK
577
        LBSR XREAD
578
        LBCS UXERR
579
*
580
        LDX  #BUFFER
581
        LDA  TRACK
582
        LDB  SECTOR
583
        LBSR WRITSC
584
        LBSR XACK
585
*
586
        LDA  TRACK
587
        LDB  SECTOR
588
        INCB
589
        CMPB MAXSEC
590
        BNE  UXLOOP
591
        LDB  #1
592
        INCA
593
        CMPA MAXTRK
594
        BNE  UXLOOP
595
*
596
*
597
*  Write Boot sector
598
*
599
        LDX  #BOOT
600
        CLRA         TRACK 0
601
        LDB  #$01    SECTOR 1
602
        STA  TRACK
603
        STB  SECTOR
604
        LBSR WRITSC
605
*
606
UXEXIT  LDX  #UXMES1
607
        JMP  PDATA1
608
*
609
UXERR   LDX  #UXMES2
610
        LBRA PDATA1
611
*
612
* Get a Byte using XModem protocol
613
* Carry clear => no errors
614
* Carry set   => errors
615
*
616
XREAD   PSHS U
617
        LDU  XSTATE
618
*
619
XBYTE0  LBSR INTER
620
        BVC  XBYTE1
621
        LDA  #NAK
622
        LBSR OUTTER
623
        LDU  #XSTST
624
        BRA  XBYTE0
625
*
626
XBYTE1  JSR  ,U
627
        BNE  XBYTE0
628
        STU  XSTATE
629
        PULS U,PC
630
*
631
* START - LOOK FOR SOH (START OF HEADER) = $01
632
*
633
XSTST   CMPA #SOH
634
        BNE  XSTST1
635
        LDU  #XSTBL
636
        ANDCC #$FF-CFLAG-ZFLAG No abort, no valid data (no exit)
637
        RTS
638
*
639
XSTST1  CMPA #EOT
640
        BNE  XSTST2
641
        LDA  #ACK
642
        LBSR OUTTER
643
        ORCC  #CFLAG+ZFLAG  Set (c)=1 abort & exit
644
        RTS
645
*
646
XSTST2  CMPA #CAN
647
        BNE  XSTST3
648
        ORCC  #CFLAG+ZFLAG  Set (c)=1 abort & exit
649
        RTS
650
*
651
XSTST3  ANDCC #$FF-CFLAG-ZFLAG
652
        RTS
653
*
654
* Got SOH
655
* Now get block number
656
*
657
XSTBL   CMPA BLKNUM
658
        BNE  XSTBLE
659
        LDU  #XSTCOM
660
        ANDCC #$FF-CFLAG-ZFLAG No abort, No valid data (no exit)
661
        RTS
662
*
663
* Error in block number
664
*
665
XSTBLE  LDA  #NAK
666
        LBSR OUTTER
667
        LDU  #XSTST
668
        ANDCC #$FF-CFLAG-ZFLAG No abort, No valid data (no exit)
669
        RTS
670
*
671
* Get complement of block number
672
*
673
XSTCOM  COMA
674
        CMPA BLKNUM
675
        BNE  XSTBLE
676
        CLR  CHKSUM
677
        LDA  #128
678
        STA  BYTCNT
679
        LDU  #XSTDA
680
        ANDCC #$FF-CFLAG-ZFLAG No abort, No valid data (no exit)
681
        RTS
682
*
683
* Get data bytes
684
*
685
XSTDA   PSHS A
686
        ADDA CHKSUM
687
        STA  CHKSUM
688
        PULS A
689
        DEC  BYTCNT
690
        BNE  XSTDA1
691
        LDU  #XSTCK
692
XSTDA1  STA  ,X+
693
        ANDCC #$FF-CFLAG-ZFLAG No abort, no valid data (no exit)
694
        RTS
695
*
696
* Byte count reached zero
697
* Check checksum byte
698
*
699
XSTCK   CMPA CHKSUM
700
        BNE  XSTCK1 retry if wrong checksum
701
*
702
* Checksum OK ...
703
* increment block number
704
* Don't send ACK until data written to CF
705
*
706
        INC  BLKNUM
707
        LDU  #XSTST
708
        ANDCC #$FF-CFLAG No abort
709
        ORCC #ZFLAG      Valid data (exit)
710
        RTS
711
*
712
* Checksum Error detected ...
713
* Reset Sector counter in ACCB to last 128 byte boundary
714
* and send NAK
715
*
716
XSTCK1  PSHS B
717
        TFR  X,D
718
        DECB
719
        ANDB #128
720
        TFR  D,X
721
        PULS B
722
        LDA  #NAK
723
XSTCK2  LBSR OUTTER
724
        LDU  #XSTST
725
        ANDCC #$FF-CFLAG-ZFLAG No abort, no valid data (no exit)
726
        RTS
727
*
728
* Acknowledge Data Received
729
*
730
XACK    PSHS A
731
        LDA  #ACK
732
        LBSR OUTTER
733
        PULS A,PC
734
*
735
*
736
** FLEX 9 IDE DISK DRIVERS
737
*
738
* FOR SYS09BUG 1.2 ON THE XSA-3S1000
739
* WITH I/O MAPPED AT $XE000
740
* AND ROM MAPPED AT $XF000
741
*
742
*
743
* INITIALIZE CF CARD FOR 8 BIT LBA MODE
744
*
745
INITDR LDD #AUXRESET
746
       STD CF_AUX
747
       LDD #AUXRSTREL
748
       STD CF_AUX
749
       LDD  #HEADLBA
750
       STD  CF_HEAD
751
       LBRA WTRDY
752
*
753
* RESTORE DISK DRIVER (SEEK TRACK 00)
754
*
755
RESTR1 BSR   DRVSEL
756
       CLRA           ; Track 0
757
       LDB   #$01     ; Sector 1
758
*
759
* Seek track and sector
760
* A holds track number (0 - ??)
761
* B holds sector number (1 - ??)
762
* Sector numbers starts from 1
763
* subtract 1 to start from sector 0 on CF
764
*
765
SEEKTS PSHS A
766
       CLRA
767
       DECB
768
       STD  CF_SECNUM
769
       LDB ,S
770
       STD  CF_CYLLO
771
       LDB  DRVNUM
772
       STD  CF_CYLHI
773
       LDB  #$01
774
       STD  CF_SECCNT
775
       CLRB
776
       PULS A,PC
777
*
778
* READ SECTORS FROM CF
779
*
780
*
781
READSC BSR  SEEKTS
782
       LDD  #CMDREAD ; IDE READ MULTIPLE
783
       STD  CF_COMAND
784
       LBSR  WTRDY
785
*
786
* READ LOOP
787
*
788
       PSHS Y
789
       LDY #256
790
RDLP1  LBSR  WTDRQ
791
       LDD  CF_DATA
792
       STB  ,X+
793
       LEAY -1,Y
794
       BNE  RDLP1
795
       PULS Y
796
*
797
       LBSR  WTRDY
798
       CLRB
799
       RTS
800
*
801
* WRITE SECTOR TO CF
802
*
803
WRITSC BSR  SEEKTS   ; SEEK TRACK & SECTOR
804
       LDD  #CMDWRITE ; IDE WRITE MULTIPLE
805
       STD  CF_COMAND
806
       LBSR  WTRDY
807
*
808
* WRITE LOOP
809
*
810
       PSHS Y
811
       LDY #256
812
       CLRA
813
WRTLP1 LBSR  WTDRQ
814
       LDB  ,X+
815
       STD  CF_DATA
816
       LEAY -1,Y
817
       BNE  WRTLP1
818
       PULS Y
819
*
820
       LBSR  WTRDY
821
       CLRB
822
       RTS
823
*
824
* DRIVE SELECT DISK DRIVER
825
*
826
DRVSEL LDA   3,X       GET DRIVE # FROM FCB
827
       CMPA  #3
828
       BLS   DRVS2     IF > 3, SET IT TO 0
829
       CLRA
830
DRVS2  STA   DRVNUM
831
       CLRB            ; SET Z, CLEAR C
832
       RTS
833
*
834
* CHECK DRIVE READY DISK DRIVER
835
*
836
CHKDRV LDA  3,X
837
       CLRB             ; CLEAR C, SET Z
838
       RTS
839
*******************************************************
840
*
841
* Bootstrap FLEX Loader
842
*
843
* SBUG1.8 loads the bootstap loader at $C000
844
* however the Flex adaption manual has the
845
* bootstrap loader residing at $C100
846
* Bootstrap Loader is position independent code
847
*
848
******************************************************
849
*
850
* Equates
851
*
852
BSSTACK EQU $C0FF
853
SCTBUF  EQU $C300
854
*
855
* Start of Utility
856
*
857
        ORG MONEXT+$0700
858
BOOT    BRA BLOAD0
859
        FCB 0,0,0
860
TRK     FCB 0        File start track
861
SCT     FCB 0        File start sector
862
DNS     FCB 0        Density Flag (not used)
863
TADR    FDB $C000    Transfer address
864
LADR    FDB 0        Load Address
865
DRNUM   FCB 0        Drive number 0
866
*
867
BLOAD0  LDS  #BSSTACK   Set up Bootstrap stack
868
        LDD  TRK,PCR    Set up start track and sector
869
        STD  SCTBUF
870
        LDY  #SCTBUF+256
871
*
872
* Perform actual file load
873
*
874
BLOAD1  BSR GETCH    Get acharcater
875
        CMPA #$02    Data record hearder ?
876
        BEQ  BLOAD2   Skip, is so
877
        CMPA #$16    Xfr address hearder ?
878
        BNE BLOAD1    Loop if neither
879
*
880
* Get transfer address
881
*
882
        BSR  GETCH
883
        STA  TADR,PCR
884
        BSR  GETCH
885
        STA  TADR+1,PCR
886
        BRA  BLOAD1
887
*
888
* Load data record
889
*
890
BLOAD2 BSR  GETCH  Get load address
891
       STA  LADR,PCR
892
       BSR  GETCH
893
       STA  LADR+1,PCR
894
       BSR  GETCH  Get Bytes count
895
       TFR  A,B
896
       TSTB
897
       BEQ  BLOAD1 Loop if count = 0
898
       LDX  LADR,PCR  Get load address
899
BLOAD3 PSHS B,X
900
       BSR  GETCH  Get data character
901
       PULS B,X
902
       STA  ,X+    Store at load address
903
       DECB
904
       BNE  BLOAD3  Loop until count = 0
905
       BRA  BLOAD1
906
*
907
* Get Character routine
908
* Reads a sector if needed
909
*
910
GETCH  CMPY #SCTBUF+256 out of data ?
911
       BNE  GETCH4      Go read Character if not
912
GETCH2 LDX  #SCTBUF     Point to buffer
913
       LDD  0,X         Get forward Link
914
       BEQ  GOFLEX      if zero, file is loaded
915
       BSR  READ        Read next sector
916
       BNE  BOOT        start over if error
917
       LDY  #SCTBUF+4   Point past link
918
GETCH4 LDA  ,Y+         Else, get a character
919
       RTS
920
*
921
* File is loaded, Jump to it
922
*
923
GOFLEX JMP  [TADR,PCR]      Jump to transfer address
924
 
925
*
926
** FLEX 9 IDE DISK DRIVERS
927
*
928
* Seek track and sector
929
* A holds track number (0 - ??)
930
* B holds sector number (1 - ??)
931
* Sector numbers starts from 1
932
* subtract 1 to start from sector 0 on CF
933
*
934
SEEK   PSHS A
935
       CLRA
936
       DECB
937
       STD  CF_SECNUM
938
       LDB  ,S
939
       STD  CF_CYLLO
940
       LDB  DRNUM,PCR
941
       STD  CF_CYLHI
942
       LDB  #$01
943
       STD  CF_SECCNT
944
       CLRB
945
       PULS A,PC
946
*
947
* READ SECTORS FROM CF
948
*
949
*
950
READ   BSR  SEEK
951
       LDD  #CMDREAD ; IDE READ MULTIPLE
952
       STD  CF_COMAND
953
       BSR  WTRDY
954
*
955
* READ LOOP
956
*
957
       PSHS Y
958
       LDY #256
959
READ1  BSR  WTDRQ
960
       LDD  CF_DATA
961
       STB  ,X+
962
       LEAY -1,Y
963
       BNE  READ1
964
       PULS Y
965
*
966
       BSR  WTRDY
967
       CLRB
968
       RTS
969
*
970
* WAIT UNTIL READY
971
*
972
WTRDY   LDD  CF_STATUS
973
        BITB #BUSY
974
        BNE  WTRDY
975
        LDD  CF_STATUS
976
        BITB #DRDY
977
        BEQ  WTRDY
978
        RTS
979
*
980
* WAIT FOR DATA REQUEST
981
*
982
WTDRQ   LDD  CF_STATUS
983
        BITB #DRQ
984
        BEQ  WTDRQ
985
        RTS
986
*
987
       END

powered by: WebSVN 2.1.0

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