mirror of
https://github.com/g012/l65.git
synced 2025-02-08 10:30:37 +00:00
Added MOV (hhll),R8 instructions.
This commit is contained in:
parent
bac144896a
commit
b47f3ebb99
53
l7801.lua
53
l7801.lua
@ -102,8 +102,11 @@ local opcode_relative = lookupify{
|
||||
local opcode_reg = lookupify{
|
||||
'dcr','dcx','inr','inx','pop','push','rll','rlr','sll','slr',
|
||||
}
|
||||
local opcode_mov = lookupify{
|
||||
'mov'
|
||||
}
|
||||
local opcode_reg_reg = lookupify{
|
||||
'mov','ana','xra','ora','addnc','gta','subnb','lta','add','adc','sub','nea','sbb','eqa','ona','offa'
|
||||
'ana','xra','ora','addnc','gta','subnb','lta','add','adc','sub','nea','sbb','eqa','ona','offa'
|
||||
}
|
||||
local opcode_regb = lookupify{
|
||||
'aci','adi','adinc','ani','eqi','gti','lti','mvi','nei','offi','oni','ori','sbi','sui','suinb','xri',
|
||||
@ -185,7 +188,7 @@ local opcode_reg_reg_list = {
|
||||
tm1 = { a = lookupify{'mov'} },
|
||||
s = { a = lookupify{'mov'} },
|
||||
}
|
||||
local op60names = {}
|
||||
local registers_8 = lookupify {'v','a','b','c','d','e','h','l'}
|
||||
local register_names = {'v','a','b','c','d','e','h','l'}
|
||||
|
||||
local addressing_map = {
|
||||
@ -1522,11 +1525,53 @@ local function ParseLua(src, src_name)
|
||||
end
|
||||
inverse_encapsulate = tok:ConsumeSymbol('!', tokenList)
|
||||
local st, expr = ParseExpr(scope) if not st then return false, expr end
|
||||
local paren_open_whites,paren_close_whites,mod_st,mod_expr = {},{}
|
||||
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
|
||||
stat = emit_call{name=op, args={expr, mod_expr}, inverse_encapsulate=inverse_encapsulate, paren_open_white=paren_open_whites} break
|
||||
stat = emit_call{name=op, args={expr}, inverse_encapsulate=inverse_encapsulate, paren_open_white=paren_open_whites} break
|
||||
end
|
||||
if opcode_mov[op] then
|
||||
tok:Save()
|
||||
local r0_name = tok:Get(tokenList).Data
|
||||
if not Registers_7801[r0_name] then
|
||||
tok:Restore()
|
||||
if not tok:ConsumeSymbol('(', tokenList) then
|
||||
return false, GenerateError("Opcode " .. op .. " doesn't support this addressing mode")
|
||||
end
|
||||
inverse_encapsulate = tok:ConsumeSymbol('!', tokenList)
|
||||
local st, expr = ParseExpr(scope) if not st then return false, expr end
|
||||
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 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
|
||||
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
|
||||
tok:Commit()
|
||||
end
|
||||
|
||||
if not tok:ConsumeSymbol(',', tokenList) then
|
||||
return false, GenerateError("Opcode " .. op .. " doesn't support this addressing mode")
|
||||
end
|
||||
local r1_name = tok:Get(tokenList).Data
|
||||
if not Registers_7801[r1_name] then
|
||||
return false, GenerateError(r0_name .. " is not a valid register")
|
||||
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")
|
||||
end
|
||||
stat = emit_call{name=op .. r0_name .. r1_name} break
|
||||
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
|
||||
local paren_open_whites,paren_close_whites = {},{}
|
||||
|
@ -613,5 +613,13 @@ section{"rom", org=0x8000}
|
||||
lded (0x8101)
|
||||
shld (0x8110)
|
||||
lhld (0x8111)
|
||||
|
||||
mov (0xab00),v
|
||||
mov (0xbc01),a
|
||||
mov (0xde02),b
|
||||
mov (0xfa03),c
|
||||
mov (0xeb04),d
|
||||
mov (0xdc05),e
|
||||
mov (0xcd06),h
|
||||
mov (0xbe07),l
|
||||
|
||||
writebin(filename .. '.bin')
|
||||
|
39
uPD7801.lua
39
uPD7801.lua
@ -557,7 +557,7 @@ for k,v in pairs(op74wa) do
|
||||
end
|
||||
end
|
||||
|
||||
local op70w = {
|
||||
local op70ind = {
|
||||
sspd=M.op(0x0e,20),
|
||||
lspd=M.op(0x0f,20),
|
||||
sbcd=M.op(0x1e,20),
|
||||
@ -566,11 +566,11 @@ local op70w = {
|
||||
lded=M.op(0x2f,20),
|
||||
shld=M.op(0x3e,20),
|
||||
lhld=M.op(0x3f,20),
|
||||
} M.op70w = op70w
|
||||
for k,v in pairs(op70w) do
|
||||
} M.op70ind = op70ind
|
||||
for k,v in pairs(op70ind) 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 3 end
|
||||
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 }
|
||||
@ -579,6 +579,27 @@ for k,v in pairs(op70w) do
|
||||
end
|
||||
end
|
||||
|
||||
local op70indr8 = {
|
||||
movindv=M.op(0x78,17),
|
||||
movinda=M.op(0x79,17),
|
||||
movindb=M.op(0x7a,17),
|
||||
movindc=M.op(0x7b,17),
|
||||
movindd=M.op(0x7c,17),
|
||||
movinde=M.op(0x7d,17),
|
||||
movindh=M.op(0x7e,17),
|
||||
movindl=M.op(0x7f,17),
|
||||
} M.op70indr8 = op70indr8
|
||||
for k,v in pairs(op70indr8) 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
|
||||
|
||||
@ -596,14 +617,8 @@ return M
|
||||
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 0x78: my_stprintf_s(buffer, buffer_len, _T("mov %s,v"), get_value_or_symbol(d_debugger->first_symbol, _T("%04xh"), getw())); break;
|
||||
case 0x79: my_stprintf_s(buffer, buffer_len, _T("mov %s,a"), get_value_or_symbol(d_debugger->first_symbol, _T("%04xh"), getw())); break;
|
||||
case 0x7a: my_stprintf_s(buffer, buffer_len, _T("mov %s,b"), get_value_or_symbol(d_debugger->first_symbol, _T("%04xh"), getw())); break;
|
||||
case 0x7b: my_stprintf_s(buffer, buffer_len, _T("mov %s,c"), get_value_or_symbol(d_debugger->first_symbol, _T("%04xh"), getw())); break;
|
||||
case 0x7c: my_stprintf_s(buffer, buffer_len, _T("mov %s,d"), get_value_or_symbol(d_debugger->first_symbol, _T("%04xh"), getw())); break;
|
||||
case 0x7d: my_stprintf_s(buffer, buffer_len, _T("mov %s,e"), get_value_or_symbol(d_debugger->first_symbol, _T("%04xh"), getw())); break;
|
||||
case 0x7e: my_stprintf_s(buffer, buffer_len, _T("mov %s,h"), get_value_or_symbol(d_debugger->first_symbol, _T("%04xh"), getw())); break;
|
||||
case 0x7f: my_stprintf_s(buffer, buffer_len, _T("mov %s,l"), 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 0x8a: my_stprintf_s(buffer, buffer_len, _T("anax d")); break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user