mirror of
https://github.com/g012/l65.git
synced 2025-01-18 13:34:08 +00:00
Added IN and OUT instructions.
This commit is contained in:
parent
283c4256f5
commit
c09a04964a
@ -41,10 +41,10 @@ local Keywords_7801 = {
|
||||
'aci','adi','adinc','ani','bit0','bit1','bit2','bit3',
|
||||
'bit4','bit5','bit6','bit7','block','calb','calf','call',
|
||||
'calt','clc','ei','eqi','eqiw','daa','di','dcr',
|
||||
'dcrw','dcx','ex','exx','gti','halt','inr','inrw',
|
||||
'dcrw','dcx','ex','exx','gti','halt','in','inr','inrw',
|
||||
'inx','jb','jmp','jr','jre','ldaw','ldax','ldaxd',
|
||||
'ldaxi','lti','lxi','mov','mvi','mviw','mvix','nei',
|
||||
'nop','offi','oni','ori','pen','per','pex','pop','push','ret',
|
||||
'nop','offi','oni','ori','out','pen','per','pex','pop','push','ret',
|
||||
'reti','rets','rld','rll','rlr','rrd','sbi','sio','skc',
|
||||
'skit','sknit','skz','sknc','sknz','sll','slr','softi',
|
||||
'staw','stax','staxd','staxi','stc','stm','sui','suinb',
|
||||
@ -80,7 +80,7 @@ local opcode_implied = lookupify{
|
||||
'stc','stm','table'
|
||||
}
|
||||
local opcode_immediate = lookupify{
|
||||
'calf','calt','call','jmp',
|
||||
'calf','calt','call','in','jmp','out',
|
||||
}
|
||||
local opcode_wa = lookupify{
|
||||
'inrw','ldaw','dcrw','staw',
|
||||
@ -1488,7 +1488,7 @@ local function ParseLua(src, src_name)
|
||||
mod_st, mod_expr = ParseExpr(scope)
|
||||
if not mod_st then return false, mod_expr end
|
||||
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 .. 'imm', args={expr, mod_expr}, inverse_encapsulate=inverse_encapsulate, paren_open_white=paren_open_whites} 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 = {},{}
|
||||
|
@ -162,5 +162,11 @@ section{"rom", org=0x8000}
|
||||
sknit f1
|
||||
sknit f2
|
||||
sknit fs
|
||||
in 0x00
|
||||
in 0xa7
|
||||
in 0xbf
|
||||
out 0x00
|
||||
out 0x5a
|
||||
out 0xbf
|
||||
|
||||
writebin(filename .. '.bin')
|
41
uPD7801.lua
41
uPD7801.lua
@ -162,12 +162,26 @@ end
|
||||
local opw = {
|
||||
call=M.op(0x44,16),
|
||||
jmp=M.op(0x54,10),
|
||||
} M.opw = opw
|
||||
for k,v in pairs(opw) do
|
||||
M[k .. 'imm'] = 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 bin = function() local l65dbg=l65dbg
|
||||
local x = M.op_eval_word(late,early)
|
||||
return { v.opc, x&0xff, x>>8 }
|
||||
end
|
||||
table.insert(M.section_current.instructions, { size=size, cycles=v.cycles, bin=bin })
|
||||
end
|
||||
end
|
||||
|
||||
local opr16w = {
|
||||
lxisp=M.op(0x04,10),
|
||||
lxibc=M.op(0x14,10),
|
||||
lxide=M.op(0x24,10),
|
||||
lxihl=M.op(0x34,10)
|
||||
} M.opw = opw
|
||||
for k,v in pairs(opw) do
|
||||
} M.opr16w = opr16w
|
||||
for k,v in pairs(opr16w) 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
|
||||
@ -179,7 +193,8 @@ for k,v in pairs(opw) do
|
||||
end
|
||||
end
|
||||
|
||||
M.calt = function(late, early)
|
||||
|
||||
M['calt' .. 'imm'] = function(late, early)
|
||||
local l65dbg = { info=debug.getinfo(2, 'Sl'), trace=debug.traceback(nil, 1) }
|
||||
local op = { cycles=19 }
|
||||
op.size = function() late,early = M.size_op(late,early) return 1 end
|
||||
@ -194,7 +209,7 @@ M.calt = function(late, early)
|
||||
table.insert(M.section_current.instructions, op)
|
||||
end
|
||||
|
||||
M.calf = function(late, early)
|
||||
M['calf' .. 'imm'] = function(late, early)
|
||||
local l65dbg = { info=debug.getinfo(2, 'Sl'), trace=debug.traceback(nil, 1) }
|
||||
local op = { cycles=16 }
|
||||
op.size = function() late,early = M.size_op(late,early) return 2 end
|
||||
@ -379,6 +394,24 @@ for k,v in pairs(op48int) do
|
||||
end
|
||||
end
|
||||
|
||||
-- IN/OUT
|
||||
local opinout={
|
||||
['in']=M.op(0x4c,10),
|
||||
out=M.op(0x4d,10),
|
||||
} M.opinout = op4inout
|
||||
for k,v in pairs(opinout) do
|
||||
M[k .. 'imm'] = function(late, early)
|
||||
local l65dbg = { info=debug.getinfo(2, 'Sl'), trace=debug.traceback(nil, 1) }
|
||||
local op = { cycles=v.cycles }
|
||||
op.size = function() late,early = M.size_op(late,early) return 2 end
|
||||
op.bin = function() local l65dbg=l65dbg
|
||||
local x = 0x00 + M.op_eval_byte(late,early)
|
||||
return { v.opc, 0x00, x }
|
||||
end
|
||||
table.insert(M.section_current.instructions, op)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
--[[ [todo]
|
||||
|
Loading…
x
Reference in New Issue
Block a user