Hello, Guest the thread was viewed345 times and contains 3 replies

last post from Kibabalu at the

Writing to a file and reading from a file in C using LLVM-MOS-SDK

  • I'm still struggling to write to files or read from files in C using the LLVM-SDK.


    I wrote my own library with implementations of the kernal functions open, close, setnam, ckout, bsout , etc. with the hope, that I can use those kernal functions from C. Most of the code works fine, at least is the returned error code of the 'open' call 0. But then calling 'ckout' gives always the return code 7, what means 'bad device'. I checked the code again and again without finding the quirk.


    ChatGPT gave just bullshit answers (first use kernal functions, then kernal is mapped out and it is not possible to use kernal functions, you have to map it in first, etc.) and the delivered code never worked and was obviously bullshit. It took me a couple days to visit all this rabbit holes. Then I asked for the sources for the proposals and it turned out none of them, mostly just the mega65 handbooks at GitHub, included anything of the proposed. It was just 'dreamed' by chatGPT. Strange!


    Now I'm really exhausted. I went into all rabbit holes I know. There seems to be a fundamental lack of knowledge on my side. Is there some speciality I have to be beware of I don't know? Or is it just not possible to use the kernal functions using the LLVM-MOS-SDK?

  • Kibabalu

    Changed the title of the thread from “Writing to a file and reading from a file in C using LLVM-MOS resp. clang” to “Writing to a file and reading from a file in C using LLVM-MOS-SDK”.
  • I wrote a game prototype using llvm-mos a while ago: Collab: Entwicklung eines TSB-Puzznic-Klons but that doesn't use KERNAL routines. I was quite happy with llvm-mos concerning generated code size and speed.


    You can examine things in an emulator (monitor) and debug there (not sure about the Mega64 but certainly in VICE/x64).

  • Managed to port my game Pasca's Siege from LLVM-MOS-SDK to Calypsi Tool Chain. Most of the mega-libc libraries are quite easy to port over by editing their include paths. Just a few made problems because of assembler code. There's a difference in syntax and calling convention. Fortunately, my game didn't use one of these.


    The game is now slightly slower and approx. 50% bigger compared to the LLVM-MOS code.
    Anyawy, now I'm happy ;-)


    Using the LLVM-MOS-SDK it wasn't possible to write or read to the disk, at least not for me. With the calypsi tool chain it worked immediately. Now I can add longer sound files during runtime :-)