Added MOV r8,(hhll) instructions.

This commit is contained in:
mooz 2018-11-17 23:40:10 +01:00
parent b47f3ebb99
commit ec56b7b504
3 changed files with 66 additions and 43 deletions

View File

@ -1533,45 +1533,50 @@ local function ParseLua(src, src_name)
end end
if opcode_mov[op] then if opcode_mov[op] then
tok:Save() tok:Save()
local r0_name = tok:Get(tokenList).Data local r0_name, r1_name = tok:Get(tokenList).Data, ''
if not Registers_7801[r0_name] then if Registers_7801[r0_name] then
tok:Restore() tok:Commit()
if not tok:ConsumeSymbol('(', tokenList) then if not tok:ConsumeSymbol(',', tokenList) then
return false, GenerateError("Opcode " .. op .. " doesn't support this addressing mode") return false, GenerateError("Opcode " .. op .. " doesn't support this addressing mode")
end end
inverse_encapsulate = tok:ConsumeSymbol('!', tokenList) tok:Save()
local st, expr = ParseExpr(scope) if not st then return false, expr end r1_name = tok:Get(tokenList).Data
local paren_open_whites,paren_close_whites = {},{} if Registers_7801[r1_name] then
if inverse_encapsulate then for _,v in ipairs(tokenList[#tokenList-1].LeadingWhite) do table.insert(paren_open_whites, v) end end tok:Commit()
for _,v in ipairs(tokenList[#tokenList].LeadingWhite) do table.insert(paren_open_whites, v) end if not (opcode_reg_reg_list[r0_name] and opcode_reg_reg_list[r0_name][r1_name] and opcode_reg_reg_list[r0_name][r1_name][op]) then
return false, GenerateError("Opcode " .. op .. " doesn't support this addressing mode")
if not tok:ConsumeSymbol(')', tokenList) then return false, expr end end
stat = emit_call{name=op .. r0_name .. r1_name} break
for _,v in ipairs(tokenList[#tokenList-1].LeadingWhite) do table.insert(paren_close_whites, v) end else
for _,v in ipairs(tokenList[#tokenList].LeadingWhite) do table.insert(paren_close_whites, v) end r1_name = ''
if not tok:ConsumeSymbol(',', tokenList) then return false, expr end
r0_name = tok:Get(tokenList).Data
if not registers_8[r0_name] then
return false, GenerateError(r0_name .. " is not a valid register")
end end
stat = emit_call{name=op .. "ind" .. r0_name, args={expr}, inverse_encapsulate=inverse_encapsulates, paren_open_white=paren_open_whites, paren_close_white=paren_close_whites} break
else else
tok:Commit() r0_name = ''
end end
tok:Restore()
if not tok:ConsumeSymbol(',', tokenList) then
if not tok:ConsumeSymbol('(', tokenList) then
return false, GenerateError("Opcode " .. op .. " doesn't support this addressing mode") return false, GenerateError("Opcode " .. op .. " doesn't support this addressing mode")
end end
local r1_name = tok:Get(tokenList).Data inverse_encapsulate = tok:ConsumeSymbol('!', tokenList)
if not Registers_7801[r1_name] then local st, expr = ParseExpr(scope) if not st then return false, expr end
return false, GenerateError(r0_name .. " is not a valid register") local paren_open_whites,paren_close_whites = {},{}
if inverse_encapsulate then for _,v in ipairs(tokenList[#tokenList-1].LeadingWhite) do table.insert(paren_open_whites, v) end end
for _,v in ipairs(tokenList[#tokenList].LeadingWhite) do table.insert(paren_open_whites, v) end
if not tok:ConsumeSymbol(')', tokenList) then return false, expr end
for _,v in ipairs(tokenList[#tokenList-1].LeadingWhite) do table.insert(paren_close_whites, v) end
for _,v in ipairs(tokenList[#tokenList].LeadingWhite) do table.insert(paren_close_whites, v) end
if r0_name == '' then
if not tok:ConsumeSymbol(',', tokenList) then return false, expr end
r1_name = tok:Get(tokenList).Data
if not registers_8[r1_name] then
return false, GenerateError(r1_name .. " is not a valid register")
end
end end
if not (opcode_reg_reg_list[r0_name] and opcode_reg_reg_list[r0_name][r1_name] and opcode_reg_reg_list[r0_name][r1_name][op]) then stat = emit_call{name=op .. r0_name .. "ind" .. r1_name, args={expr}, inverse_encapsulate=inverse_encapsulates, paren_open_white=paren_open_whites, paren_close_white=paren_close_whites} break
return false, GenerateError("Opcode " .. op .. " doesn't support this addressing mode")
end
stat = emit_call{name=op .. r0_name .. r1_name} break
end end
if (opcode_wa[op] or opcode_wab[op] or opcode_reg_ind[op] or opcode_reg_ind_ex[op]) and tok:ConsumeSymbol('(', tokenList) then if (opcode_wa[op] or opcode_wab[op] or opcode_reg_ind[op] or opcode_reg_ind_ex[op]) and tok:ConsumeSymbol('(', tokenList) then
local paren_open_whites,paren_close_whites = {},{} local paren_open_whites,paren_close_whites = {},{}

View File

@ -621,5 +621,13 @@ section{"rom", org=0x8000}
mov (0xdc05),e mov (0xdc05),e
mov (0xcd06),h mov (0xcd06),h
mov (0xbe07),l mov (0xbe07),l
mov v,(0x000f)
mov a,(0x00f0)
mov b,(0x00ff)
mov c,(0x0f00)
mov d,(0x0f0f)
mov e,(0x0ff0)
mov h,(0x0fff)
mov l,(0xf000)
writebin(filename .. '.bin') writebin(filename .. '.bin')

View File

@ -601,6 +601,28 @@ for k,v in pairs(op70indr8) do
end end
end end
local op70r8ind = {
movvind=M.op(0x68,17),
movaind=M.op(0x69,17),
movbind=M.op(0x6a,17),
movcind=M.op(0x6b,17),
movdind=M.op(0x6c,17),
moveind=M.op(0x6d,17),
movhind=M.op(0x6e,17),
movlind=M.op(0x6f,17),
} M.op70r8ind = op70r8ind
for k,v in pairs(op70r8ind) do
M[k] = function(late, early)
local l65dbg = { info=debug.getinfo(2, 'Sl'), trace=debug.traceback(nil, 1) }
local size = function() late,early = M.size_op(late,early) return 4 end
local bin = function() local l65dbg=l65dbg
local x = M.op_eval_word(late,early)
return { 0x70, v.opc, x&0xff, x>>8 }
end
table.insert(M.section_current.instructions, { size=size, cycles=v.cycles, bin=bin })
end
end
return M return M
--[[ [todo] --[[ [todo]
@ -608,18 +630,6 @@ return M
16 bits instructions: 16 bits instructions:
0x70xx 0x70xx
17
case 0x68: my_stprintf_s(buffer, buffer_len, _T("mov v,%s"), get_value_or_symbol(d_debugger->first_symbol, _T("%04xh"), getw())); break;
case 0x69: my_stprintf_s(buffer, buffer_len, _T("mov a,%s"), get_value_or_symbol(d_debugger->first_symbol, _T("%04xh"), getw())); break;
case 0x6a: my_stprintf_s(buffer, buffer_len, _T("mov b,%s"), get_value_or_symbol(d_debugger->first_symbol, _T("%04xh"), getw())); break;
case 0x6b: my_stprintf_s(buffer, buffer_len, _T("mov c,%s"), get_value_or_symbol(d_debugger->first_symbol, _T("%04xh"), getw())); break;
case 0x6c: my_stprintf_s(buffer, buffer_len, _T("mov d,%s"), get_value_or_symbol(d_debugger->first_symbol, _T("%04xh"), getw())); break;
case 0x6d: my_stprintf_s(buffer, buffer_len, _T("mov e,%s"), get_value_or_symbol(d_debugger->first_symbol, _T("%04xh"), getw())); break;
case 0x6e: my_stprintf_s(buffer, buffer_len, _T("mov h,%s"), get_value_or_symbol(d_debugger->first_symbol, _T("%04xh"), getw())); break;
case 0x6f: my_stprintf_s(buffer, buffer_len, _T("mov l,%s"), get_value_or_symbol(d_debugger->first_symbol, _T("%04xh"), getw())); break;
case 0x89: my_stprintf_s(buffer, buffer_len, _T("anax b")); break; case 0x89: my_stprintf_s(buffer, buffer_len, _T("anax b")); break;
case 0x8a: my_stprintf_s(buffer, buffer_len, _T("anax d")); break; case 0x8a: my_stprintf_s(buffer, buffer_len, _T("anax d")); break;
case 0x8b: my_stprintf_s(buffer, buffer_len, _T("anax h")); break; case 0x8b: my_stprintf_s(buffer, buffer_len, _T("anax h")); break;