Kernal LOAD does not always return an error when failing

This is the starting place for reporting bugs to the team. We will pass bug reports on to the developers after validating the reports.

You can report bugs in hardware, operating system (KERNAL or BASIC ROMs), the emulator, or the Demo library. For bugs specific to downloaded programs, use the download forum.
Post Reply
Johan Kårlin
Posts: 286
Joined: Wed Jun 03, 2020 11:33 am
Location: Kalmar, Sweden

Kernal LOAD does not always return an error when failing

Post by Johan Kårlin »

I load files with the following routine in the emulator R43:

LoadFile:
;IN: ZP0, ZP1 = filename
; ZP2, ZP3 = load address,
; ZP4 = RAM or VRAM (0 = load, 1 = verify, 2 = VRAM bank 0, 3 = VRAM bank 1)
; ZP5 = header or not (0 = file contains header, 2 = no header)
jsr GetStringLength ;will return length of filename in .A
ldx ZP0
ldy ZP1
jsr SETNAM
lda #$02
ldx #$08 ;device
ldy ZP5 ;header or not
jsr SETLFS
ldx ZP2 ;load address
ldy ZP3
lda ZP4 ;RAM or VRAM
jsr LOAD ;KERNAL routine
rts

When I try to load a headerless file that doesn't exist (by setting .Y to 2 before calling SETLFS), I get no indication that LOAD has failed. I expect the carry flag to be set and an error number in .A. When loading files with headers, everything works.

I asked about this in a Discord when R41 was the latest KERNAL version. I think Zerobyte created an issue about it but I cannot find any open issue relating to this, and I just realized that the problem is still there.
User avatar
desertfish
Posts: 1038
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Re: Kernal LOAD does not always return an error when failing

Post by desertfish »

If you're running on hostfs, this was an emulator issue that got fixed in https://github.com/X16Community/x16-emulator/pull/109
Johan Kårlin
Posts: 286
Joined: Wed Jun 03, 2020 11:33 am
Location: Kalmar, Sweden

Re: Kernal LOAD does not always return an error when failing

Post by Johan Kårlin »

Ok, fine. Then it will work in R44 as I understand it.
User avatar
desertfish
Posts: 1038
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Re: Kernal LOAD does not always return an error when failing

Post by desertfish »

I think so! In the meantime you can use READST and check the result status to detect a load error even when using headerless load.
Johan Kårlin
Posts: 286
Joined: Wed Jun 03, 2020 11:33 am
Location: Kalmar, Sweden

Re: Kernal LOAD does not always return an error when failing

Post by Johan Kårlin »

Thanks for the tip! I didn’t know about that.
Post Reply