-
Notifications
You must be signed in to change notification settings - Fork 33
[WIP] Implement interrupts #51
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
base: master
Are you sure you want to change the base?
Conversation
|
When implementing privileged instructions (which was generally quite simple), I noticed that fetch/decode and execute steps should be separated. |
|
I can't find where pseudo halt is implemented. I think it should happen only if timer and hardware interrupts are disabled. Only in that case could a busy wait not be interrupted. Also there seems to be an idle flag in SW. Does that mean that instructions would not be executed if the processor would be in idle state? |
|
TODO (GUI):
|
|
I'm happy with the changes and I'm done for now. |
done |
I had assumed it is enough to set text for start/stop button in the update method. But since the displayedMnemonicIndex is set, the empty text throws an exception.
I tried implementing interrupts. There is still some work to do.
SVC,STIandLPSinstructions now work.SVCand timer interrupts are implemented.Also added two test programs:
interrupts.asm–entrysets up theSWthen jumps to some code, that triggers twoSVCinterrupts.interrupts_timer.asm– main loop printsA, and is interrupted by interrupt handler that printsTIM. Then the timer is reset to random value. It should be used with-a addons/out/make/rand.jarI also changed
SVCinstruction in asm so that it can both r1 and r2 can be used. This seems logical to me (interrupt code can hold a whole byte) and might be a mistake in Beck's book, since the processor is very hypotethical. Although I haven't read the relevant chapters in the book as precisely this time and may have missed something.All current programs should work out-of-the-box, since the processor starts in privileged mode and all interrupts are masked. Those two states can only be changed by writing to
SW, which is very hard to do accidentally (to my knowledge only method is withLPSinstruction). There is still question about faults that wrote an erro to the logger (for example invalid opcode, addressing or division by zero). If the program interrupt is enabled, the behaviour is quite clear. In other cases (default) should the error still be output or should we just silently continue executing?Early comments are appreciated.
TODO:
MODEinSWbefore executing an instruction. Should also need a software interrupt.)IDinSWset by the "kernel" – not sure if anything has to be done in vm)label J label) should maybe not stop the processor if interrupts are enabled.