Skip to content
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

Instructions for setting the cpu error or clearing it in programs #13

Merged
merged 5 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lua/wire/cpulib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,8 @@ CPU(137, "EXTRETP", 1, 10.00, R0, "PTBL", "", "Set PTBL,
CPU(140, "EXTRETA", 0, 11.00, R0, "", "", "Return from an external interrupt and restore R0-R31 registers")
CPU(141, "EXTRETPA", 1, 11.00, R0, "PTBL", "", "Set PTBL, then return from an external interrupt with restoring R0-R31 registers")
---- Dec 15 -- UNDEFINED ------------------------------------------------------------------------------------------------------------------------
CPU(150, "STERR", 2, 3.00, R0, "X", "Y", "Output an external error where X is error number and Y is error parameter")
CPU(151, "CLERR", 0, 1.00, R0, "", "", "Clear the external error output")
---- Dec 16 -- UNDEFINED ------------------------------------------------------------------------------------------------------------------------
---- Dec 17 -- UNDEFINED ------------------------------------------------------------------------------------------------------------------------
---- Dec 18 -- UNDEFINED ------------------------------------------------------------------------------------------------------------------------
Expand Down
10 changes: 10 additions & 0 deletions lua/wire/zvm/zvm_opcodes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,16 @@ ZVM.OpcodeTable[141] = function(self) --EXTRETPA
end


ZVM.OpcodeTable[150] = function(self) -- STERR
self:Dyn_Emit("$L P = $2")
self:Dyn_Emit("P = P * (10^math.floor(-math.log10(math.abs(P)+1e-12)-1))")
self:Dyn_Emit("VM:SignalError(math.floor($1)+P)")
DerelictDrone marked this conversation as resolved.
Show resolved Hide resolved
end

ZVM.OpcodeTable[151] = function(self) -- CLERR
self:Dyn_Emit("VM:SignalError(0)")
end

--------------------------------------------------------------------------------
ZVM.OpcodeTable[250] = function(self) --VADD
self:Dyn_Emit("if VM.VMODE == 2 then")
Expand Down