Repository navigation
Fix interrupt(): clear INTE on acceptance, EI delay, 11 T-states; remove global T - #14
Merged
Merged
Conversation
…emove global T - interrupt() now clears INTE (and a pending EI), wakes from HLT, pushes PC, jumps to the vector (interrupt(0) -> 0x0000, default 0x38) and adds 11 T-states - EI enables interrupts only after the following instruction; DI cancels a pending EI - reset clears a pending EI - remove the undeclared T=0 in steps() that leaked a global - add Interrupts regression tests, adjust reset tests for the EI delay - document interrupt() in README Closes #13
4 tasks
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.
Closes #13
Changes (
8080.js)interrupt(vector)): clears INTE and any pending EI, wakes a halted CPU, pushes PC, jumps to the vector and adds 11 T-states. The vector uses an explicitundefinedcheck, sointerrupt(0)now jumps to0x0000(the default is still0x38).EIsetseiPending, and INTE becomes 1 only after the following instruction, soEI; RETat the end of a handler is safe.DIclears INTE and cancels a pending EI.resetand theCpuconstructor initialiseeiPending.T: removed the undeclaredT=0;insteps().Deviation from the proposed snippet: the issue's
step()applied the pending enable after executing the next instruction. With that code,EI; DIwould end with interrupts enabled, because DI's clear gets overwritten, and that contradicts the "DI cancels a pending EI" requirement. Interrupts are only accepted betweenstep()calls, so this PR sets INTE right before the instruction after EI. Seen from outside, the timing is identical: no interrupt can be taken between EI and the next instruction. A following DI now correctly wins.Tests
Interruptssuite intest/node/cpu8080.test.jscovering:EI; HLTfollowed by an interrupt wakes the CPU and returns after HLTinterrupt(0)jumps to0x0000and the default vector is0x38globalThis.Taftersteps()test/node/cpu8080.test.jsandtest/tests.js(QUnit) now step twice to get past the EI delay.npm test: 18/18 pass, including the cpudiag diagnostic. The reproduction from the issue now prints38 11,38,undefined.Docs
interrupt(vector).