Hi there!
I'm try to load a file from Disc in ASM, but i have no success, my
latest Version (for test-reasons i use call&bb5a instead of write to the memory):
ld hl,Testfile
ld b,12
ld de,Buffer
call CAS_IN_OPEN
jr nc,error
read_one_char:
call CAS_TEST_EOF
jr nc,eof_found
call CAS_IN_CHAR ; "a" is everytime "Zero"!!! Why? :(
;jp nc,check_eof ; needed?
call &bb5a
jr read_one_char
eof_found:
call CAS_IN_CLOSE
ret
check_eof:
cp 26 ; cp &e / cp &f ?!
jr z,eof_found
jp read_one_char
error:
call CAS_IN_ABADON
ret
Testfile
defb "FC .TXT"
Has someone an idea, what's wrong with the code?
Thanks & Bye
Bernd
This is what i came up with which seems to be working with my ASCII files:
org <wherever>
ld b,12
ld hl,testfile
ld de,buffer
call &bc77
.readchar
call &bc89
jr nc,eof_found
call &bc80
push hl
ld hl,buffer
ld (hl),a
inc (hl)
pop hl
;; call &bb5a
jr readchar
.eof_found
call &bc7a
ret
.testfile
defb "filename.ext"
.buffer
defb 0
Just note I'm reading the Text into the Buffer (wherever you decide to put it in memory), but I did test the output which appeared to be fine.