mirror of
https://github.com/g012/l65.git
synced 2025-01-05 01:33:41 +00:00
first uPD7801 assembler tests.
This commit is contained in:
parent
d5c53b2f01
commit
f8ad543033
11
asm.lua
11
asm.lua
@ -823,15 +823,4 @@ local op_eval = function(late, early)
|
|||||||
end
|
end
|
||||||
M.op_eval = op_eval
|
M.op_eval = op_eval
|
||||||
|
|
||||||
local op_eval_byte = function(late, early, nozp)
|
|
||||||
local v = op_eval(late, early)
|
|
||||||
local zpv = zeropage(v)
|
|
||||||
if not nozp and zpv then return zpv end
|
|
||||||
return byte_normalize(v)
|
|
||||||
end
|
|
||||||
M.op_eval_byte = op_eval_byte
|
|
||||||
|
|
||||||
local op_eval_word = function(late, early) return word_normalize(op_eval(late, early)) end
|
|
||||||
M.op_eval_word = op_eval_word
|
|
||||||
|
|
||||||
return M
|
return M
|
3
l65.lua
3
l65.lua
@ -32,7 +32,7 @@ local Keywords = lookupify{
|
|||||||
'return', 'then', 'true', 'until', 'while',
|
'return', 'then', 'true', 'until', 'while',
|
||||||
};
|
};
|
||||||
|
|
||||||
-- 6502
|
-------------------------------------------------------- 6502::begin
|
||||||
local Keywords_control = {
|
local Keywords_control = {
|
||||||
-- control keywords
|
-- control keywords
|
||||||
'samepage', 'crosspage',
|
'samepage', 'crosspage',
|
||||||
@ -168,6 +168,7 @@ local addressing_map = {
|
|||||||
iny = opcode_indirect_y,
|
iny = opcode_indirect_y,
|
||||||
rel = opcode_relative,
|
rel = opcode_relative,
|
||||||
}
|
}
|
||||||
|
-------------------------------------------------------- 6502::end
|
||||||
|
|
||||||
local Scope = {
|
local Scope = {
|
||||||
new = function(self, parent)
|
new = function(self, parent)
|
||||||
|
46
uPD7801.lua
46
uPD7801.lua
@ -1,9 +1,9 @@
|
|||||||
M = require "asm"
|
M = require "asm"
|
||||||
|
|
||||||
local op_eval_byte = function(late, early) return byte_normalize(op_eval(late, early)) end
|
local op_eval_byte = function(late, early) return M.byte_normalize(M.op_eval(late, early)) end
|
||||||
M.op_eval_byte = op_eval_byte
|
M.op_eval_byte = op_eval_byte
|
||||||
|
|
||||||
local op_eval_word = function(late, early) return word_normalize(op_eval(late, early)) end
|
local op_eval_word = function(late, early) return M.word_normalize(M.op_eval(late, early)) end
|
||||||
M.op_eval_word = op_eval_word
|
M.op_eval_word = op_eval_word
|
||||||
|
|
||||||
local opimp={
|
local opimp={
|
||||||
@ -61,9 +61,9 @@ end
|
|||||||
|
|
||||||
local opd={
|
local opd={
|
||||||
ldaxm=M.op(0x2e,7),
|
ldaxm=M.op(0x2e,7),
|
||||||
ldaxp=M.op(0x2c 7),
|
ldaxp=M.op(0x2c,7),
|
||||||
staxm=M.op(0x3e,7),
|
staxm=M.op(0x3e,7),
|
||||||
staxp=M.op(0x3c,7),
|
staxp=M.op(0x3c,7)
|
||||||
} M.opd = opd
|
} M.opd = opd
|
||||||
for k,v in pairs(opd) do
|
for k,v in pairs(opd) do
|
||||||
M[k .. 'd'] = function()
|
M[k .. 'd'] = function()
|
||||||
@ -83,7 +83,7 @@ for k,v in pairs(oph) do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local opind={
|
local oprwind={
|
||||||
dcxbc=M.op(0x13,7),
|
dcxbc=M.op(0x13,7),
|
||||||
dcxde=M.op(0x23,7),
|
dcxde=M.op(0x23,7),
|
||||||
dcxhl=M.op(0x33,7),
|
dcxhl=M.op(0x33,7),
|
||||||
@ -260,18 +260,33 @@ for k,v in pairs(opwwww) do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for i=0x80,0xbf,1 do
|
M.calt = function(late, early)
|
||||||
M['calt' .. i]=M.op(i,cycles)
|
local l65dbg = { info=debug.getinfo(2, 'Sl'), trace=debug.traceback(nil, 1) }
|
||||||
table.insert(M.section_current.instructions, { size=1, cycles=19, bin=i})
|
local op = { cycles=19 }
|
||||||
|
op.size = function() late,early = M.size_op(late,early) return 1 end
|
||||||
|
op.bin = function()
|
||||||
|
local l65dbg=l65dbg
|
||||||
|
local x = M.op_eval_byte(late,early)
|
||||||
|
if (x%2 == 1) then error("offset should be even : " .. x) end
|
||||||
|
if x < 0x80 or x > 0xfe then error("offset out of range : " .. x) end
|
||||||
|
x = (x>>1) + 0x40
|
||||||
|
return x
|
||||||
|
end
|
||||||
|
table.insert(M.section_current.instructions, op)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
M.jr = function(label)
|
M.jr = function(label)
|
||||||
local l65dbg = { info=debug.getinfo(2, 'Sl'), trace=debug.traceback(nil, 1) }
|
local l65dbg = { info=debug.getinfo(2, 'Sl'), trace=debug.traceback(nil, 1) }
|
||||||
local parent,offset = M.label_current
|
local parent,offset = M.label_current
|
||||||
local section,rorg = M.section_current,M.location_current.rorg
|
local section,rorg = M.section_current,M.location_current.rorg
|
||||||
local op = { cycles=13, size=1 }
|
local op = { cycles=13 }
|
||||||
op.bin = function() local l65dbg=l65dbg
|
op.size = function()
|
||||||
|
offset = section.size
|
||||||
|
label = M.size_dc(label)
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
op.bin = function()
|
||||||
|
local l65dbg=l65dbg
|
||||||
local x,l = label,label
|
local x,l = label,label
|
||||||
if type(x) == 'function' then x=x() end
|
if type(x) == 'function' then x=x() end
|
||||||
if type(x) == 'string' then
|
if type(x) == 'string' then
|
||||||
@ -279,12 +294,13 @@ M.jr = function(label)
|
|||||||
x = symbols[x]
|
x = symbols[x]
|
||||||
end
|
end
|
||||||
if type(x) ~= 'number' then error("unresolved branch target: " .. tostring(x)) end
|
if type(x) ~= 'number' then error("unresolved branch target: " .. tostring(x)) end
|
||||||
x = x - offset - rorg(section.org)
|
x = x-1 - offset - rorg(section.org)
|
||||||
if x < -32 or x > 0x32 then error("branch target out of range for " .. l .. ": " .. x) end
|
if x < -32 or x > 0x32 then error("branch target out of range for " .. l .. ": " .. x)
|
||||||
elseif x >= 0 then
|
elseif x >= 0 then
|
||||||
return 0xc0 + x
|
x = 0xc0 + x
|
||||||
|
return
|
||||||
else
|
else
|
||||||
return x
|
return x & 0xff
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
table.insert(M.section_current.instructions, op)
|
table.insert(M.section_current.instructions, op)
|
||||||
|
Loading…
Reference in New Issue
Block a user