Repository navigation
Restore parent segment registers after DOS EXEC - #2610
Draft
maximilien-noal wants to merge 1 commit into
Draft
maximilien-noal wants to merge 1 commit into
maximilien-noal wants to merge 1 commit into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 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; |
|
No change in generated code or listings. Base |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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.