Skip to content

Commit

Permalink
Fix emits killing lua on emitted interrupt (#28)
Browse files Browse the repository at this point in the history
* Fix emits killing lua on emitted interrupt

* Fix for CPG using idx and not IDX

* Fix for CPG indexing VM.Page when it should index PAGE

* Requested comment for dyn_emitinterrupt
DerelictDrone authored Dec 11, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 8f72574 commit ac69f02
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lua/wire/zvm/zvm_core.lua
Original file line number Diff line number Diff line change
@@ -265,11 +265,13 @@ end

--------------------------------------------------------------------------------
-- Emit interrupt call
-- intNo can only be numeric or "$1"
-- intParam can only be numeric or "IDX"
function ZVM:Dyn_EmitInterrupt(intNo,intParam)
self:Dyn_EmitState()
self:Emit("VM.IP = %d",(self.PrecompileIP or 0))
self:Emit("VM.XEIP = %d",(self.PrecompileTrueXEIP or 0))
self:Dyn_Emit("VM:Interrupt(%d,%d)",intNo,intParam)
self:Dyn_Emit("VM:Interrupt(%s,%s)",intNo,intParam)
self:Dyn_EmitBreak()
end

4 changes: 2 additions & 2 deletions lua/wire/zvm/zvm_opcodes.lua
Original file line number Diff line number Diff line change
@@ -234,11 +234,11 @@ ZVM.OpcodeTable[28] = function(self) --SPG
self:Dyn_Emit("end")
end
ZVM.OpcodeTable[29] = function(self) --CPG
self:Dyn_Emit("$L idx = math.floor($1 / 128)")
self:Dyn_Emit("$L IDX = math.floor($1 / 128)")
self:Dyn_Emit("$L PAGE = VM:GetPageByIndex(IDX)")
self:Dyn_EmitInterruptCheck()

self:Dyn_Emit("if VM.CurrentPage.RunLevel <= VM.Page[idx].RunLevel then")
self:Dyn_Emit("if VM.CurrentPage.RunLevel <= PAGE.RunLevel then")
self:Dyn_Emit("PAGE.Read = 1")
self:Dyn_Emit("PAGE.Write = 1")
self:Dyn_Emit("VM:SetPageByIndex(IDX)")

0 comments on commit ac69f02

Please sign in to comment.