Automatic Generated Disassembly of `dos1fdc'



; *** Symbol table  follows ***
 CLOCK      =$0000
 MTRTM      =$0001
 DRVST      =$0003
 STEPS      =$0005
 COW        =$0007
 WORK       =$0008
 DTRCK      =$000A
 DSECT      =$000B
 CSECT      =$000C
 STAB       =$000D
 DRIVE      =$0012
 TRACK      =$0013
 NEXTS      =$0014
 SECTR      =$0015
 BUFPT      =$0016
 HDRPNT     =$0018
 FTNUM      =$001A
 IP         =$001B
 IOB        =$001E
 JOBNUM     =$001F
 VIA_VB     =$0040
 VIA_DIN    =$0041
 VIA_VDDRB  =$0042
 VIA_T1LL   =$0044
 VIA_TIMER  =$0045
 VIA_ACR    =$004B
 VIA_PCR    =$004C
 VIA_IFR    =$004D
 VIA_IER    =$004E
 RIOT_DOUT  =$0080
 RIOT_EOUT  =$0081
 RIOT_PB    =$0082
 RIOT_DDRB  =$0083
 x8F        =$8F
 TICK       =$0400
 DELAY      =$0401
 CUTMT      =$0402
 JOBS       =$0403
 x0412      =$0412
 i0543      =$0543
 i104D      =$104D

; *** text follows ***

 *=$FC00


 FC00  A2 3F     RESET      LDX #$3F      
 FC02  9A                   TXS           
 FC03  D8                   CLD           
 FC04  A2 FF                LDX #$FF      
 FC06  86 42                STX VIA_VDDRB 
 FC08  8E 02 04             STX CUTMT     
 FC0B  A9 07                LDA #$07      
 FC0D  85 83                STA RIOT_DDRB 
 FC0F  86 1B                STX IP        
 FC11  A9 FC                LDA #$FC      
 FC13  85 4C                STA VIA_PCR   
 FC15  86 40                STX VIA_VB    
 FC17  A9 92                LDA #$92      
 FC19  85 4E                STA VIA_IER   
 FC1B  A9 01                LDA #$01      
 FC1D  85 4B                STA VIA_ACR   
 FC1F  4A                   LSR           
 FC20  85 44                STA VIA_T1LL  
 FC22  85 16                STA BUFPT     
 FC24  85 1E                STA IOB       
 FC26  A0 0E                LDY #$0E      
 FC28  99 03 04  iFC28      STA JOBS,Y    
 FC2B  99 05 00             STA STEPS,Y   
 FC2E  88                   DEY           
 FC2F  10 F7                BPL iFC28     
 FC31  A9 0F                LDA #$0F      
 FC33  8D 00 04             STA TICK      
 FC36  85 8F                STA x8F       
 FC38  A9 80                LDA #$80      
 FC3A  85 03                STA DRVST     
 FC3C  85 04                STA DRVST+1   
 FC3E  A9 32                LDA #$32      
 FC40  8D 01 04             STA DELAY     
 FC43  A9 04                LDA #$04      
 FC45  85 19                STA HDRPNT+1  
 FC47  A0 0E     START      LDY #$0E       ; load # of jobs
 FC49  58        L010       CLI            ; check if valid job, if so which drive
 FC4A  B9 03 04             LDA JOBS,Y    
 FC4D  10 28                BPL iFC77     
 FC4F  29 01                AND #$01      
 FC51  AA                   TAX           
 FC52  85 12                STA DRIVE     
 FC54  78                   SEI           
 FC55  A5 40                LDA VIA_VB     ; test motor status, turn on if not and set time for accel delay
 FC57  3D ED FF             AND ANDC,X    
 FC5A  F0 0E                BEQ iFC6A     
 FC5C  A5 40                LDA VIA_VB    
 FC5E  5D F1 FF             EOR ANDE,X    
 FC61  85 40                STA VIA_VB    
 FC63  A5 00                LDA CLOCK     
 FC65  6D 01 04             ADC DELAY     
 FC68  95 01                STA MTRTM,X   
 FC6A  B5 03     iFC6A      LDA DRVST,X    ; test motor speed
 FC6C  30 06                BMI iFC74     
 FC6E  A5 00                LDA CLOCK     
 FC70  95 01                STA MTRTM,X   
 FC72  B5 03                LDA DRVST,X   
 FC74  0A        iFC74      ASL            ; test head status, if not moving branch to QUE
 FC75  10 05                BPL QUE       
 FC77  88        iFC77      DEY            ; scan next job, if next job, branch to L010
 FC78  10 CF                BPL L010      
 FC7A  D0 CB     END        BNE START      ; branch to start

; motor is on and head is still, if head is on right track, start
; processing by branching to GOTU, otherwise move to closest
; needed track: x=drive#, y=job#

 FC7C  58        QUE        CLI            ; initialize to maximum distance + 1, and set y for max job#
 FC7D  A9 40                LDA #$40      
 FC7F  85 08                STA WORK      
 FC81  A0 0E                LDY #$0E      
 FC83  B9 03 04  iFC83      LDA JOBS,Y     ; init JOBS and HOBID by y offset
 FC86  84 1A                STY FTNUM     
 FC88  10 27                BPL iFCB1     
 FC8A  29 01                AND #$01      
 FC8C  C5 12                CMP DRIVE     
 FC8E  D0 21                BNE iFCB1     
 FC90  B5 03                LDA DRVST,X    ; test if on right track
 FC92  29 3F                AND #$3F      
 FC94  85 13                STA TRACK     
 FC96  F0 41                BEQ GOTU      
 FC98  38                   SEC           
 FC99  F9 12 04             SBC x0412,Y   
 FC9C  F0 3B                BEQ GOTU      
 FC9E  85 0A                STA DTRCK      ; find closest seek
 FCA0  10 05                BPL iFCA7     
 FCA2  18                   CLC           
 FCA3  49 FF                EOR #$FF      
 FCA5  69 01                ADC #$01      
 FCA7  C5 08     iFCA7      CMP WORK      
 FCA9  B0 06                BCS iFCB1     
 FCAB  85 08                STA WORK      
 FCAD  A5 0A                LDA DTRCK     
 FCAF  85 09                STA WORK+1    
 FCB1  88        iFCB1      DEY            ; decrement y loop for all jobs
 FCB2  10 CF                BPL iFC83     
 FCB4  A5 08                LDA WORK       ; set up seek to closest track
 FCB6  24 09                BIT WORK+1    
 FCB8  30 05                BMI iFCBF     
 FCBA  18                   CLC           
 FCBB  49 FF                EOR #$FF      
 FCBD  69 01                ADC #$01      
 FCBF  85 08     iFCBF      STA WORK      
 FCC1  0A                   ASL           
 FCC2  78                   SEI           
 FCC3  95 05                STA STEPS,X   
 FCC5  A9 40                LDA #$40      
 FCC7  15 03                ORA DRVST,X   
 FCC9  18                   CLC           
 FCCA  65 08                ADC WORK      
 FCCC  95 03                STA DRVST,X   
 FCCE  D0 AA     FIN        BNE END        ; loop to search table again


; sectors/tracks table: .byt 17,18,20,21

 FCD0  TAB1       .byte $11, $12, $14, $15                      ;qrtu


; .byt $f3

 FCD4  ANDA       .byte $F3                                     ;.


; TAB3+1 = tracks: .byt $fc, 31, 25,18


; *** Invalid reference FCD5 ignored.

 FCD5  TAB3       .byte $FC, $1F, $19, $12                      ;._yr


; head is on desired track, set drive switch, # of sectors and bit density


 FCD9  B5 03     GOTU       LDA DRVST,X    ; head is on desired track, set drive switch, # of sectors and bit density
 FCDB  30 F1                BMI FIN       
 FCDD  A2 04                LDX #$04       ; set up for check of track zone
 FCDF  B9 12 04             LDA x0412,Y   
 FCE2  DD D4 FC  L032       CMP ANDA,X     ; check for track zone
 FCE5  CA                   DEX           
 FCE6  B0 FA                BCS L032      
 FCE8  BD D0 FC             LDA TAB1,X     ; set # sectors/track by results of L032
 FCEB  85 15                STA SECTR     
 FCED  8A                   TXA           
 FCEE  0A                   ASL           
 FCEF  85 08                STA WORK      
 FCF1  A5 82                LDA RIOT_PB   
 FCF3  29 F8                AND #$F8      
 FCF5  05 08                ORA WORK      
 FCF7  05 12                ORA DRIVE     
 FCF9  85 82                STA RIOT_PB   
 FCFB  A6 12                LDX DRIVE     
 FCFD  B9 03 04             LDA JOBS,Y    
 FD00  29 70                AND #$70      

; Job Routine: execute: mode = 110 (E)
; check if execute, branch to EX if so, check if bump, branch to bump
; if so, jump seek

 FD02  C9 60     EXE        CMP #$60      
 FD04  F0 07                BEQ EX        
 FD06  C9 40                CMP #$40      
 FD08  F0 0C                BEQ BUMP      
 FD0A  4C 65 FE             JMP SEEK      
 FD0D  98        EX         TYA            ; execute routing: get job#, calc buffer address, branch to it
 FD0E  18                   CLC           
 FD0F  69 05                ADC #$05      
 FD11  85 17                STA BUFPT+1   
 FD13  6C 16 00             JMP (BUFPT)   

; Job Routine: bump the hub: more 100 (C)
; load drive #, accel to track, isolate drive, set head to phase "a"
; set head to max distance (#256-116), jmp DONE

 FD16  78        BUMP       SEI           
 FD17  A9 C1                LDA #$C1      
 FD19  A6 12                LDX DRIVE     
 FD1B  95 03                STA DRVST,X   
 FD1D  A9 0F                LDA #$0F      
 FD1F  3D EF FF             AND ANDD,X    
 FD22  05 40                ORA VIA_VB    
 FD24  85 40                STA VIA_VB    
 FD26  A9 8C                LDA #$8C      
 FD28  95 05                STA STEPS,X   
 FD2A  4C C1 FE             JMP DONE      

 FD2D  A9 FF     WSECT      LDA #$FF       ; decide which sector to service
 FD2F  85 1A                STA FTNUM     
 FD31  4A                   LSR           
 FD32  85 0C                STA CSECT     
 FD34  A5 10                LDA STAB+3    
 FD36  18                   CLC           
 FD37  69 01                ADC #$01      
 FD39  C5 15                CMP SECTR     
 FD3B  D0 02                BNE iFD3F     
 FD3D  A9 00                LDA #$00      
 FD3F  85 14     iFD3F      STA NEXTS     
 FD41  A2 0E                LDX #$0E      
 FD43  BD 03 04  iFD43      LDA JOBS,X     ; check which job type, check track, drive
 FD46  10 3B                BPL iFD83     
 FD48  BD 12 04             LDA x0412,X   
 FD4B  29 3F                AND #$3F      
 FD4D  C5 13                CMP TRACK     
 FD4F  D0 32                BNE iFD83     
 FD51  BD 03 04             LDA JOBS,X    
 FD54  A8                   TAY           
 FD55  29 01                AND #$01      
 FD57  C5 12                CMP DRIVE     
 FD59  D0 28                BNE iFD83     
 FD5B  98                   TYA           
 FD5C  C9 60                CMP #$60      
 FD5E  F0 23                BEQ iFD83     
 FD60  8A                   TXA           
 FD61  20 99 FD             JSR iFD99     
 FD64  A0 03                LDY #$03      
 FD66  38                   SEC           
 FD67  B1 18                LDA (HDRPNT),Y
 FD69  E5 14                SBC NEXTS     
 FD6B  10 03                BPL iFD70     
 FD6D  18                   CLC           
 FD6E  65 15                ADC SECTR     
 FD70  85 0B     iFD70      STA DSECT     
 FD72  38                   SEC           
 FD73  E5 0C                SBC CSECT     
 FD75  10 0C                BPL iFD83     
 FD77  86 1A                STX FTNUM     
 FD79  A5 0B                LDA DSECT     
 FD7B  85 0C                STA CSECT     
 FD7D  8A                   TXA           
 FD7E  18                   CLC           
 FD7F  69 05                ADC #$05      
 FD81  85 17                STA BUFPT+1   
 FD83  CA        iFD83      DEX           
 FD84  10 BD                BPL iFD43     
 FD86  A4 1A                LDY FTNUM     
 FD88  10 03                BPL HPNT      
 FD8A  4C 47 FC             JMP START     
 FD8D  98        HPNT       TYA            ; adjust header pointer: job.8 = hi byte of HDRS into HDRPNT
 FD8E  20 99 FD             JSR iFD99     
 FD91  B9 03 04             LDA JOBS,Y    
 FD94  29 70                AND #$70      
 FD96  4C AA FD             JMP READ      

 FD99  0A        iFD99      ASL           
 FD9A  0A                   ASL           
 FD9B  0A                   ASL           
 FD9C  69 21                ADC #$21      
 FD9E  85 18                STA HDRPNT    
 FDA0  60                   RTS           

 FDA1  A0 03     FSNUM      LDY #$03       ; fix sector number for fake seek
 FDA3  B1 18                LDA (HDRPNT),Y
 FDA5  85 10                STA STAB+3    
 FDA7  4C 2D FD             JMP WSECT     

; Job Routine: read a block: mode =000 (8)
; check if read or write, branch to WRITE if so

 FDAA  C9 00     READ       CMP #$00      
 FDAC  D0 28                BNE WRITE     
 FDAE  20 C3 FD             JSR DSTRT     
 FDB1  24 4D     iFDB1      BIT VIA_IFR    ; get the bytes, store in (BUFPT),y, update checksum, jmp DEND
 FDB3  10 FC                BPL iFDB1     
 FDB5  A5 41                LDA VIA_DIN   
 FDB7  91 16                STA (BUFPT),Y 
 FDB9  45 08                EOR WORK      
 FDBB  85 08                STA WORK      
 FDBD  C8                   INY           
 FDBE  D0 F1                BNE iFDB1     
 FDC0  4C 4E FE             JMP DEND      
 FDC3  A0 00     DSTRT      LDY #$00       ; start reading data: init checksum, seach for header & start of data
 FDC5  84 08                STY WORK      
 FDC7  20 CE FE             JSR SRCH      
 FDCA  20 3F FF             JSR SYNC      
 FDCD  C9 07                CMP #$07      
 FDCF  F0 04                BEQ iFDD5     
 FDD1  A9 04                LDA #$04      
 FDD3  D0 0D                BNE iFDE2     
 FDD5  60        iFDD5      RTS           

; Job Routine: write a block: mode =001 (9)
; check if verify, branch to VRFY if so
; check write protect, if ok L198, if no good, ER

 FDD6  C9 20     WRITE      CMP #$20      
 FDD8  10 60                BPL VRFY      
 FDDA  A5 82                LDA RIOT_PB   
 FDDC  29 08                AND #$08      
 FDDE  F0 04                BEQ L198      
 FDE0  A9 08                LDA #$08      
 FDE2  D0 7F     iFDE2      BNE ER        
 FDE4  A9 10     L198       LDA #$10       ; disable CB1 flag, get correct block
 FDE6  85 4E                STA VIA_IER   
 FDE8  20 CE FE             JSR SRCH      
 FDEB  24 4D     iFDEB      BIT VIA_IFR    ; write sync mode, load fill code
 FDED  10 FC                BPL iFDEB     
 FDEF  24 41                BIT VIA_DIN   
 FDF1  A9 DE                LDA #$DE      
 FDF3  85 4C                STA VIA_PCR   
 FDF5  A2 FF                LDX #$FF      
 FDF7  86 80                STX RIOT_DOUT 
 FDF9  86 81                STX RIOT_EOUT 
 FDFB  24 4D     iFDFB      BIT VIA_IFR    ; reset port a flag, set 1st sync
 FDFD  10 FC                BPL iFDFB     
 FDFF  24 41                BIT VIA_DIN   
 FE01  86 80                STX RIOT_DOUT 
 FE03  A9 DC                LDA #$DC      
 FE05  24 4D     iFE05      BIT VIA_IFR    ; store normal code mode in PCR, set 2nd sync, chksum
 FE07  10 FC                BPL iFE05     
 FE09  24 41                BIT VIA_DIN   
 FE0B  85 4C                STA VIA_PCR   
 FE0D  A9 07                LDA #$07      
 FE0F  85 80                STA RIOT_DOUT 
 FE11  A0 00                LDY #$00      
 FE13  84 08                STY WORK      
 FE15  24 4D     iFE15      BIT VIA_IFR    ; write block, write chksum, change job to verify, end
 FE17  10 FC                BPL iFE15     
 FE19  24 41                BIT VIA_DIN   
 FE1B  B1 16                LDA (BUFPT),Y 
 FE1D  85 80                STA RIOT_DOUT 
 FE1F  45 08                EOR WORK      
 FE21  85 08                STA WORK      
 FE23  C8                   INY           
 FE24  D0 EF                BNE iFE15     
 FE26  AA                   TAX           
 FE27  20 7C FF             JSR OUT       
 FE2A  20 59 FF             JSR OFF       
 FE2D  A4 1A                LDY FTNUM     
 FE2F  B9 03 04             LDA JOBS,Y    
 FE32  49 30                EOR #$30      
 FE34  99 03 04             STA JOBS,Y    
 FE37  4C A1 FD             JMP FSNUM     

; Job Routine: verify a written block: mode=010 (A)
; read data

 FE3A  20 C3 FD  VRFY       JSR DSTRT     
 FE3D  24 4D     iFE3D      BIT VIA_IFR    ; get byte and compare with contents of buffer, add up chksum
 FE3F  10 FC                BPL iFE3D     
 FE41  A5 41                LDA VIA_DIN   
 FE43  D1 16                CMP (BUFPT),Y 
 FE45  D0 1A                BNE iFE61     
 FE47  45 08                EOR WORK      
 FE49  85 08                STA WORK      
 FE4B  C8                   INY           
 FE4C  D0 EF                BNE iFE3D     
 FE4E  20 52 FF  DEND       JSR BYTE       ; end reading data, final chksum compare
 FE51  C5 08                CMP WORK      
 FE53  F0 04                BEQ iFE59     
 FE55  A9 05                LDA #$05      
 FE57  D0 0A                BNE ER        
 FE59  A9 10     iFE59      LDA #$10       ; check if decoding error: if not then DONE, else ER
 FE5B  24 4D                BIT VIA_IFR   
 FE5D  F0 62                BEQ DONE      
 FE5F  D0 02                BNE ER        
 FE61  A9 07     iFE61      LDA #$07       ; set for verify error
 FE63  D0 5E     ER         BNE ERR        ; branch to error routing ERR

; seek to determine next sector number
; init chksum, get block header

 FE65  A9 00     SEEK       LDA #$00      
 FE67  85 08                STA WORK      
 FE69  A2 06                LDX #$06      
 FE6B  20 F3 FE             JSR HEAD      
 FE6E  A0 04                LDY #$04      
 FE70  20 4D 10  iFE70      JSR i104D      ; get a byte, store in STAB update chksum, branch again if more

; FE73: Illegal instruction.

 FE73             .byte $FC, $A5, $41, $99, $0D, $00, $45, $08  ;.%a.m.eh
 FE7B             .byte $85, $08, $88, $10, $F0, $C9, $00, $D0  ;.h.p.I.P

; Job Routine: seek: mode 011 (b)


; *** Invalid reference FE83 ignored.

 FE83  ESEEK      .byte $42, $A5, $0F, $29, $3F, $A6, $12, $95  ;b%o)?&r.
 FE8B             .byte $03                                     ;c


; load job# and type, test if seek, branch to ESEEK if so

 FE8C             .byte $A4, $1A, $B9, $03, $04, $29, $70, $C9  ;$z9cd)PI
 FE94             .byte $30, $F0, $1C, $98, $20, $99, $FD, $A0  ;0.\. .. 
 FE9C             .byte $02, $B1, $18, $45, $0F, $29, $C0, $D0  ;b1xeo).P
 FEA4             .byte $25, $88                                ;%.


; check if id in (HDPTR),y = STAB,y error if not. continue loop, at end jmp WSECT


 FEA6  B1 18     iFEA6      LDA (HDRPNT),Y ; check if id in (HDPTR),y = STAB,y error if not. continue loop, at end jmp WSECT
 FEA8  D9 0D 00             CMP STAB,Y    
 FEAB  D0 1D                BNE iFECA     
 FEAD  88                   DEY           
 FEAE  10 F6                BPL iFEA6     
 FEB0  4C 2D FD             JMP WSECT     
 FEB3  98        iFEB3      TYA           
 FEB4  20 99 FD             JSR iFD99     
 FEB7  A0 04                LDY #$04      
 FEB9  B9 0D 00  iFEB9      LDA STAB,Y     ; get complete header from STAB,y into (HDRPNT),y
 FEBC  91 18                STA (HDRPNT),Y
 FEBE  88                   DEY           
 FEBF  10 F8                BPL iFEB9     
 FEC1  A9 01     DONE       LDA #$01       ; set for no error: #1
 FEC3  4C F9 FE  ERR        JMP ERROR      ; jump ERROR: error routine
 FEC6  A9 09     CSERR      LDA #$09       ; lda #9 (chksum error) branch to ERR
 FEC8  D0 F9                BNE ERR       
 FECA  A9 0B     iFECA      LDA #$0B      
 FECC  D0 F5                BNE ERR        ; lda#11 (mismatch), branch to ERR
 FECE  A0 03     SRCH       LDY #$03       ; search for specific block
 FED0  A9 00                LDA #$00      
 FED2  51 18     iFED2      EOR (HDRPNT),Y ; compute checksum, set up for search for a sector
 FED4  88                   DEY           
 FED5  10 FB                BPL iFED2     
 FED7  A0 04                LDY #$04      
 FED9  91 18                STA (HDRPNT),Y
 FEDB  A4 1A                LDY FTNUM     
 FEDD  A2 5A                LDX #$5A      
 FEDF  20 F3 FE  iFEDF      JSR HEAD       ; jsr HEAD, set y for compare, every byte in hdr must be identical
 FEE2  A0 04                LDY #$04      
 FEE4  24 4D     iFEE4      BIT VIA_IFR    ; compare to header loop, loop entire header
 FEE6  10 FC                BPL iFEE4     
 FEE8  A5 41                LDA VIA_DIN   
 FEEA  D1 18                CMP (HDRPNT),Y
 FEEC  D0 F1                BNE iFEDF     
 FEEE  88                   DEY           
 FEEF  10 F3                BPL iFEE4     
 FEF1  C8                   INY           
 FEF2  60                   RTS           

 FEF3  58        HEAD       CLI            ; seach for block head: .x=max# of trials
 FEF4  CA                   DEX           
 FEF5  10 2E                BPL iFF25     
 FEF7  A9 02                LDA #$02      

; send error code
; #1: no error
; #2: can't find block head
; #3: no sync character
; #4: data block not present
; #5: checksum error
; #7: verify error
; #8: write with write protect on
; #9: checksum error in seeked header
; #10: data ran into next header
; #11: disk id mismatch
; #16: decoding error

 FEF9  24 1E     ERROR      BIT IOB       
 FEFB  10 0A                BPL iFF07     
 FEFD  E6 1F                INC JOBNUM    
 FEFF  A2 3F                LDX #$3F      
 FF01  9A                   TXS           
 FF02  A6 12                LDX DRIVE     
 FF04  4C 43 05             JMP i0543     
 FF07  A4 1A     iFF07      LDY FTNUM     
 FF09  99 03 04             STA JOBS,Y    
 FF0C  A6 12                LDX DRIVE     
 FF0E  A5 00                LDA CLOCK     
 FF10  6D 02 04             ADC CUTMT     
 FF13  95 01                STA MTRTM,X   
 FF15  B9 03 04             LDA JOBS,Y    
 FF18  C9 01                CMP #$01      
 FF1A  D0 03                BNE iFF1F     
 FF1C  4C A1 FD             JMP FSNUM     
 FF1F  A2 3F     iFF1F      LDX #$3F      
 FF21  9A                   TXS           
 FF22  4C 47 FC             JMP START     
 FF25  20 3F FF  iFF25      JSR SYNC      
 FF28  C9 08                CMP #$08      
 FF2A  D0 C7                BNE HEAD      
 FF2C  60                   RTS           

; watch for sync characters
; bit PB, bvc L450: test if sync present, branch if yes
; bit IFR, bpl WATCH, test if byte present, loop until yes
; .x contains # of tests, branch to WATCH till .x=0
; bit PB, rts; test if sync present then return

 FF2D  24 82     WATCH      BIT RIOT_PB   
 FF2F  50 0D                BVC iFF3E     
 FF31  24 4D                BIT VIA_IFR   
 FF33  10 F8                BPL WATCH     
 FF35  24 41                BIT VIA_DIN   
 FF37  24 40                BIT VIA_VB    
 FF39  CA                   DEX           
 FF3A  D0 F1                BNE WATCH     
 FF3C  24 82                BIT RIOT_PB   
 FF3E  60        iFF3E      RTS           

 FF3F  78        SYNC       SEI           
 FF40  A9 D0                LDA #$D0      
 FF42  85 45                STA VIA_TIMER 
 FF44  A9 03                LDA #$03      
 FF46  24 45     iFF46      BIT VIA_TIMER 
 FF48  10 AF                BPL ERROR     
 FF4A  24 82                BIT RIOT_PB   
 FF4C  70 F8                BVS iFF46     
 FF4E  24 40                BIT VIA_VB    
 FF50  24 41                BIT VIA_DIN   
 FF52  24 4D     BYTE       BIT VIA_IFR   
 FF54  10 FC                BPL BYTE      
 FF56  A5 41                LDA VIA_DIN   
 FF58  60                   RTS           

 FF59  20 7C FF  OFF        JSR OUT       
 FF5C  A2 00                LDX #$00      
 FF5E  20 7C FF             JSR OUT       
 FF61  A9 FC                LDA #$FC      

; change EOUT and PCR to send sync. 
; enable CB1, CA1, CB2 (IER=%10011010), get a byte. 
; reset VIA flags, get next byte, reset VIA, jmp BYTE (get next byte)

 FF63  24 4D     iFF63      BIT VIA_IFR   
 FF65  10 FC                BPL iFF63     
 FF67  86 81                STX RIOT_EOUT 
 FF69  85 4C                STA VIA_PCR   
 FF6B  A9 9A                LDA #$9A      
 FF6D  85 4E                STA VIA_IER   
 FF6F  20 52 FF             JSR BYTE      
 FF72  24 40                BIT VIA_VB    
 FF74  20 52 FF             JSR BYTE      
 FF77  24 40                BIT VIA_VB    
 FF79  4C 52 FF             JMP BYTE      

 FF7C  24 4D     OUT        BIT VIA_IFR   
 FF7E  10 FC                BPL OUT       
 FF80  86 80                STX RIOT_DOUT 
 FF82  24 41                BIT VIA_DIN   
 FF84  60                   RTS           

; CPU interrupt routine

 FF85  48        IRQ        PHA           
 FF86  8A                   TXA           
 FF87  48                   PHA           
 FF88  AD 00 04             LDA TICK      
 FF8B  85 8F                STA x8F       
 FF8D  E6 00                INC CLOCK     
 FF8F  A2 01                LDX #$01      
 FF91  A5 00     iFF91      LDA CLOCK     
 FF93  D5 01                CMP MTRTM,X   
 FF95  D0 16                BNE iFFAD     
 FF97  BD ED FF             LDA ANDC,X    
 FF9A  16 03                ASL DRVST,X   
 FF9C  24 40                BIT VIA_VB    
 FF9E  B0 08                BCS iFFA8     
 FFA0  38                   SEC           
 FFA1  BD F1 FF             LDA ANDE,X    
 FFA4  45 40                EOR VIA_VB    
 FFA6  85 40                STA VIA_VB    
 FFA8  D0 01     iFFA8      BNE iFFAB     
 FFAA  18                   CLC           
 FFAB  76 03     iFFAB      ROR DRVST,X   
 FFAD  B5 05     iFFAD      LDA STEPS,X   
 FFAF  D0 09                BNE L911      
 FFB1  B5 03                LDA DRVST,X   
 FFB3  29 BF                AND #$BF      
 FFB5  95 03                STA DRVST,X   
 FFB7  4C E4 FF             JMP iFFE4     
 FFBA  0A        L911       ASL           
 FFBB  A5 40                LDA VIA_VB    
 FFBD  3D D4 FC             AND ANDA,X    
 FFC0  85 07                STA COW       
 FFC2  A5 40                LDA VIA_VB    
 FFC4  3D EF FF             AND ANDD,X    
 FFC7  B0 07     ERR1       BCS iFFD0      ; send job status, make motor stay longer, check job type
 FFC9  D6 05                DEC STEPS,X    ; step in (+)
 FFCB  7D EB FF             ADC ANDB,X    
 FFCE  D0 05                BNE iFFD5     
 FFD0  F6 05     iFFD0      INC STEPS,X    ; step out (-)
 FFD2  FD EB FF             SBC ANDB,X    
 FFD5  ED EF FF  iFFD5      SBC ANDD      
 FFD8  05 07                ORA COW        ; store new stepper position, test if DRVTST ready
 FFDA  85 40                STA VIA_VB    
 FFDC  B5 03                LDA DRVST,X   
 FFDE  30 04                BMI iFFE4     
 FFE0  A5 00                LDA CLOCK     
 FFE2  95 01                STA MTRTM,X   
 FFE4  CA        iFFE4      DEX           
 FFE5  10 AA                BPL iFF91     
 FFE7  68                   PLA            ; pop the stack of a and x and RTI
 FFE8  AA                   TAX           
 FFE9  68                   PLA           
 FFEA  40                   RTI           

 FFEB  ANDB       .byte $04, $01                                ;da
 FFED  ANDC       .byte $20, $10                                ; p
 FFEF  ANDD       .byte $0C, $03                                ;lc
 FFF1  ANDE       .byte $A0, $50, $20, $49, $53, $20, $4F, $4E  ; p is on
 FFF9             .byte $20, $41, $4E

; CPU vectors

, RESET   
 FFFE             .word IRQ     


; Misassembly source 4.08 15 May 2005   Generated  Sun Jul 31 00:15:53 CEST 2005



Formatted to HTML by recomment 4.08 15 May 2005 reassembler.

Misassembled from dos1fdc by fachat@linux using header file dos1fdc.hdr in a 2-pass run at Sun Jul 31 00:15:53 CEST 2005 .