home *** CD-ROM | disk | FTP | other *** search
- ;BPUT"C2SEC.SRC
- ;RPUT"C2SEC.SRC
- ;
- ;+++++++++++++++++++++++++++++++++
- ;+ SECTOR, SAT, AND DISK ADDRESS +
- ;+ ROUTINES. +
- ;+ ENTRY POINTS: +
- ;+* SEC2CYLDCB - CONVERT SECNUM TO +
- ;+ MSBSEC, LSB, HEAD FORMAT. +
- ;+* SEC2CYLDCB1 - CONVERT CYLMSB AND +
- ;+ SECTOR NUMBER TO MSBSEC +
- ;+ FORMAT WITH OUTPUT IN +
- ;+ CYLMSB. +
- ;+* SECTR2CYLINDR - CONVERT SECNUM TO +
- ;+ CYLMSB, CYLLSB, HEAD, +
- ;+ SECTOR. +
- ;+* SAT2SECTOR - CONVERT SATSEC, +
- ;+ SATBYT, AND SATBIT TO A +
- ;+ SECTOR NUMBER. +
- ;+* SECTOR2SAT - CONVERT SECNUM TO +
- ;+ SAT ENTRY. INPUT IS X - +
- ;+ HI BYTE OF SECNUM, A - MID +
- ;+ BYTE OF SECNUM, AND Y - LOW+
- ;+ BYTE OF SECNUM. +
- ;+* CYL2SECTORDCB - CONVERT DCB FORMAT +
- ;+ DISK ADDRESS TO SECNUM. +
- ;+ INPUT: A - DRIVE-HEAD +
- ;+ X - MSB CYLINDER +
- ;+ Y - LSB CYLINDER +
- ;+* CYLINDER2SECTR - CONVERT HEAD, CYLLSB+
- ;+ CYLMSB, & SECTOR TO SECNUM.+
- ;+++++++++++++++++++++++++++++++++
- ;
- ;+++++++++++++++++++++++++++++++++
- ;+THE FOLLOWING AREAS ARE USED BY+
- ;+ THESE SUBROUTINES. +
- ;+-------------------------------+
- ;+ SHIFTS 1 BYTE WORK +
- ;+ WORKA 3 BYTE WORK AREA +
- ;+ WORKB 2 BYTE WORK AREA +
- ;+ WORKC 2 BYTE WORK AREA +
- ;+ SECNUM 3 BYTE SECTOR NUMBER IN+
- ;+ HI, MED, LO FORMAT +
- ;+ SATSEC 1 BYTE SAT SECTOR +
- ;+ SATBYT 2 BYTE BYTE OFFSET IN +
- ;+ SAT SECTOR. HI, LO +
- ;+ SATBIT 1 BYTE BIT MASK OF SAT +
- ;+ SECTOR BYTE +
- ;+ CYLMSB 1 BYTE MSB OF CYLINDER +
- ;+ CYLLSB 1 BYTE LSB OF CYLINDER +
- ;+ HEAD 1 BYTE HEAD NUMBER +
- ;+ SECTOR 1 BYTE SECTOR NUMBER +
- ;+ SECTRK 1 BYTE NUMBER OF +
- ;+ SECTORS PER TRACK +
- ;+ SECCYL 1 BYTE NUMBER OF +
- ;+ SECTORS PER CYLINDER +
- ;+++++++++++++++++++++++++++++++++
- ;
- ;
- ;+++++++++++++++++++++++++++++++++
- ;+ CONVERT RELATIVE SECTOR NUMBER+
- ;+ TO CYLINDER, HEAD AND SECTOR. +
- ;+ +
- ;+ INPUT - FIELD SECNUM WHICH +
- ;+ CONTAINS THE RELATIVE SECTOR.+
- ;+ +
- ;+ OUTPUT - FIELDS HEAD, CYLLSB, +
- ;+ CYLMSB, AND SECTOR FILLED AND+
- ;+ A - HEAD NUMBER +
- ;+ Y - CYLINDER LSB +
- ;+ X - SECTOR AND CYL MSB +
- ;+++++++++++++++++++++++++++++++++
- ;
- ;
- SEC2CYLDCB JSR SECTR2CYLINDR ;GO CONVERT
- SEC2CYLDCB1 LDX #6 ;PUT CHR IN DCB FORM
- LDA CYLMSB
- SHIFTMSBLEFT ASL A
- DEX
- BNE SHIFTMSBLEFT
- ORA SECTOR
- STA CYLMSB
- RTS ;TIS DONE
- ;
- SECTR2CYLINDR LDA #0 ;ZERO WORK, ETC.
- STA WORKB
- STA WORKB+1
- STA WORKC+1
- STA HEAD
- STA CYLMSB
- STA CYLLSB
- LDX #2 ;MOVE SECNUM TO WORK A
- MOVESECNUM2A LDA SECNUM,X
- STA WORKA,X
- DEX
- BPL MOVESECNUM2A
- JSR DEFSET ;GET PTR TO PARMTAB
- LDA PTSCYL,X ;GET SECTOR PER CYL
- STA WORKC ;TIMES HEX 100
- INC WORKB ;MAKE COUNTER 256
- LDX #9 ;PRIME COUNT DOWN
- CALCCYLINDER JSR DIVIDESECTOR ;GO SUBTRACT
- BCC UPDATEOPERANDS
- LDA WORKB+1
- CLC
- ADC CYLLSB
- STA CYLLSB
- LDA WORKB
- ADC CYLMSB
- STA CYLMSB
- JMP CALCCYLINDER ;GO SEE IF MORE
- ;
- UPDATEOPERANDS LSR WORKB ;ADJUST ADDER
- ROR WORKB+1
- LSR WORKC ;SHIFT DIVISOR
- ROR WORKC+1
- DEX
- BNE CALCCYLINDER ;TRY SOME MORE
- LDA #17 ;GET NUM SEC PER TRK
- STA WORKC+1 ;IN SUBTRACTOR
- CALCULATEHEAD JSR DIVIDESECTOR ;GO SUBTRACT
- BCC SAVESECTORNUM ;GO IF DONE
- INC HEAD
- BNE CALCULATEHEAD
- SAVESECTORNUM LDA WORKA+2 ;GET SECTOR NUM
- STA SECTOR
- RTS
- ;
- ;
- ;+++++++++++++++++++++++++++++++++
- ;+ SUBTRACT WORKC FROM WORK A IF +
- ;+ WORKA >= WORKC +
- ;+ RETURN CARRY SET FOR DIDIT. +
- ;+ RETURN CARRY CLEAR FOR SMALL. +
- ;+++++++++++++++++++++++++++++++++
- ;
- DIVIDESECTOR LDA WORKA ;CHECK HI SEC BYT
- BNE SUBTRACTEM
- LDA WORKA+1 ;CHECK SECOND BYTE
- CMP WORKC ;FOR <=
- BCC DIVIDERETURN ;GO IF TOO SMALL
- BNE SUBTRACTEM ;GO NOT EQUAL
- LDA WORKA+2 ;CHECK LOW BYTE
- CMP WORKC+1
- BCC DIVIDERETURN ;TOO SMALL GO ON
- SUBTRACTEM LDA WORKA+2 ;SUBTRACT
- SEC
- SBC WORKC+1
- STA WORKA+2
- LDA WORKA+1
- SBC WORKC
- STA WORKA+1
- LDA WORKA
- SBC #0
- STA WORKA
- SEC
- DIVIDERETURN RTS
- ;
- ;+++++++++++++++++++++++++++++++++
- ;+ CONVERT SATSEC, SATBYT, AND +
- ;+ SATBIT TO RELATIVE SECTOR #. +
- ;+ +
- ;+ INPUT - FIELDS SATSEC, SATBYT +
- ;+ AND SATBIT. +
- ;+ +
- ;+ OUTPUT- RELATIVE SECTOR IN +
- ;+ SECNUM. +
- ;+++++++++++++++++++++++++++++++++
- ;
- SAT2SECTOR LDA #0 ;INIT SECTOR NUM
- STA SECNUM
- LDX #4 ;NUMBER TO SHIFT
- LDA SATSEC ;GET FIELD
- SHIFTSATSECLF ASL A
- ROL SECNUM
- DEX
- BNE SHIFTSATSECLF
- STA SECNUM+1
- LDA SATBYT ;GET HI
- STA WORKA
- LDX #3 ;MULTIPLY BY 8
- LDA SATBYT+1 ;NOW LO BYTE OFFSET
- SHIFTSATBYTLF ASL A
- ROL WORKA
- DEX
- BNE SHIFTSATBYTLF
- STA SECNUM+2
- CLC
- LDA WORKA ;ADD HI BYTE
- ADC SECNUM+1
- STA SECNUM+1
- LDA SATBIT ;GET THE BIT NUMBER
- LDX #0
- SHIFTSATBITLF ASL A ;SHIFT TILL IT GOES
- BCS ADDTOSECNUM ;OUT
- INX
- BNE SHIFTSATBITLF
- ADDTOSECNUM TXA ;SET UP FOR ADD
- JMP ADDBYTE2SECNUM
- ;CLC
- ;ADC SECNUM+2 ;ADD TO TOTAL
- ;STA SECNUM+2
- ;BCC SAT2SECRETURN
- ;INC SECNUM+1 ;ELSE ADD OVERFLOW
- ;BNE SAT2SECRETURN
- ;INC SECNUM
- ;SAT2SECRETURN RTS ;RETURN
- ;
- ;+++++++++++++++++++++++++++++++++
- ;+ CONVERT SECTOR NUMBER TO SAT +
- ;+ ENTRY. +
- ;+ +
- ;+ INPUT: A-MIDDLE BYTE OF SECNUM+
- ;+ X-HI BYTE OF SECNUM +
- ;+ Y-LO BYTE OF SECNUM +
- ;+ +
- ;+ +
- ;+ OUTPUT: SAT SECTOR, BYTE, AND +
- ;+ BIT IN BYTE. +
- ;+ SATSEC - SECTOR NUMBER OF SATE+
- ;+ SATBYT - BYTE OF SATE +
- ;+ SATBIT - BIT OF BYTE +
- ;+++++++++++++++++++++++++++++++++
- ;
- SECTOR2SAT STA SATSEC ;A HAS MIDDLE BYTE
- AND #$0F ;ISOLATE LOW 12 BITS FOR
- STA SATBYT ;FOR SATBYT
- TXA ;GET HI BYTE OF SECNUM
- LDX #4 ;NEED TO SHIFT FOR SATSEC
- DIVIDEBY4096 LSR A ;SATSEC = INT(SECNUM/4096)
- ROR SATSEC
- DEX
- BNE DIVIDEBY4096 ;DO ALL 4 SHIFTS
- TYA ;GET LOW BYTE OF SECNUM
- STA SATBYT+1 ;PUT IN OFFSET
- AND #$07 ;ISOLATE THE BIT NUMBER
- TAX ;NOW PUT BIT IN ITS PLACE
- LDA #$80 ;PRIME BIT
- SHIFTSEC DEX ;CHECK IF THRU
- BMI SAVESATBIT
- LSR A
- BNE SHIFTSEC
- SAVESATBIT STA SATBIT ;NOW HAVE BIT
- LDX #3 ;NOW DIVIDE BYTE OFFSET BY 8
- DIVIDSATBYTBY8 LSR SATBYT
- ROR SATBYT+1
- DEX
- BNE DIVIDSATBYTBY8
- RTS
- ;
- ;+++++++++++++++++++++++++++++++++
- ;+ CONVERT CYLINDER, HEAD, SECTOR+
- ;+ TO SECTOR NUMBER. +
- ;+ +
- ;+ THERE ARE 2 ENTRIES TO THIS +
- ;+ SUBROUTINE. +
- ;+ CYL2SECTORDCB - INPUT IS AS FOLLOWS +
- ;+ A - DRIVE-HEAD BYTE +
- ;+ X - MSB-SECTOR +
- ;+ Y - LSB CYLINDER +
- ;+ +
- ;+ CYLINDER2SECTR - THE FOLLOWING FIELDS +
- ;+ MUST BE INITIALIZED BEFORE+
- ;+ CALLING THIS ENTRY. +
- ;+ HEAD, SECTOR, CYLLSB, CYLMSB +
- ;+ +
- ;+++++++++++++++++++++++++++++++++
- ;
- CYL2SECTORDCB STY CYLLSB ;PUT IN LSB OF CYLINDER
- AND #$0F ;ISOLATE JUST THE HEAD
- STA HEAD
- TXA ;GET MSB AND SECTOR
- AND #$1F ;ISOLATE SECTOR NUMBER
- STA SECTOR
- TXA ;NOW HANDLE MSB OF CYLINDER
- LDX #6 ;NUMBER OF SHIFTS
- SHIFTDOWNMSB LSR A
- DEX
- BNE SHIFTDOWNMSB
- STA CYLMSB ;PUT IT AWAY
- ;
- CYLINDER2SECTR LDA #0 ;CLEAR THE RESULT FIELD
- STA SECNUM
- STA SECNUM+1
- STA SECNUM+2
- LDY #8 ;PRIME SHIFTS
- JSR DEFSET ;GET PARM TAB OFFSET
- LDA PTSCYL,X ;AND SECTOR PER CYL
- STA WORKB
- MULIPLYCYLINDR = * ;CLEAR CARRY
- LDA CYLLSB ;GET LOW CYL NUMBER
- STA WORKA+2
- LDA CYLMSB ;GET HIGH CYL NUMBER
- STA WORKA+1
- LDA #0 ;CLEAR NEXT WORK
- STA WORKA
- DEY
- ASL WORKB ;SHIFT SEC/CYL
- BCC ANYMORESHIFTS
- TYA ;MOVE TO X
- TAX
- BEQ ADDTOSECNUM2
- CLC
- SHIFTWORKAL ASL WORKA+2
- ROL WORKA+1
- ROL WORKA
- DEX
- BNE SHIFTWORKAL
- ADDTOSECNUM2 LDX #2
- CLC
- ADDTOSECNUMLP LDA SECNUM,X
- ADC WORKA,X
- STA SECNUM,X
- DEX
- BPL ADDTOSECNUMLP
- ANYMORESHIFTS CPY #0 ;ANY MORE?
- BNE MULIPLYCYLINDR
- ;+ ADD IN HEAD X SECTOR PER TRK
- LDX HEAD ;GET COUNTER
- BEQ ADDSECT2SECNUM ;GO IF HEAD 0
- ADDHEADXSECTRK LDA #17 ;GET SECTORS PER TRACK
- JSR ADDBYTE2SECNUM ;GO ADD TO TOTAL
- DEX
- BNE ADDHEADXSECTRK
- ;+ ADD THE SECTOR
- ADDSECT2SECNUM LDA SECTOR
- JSR ADDBYTE2SECNUM
- LDA SECNUM
- LDX SECNUM+1
- LDY SECNUM+2
- RTS
- ADDBYTE2SECNUM CLC
- ADC SECNUM+2
- STA SECNUM+2
- BCC ADDALLDONE
- INC SECNUM+1
- BNE ADDALLDONE
- INC SECNUM
- ADDALLDONE = *
- RTS
- ;
- .END C2SEC