From e56a44afa95442d2ce88525d30c087d0197b3f7a Mon Sep 17 00:00:00 2001 From: mooz Date: Wed, 7 Nov 2018 20:28:48 +0100 Subject: [PATCH] Added CALF instruction. --- l7801.lua | 4 ++-- uPD7801.lua | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/l7801.lua b/l7801.lua index cd68a43..59bc296 100644 --- a/l7801.lua +++ b/l7801.lua @@ -38,7 +38,7 @@ local Keywords_data = { 'dc', } local Keywords_7801 = { - 'block', 'calt', 'dcr', 'jr', 'lxi', 'mvi', 'nop' + 'block', 'calf', 'calt', 'dcr', 'jr', 'lxi', 'mvi', 'nop' } local Registers_7801 = { a=8,b=8,c=8,d=8,e=8,h=8,l=8,v=8, @@ -65,7 +65,7 @@ local opcode_implied = lookupify{ 'block', 'dcr', 'nop' } local opcode_immediate = lookupify{ - 'calt', 'lxi', 'mvi' + 'calf', 'calt', 'lxi', 'mvi' } local opcode_relative = lookupify{ 'jr', diff --git a/uPD7801.lua b/uPD7801.lua index e0142d0..9c4da8d 100644 --- a/uPD7801.lua +++ b/uPD7801.lua @@ -275,6 +275,19 @@ M.calt = function(late, early) table.insert(M.section_current.instructions, op) end +M.calf = 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 + op.bin = function() local l65dbg=l65dbg + local x = 0 + M.op_eval_word(late,early) + if x < 0x0800 or x > 0xffff then error("subroutine address out of range [0x0800-0xffff]: " .. x) end + x = x - 0x0800; + return { 0x78 | ((x>>8) & 0x07), x&0xff } + end + table.insert(M.section_current.instructions, op) +end + M.jr = function(label) local l65dbg = { info=debug.getinfo(2, 'Sl'), trace=debug.traceback(nil, 1) } local parent,offset = M.label_current @@ -312,7 +325,6 @@ return M 8 bits instructions: JRE+ 0x4e xx 17 JRE- 0x4f xx 17 - CALF 0x78-0x75 xx 16 16 bits instructions: 0x48xx