add aliases, fix cond jumps
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
local arch8608 = require("rom-8608-defs")
|
||||
|
||||
local aliases = {
|
||||
-- todo
|
||||
["jpz imm8"] = {"jeq imm8"},
|
||||
["jnz imm8"] = {"jne imm8"},
|
||||
["jmp q" ] = {"ret" },
|
||||
}
|
||||
|
||||
local function trim(s) return s:gsub("^ +", ""):gsub(" +$", "").."" end
|
||||
@@ -357,13 +359,18 @@ local function instrsFromArch(arch)
|
||||
["word [ imm8 ]" ] = function(imms) return arraySize(imms)*2, false end,
|
||||
["word [ imm16 ]"] = function(imms) return arraySize(imms)*2, false end,
|
||||
}
|
||||
local function addMnem(mnem, opcode)
|
||||
instrs[mnem] = opcode
|
||||
if mnem:find("%*") then instrs[mnem:gsub("%*", "%[").." ]"] = opcode end
|
||||
end
|
||||
for _, instr in ipairs(arch.instructions) do
|
||||
if instr.mnem then
|
||||
local mnem = instr.mnem
|
||||
mnem = mnem:gsub("([%*%+%-])", " %1 ")
|
||||
mnem = trim(mnem):gsub(" +", " ")
|
||||
instrs[mnem] = instr.opcode
|
||||
if mnem:find("%*") then instrs[mnem:gsub("%*", "%[").." ]"] = instr.opcode end
|
||||
addMnem(mnem, instr.opcode)
|
||||
local alias = aliases[trim(mnem)]
|
||||
if alias then for _, v in ipairs(alias) do addMnem(v, instr.opcode) end end
|
||||
end
|
||||
end
|
||||
return instrs
|
||||
|
||||
Reference in New Issue
Block a user