Skip to content

Restore parent segment registers after DOS EXEC - #2610

Draft
maximilien-noal wants to merge 1 commit into
masterfrom
fix/dos-parent-registers
Draft

maximilien-noal wants to merge 1 commit into
masterfrom
fix/dos-parent-registers

Conversation

@maximilien-noal

Copy link
Copy Markdown
Member

Description of Changes

Save parent DS and ES below the DOS interrupt frame and restore them when a child terminates. Preserve the root shell's existing segment behavior.

Rationale behind Changes

A parent program can continue after a child exits without losing its data segment registers.

Suggested Testing Steps

  • dotnet build tmp\real-mode-pr\src\Spice86.sln --no-restore --nologo -v:q: passed with 0 warnings and 0 errors.
  • Local tests were not run as requested. Automatic GitHub checks may run.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings December 3, 2026 08:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unmodeled DS/ES inputs can cause generated DOS calls to save stale segment values, and the contract harness’s differential checks fail.

1 open issue
What changed in this PR

This PR preserves a parent DOS program's DS and ES registers after an EXEC child exits, while retaining the root shell's existing behavior.

Changes:

  • Save DS/ES below the DOS interrupt frame.
  • Restore saved segments on child termination, sharing parent-stack saving across COM and EXE loaders.
File Description
src/​Spice86.Core/​Emulator/​OperatingSystem/​DosProcessManager.cs Saves and restores parent segments while preserving root-shell handling.
src/​Spice86.Core/​Emulator/​InterruptHandlers/​Dos/​DosInt21Handler.cs Records DS/ES alongside the caller's interrupt-frame pointer.

Review effort: Balanced

Comment on lines +2376 to +2377
Memory.UInt16[ss, (ushort)(callerSp - Stack.InterruptFrameSize - 4), SegmentAccessKind.Stack] = State.DS;
Memory.UInt16[ss, (ushort)(callerSp - Stack.InterruptFrameSize - 2), SegmentAccessKind.Stack] = State.ES;
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

No change in generated code or listings. Base 7ee006f4, head 384cfe10.
Warning: the head dump step failed; missing or changed scenarios can come from test failures.

Full diff and dumps (zip) · Run

@maximilien-noal maximilien-noal self-assigned this Dec 3, 2026
@maximilien-noal
maximilien-noal marked this pull request as draft December 3, 2026 20:49

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

2 participants