(ASM) Need a litttle help - loading a file

Started by SOS, 18:55, 10 January 15

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

SOS

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

AMSDOS

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.

* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Powered by SMFPacks Menu Editor Mod