Allow displacements to be used directly without register values.

Allows sllg r1, r1, 3(r0,r0) to be written as sllg r1, r1, 3.
This commit is contained in:
Michael Munday 2017-01-10 10:50:41 -05:00
parent dae61f59d6
commit a8562b7f34
2 changed files with 226 additions and 228 deletions

View File

@ -324,11 +324,16 @@ local function split_memop(arg)
if d then
return d, 0, parse_reg(b)
end
-- Assuming the two registers are passed as "(r1,r2)", and displacement(d) is not specified
-- Assume the two registers are passed as "(r1,r2)", and displacement(d) is not specified. TODO: not sure if we want to do this, GAS doesn't.
local x, b = match(arg,"%(%s*("..reg..")%s*,%s*("..reg..")%s*%)$")
if b then
return 0, parse_reg(x), parse_reg(b)
end
-- Accept a lone integer as a displacement. TODO: allow expressions/variables here? Interacts badly with the other rules currently.
local d = match(arg,"^(-?[%d]+)$")
if d then
return d, 0, 0
end
local reg, tailr = match(arg, "^([%w_:]+)%s*(.*)$")
if reg then
local r, tp = parse_reg(reg)
@ -336,13 +341,6 @@ local function split_memop(arg)
return format(tp.ctypefmt, tailr), 0, r
end
end
-- Assuming that only displacement is passed, as either digit or label "45 or label1"
local d = match(arg,"[%w_]+")
if d then
return d, 0, 0
end
-- TODO: handle values without registers?
-- TODO: handle registers without a displacement? -- done, above ,needs to be tested
werror("bad memory operand: "..arg)
return nil
end

File diff suppressed because it is too large Load Diff