Hi!
I have any problem. I want to read file byte-per-byte and show on screen data. In BASIC it's not problem:
1DOPEN#1,"NAME,P"
2GET#1,A$
3PRINTA$;
4IFST<>64THEN2
5DCLOSE#1
my problem in assembler and also BASIC 2.0 (C64 mode) is that it seems that it reads one first byte only and loop forever...
Here's code:
// IO - variables
.var read = $ffe4
.var setlfs = $ffba
.var setnam = $ffbd
.var open = $ffc0
.var clrch = $ffcc
.var close = $ffc3
.var chkin = $ffc6
.var ckout = $ffc9
.var chrin = $ffcf
.var bsout = $ffd2
start: lda #7
ldx #<dirnam
ldy #>dirnam
jsr setnam
lda #1
ldx device
ldy #1
jsr setlfs
ldx #$01
jsr chkin
ldx #$00
back: jsr read
sta $0400,x
inx
lda $90
bvc back
jsr clrch
lda #1
jsr close
rts
dirnam:
.text "KOD,P,R"
device:
.byte 8
Where I did a mistake?
Many many many thanks for every reply!
Miro
Hi Miro,
the error is here:
...
back: jsr read
sta $0400,x
inx
lda $90 <- it has to be BIT $90 as LDA didn't set/clear the overflow flag. (EOF)
bvc back
...
You might want to lda $90, beq back since if you bit $90, bvc back you might set up a condition where you have an endless loop, since only an EOI will terminate your loop.
Hi!
Thanks. Yes, I fixed this error before, but still it does endless loop with the same value, don't you know why?
Thanks.
Miro
Hi!
Thanks for all advices, now is problem solved.
I was amazed what can to do secondary address - in this case equals #2.
Else one Q as last: first two readed bytes are address from where was file saved?
Many many thanks.
Miro
You setnam, setlfs, and chkin, but never seem to open the file.