Repository navigation
Expand file tree
/
Copy pathdisk2.asm
More file actions
67 lines (52 loc) · 1.68 KB
/
Copy pathdisk2.asm
File metadata and controls
67 lines (52 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
*=$1000 ; just an example
LDA #4 ; length of filename
LDX #<fname
LDY #>fname
JSR $FFBD ; call SETNAM
LDA #$02 ; file number 2
LDX $BA ; last used device number
BNE .skip
LDX #$08 ; default to device 8
.skip LDY #$02 ; secondary address 2
JSR $FFBA ; call SETLFS
JSR $FFC0 ; call OPEN
BCS .error ; if carry set, the file could not be opened
; check drive error channel here to test for
; FILE NOT FOUND error etc.
LDX #$02 ; filenumber 2
JSR $FFC6 ; call CHKIN (file 2 now used as input)
LDA #<load_address
STA $AE
LDA #>load_address
STA $AF
LDY #$00
.loop JSR $FFB7 ; call READST (read status byte)
BNE .eof ; either EOF or read error
JSR $FFCF ; call CHRIN (get a byte from file)
STA ($AE),Y ; write byte to memory
INC $AE
BNE .skip2
INC $AF
.skip2 JMP .loop ; next byte
.eof
AND #$40 ; end of file?
BEQ .readerror
.close
LDA #$02 ; filenumber 2
JSR $FFC3 ; call CLOSE
JSR $FFCC ; call CLRCHN
RTS
.error
; Akkumulator contains BASIC error code
; most likely errors:
; A = $05 (DEVICE NOT PRESENT)
;... error handling for open errors ...
JMP .close ; even if OPEN failed, the file has to be closed
.readerror
; for further information, the drive error channel has to be read
;... error handling for read errors ...
JMP .close
fname
text "test"
*=$2000
load_address