Resetting the Emulator When It Locks Up

All aspects of programming on the Commander X16.
Post Reply
Martin Schmalenbach
Posts: 140
Joined: Tue Jul 21, 2020 10:08 pm

Resetting the Emulator When It Locks Up

Post by Martin Schmalenbach »

Apologies if my searches have missed the answer to this, but...

... how can I 'reset' the emulator when it is running a user-loaded machine language routine that doesn't respond to CTRL-C - I'd like to get back to the BASIC environment, ideally with any BASIC program intact, without having to exit the emulator and then restart it?

Cheers in advance,

Martin
User avatar
StephenHorn
Posts: 565
Joined: Tue Apr 28, 2020 12:00 am
Contact:

Re: Resetting the Emulator When It Locks Up

Post by StephenHorn »

It is up to the machine-language program whether or not it will respond to Ctrl-C or the Run/Stop key, and even if it normally handles those keys then it may still fail to return to the BASIC environment if the program becomes unresponsive. This is because machine language programs can do literally anything they want on the system, including overriding 99% of the kernal's interrupt process (and the remaining 1% is the minimal overhead necessary to invoke the interrupt in the first place). There is no "protected mode" or "ring 0" separate from a running process.

Edited to add: In fact, a machine-language program can take such total control over the system that, asides from that 1% overhead on interrupts, it can completely ignore the kernal, trash all of the kernal's memory, and generally do whatever it pleases to any writable component, which may well leave the X16 in a state where it cannot meaningfully return to the BASIC environment and thus requires a complete system reboot and reload in order to be started again.

Welcome to the metal. <3
Developer for Box16, the other X16 emulator. (Box16 on GitHub)
I also accept pull requests for x16emu, the official X16 emulator. (x16-emulator on GitHub)
TomXP411
Posts: 1781
Joined: Tue May 19, 2020 8:49 pm

Re: Resetting the Emulator When It Locks Up

Post by TomXP411 »

Control+R triggers a “hardware” reset of the emulator.

(This really needs to change, but it is what it is for now.)

You can use “old” to recover a BASIC program, as a reset doesn’t generally clear memory.
Martin Schmalenbach
Posts: 140
Joined: Tue Jul 21, 2020 10:08 pm

Re: Resetting the Emulator When It Locks Up

Post by Martin Schmalenbach »

Thanks all, and esp. TomXP411 for the CTRL-R info!

Cheers

Martin
Post Reply