Classic Computer Magazine Archive PROGRAM LISTING: 84-07/SEQDOS.ASM


1000         *=      $0600         ; program origin 
1010 ; 
1020 ; SYMBOL EQUATES 
1030 ; 
1040 EOL     =       $9B           ; end-of-line symbol 
1050 ; 
1060 ; ADDRESS EQUATES 
1070 ; 
1080 WARMST  =       $08           ; warm start flag 
1090 BOOTQ   =       $09           ; boot flag 
1100 ICAX1Z  =       $2A           ; direction byte 
1110 ICAX6Z  =       $2F           ; put byte storage 
1120 BPTR    =       $3D           ; buffer pointer 
1130 FTYPE   =       $3E           ; input/output flag 
1140 DCB     =       $0300         ; data control block 
1150 DCOMND  =       $0302         ; command byte 
1160 DAUX1   =       $030A         ; sector LSB 
1170 DAUX2   =       $030B         ; sector MSB 
1180 HATABS  =       $031A         ; handler table 
1190 CASBUF  =       $0400         ; cassette buffer 
1200 DSKINV  =       $E453         ; disk interface routine 
1210 ; 
1220 ; HEADER BYTES 
1230 ; 
1240 PST     .BYTE   0             ; boot header 
1250         .BYTE   2             ; sector count 
1260         .WORD   PST           ; program start 
1270         .WORD   PINIT         ; program init 
1280         CLC                   ; good boot 
1290         RTS                   ; return 
1300 ; 
1310 ; BASIC ENTRY 
1320 ; 
1330         PLA                   ; pull arg count 
1340 ; 
1350 ; CASSETTE HANDLER SWAP 
1360 ; 
1370 PINIT   LDA     #$43          ; look for "C: 
1380         LDX     #0            ; first handler 
1390         STX     CHKSTA+1      ; clear I/O state 
1400 FINHND  CMP     HATABS,X      ; check handler 
1410         BEQ     FNDHND        ; if found 
1420 ; 
1430         INX                   ; otherwise, next handler 
1440         INX 
1450         INX 
1460         BNE     FINHND 
1470 ; 
1480 FNDHND  LDA     #NEWTAB&$FF   ; set new table 
1490         STA     HATABS+1,X 
1500         LDA     #NEWTAB/256   ; also set MSB 
1510         STA     HATABS+2,X 
1520         RTS                   ; return 
1530 ; 
1540 ; OPEN FILE HANDLER 
1550 ; 
1560 OPNFIL  LDA     ICAX1Z        ; check direction 
1570         LDX     #$03          ; if new direction, 
1580         LDY     #0            ;   start at sector #3 
1590 CHKSTA  CMP     #0            ; check against old 
1600         BNE     RESET         ;  direction 
1610 ; 
1620 SAUX1   LDX     #0            ; old sector number 
1630 SAUX2   LDY     #0 
1640         INX                   ; increment sector 
1650         BNE     RESET 
1660 ; 
1670         INY 
1680 ; 
1690 RESET   STX     CASBUF+$7E    ; store sector number 
1700         STY     CASBUF+$7D 
1710         STA     CHKSTA+1      ; save direction state 
1720         ORA     #$F7          ; =$FF for write 
1730         STA     BPTR          ; save for new pointer 
1740         LDA     #$7D          ; starting length 
1750         STA     BYTCNT+1      ; save length 
1760         LDY     #1            ; good status 
1770         RTS                   ; return 
1780 ; 
1790 ; CLOSE FILE HANDLER 
1800 ; 
1810 CLSFIL  BIT     FTYPE         ; check I/O type 
1820         BPL     DUMMY         ; do nothing if read 
1830 ; 
1840         LDA     BPTR          ; prepare for final 
1850         ORA     #$80          ;  sector output 
1860         TAX 
1870         BNE     INCBYT        ; output last sector 
1880 ; 
1890 ; GET/PUT BYTE HANDLER 
1900 ; 
1910 GETBYT  LDY     #$40          ; input direction 
1920         BNE     SAVDIR 
1930 ; 
1940 PUTBYT  LDY     #$80          ; output direction 
1950         STA     ICAX6Z        ; save output byte 
1960 SAVDIR  STY     FTYPE         ; save direction 
1970         LDX     BPTR          ; get pointer 
1980 INCBYT  INX                   ; increment 
1990         STX     BPTR          ; save pointer 
2000 BYTCNT  CPX     #$7D          ; check for sector end 
2010         BCS     ENDSEC        ; perform I/O 
2020 ; 
2030         LDA     ICAX6Z        ; get output byte 
2040         BIT     FTYPE         ; if output, store 
2050         BMI     STORE 
2060 ; 
2070         LDA     CASBUF,X      ; otherwise, read 
2080 STORE   STA     CASBUF,X      ;  and store 
2090 DUMMY   LDY     #1            ; good status 
2100         RTS                   ; return 
2110 ; 
2120 ; FORMAT DCB 
2130 ; 
2140 FMTBLK  .BYTE   $31,$01       ; format block for init 
2150         .BYTE   $21,$00 
2160         .WORD   CASBUF 
2170 ; 
2180         *=      $680          ; allow for flag bytes 
2190 ;                             ;  from init routine 
2200 ENDSEC  LDA     CASBUF+$7D    ; get sector 
2210         AND     #$03 
2220         STA     DAUX2         ; save to DCB sector 
2230         TAY                   ; save for later 
2240         LDA     CASBUF+$7E    ; also do MSB 
2250         STA     DAUX1 
2260         TAX                   ; save for later 
2270         ORA     DAUX2         ; check for last 
2280         BEQ     ERROR         ; if so, end-of-file 
2290 ; 
2300         STX     SAUX1+1       ; save sector for open 
2310         STY     SAUX2+1 
2320         LDX     #$05          ; set up DCB 
2330 SETDCB  LDA     RDSEC,X 
2340         STA     DCB,X 
2350         DEX 
2360         BPL     SETDCB 
2370 ; 
2380         BIT     FTYPE         ; check for write 
2390         BPL     GODISK        ; if not, go ahead 
2400 ; 
2410         LDA     #$57          ; change command to write 
2420         STA     DCOMND 
2430         LDA     BPTR          ; check for last sector 
2440         BPL     STBPTR 
2450 ; 
2460         LDX     #$FF          ; clear sector 
2470         STX     CASBUF+$7D 
2480         STX     CASBUF+$7E 
2490 STBPTR  STA     CASBUF+$7F    ; save byte count 
2500         INC     CASBUF+$7E    ; increment sector link 
2510         BNE     GODISK 
2520 ; 
2530         INC     CASBUF+$7D 
2540 GODISK  JSR     DSKINV        ; perform I/O 
2550         BPL     SETSEC 
2560 ; 
2570 ERROR   LDY     #$88          ; error or end-of-file 
2580         RTS 
2590 ; 
2600 SETSEC  LDA     CASBUF+$7F    ; get byte count 
2610         AND     #$7F 
2620         STA     BYTCNT+1      ; save 
2630         LDX     #$FF          ; set for first byte
2640         BNE     INCBYT        ; return 
2650 ; 
2660 ; READ SECTOR DCB 
2670 ; 
2680 RDSEC   .BYTE   $31,$01       ; DCB for read sector 
2690         .BYTE   $52,$00 
2700         .WORD   CASBUF 
2710 ; 
2720 ; HANDLER TABLE 
2730 ; 
2740 NEWTAB  .WORD   OPNFIL-1      ; open handler 
2750         .WORD   CLSFIL-1      ; close handler 
2760         .WORD   GETBYT-1      ; get byte handler 
2770         .WORD   PUTBYT-1      ; put byte handler 
2780         .WORD   DUMMY-1       ; rest dummy 
2790         .WORD   DUMMY-1 
2800         JMP     DUMMY 
2810 ; 
2820 ; FORMAT DISK 
2830 ; 
2840         PLA                   ; for BASIC call 
2850         LDX     #$05          ; move format block 
2860 MVFMT   LDA     FMTBLK,X      ;  to DCB 
2870         STA     DCB,X 
2880         DEX 
2890         BPL     MVFMT 
2900 ; 
2910         JMP     DSKINV        ; format and return 
2920 ; 
2930         .END 



Back to previous page