mirror of
https://github.com/g012/l65.git
synced 2024-09-27 19:55:29 +00:00
Added JRE instruction.
This commit is contained in:
parent
2d96e4e1d2
commit
f917afff6a
@ -40,7 +40,7 @@ local Keywords_data = {
|
||||
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','lti','lxi','mov','mvi','nei','nop',
|
||||
'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',
|
||||
'sbi','sui','suinb','table','xri',
|
||||
}
|
||||
@ -72,10 +72,10 @@ local opcode_implied = lookupify{
|
||||
}
|
||||
|
||||
local opcode_immediate = lookupify{
|
||||
'calf', 'calt','call','jmp'
|
||||
'calf','calt','call','jmp'
|
||||
}
|
||||
local opcode_relative = lookupify{
|
||||
'jr',
|
||||
'jr','jre'
|
||||
}
|
||||
local opcode_reg = lookupify{
|
||||
'dcr','dcx','inr','inx'
|
||||
|
@ -14,7 +14,7 @@ section{"rom", org=0x8000}
|
||||
block
|
||||
|
||||
lxi hl,message
|
||||
lxi de,0x3043
|
||||
lxi de,0x3044
|
||||
lxi bc,0x01ff
|
||||
|
||||
@loop_0
|
||||
@ -34,7 +34,7 @@ section{"vdc_data", org=0x8030}
|
||||
dc.b 0xC0,0x00,0x00,0xF2
|
||||
|
||||
section{"message", org=0x8040}
|
||||
dc.b "hello world"
|
||||
dc.b "\t\t\t\t Hello world! \t\t\t\t"
|
||||
dc.b 0x00
|
||||
|
||||
writebin(filename .. '.bin')
|
@ -76,6 +76,23 @@ section{"rom", org=0x8000}
|
||||
mov e,a
|
||||
mov h,a
|
||||
mov l,a
|
||||
|
||||
|
||||
@l0 jre l0
|
||||
@l1 nop
|
||||
jre l1
|
||||
@l2 nop nop
|
||||
jre l2
|
||||
@l3 nop nop nop
|
||||
jre l3
|
||||
@l4 nop nop nop nop
|
||||
jre l4
|
||||
jre l5
|
||||
@l5 jre l6
|
||||
nop
|
||||
@l6 jre l7
|
||||
nop nop
|
||||
@l7 jre l8
|
||||
nop nop nop
|
||||
@l8 jre l9
|
||||
nop nop nop nop
|
||||
@l9
|
||||
writebin(filename .. '.bin')
|
37
uPD7801.lua
37
uPD7801.lua
@ -207,6 +207,33 @@ M.jr = function(label)
|
||||
table.insert(M.section_current.instructions, op)
|
||||
end
|
||||
|
||||
M.jre = function(label)
|
||||
local l65dbg = { info=debug.getinfo(2, 'Sl'), trace=debug.traceback(nil, 1) }
|
||||
local parent,offset = M.label_current
|
||||
local section,rorg = M.section_current,M.location_current.rorg
|
||||
local op = { cycles=17 }
|
||||
op.size = function()
|
||||
offset = section.size
|
||||
label = M.size_dc(label)
|
||||
return 2
|
||||
end
|
||||
op.bin = function()
|
||||
local l65dbg=l65dbg
|
||||
local x,l = label,label
|
||||
if type(x) == 'function' then x=x() end
|
||||
if type(x) == 'string' then
|
||||
if x:sub(1,1) == '_' then x=parent..x l=x end
|
||||
x = symbols[x]
|
||||
end
|
||||
if type(x) ~= 'number' then error("unresolved branch target: " .. tostring(x)) end
|
||||
x = x-2 - offset - rorg(section.org)
|
||||
if x < -128 or x > 127 then error("branch target out of range for " .. l .. ": " .. x) end
|
||||
local opcode = x >= 0 and 0x4e or 0x4f
|
||||
return { opcode, x&0xff }
|
||||
end
|
||||
table.insert(M.section_current.instructions, op)
|
||||
end
|
||||
|
||||
local op48imp = {
|
||||
ei=M.op(0x20,8),
|
||||
di=M.op(0x24,8),
|
||||
@ -228,8 +255,6 @@ return M
|
||||
|
||||
--[[ [todo]
|
||||
8 bits instructions:
|
||||
JRE+ 0x4e xx 17
|
||||
JRE- 0x4f xx 17
|
||||
|
||||
-- d
|
||||
ldaxm=M.op(0x2e,7),
|
||||
@ -257,14 +282,6 @@ return M
|
||||
bit6=M.op(0x5e,10),
|
||||
bit7=M.op(0x5f,10)
|
||||
|
||||
-- hhll
|
||||
call=M.op(0x44,16),
|
||||
jmp=M.op(0x54,10),
|
||||
lxisp=M.op(0x04,10),
|
||||
lxibc=M.op(0x14,10),
|
||||
lxide=M.op(0x24,10),
|
||||
lxihl=M.op(0x34,10)
|
||||
|
||||
-- (r16),hhll
|
||||
mvixbc=M.op(0x49,10),
|
||||
mvixde=M.op(0x4a,10),
|
||||
|
Loading…
Reference in New Issue
Block a user