Privileged instructions can now be proxied by interrupt 13 #66
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.
Now upon executing a privileged instruction without being of the right runlevel, the interrupt will pass the privileged instruction's operands into PreqOperand1 and PreqOperand2, and certain instructions that needed to write to an operand can now retrieve a return value from PreqReturn.
Internal registers added:
71 = PreqOperand1 | in MOV R0,R1, this would hold R0
72 = PreqOperand2 | in MOV R0,R1, this would hold R1
73 = PreqReturn | The number to be returned, if the instruction needs one.
74 = PreqHandled | Whether or not this request was handled, is set to -1 on entering interrupt, if set to 1 then PreqReturn will be used if needed. As long as it's nonzero the privileged instruction is considered handled on return
Opcodes that will use PreqReturn:
CPUGET
RD
GMAP (which I've also fixed in this PR)
Example use cases:
Overriding program's use of CPUGET, you could make a program that gets register 43(size of cpu internal memory) instead receive the size of the program's allotted memory(making it work without needing to recompile it to use a constant mem size)
Running previously privileged code without having to put it on runlevel 0, by handling specific instructions and ignoring others rather than flat out denying all.
Example code:
(This divides the CPU's memory by 2 before returning it)