mirror of
https://github.com/notwa/mm
synced 2024-11-05 01:19:02 -08:00
handle immediates in place of most offsets
This commit is contained in:
parent
86ce3ea0d7
commit
3cc511182a
1 changed files with 31 additions and 1 deletions
|
@ -898,6 +898,34 @@ function Parser:instruction()
|
|||
args.immediate = {'LOWER', im}
|
||||
self:format_out(addi[3], addi[1], args, addi[4], addi[5])
|
||||
end
|
||||
elseif h[2] == 'tob' then -- or h[2] == 'Tob' then
|
||||
local lui = instruction_handlers['LUI']
|
||||
local args = {}
|
||||
args.rt = self:register()
|
||||
self:optional_comma()
|
||||
local o = self:const()
|
||||
if o[1] == 'LABELSYM' then
|
||||
self:error('unimplemented: label as an offset')
|
||||
end
|
||||
if self:is_EOL() then
|
||||
local upper = math.floor(o[2]/0x10000)
|
||||
local lower = o[2] % 0x10000
|
||||
if lower >= 0x8000 then
|
||||
-- accommodate for offsets being signed
|
||||
upper = (upper + 1) % 0x10000
|
||||
end
|
||||
local lui_args = {}
|
||||
lui_args.immediate = {'NUM', upper}
|
||||
lui_args.rt = 'AT'
|
||||
self:format_out(lui[3], lui[1], lui_args, lui[4], lui[5])
|
||||
args.offset = {'NUM', lower}
|
||||
args.base = 'AT'
|
||||
else
|
||||
args.offset = o
|
||||
self:optional_comma()
|
||||
args.base = self:deref()
|
||||
end
|
||||
self:format_out(h[3], h[1], args, h[4], h[5])
|
||||
elseif h[2] ~= nil then
|
||||
args = self:format_in(h[2])
|
||||
self:format_out(h[3], h[1], args, h[4], h[5])
|
||||
|
@ -961,7 +989,9 @@ function Parser:parse(asm)
|
|||
self:tokenize()
|
||||
self:advance()
|
||||
while true do
|
||||
if self.tt == 'EOL' then
|
||||
if self.tt == 'EOF' then
|
||||
break
|
||||
elseif self.tt == 'EOL' then
|
||||
-- empty line
|
||||
self:advance()
|
||||
elseif self.tt == 'DEF' then
|
||||
|
|
Loading…
Reference in a new issue