Updated the addressing mode working

The case where immediate was passed as label was not covered initially, so updated it
This commit is contained in:
niravthakkar 2016-12-06 12:23:51 +05:30 committed by GitHub
parent 73ad6dc77d
commit 2156278508

View File

@ -370,10 +370,15 @@ end
local function parse_imm(arg) local function parse_imm(arg)
local imm_val = tonumber(arg,16) local imm_val = tonumber(arg,16)
if not is_int32(imm_val) then if imm_val then
werror("Immediate value out of range: ", imm_val) if not is_int32(imm_val) then
werror("Immediate value out of range: ", imm_val)
end
wputhw(band(shr(imm_val, 16), 0xffff));
wputhw(band(imm_val, 0xffff));
else
waction("IMM32", nil, arg) -- if we get label
end end
return imm_val
end end
local function parse_label(label, def) local function parse_label(label, def)
@ -1042,8 +1047,8 @@ local function parse_template(params, template, nparams, pos)
elseif p == "n" then elseif p == "n" then
op0 = op0 + shl(parse_gpr(params[1]), 4) op0 = op0 + shl(parse_gpr(params[1]), 4)
local imm = parse_imm(params[2]) wputhw(op0);
wputhw(op0); waction("IMM32", nil, imm) parse_imm(params[2])
elseif p == "q" then elseif p == "q" then
local d, b, a = parse_mem_b(params[3]) local d, b, a = parse_mem_b(params[3])
op1 = op1 + shl(parse_gpr(params[1]), 4) + parse_gpr(params[2]) op1 = op1 + shl(parse_gpr(params[1]), 4) + parse_gpr(params[2])