Skip to content

Conversation

@DerelictDrone
Copy link
Member

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)
image

@DerelictDrone DerelictDrone merged commit 7adeecf into wiremod:master Sep 6, 2024
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