home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CBM Funet Archive
/
cbm-funet-archive-2003.iso
/
cbm
/
crossplatform
/
converters
/
unix
/
crc32.s
< prev
next >
Wrap
Text File
|
1992-05-24
|
3KB
|
226 lines
;CRC32 VERSION 1.0 FOR THE c-128 AND c-64 BY cRAIG bRUCE 23-mAY-92
.MEM
.BANK 15
.ORG $1C01
.BYTE $2C,$1C,$0A,$00,$8B,$20,$C2,$28,$36,$35,$35,$33,$34,$29,$B2,$32
.BYTE $33,$20,$A7,$20,$9E,$20,$C2,$28,$34,$35,$29,$AA,$32,$35,$36,$AC
.BYTE $C2,$28,$34,$36,$29,$AA,$37,$31,$3A,$80,$00,$45,$1C,$14,$00,$9E
.BYTE $20,$C2,$28,$34,$33,$29,$AA,$32,$35,$36,$AC,$C2,$28,$34,$34,$29
.BYTE $AA,$37,$31,$00,$00,$00,$00
STRINGbASE = 2 ;(2)
CRCaCCUM = 4 ;(4)
FILENAMElEN = 8 ;(1)
DEVICE = 9 ;(1)
CH = 10 ;(1)
ITOAbIN = CRCaCCUM
ITOAbCD = 11 ;(5)
ITOAfLAG = 2 ;(1)
CRClOW = $B7
CRCmID1 = $1D
CRCmID2 = $C1
CRChIGH = $04
KERNELsETLFS = $FFBA
KERNELsETNAM = $FFBD
KERNELoPEN = $FFC0
KERNELcLOSE = $FFC3
KERNELcHKIN = $FFC6
KERNELcLRCHN = $FFCC
KERNELcHRIN = $FFCF
KERNELcHROUT = $FFD2
FILENAME = $200+40
LDA #$60
STA STRINGbASE
SEI
JSRlABEL = *
JSR STRINGbASE
TSX
LDA $100,X
TAY
DEX
LDA $100,X
CLI
CLC
ADC #STRINGsTART-JSRlABEL-2
BCC +
INY
+ STA STRINGbASE
STY STRINGbASE+1
CLC
BCC ENTRY
STRINGsTART = *
STARTmSG = *
.ASC "ENTER NAME OF FILE TO TAKE CRC32 OF:"
.BYTE 13,0
SCANNINGmSG = *
.BYTE 13,13
.ASC "SCANNING FILE... "
.BYTE 0
CRCmSG = *
.ASC "CRC32 = "
.BYTE 0
ENTRY = *
LDA 186
STA DEVICE
LDY #STARTmSG-STRINGsTART
- LDA (STRINGbASE),Y
BEQ +
JSR KERNELcHROUT
INY
BNE -
+ LDY #0
- JSR KERNELcHRIN
STA FILENAME,Y
CMP #13
BEQ +
INY
BNE -
+ STY FILENAMElEN
LDY #SCANNINGmSG-STRINGsTART
- LDA (STRINGbASE),Y
BEQ +
JSR KERNELcHROUT
INY
BNE -
;***OPEN FILE
+ LDX #<FILENAME
LDY #>FILENAME
LDA FILENAMElEN
JSR KERNELsETNAM
LDA #1
LDX DEVICE
LDY #2
JSR KERNELsETLFS
JSR KERNELoPEN
BCC +
- RTS
+ LDX #1
JSR KERNELcHKIN
BCS -
LDX #3
LDA #0
- STA CRCaCCUM,X
DEX
BPL -
;***SCAN FILE
NEXTcHAR = *
JSR KERNELcHRIN
STA CH
LDX #8
NEXTbIT = *
ASL CH
ROL CRCaCCUM+0
ROL CRCaCCUM+1
ROL CRCaCCUM+2
ROL CRCaCCUM+3
BCC +
LDA CRCaCCUM+0
EOR #CRClOW
STA CRCaCCUM+0
LDA CRCaCCUM+1
EOR #CRCmID1
STA CRCaCCUM+1
LDA CRCaCCUM+2
EOR #CRCmID2
STA CRCaCCUM+2
LDA CRCaCCUM+3
EOR #CRChIGH
STA CRCaCCUM+3
+ DEX
BNE NEXTbIT
BIT $90
BVC NEXTcHAR
;***CLOSE FILE
JSR KERNELcLRCHN
LDA #1
JSR KERNELcLOSE
LDY #CRCmSG-STRINGsTART
- LDA (STRINGbASE),Y
BEQ +
JSR KERNELcHROUT
INY
BNE -
;*** PRINT OUT RESULT
+ LDX #4
LDA #0
- STA ITOAbCD,X
DEX
BPL -
STA ITOAfLAG
LDY #32
SEI
SED
ITOAnEXTbIT = *
ASL ITOAbIN+0
ROL ITOAbIN+1
ROL ITOAbIN+2
ROL ITOAbIN+3
LDX #4
- LDA ITOAbCD,X
ADC ITOAbCD,X
STA ITOAbCD,X
DEX
BPL -
DEY
BNE ITOAnEXTbIT
CLD
CLI
LDX #0
NEXTbCD = *
LDA ITOAbCD,X
;** PRINT FIRST DIGIT
PHA
LSR
LSR
LSR
LSR
CMP ITOAfLAG
BEQ +
ORA #$30
STA ITOAfLAG
JSR KERNELcHROUT
;** PRINT SECOND DIGIT
+ PLA
AND #$0F
CMP ITOAfLAG
BEQ +
ORA #$30
STA ITOAfLAG
JSR KERNELcHROUT
+ INX
CPX #5
BCC NEXTbCD
;*** FINISH UP
LDA ITOAfLAG
BNE +
LDA #"0"
JSR KERNELcHROUT
+ LDA #13
JSR KERNELcHROUT
RTS