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

Fix emits killing lua on emitted interrupt #28

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 3 additions & 1 deletion lua/wire/zvm/zvm_core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
then pad = pad - 1 end

if string.find(text,"elseif") or string.find(text,"else")
then self.EmitBlock = self.EmitBlock..string.rep(" ",pad-1)..text.."\n"

Check warning on line 35 in lua/wire/zvm/zvm_core.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator

Check warning on line 35 in lua/wire/zvm/zvm_core.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace after ')'

Check warning on line 35 in lua/wire/zvm/zvm_core.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator
else self.EmitBlock = self.EmitBlock..string.rep(" ",pad)..text.."\n"

Check warning on line 36 in lua/wire/zvm/zvm_core.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator
end

if (string.find(text,"if") or string.find(text,"for"))
Expand Down Expand Up @@ -265,11 +265,13 @@

--------------------------------------------------------------------------------
-- 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)
DerelictDrone marked this conversation as resolved.
Show resolved Hide resolved
self:Dyn_EmitBreak()
end

Expand Down
4 changes: 2 additions & 2 deletions lua/wire/zvm/zvm_opcodes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,11 @@
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)")
Expand Down Expand Up @@ -458,8 +458,8 @@
--------------------------------------------------------------------------------
ZVM.OpcodeTable[70] = function(self) --EXTINT
self:Dyn_EmitState()
self:Emit("VM.IP = %d",(self.PrecompileIP or 0))

Check warning on line 461 in lua/wire/zvm/zvm_opcodes.lua

View workflow job for this annotation

GitHub Actions / lint

"Unnecessary parentheses"

Unnecessary parentheses
self:Emit("VM.XEIP = %d",(self.PrecompileTrueXEIP or 0))

Check warning on line 462 in lua/wire/zvm/zvm_opcodes.lua

View workflow job for this annotation

GitHub Actions / lint

"Unnecessary parentheses"

Unnecessary parentheses
self:Dyn_Emit("VM:ExternalInterrupt(math.floor($1))")
self:Dyn_EmitBreak()
self.PrecompileBreak = true
Expand Down Expand Up @@ -687,7 +687,7 @@
self:Dyn_Emit("end")
end
ZVM.OpcodeTable[98] = function(self) --TIMER
self:Dyn_EmitOperand("(VM.TIMER+%d*VM.TimerDT)",(self.PrecompileInstruction or 0))

Check warning on line 690 in lua/wire/zvm/zvm_opcodes.lua

View workflow job for this annotation

GitHub Actions / lint

"Unnecessary parentheses"

Unnecessary parentheses
end
ZVM.OpcodeTable[99] = function(self) --LIDTR
self:Dyn_Emit("VM.IDTR = $1")
Expand Down Expand Up @@ -1046,7 +1046,7 @@
ZVM.OpcodeTable[126] = function(self) --LEA
local emitText = self.OperandEffectiveAddress[self.EmitOperandRM[2]] or "0"
emitText = string.gsub(emitText,"$BYTE",self.EmitOperandByte[2] or "0")
emitText = string.format(string.gsub(emitText,"$SEG","VM[%q]",(self.EmitOperandSegment[2] or "DS")))

Check warning on line 1049 in lua/wire/zvm/zvm_opcodes.lua

View workflow job for this annotation

GitHub Actions / lint

"Unnecessary parentheses"

Unnecessary parentheses
self:Dyn_EmitOperand(emitText)
end
ZVM.OpcodeTable[127] = function(self) --BLOCK
Expand Down Expand Up @@ -1188,7 +1188,7 @@
self:Dyn_Emit("V = VM:Pop()") -- IRET EIP
self:Dyn_EmitInterruptCheck()

for i=0,31 do

Check warning on line 1191 in lua/wire/zvm/zvm_opcodes.lua

View workflow job for this annotation

GitHub Actions / lint

"Whitespace style"

Style: Please put some whitespace before the operator
self:Dyn_Emit("V = VM:Pop()") self:Dyn_EmitInterruptCheck() self:Dyn_Emit("VM.R%d = V")
end

Expand Down Expand Up @@ -1641,7 +1641,7 @@
self:Dyn_EmitInterruptCheck()
end
ZVM.OpcodeTable[269] = function(self) --VLEN
local seg1code = self.EmitOperandSegment[1] and "0" or "VM.DS"

Check warning on line 1644 in lua/wire/zvm/zvm_opcodes.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: seg1code
local seg2code = self.EmitOperandSegment[2] and "0" or "VM.DS"
self:Dyn_Emit("if VM.VMODE == 2 then")
self:Dyn_Emit("$L V = VM:ReadVector2f($2 + %s)",seg2code)
Expand Down
Loading