[Emulator] OLD - command crashes (on start / reset with no 'old' code)

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
OldOzC64er
Posts: 8
Joined: Wed Jan 25, 2023 8:03 am

[Emulator] OLD - command crashes (on start / reset with no 'old' code)

Post by OldOzC64er »

The OLD command is still crashing the emulator (R46, Windows 10), if you enter it when there is no past program history. On boot, type OLD (enter) and it will hang. If you were to boot up, move around screen, even type in 10 (enter) [with no program] and then try OLD it will still hang. If you enter some function/command it seems to break the spell - so, if you direct enter PRINT "HELLO" (enter) then it seems to be okay if type OLD.
* I don't have a x16 computer, so not sure if it's the same in hardware version.
mortarm
Posts: 228
Joined: Tue May 16, 2023 6:21 pm

Re: [Emulator] OLD - command crashes (on start / reset with no 'old' code)

Post by mortarm »

OldOzC64er wrote: Mon Dec 11, 2023 3:56 am ...if you direct enter PRINT "HELLO" (enter) then it seems to be okay if type OLD.
Mine hangs, also R46 w/Win10.
kelli217
Posts: 512
Joined: Sun Jul 05, 2020 11:27 pm

Re: [Emulator] OLD - command crashes (on start / reset with no 'old' code)

Post by kelli217 »

I believe this is a known issue, and one that I don't think anyone is inclined to fix.
OldOzC64er
Posts: 8
Joined: Wed Jan 25, 2023 8:03 am

Re: [Emulator] OLD - command crashes (on start / reset with no 'old' code)

Post by OldOzC64er »

Mine hangs, also R46 w/Win10.
Hmm... I can't seem to replicate what I did when I noticed this? Mine too just hangs even after the print command.
DragWx
Posts: 306
Joined: Tue Mar 07, 2023 9:07 pm

Re: [Emulator] OLD - command crashes (on start / reset with no 'old' code)

Post by DragWx »

It's because the "OLD" command naively assumes there's a valid BASIC program in memory at $0801, and in your case, the emulator is likely initializing RAM to random values instead, so the routine is trying to scan through garbage data as though it were a BASIC program and it ends up choking. :P

More specifically, the issue is in x16rom/basic/code1.s, at lnkprg. This routine needs to read some zeroes at the correct times in order to terminate. With garbage data, it probably won't, so it gets stuck in a loop like you're seeing.

EDIT: I don't think the solution is necessarily to update lnkprg, but instead to update the OLD command itself to do some kind of contingency check to make sure something that "looks like" a BASIC program is indeed at $0801 before doing anything else.
OldOzC64er
Posts: 8
Joined: Wed Jan 25, 2023 8:03 am

Re: [Emulator] OLD - command crashes (on start / reset with no 'old' code)

Post by OldOzC64er »

Thanks for explanation.

I noticed a previous post from Tomxp411 mentioning the CTRL + R key to reset, and it seems to work in this lock-up 👍.
It's fringe case situation that someone does enter OLD, but I was more wondering if it pointed to a bigger issue (originally).
DragWx
Posts: 306
Joined: Tue Mar 07, 2023 9:07 pm

Re: [Emulator] OLD - command crashes (on start / reset with no 'old' code)

Post by DragWx »

It may be fringe, but I'm all for eliminating any kind of "lol here's how you can crash the X16 with one simple command lol" memes. :P
User avatar
JimmyDansbo
Posts: 450
Joined: Sun Apr 26, 2020 8:10 pm
Location: Denmark
Contact:

Re: [Emulator] OLD - command crashes (on start / reset with no 'old' code)

Post by JimmyDansbo »

kelli217 wrote: Mon Dec 11, 2023 6:16 pm I believe this is a known issue, and one that I don't think anyone is inclined to fix.
I have just created a pull request that will prevent OLD command from hanging.
https://github.com/X16Community/x16-rom/pull/237
Granted, it will restore a random BASIC line, but it does not hang.
Visit my Github repo
or my personal site with CX16/C64/6502 related information.
Feel free to contact me regarding any of my projects or even about meeting up somewhere near Denmark
Post Reply