mirror of https://github.com/g012/l65.git
Added INRW, LDAW, DCRW and STAW instructions.
This commit is contained in:
parent
f917afff6a
commit
4ef0a69e8e
38
l7801.lua
38
l7801.lua
|
@ -38,10 +38,10 @@ local Keywords_data = {
|
|||
'dc',
|
||||
}
|
||||
local Keywords_7801 = {
|
||||
'aci','adi','adinc','ani',
|
||||
'block','calb','calf','call','calt','clc','ei','eqi','daa','di','dcr','dcx',
|
||||
'ex','exx','gti','halt','inr','inx','jb','jmp','jr','jre','lti','lxi','mov','mvi','nei','nop',
|
||||
'offi','oni','ori','pen','per','pex','ret','reti','rets','rld','rrd','sio','softi','stc','stm',
|
||||
'aci','adi','adinc','ani','bit0','bit1','bit2','bit3','bit4','bit5','bit6','bit7',
|
||||
'block','calb','calf','call','calt','clc','ei','eqi','daa','di','dcr','dcrw','dcx',
|
||||
'ex','exx','gti','halt','inr','inrw','inx','jb','jmp','jr','jre','ldaw','lti','lxi','mov','mvi','nei','nop',
|
||||
'offi','oni','ori','pen','per','pex','ret','reti','rets','rld','rrd','sio','softi','staw','stc','stm',
|
||||
'sbi','sui','suinb','table','xri',
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,10 @@ local opcode_implied = lookupify{
|
|||
}
|
||||
|
||||
local opcode_immediate = lookupify{
|
||||
'calf','calt','call','jmp'
|
||||
'calf','calt','call','jmp',
|
||||
}
|
||||
local opcode_wa = lookupify{
|
||||
'inrw','ldaw','dcrw','staw'
|
||||
}
|
||||
local opcode_relative = lookupify{
|
||||
'jr','jre'
|
||||
|
@ -136,6 +139,7 @@ local opcode_reg_reg_list = {
|
|||
|
||||
local addressing_map = {
|
||||
imp = opcode_implied,
|
||||
wa = opcode_wa,
|
||||
imm = opcode_immediate,
|
||||
rel = opcode_relative,
|
||||
reg = opcode_reg,
|
||||
|
@ -1448,6 +1452,30 @@ local function ParseLua(src, src_name)
|
|||
end
|
||||
stat = emit_call{name=op, args={expr, mod_expr}, inverse_encapsulate=inverse_encapsulate, paren_open_white=paren_open_whites} break
|
||||
end
|
||||
if opcode_wa[op] then
|
||||
if not tok:ConsumeSymbol('(', tokenList) then
|
||||
return false, GenerateError("Unexpected character")
|
||||
end
|
||||
if not (tok:Get(tokenList).Data == 'v') then
|
||||
return false, GenerateError("Opcode " .. op .. " doesn't support this addressing mode")
|
||||
end
|
||||
if not tok:ConsumeSymbol(',', tokenList) then
|
||||
return false, GenerateError("Unexpected character")
|
||||
end
|
||||
inverse_encapsulate = tok:ConsumeSymbol('!', tokenList)
|
||||
local st, expr = ParseExpr(scope) if not st then return false, expr end
|
||||
local paren_open_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 tok:ConsumeSymbol(',', tokenList) then
|
||||
commaTokenList[1] = tokenList[#tokenList]
|
||||
mod_st, mod_expr = ParseExpr(scope)
|
||||
if not mod_st then return false, mod_expr end
|
||||
end
|
||||
if not tok:ConsumeSymbol(')', tokenList) then return false, expr
|
||||
end
|
||||
stat = emit_call{name=op .. "wa", args={expr, mod_expr}, inverse_encapsulate=inverse_encapsulate, paren_open_white=paren_open_whites} break
|
||||
end
|
||||
if opcode_reg_reg[op] then
|
||||
tok:Save()
|
||||
local r0_name = tok:Get(tokenList).Data
|
||||
|
|
39
uPD7801.lua
39
uPD7801.lua
|
@ -234,6 +234,29 @@ M.jre = function(label)
|
|||
table.insert(M.section_current.instructions, op)
|
||||
end
|
||||
|
||||
local opwa = {
|
||||
inrw=M.op(0x20,13),
|
||||
ldaw=M.op(0x28,10),
|
||||
dcrw=M.op(0x30,13),
|
||||
staw=M.op(0x38,10),
|
||||
bit0=M.op(0x58,10),
|
||||
bit1=M.op(0x59,10),
|
||||
bit2=M.op(0x5a,10),
|
||||
bit3=M.op(0x5b,10),
|
||||
bit4=M.op(0x5c,10),
|
||||
bit5=M.op(0x5d,10),
|
||||
bit6=M.op(0x5e,10),
|
||||
bit7=M.op(0x5f,10)
|
||||
} M.opwa = opwa
|
||||
for k,v in pairs(opwa) do
|
||||
M[k .. 'wa'] = 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 2 end
|
||||
local bin = function() local l65dbg=l65dbg return { v.opc, M.op_eval_byte(late,early) } end
|
||||
table.insert(M.section_current.instructions, { size=size, cycles=v.cycles, bin=bin })
|
||||
end
|
||||
end
|
||||
|
||||
local op48imp = {
|
||||
ei=M.op(0x20,8),
|
||||
di=M.op(0x24,8),
|
||||
|
@ -255,7 +278,6 @@ return M
|
|||
|
||||
--[[ [todo]
|
||||
8 bits instructions:
|
||||
|
||||
-- d
|
||||
ldaxm=M.op(0x2e,7),
|
||||
ldaxp=M.op(0x2c,7),
|
||||
|
@ -268,20 +290,6 @@ return M
|
|||
staxm=M.op(0x3f,7),
|
||||
staxp=M.op(0x3d,7)
|
||||
|
||||
-- wa = v+xx
|
||||
inrw=M.op(0x20,13),
|
||||
ldaw=M.op(0x28,10),
|
||||
dcrw=M.op(0x30,13),
|
||||
staw=M.op(0x38,10),
|
||||
bit0=M.op(0x58,10),
|
||||
bit1=M.op(0x59,10),
|
||||
bit2=M.op(0x5a,10),
|
||||
bit3=M.op(0x5b,10),
|
||||
bit4=M.op(0x5c,10),
|
||||
bit5=M.op(0x5d,10),
|
||||
bit6=M.op(0x5e,10),
|
||||
bit7=M.op(0x5f,10)
|
||||
|
||||
-- (r16),hhll
|
||||
mvixbc=M.op(0x49,10),
|
||||
mvixde=M.op(0x4a,10),
|
||||
|
@ -301,7 +309,6 @@ return M
|
|||
staxde=M.op(0x3a,7),
|
||||
staxhl=M.op(0x3b,7),
|
||||
|
||||
|
||||
16 bits instructions:
|
||||
0x48xx
|
||||
0x4cxx
|
||||
|
|
Loading…
Reference in New Issue