I'm trying to load a file from hyppo in C, with llvm-mos on latest Xemu. But whatever I do, I always get 88 error code (file not found). Example:
- __attribute((aligned(256))) const char *name = "GLLOOK.INF";
- uint8_t name_hi = (uint8_t)(((uint16_t)&name) >> 8)
- uint8_t r = 0;
- // clang-format off
- __asm__ volatile(
- "ldx #$00\n"
- "lda #$2e\n" // hyppo_setname
- "sta $d640\n"
- "clv\n"
- :
- : "y"(name_hi)
- );
- // clang-format on
- // clang-format off
- __asm__ volatile(
- " ldz #$10\n"
- " ldy #$00\n"
- " ldx #$00\n"
- " lda #$36\n" // hyppo_loadfile
- " sta $d640\n"
- " clv\n"
- " bcc ler%=\n"
- " lda #0\n"
- " jmp lok%=\n"
- "ler%=:\n"
- " lda #$38\n" // hyppo_geterrorcode
- " sta $d640\n"
- " clv\n"
- "lok%=:\n"
- : "=a"(r)
- );
I also tried hyppo_findfile + hyppo_openfile + hyppo_readfile but with same results. File definitely exists and hyppo services are working as I can use hyppo_opendir + hyppo_readdir to read the contents.
The name string starts at page boundary as expected according to documentation (though it seems setfile function can actually read string from any location and expects X to hold low byte of the address), in my case it's $3000. If I printf the string, it's correct. I tried upper case and lower case too. If I inspect dissassembled code, it also looks correct:
- 2050: a0 30 ldy #$30
- 2052: a2 00 ldx #$0
- 2054: a9 2e lda #$2e
- 2056: 8d 40 d6 sta $d640 ; 0xd640 <__heap_start+0xa63e>
- 2059: b8 clv
- 205a: a3 c0 ldz #$10
- 205c: a0 00 ldy #$0
- 205e: a2 00 ldx #$0
- 2060: a9 36 lda #$36
- 2062: 8d 40 d6 sta $d640 ; 0xd640 <__heap_start+0xa63e>
- 2065: b8 clv
- 2066: 90 05 bcc $206d <ler0>
- 2068: a9 00 lda #$0
- 206a: 4c 73 20 jmp $2073 <lok0>
- 0000206d <ler0>:
- 206d: a9 38 lda #$38
- 206f: 8d 40 d6 sta $d640 ; 0xd640 <__heap_start+0xa63e>
- 2072: b8 clv
- 00002073 <lok0>:
- 2073: 85 22 sta $22 ; 0x2022 <_start+0xb>
looking at Xemu log hints at the issue - setname seems to set wrong name but I don't know why:
- HDOS: entering function #$2E (setname) A=$2E X=$00 Y=$30 Z=$00
- HDOS: leaving function #$2E (setname) with carry SET (A,X,Y,Z=$2E,$00,$30,$00)
- HDOS: setname: selected filename is [x/] from $3000
- HDOS: entering function #$36 (loadfile) A=$36 X=$00 Y=$00 Z=$10
- HDOS: leaving function #$36 (loadfile) with carry CLEAR (A,X,Y,Z=$88,$00,$00,$10)
- HDOS: entering function #$38 (geterrorcode) A=$38 X=$00 Y=$00 Z=$10
- HDOS: leaving function #$38 (geterrorcode) with carry SET (A,X,Y,Z=$88,$00,$00,$10)
Any pointers would be appreaciated!