1
0
Fork 0
mirror of https://github.com/notwa/lips synced 2024-04-26 15:23:23 -07:00

fix loading labels with overflowed PC

This commit is contained in:
Connor Olding 2016-10-14 04:50:14 -07:00
parent 11b62bf9de
commit 575af689b5

View File

@ -221,6 +221,15 @@ function Dumper:fill(length, content)
end
function Dumper:pc()
--[[ work around a potential overflow issue. consider the assembly:
.base 0x80000000 ; possibly by default and not explicitly written
.org 0x80001000
mylabel:
la a0, mylabel ; BUG: this would load 0x1000 instead of 0x80001000
--]]
if self.pos >= 0x80000000 and self.base >= 0x80000000 then
return self.pos - 0x80000000 + self.base
end
return self.pos + self.base
end