Commodore 128 Alive!

Commodore 128 => 128 programmers => Topic started by: MIRKOSOFT on July 15, 2010, 08:53 AM

Title: Reading from file and EOF mark...
Post by: MIRKOSOFT on July 15, 2010, 08:53 AM
Hi!


I want to try to read any file byte per byte in assembler. For example, here's BASIC program which reads 10 bytes:

OPEN 1,11,1,”TESTFILE,S,R”
FOR X=1TO10:INPUT#1,A$:PRINT A$:NEXT
CLOSE 1



But I want to read it to end of File (EOF). What a mark has EOF?
'Cause when I'm reading directory in assembler it ends with $00...


But if in data are bytes with $00 value, how to find EOF?


Many thanks for every reply.


MIro
Title: Re: Reading from file and EOF mark...
Post by: bacon on July 15, 2010, 05:09 PM
Read page 215 in Compute's 128 Programmer's Guide (http://www.bombjack.org/commodore/books/pdf/Compute%27s_128_Programmer%27s_Guide.pdf). It's all explained there.
Title: Re: Reading from file and EOF mark...
Post by: LokalHorst on July 16, 2010, 08:16 AM
there is no specific EOF mark as part of the file data - you should check location $90 aka ST the IEC status byte.
bit7 - dev. not present
bit6 - EOF
bit1 - error during read (usually file not found)
bit0 - error during write (disk full etc.)

your routine should look like:

open file
readbyteloop: read byte

(do whatever)

bit $90
bvc readbyteloop
close file
EhPortal 1.34 © 2025, WebDev