Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AltairZ80: Altair DOS stops responding to key presses after interrupts have been enabled. #1189

Open
Ster0pes opened this issue Jan 29, 2024 · 8 comments

Comments

@Ster0pes
Copy link

Ster0pes commented Jan 29, 2024

Hello there.

I'd like to try to write a Fortran program in Altair DOS 1.0 on the AltairZ80 emulator.
To be able to exit, say, the Fortran compiler or an infinitely looping program gracefully I need Ctrl+C to work. Therefore, when starting Altair DOS, I answer Y to the question "INTERRUPTS?".
However, as soon as I do that, Altair DOS seem to become unresponsive. I see the next prompt ("HIGHEST DISK NUMBER?") with a flashing cursor, but whatever key I press, nothing happens.
When at startup I answer N to "INTERRUPTS?" Altair DOS works as expected.

Used simulator: Altair 8800 (Z80) simulator V3.9-0 [32b data, 32b addresses, no Ethernet]
I'm using prebuilt binaries (v3.9-0, latest release at the time of writing).

These are the commands I executed. See attachments for the disk image.

at dsk altdos.dsk
set sio upper
boot dsk

MEMORY SIZE? «Enter»
INTERRUPTS? Y«Enter»
HIGHEST DISK NUMBER?

Expected behavior:
Altair DOS works as expected and applications like the Fortran compiler can be aborted using Ctrl+C.
Actual behavior:
Altair DOS stops responding to key presses. The simulator can still be exited with Ctrl+E.
altdos.dsk.zip

@deltecent
Copy link
Contributor

deltecent commented Mar 3, 2024

I do not know how version 3 of the simulator handles interrupts. I did my testing with version 4 of open-simh (not simh).

I also do not know how the default SIO device handles interrupts. I think it has a special hook into the CPU code and doesn't use the standard 8080 interrupt mechanism.

I wrote the M2SIO[0-1] device because, in my opinion, it more accurately simulates the Mits 2SIO device, including interrupt handling.

Altair DOS expects interrupts to happen on interrupt vector 7. The Intel 8080 expects the opcode to execute during an interrupt to appear on the data bus. This would be an RST 7 instruction when the hardware is configured for interrupt vector 7. RST 7 will cause the CPU to jump to the interrupt handler at 0038H.

This can be set up with the M2SIO0 device using the following:

at dsk altdos.dsk

# Enable M2SIO0 device
set m2sio0 ena

# Set interrupt vector 7
dep M2VEC0 7

# Place RST 7 opcode on data bus during interrupt
dep M2DBVAL0 FF

# Enable global interrupts
dep M2INTEN0 1

boot dsk

Interrupts should now work.

Altair 8800 (Z80) simulator Open SIMH V4.1-0 Current        git commit id: 1a1396d0

MEMORY SIZE? 
INTERRUPTS? Y
HIGHEST DISK NUMBER? 2
HOW MANY DISK FILES? 2
HOW MANY RANDOM FILES? 2

056509 BYTES AVAILABLE
DOS MONITOR VER 1.0
COPYRIGHT 1977 BY MITS INC
.

Again, this is all on open-simh Version 4 which I believe is available here.

@deltecent
Copy link
Contributor

I figured out how to get interrupts working with SIO device.

There is a bug in the SIO device when using the BOOT command. The SET SIO INTERRUPT command adds an event to the SIMH queue. Unfortunately, the BOOT command sends a RESET to all devices, which also removes all the devices' events from the queue. After a reset, the interrupt event is never added back to the queue so interrupt processing never happens.

To get around this problem, use the G FF00 command instead.

The following works on version 4 and may work on version 3:

at dsk altdos.dsk
set sio upper
set sio interrupt
g ff00

@Ster0pes
Copy link
Author

Ster0pes commented Mar 4, 2024

Hello deltecent, thanks for your reply.
altdos.txt
I'm running on the latest stable release that's listed on Github.
I tried your solution, but for me it only works to a certain extent.
Yes, I can type now, but I literally have to hold keys for a few seconds before they register.
I don't know if it's of any use, but I attached the DO file I use for starting Altair DOS.

@deltecent
Copy link
Contributor

Try it with "SET SIO NOSLEEP" and see if it works better. SIO SLEEP causes the device to call the OS sleep() routine to reduce your host CPU utilization. This wreaks havoc with SIMH's event timing, which is used to process the interrupts. If NOSLEEP makes the keyboard respond appropriately, we can work on an alternative to SIO SLEEP to help with host CPU utilization using THROTTLE. But you may have to switch to OpenSIMH. There's a bug in SIMH that prevents using one of the THROTTLE settings that is great for this purpose.

@Ster0pes
Copy link
Author

Ster0pes commented Mar 4, 2024

I replaced 'set sio sleep' with 'set sio nosleep' in my DO-file but unfortunately that didn't solve the problem.
I had a short look at OpenSIMH but at the moment I have no experience with makefiles and that sort of thing to build source code projects, so I guess I'll have to read into that first.

@joeinwap
Copy link

joeinwap commented Mar 15, 2024 via email

@deltecent
Copy link
Contributor

deltecent commented Mar 19, 2024

The bug causing Altair DOS to stop responding when interrupts are enabled has been fixed in Open SIMH.

@joeinwap
Copy link

joeinwap commented Apr 29, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants