remake assembler with customasm, misc, need to clean up
This commit is contained in:
@ -11,13 +11,14 @@
|
||||
#define loadut readmemory(wordut)
|
||||
#define loadutp1 readmemory((wordut+1)%65536)
|
||||
#define loadp readmemory(cpu->p)
|
||||
#define loadpinc readmemory(cpu->p++)
|
||||
#define loadpp1 readmemory((cpu->p+1)%65536)
|
||||
#define loadq readmemory(cpu->q)
|
||||
#define loadqinc readmemory(cpu->q++)
|
||||
#define loadpinc readmemory((cpu->p++)%65536)
|
||||
#define loadqinc readmemory((cpu->q++)%65536)
|
||||
#define loadpp1 readmemory((cpu->p+1)%65536)
|
||||
#define loadqp1 readmemory((cpu->q+1)%65536)
|
||||
#define loadput readmemory((cpu->p+wordut)%65536)
|
||||
#define loadqut readmemory((cpu->q+wordut)%65536)
|
||||
#define signed8(x) (x>=128 ? x|0xFF00 : x)
|
||||
|
||||
#define setzf(x) cpu->nz=(x!=0);
|
||||
#define loadimmedt cpu->t = loadimmed;
|
||||
#define loadimm161 cpu->u = loadimmed;
|
||||
@ -31,11 +32,13 @@
|
||||
#define storeut(x) writememory(wordut, x);
|
||||
#define storeutp1(x) writememory((wordut+1)%65536, x);
|
||||
#define storep(x) writememory(cpu->p, x);
|
||||
#define storepinc(x) writememory(cpu->p++, x);
|
||||
#define storepp1(x) writememory((cpu->p+1)%65536, x);
|
||||
#define storeq(x) writememory(cpu->q, x);
|
||||
#define storepinc(x) writememory(cpu->p++, x);
|
||||
#define storeqinc(x) writememory(cpu->q++, x);
|
||||
#define storepp1(x) writememory((cpu->p+1)%65536, x);
|
||||
#define storeqp1(x) writememory((cpu->q+1)%65536, x);
|
||||
#define storeput(x) writememory((cpu->p+wordut)%65536, x);
|
||||
#define storequt(x) writememory((cpu->q+wordut)%65536, x);
|
||||
#define pushretaddr1 writememory(cpu->s++, hibyte((cpu->i-1)%65536));
|
||||
#define pushretaddr2 writememory(cpu->s++, lobyte((cpu->i-1)%65536));
|
||||
#define lni cpu->instr = readmemory(cpu->i++); cpu->cycle = 0;
|
||||
|
Binary file not shown.
@ -241,7 +241,7 @@ local function pdLinesFromDasm(dasm)
|
||||
end
|
||||
return lines, addrLines, lineAddrs
|
||||
end
|
||||
local function InitProgramDisplay(pd, data, code, arch)
|
||||
local function InitProgramDisplay(pd, arch, data, code, symbols)
|
||||
pd.width = 256
|
||||
pd.height = 12+pd.fontHeight*pd.numLines-3
|
||||
lg.print("Program", pd.scrX, pd.scrY-16)
|
||||
@ -249,7 +249,7 @@ local function InitProgramDisplay(pd, data, code, arch)
|
||||
pd.firstLine = 1
|
||||
pd.data = data
|
||||
pd.code = code
|
||||
local dasm = asm.disassembleMemory(data, code, arch)
|
||||
local dasm = asm.disassembleMemory(arch, data, code, symbols)
|
||||
pd.lines, pd.addrLines, pd.lineAddrs = pdLinesFromDasm(dasm)
|
||||
pd.midLine = math.floor(pd.numLines/2)
|
||||
end
|
||||
@ -490,13 +490,13 @@ WriteMemory = function(mem, addr, val)
|
||||
end
|
||||
end
|
||||
local function AssembleToMemory(mem, fn, arch)
|
||||
local data, code = asm.assembleFile(fn, arch)
|
||||
local data, code, symbols = asm.assembleFile(fn)
|
||||
for addr = 0, 65535 do
|
||||
if data[addr] then
|
||||
mem.c.data[addr] = data[addr]
|
||||
end
|
||||
end
|
||||
return data, code
|
||||
return data, code, symbols
|
||||
end
|
||||
|
||||
ffi.cdef [[
|
||||
@ -631,8 +631,8 @@ function love.load()
|
||||
InitCharDisplay(CharDisplay)
|
||||
InitRegDisplay(RegDisplay)
|
||||
InitStackDisplay(StackDisplay)
|
||||
local data, code = AssembleToMemory(Memory, arg[2] or "../../8608programs/emutest.asm", Arch)
|
||||
InitProgramDisplay(ProgramDisplay, data, code, Arch)
|
||||
local data, code, symbols = AssembleToMemory(Memory, arg[2] or "../../8608programs/emutest.asm", Arch)
|
||||
InitProgramDisplay(ProgramDisplay, Arch, data, code, symbols)
|
||||
for _, md in ipairs(MemoryDisplays) do InitMemoryDisplay(md) end
|
||||
RedrawWindow()
|
||||
lg.setCanvas()
|
||||
|
@ -1,6 +1,47 @@
|
||||
// Auto-generated by gendefs.lua
|
||||
|
||||
void cpu_instr_0_0(struct CPU* const cpu, struct Memory* const mem) { cpu->a=0; cpu->b=0; cpu->c=0; cpu->u=0; cpu->t=0; cpu->p=0; cpu->q=0; cpu->s=0; cpu->v=0; cpu->i=0; cpu->cf=0; cpu->nz=0; cpu->irq=0; cpu->ifg=0; cpu->rfg=1; cpu->ien=0; lni; }
|
||||
void cpu_instr_1_0(struct CPU* const cpu, struct Memory* const mem) { loadimm161 cpu->cycle++; }
|
||||
void cpu_instr_1_1(struct CPU* const cpu, struct Memory* const mem) { loadimm162 cpu->cycle++; }
|
||||
void cpu_instr_1_2(struct CPU* const cpu, struct Memory* const mem) { cpu->a=loadput; setzf(cpu->a); cpu->cycle++; }
|
||||
void cpu_instr_1_3(struct CPU* const cpu, struct Memory* const mem) { lni; }
|
||||
void cpu_instr_6_0(struct CPU* const cpu, struct Memory* const mem) { loadimm161 cpu->cycle++; }
|
||||
void cpu_instr_6_1(struct CPU* const cpu, struct Memory* const mem) { loadimm162 cpu->cycle++; }
|
||||
void cpu_instr_6_2(struct CPU* const cpu, struct Memory* const mem) { storeut(hibyte(cpu->q)); cpu->cycle++; }
|
||||
void cpu_instr_6_3(struct CPU* const cpu, struct Memory* const mem) { storeutp1(lobyte(cpu->q)); cpu->cycle++; }
|
||||
void cpu_instr_6_4(struct CPU* const cpu, struct Memory* const mem) { lni; }
|
||||
void cpu_instr_8_0(struct CPU* const cpu, struct Memory* const mem) { loadimm161 cpu->cycle++; }
|
||||
void cpu_instr_8_1(struct CPU* const cpu, struct Memory* const mem) { loadimm162 cpu->cycle++; }
|
||||
void cpu_instr_8_2(struct CPU* const cpu, struct Memory* const mem) { cpu->b=loadqut; setzf(cpu->b); cpu->cycle++; }
|
||||
void cpu_instr_8_3(struct CPU* const cpu, struct Memory* const mem) { lni; }
|
||||
void cpu_instr_9_0(struct CPU* const cpu, struct Memory* const mem) { loadimm161 cpu->cycle++; }
|
||||
void cpu_instr_9_1(struct CPU* const cpu, struct Memory* const mem) { loadimm162 cpu->cycle++; }
|
||||
void cpu_instr_9_2(struct CPU* const cpu, struct Memory* const mem) { cpu->c=loadqut; setzf(cpu->c); cpu->cycle++; }
|
||||
void cpu_instr_9_3(struct CPU* const cpu, struct Memory* const mem) { lni; }
|
||||
void cpu_instr_10_0(struct CPU* const cpu, struct Memory* const mem) { loadimm161 cpu->cycle++; }
|
||||
void cpu_instr_10_1(struct CPU* const cpu, struct Memory* const mem) { loadimm162 cpu->cycle++; }
|
||||
void cpu_instr_10_2(struct CPU* const cpu, struct Memory* const mem) { storeput(cpu->a); cpu->cycle++; }
|
||||
void cpu_instr_10_3(struct CPU* const cpu, struct Memory* const mem) { lni; }
|
||||
void cpu_instr_11_0(struct CPU* const cpu, struct Memory* const mem) { loadimm161 cpu->cycle++; }
|
||||
void cpu_instr_11_1(struct CPU* const cpu, struct Memory* const mem) { loadimm162 cpu->cycle++; }
|
||||
void cpu_instr_11_2(struct CPU* const cpu, struct Memory* const mem) { storeput(cpu->b); cpu->cycle++; }
|
||||
void cpu_instr_11_3(struct CPU* const cpu, struct Memory* const mem) { lni; }
|
||||
void cpu_instr_12_0(struct CPU* const cpu, struct Memory* const mem) { loadimm161 cpu->cycle++; }
|
||||
void cpu_instr_12_1(struct CPU* const cpu, struct Memory* const mem) { loadimm162 cpu->cycle++; }
|
||||
void cpu_instr_12_2(struct CPU* const cpu, struct Memory* const mem) { storeput(cpu->c); cpu->cycle++; }
|
||||
void cpu_instr_12_3(struct CPU* const cpu, struct Memory* const mem) { lni; }
|
||||
void cpu_instr_13_0(struct CPU* const cpu, struct Memory* const mem) { loadimm161 cpu->cycle++; }
|
||||
void cpu_instr_13_1(struct CPU* const cpu, struct Memory* const mem) { loadimm162 cpu->cycle++; }
|
||||
void cpu_instr_13_2(struct CPU* const cpu, struct Memory* const mem) { storequt(cpu->a); cpu->cycle++; }
|
||||
void cpu_instr_13_3(struct CPU* const cpu, struct Memory* const mem) { lni; }
|
||||
void cpu_instr_14_0(struct CPU* const cpu, struct Memory* const mem) { loadimm161 cpu->cycle++; }
|
||||
void cpu_instr_14_1(struct CPU* const cpu, struct Memory* const mem) { loadimm162 cpu->cycle++; }
|
||||
void cpu_instr_14_2(struct CPU* const cpu, struct Memory* const mem) { storequt(cpu->b); cpu->cycle++; }
|
||||
void cpu_instr_14_3(struct CPU* const cpu, struct Memory* const mem) { lni; }
|
||||
void cpu_instr_15_0(struct CPU* const cpu, struct Memory* const mem) { loadimm161 cpu->cycle++; }
|
||||
void cpu_instr_15_1(struct CPU* const cpu, struct Memory* const mem) { loadimm162 cpu->cycle++; }
|
||||
void cpu_instr_15_2(struct CPU* const cpu, struct Memory* const mem) { storequt(cpu->c); cpu->cycle++; }
|
||||
void cpu_instr_15_3(struct CPU* const cpu, struct Memory* const mem) { lni; }
|
||||
void cpu_instr_16_0(struct CPU* const cpu, struct Memory* const mem) { addf(cpu->a, 1 ); lni; }
|
||||
void cpu_instr_17_0(struct CPU* const cpu, struct Memory* const mem) { addf(cpu->a,-1 ); lni; }
|
||||
void cpu_instr_18_0(struct CPU* const cpu, struct Memory* const mem) { cpu->p++; lni; }
|
||||
@ -440,6 +481,20 @@ void cpu_instr_233_0(struct CPU* const cpu, struct Memory* const mem) { int f =
|
||||
void cpu_instr_233_1(struct CPU* const cpu, struct Memory* const mem) { lni; }
|
||||
void cpu_instr_234_0(struct CPU* const cpu, struct Memory* const mem) { int f=popbyte; cpu->nz = f&1; cpu->cf = (f>>1)&1; cpu->cycle++; }
|
||||
void cpu_instr_234_1(struct CPU* const cpu, struct Memory* const mem) { lni; }
|
||||
void cpu_instr_235_0(struct CPU* const cpu, struct Memory* const mem) { loadimm161 cpu->cycle++; }
|
||||
void cpu_instr_235_1(struct CPU* const cpu, struct Memory* const mem) { loadimm162 cpu->cycle++; }
|
||||
void cpu_instr_235_2(struct CPU* const cpu, struct Memory* const mem) { cpu->a=loadqut; setzf(cpu->a); cpu->cycle++; }
|
||||
void cpu_instr_235_3(struct CPU* const cpu, struct Memory* const mem) { lni; }
|
||||
void cpu_instr_236_0(struct CPU* const cpu, struct Memory* const mem) { loadimm161 cpu->cycle++; }
|
||||
void cpu_instr_236_1(struct CPU* const cpu, struct Memory* const mem) { loadimm162 cpu->cycle++; }
|
||||
void cpu_instr_236_2(struct CPU* const cpu, struct Memory* const mem) { cpu->p=wordut; cpu->u=loadut; cpu->cycle++; }
|
||||
void cpu_instr_236_3(struct CPU* const cpu, struct Memory* const mem) { cpu->t=loadpp1; cpu->cycle++; }
|
||||
void cpu_instr_236_4(struct CPU* const cpu, struct Memory* const mem) { cpu->p=wordut; lni; }
|
||||
void cpu_instr_238_0(struct CPU* const cpu, struct Memory* const mem) { loadimm161 cpu->cycle++; }
|
||||
void cpu_instr_238_1(struct CPU* const cpu, struct Memory* const mem) { loadimm162 cpu->cycle++; }
|
||||
void cpu_instr_238_2(struct CPU* const cpu, struct Memory* const mem) { cpu->q=wordut; cpu->u=loadut; cpu->cycle++; }
|
||||
void cpu_instr_238_3(struct CPU* const cpu, struct Memory* const mem) { cpu->t=loadqp1; cpu->cycle++; }
|
||||
void cpu_instr_238_4(struct CPU* const cpu, struct Memory* const mem) { cpu->q=wordut; lni; }
|
||||
void cpu_instr_240_0(struct CPU* const cpu, struct Memory* const mem) { cpu->rfg=0; lni; }
|
||||
void cpu_instr_241_0(struct CPU* const cpu, struct Memory* const mem) { cpu->rfg=1; lni; }
|
||||
void cpu_instr_242_0(struct CPU* const cpu, struct Memory* const mem) { cpu->irq=0; cpu->ifg=1; int t=cpu->i; cpu->i=cpu->v; cpu->v=(t-1)%65536; lni; }
|
||||
@ -447,25 +502,48 @@ void cpu_instr_243_0(struct CPU* const cpu, struct Memory* const mem) { cpu->ifg
|
||||
void cpu_instr_244_0(struct CPU* const cpu, struct Memory* const mem) { cpu->ifg=0; int t=cpu->i; cpu->i=cpu->v; cpu->v=t; lni; }
|
||||
void cpu_instr_245_0(struct CPU* const cpu, struct Memory* const mem) { cpu->ien=1; lni; }
|
||||
void cpu_instr_246_0(struct CPU* const cpu, struct Memory* const mem) { cpu->ien=0; lni; }
|
||||
void cpu_instr_247_0(struct CPU* const cpu, struct Memory* const mem) { loadimm161 cpu->cycle++; }
|
||||
void cpu_instr_247_1(struct CPU* const cpu, struct Memory* const mem) { loadimm162 cpu->cycle++; }
|
||||
void cpu_instr_247_2(struct CPU* const cpu, struct Memory* const mem) { cpu->b=loadput; setzf(cpu->b); cpu->cycle++; }
|
||||
void cpu_instr_247_3(struct CPU* const cpu, struct Memory* const mem) { lni; }
|
||||
void cpu_instr_248_0(struct CPU* const cpu, struct Memory* const mem) { loadimm161 cpu->cycle++; }
|
||||
void cpu_instr_248_1(struct CPU* const cpu, struct Memory* const mem) { loadimm162 cpu->cycle++; }
|
||||
void cpu_instr_248_2(struct CPU* const cpu, struct Memory* const mem) { cpu->p=wordut; cpu->u=loadut; cpu->cycle++; }
|
||||
void cpu_instr_248_3(struct CPU* const cpu, struct Memory* const mem) { cpu->t=loadpp1; cpu->cycle++; }
|
||||
void cpu_instr_248_4(struct CPU* const cpu, struct Memory* const mem) { cpu->p=wordut; lni; }
|
||||
void cpu_instr_250_0(struct CPU* const cpu, struct Memory* const mem) { loadimm161 cpu->cycle++; }
|
||||
void cpu_instr_250_1(struct CPU* const cpu, struct Memory* const mem) { loadimm162 cpu->cycle++; }
|
||||
void cpu_instr_250_2(struct CPU* const cpu, struct Memory* const mem) { cpu->q=wordut; cpu->u=loadut; cpu->cycle++; }
|
||||
void cpu_instr_250_3(struct CPU* const cpu, struct Memory* const mem) { cpu->t=loadqp1; cpu->cycle++; }
|
||||
void cpu_instr_250_4(struct CPU* const cpu, struct Memory* const mem) { cpu->q=wordut; lni; }
|
||||
void cpu_instr_252_0(struct CPU* const cpu, struct Memory* const mem) { loadimm161 cpu->cycle++; }
|
||||
void cpu_instr_252_1(struct CPU* const cpu, struct Memory* const mem) { loadimm162 cpu->cycle++; }
|
||||
void cpu_instr_252_2(struct CPU* const cpu, struct Memory* const mem) { storeut(hibyte(cpu->p)); cpu->cycle++; }
|
||||
void cpu_instr_252_3(struct CPU* const cpu, struct Memory* const mem) { storeutp1(lobyte(cpu->p)); cpu->cycle++; }
|
||||
void cpu_instr_252_4(struct CPU* const cpu, struct Memory* const mem) { lni; }
|
||||
void cpu_instr_254_0(struct CPU* const cpu, struct Memory* const mem) { loadimm161 cpu->cycle++; }
|
||||
void cpu_instr_254_1(struct CPU* const cpu, struct Memory* const mem) { loadimm162 cpu->cycle++; }
|
||||
void cpu_instr_254_2(struct CPU* const cpu, struct Memory* const mem) { cpu->c=loadput; setzf(cpu->c); cpu->cycle++; }
|
||||
void cpu_instr_254_3(struct CPU* const cpu, struct Memory* const mem) { lni; }
|
||||
void cpu_instr_255_0(struct CPU* const cpu, struct Memory* const mem) { lni; }
|
||||
|
||||
CPUInstruction CPUInstructions[256][8] = {
|
||||
{cpu_instr_0_0,0,0,0,0,0,0,0},
|
||||
{cpu_instr_1_0,cpu_instr_1_1,cpu_instr_1_2,cpu_instr_1_3,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0},
|
||||
{cpu_instr_6_0,cpu_instr_6_1,cpu_instr_6_2,cpu_instr_6_3,cpu_instr_6_4,0,0,0},
|
||||
{0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0},
|
||||
{cpu_instr_8_0,cpu_instr_8_1,cpu_instr_8_2,cpu_instr_8_3,0,0,0,0},
|
||||
{cpu_instr_9_0,cpu_instr_9_1,cpu_instr_9_2,cpu_instr_9_3,0,0,0,0},
|
||||
{cpu_instr_10_0,cpu_instr_10_1,cpu_instr_10_2,cpu_instr_10_3,0,0,0,0},
|
||||
{cpu_instr_11_0,cpu_instr_11_1,cpu_instr_11_2,cpu_instr_11_3,0,0,0,0},
|
||||
{cpu_instr_12_0,cpu_instr_12_1,cpu_instr_12_2,cpu_instr_12_3,0,0,0,0},
|
||||
{cpu_instr_13_0,cpu_instr_13_1,cpu_instr_13_2,cpu_instr_13_3,0,0,0,0},
|
||||
{cpu_instr_14_0,cpu_instr_14_1,cpu_instr_14_2,cpu_instr_14_3,0,0,0,0},
|
||||
{cpu_instr_15_0,cpu_instr_15_1,cpu_instr_15_2,cpu_instr_15_3,0,0,0,0},
|
||||
{cpu_instr_16_0,0,0,0,0,0,0,0},
|
||||
{cpu_instr_17_0,0,0,0,0,0,0,0},
|
||||
{cpu_instr_18_0,0,0,0,0,0,0,0},
|
||||
@ -685,10 +763,10 @@ CPUInstruction CPUInstructions[256][8] = {
|
||||
{cpu_instr_232_0,0,0,0,0,0,0,0},
|
||||
{cpu_instr_233_0,cpu_instr_233_1,0,0,0,0,0,0},
|
||||
{cpu_instr_234_0,cpu_instr_234_1,0,0,0,0,0,0},
|
||||
{cpu_instr_235_0,cpu_instr_235_1,cpu_instr_235_2,cpu_instr_235_3,0,0,0,0},
|
||||
{cpu_instr_236_0,cpu_instr_236_1,cpu_instr_236_2,cpu_instr_236_3,cpu_instr_236_4,0,0,0},
|
||||
{0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0},
|
||||
{cpu_instr_238_0,cpu_instr_238_1,cpu_instr_238_2,cpu_instr_238_3,cpu_instr_238_4,0,0,0},
|
||||
{0,0,0,0,0,0,0,0},
|
||||
{cpu_instr_240_0,0,0,0,0,0,0,0},
|
||||
{cpu_instr_241_0,0,0,0,0,0,0,0},
|
||||
@ -697,13 +775,13 @@ CPUInstruction CPUInstructions[256][8] = {
|
||||
{cpu_instr_244_0,0,0,0,0,0,0,0},
|
||||
{cpu_instr_245_0,0,0,0,0,0,0,0},
|
||||
{cpu_instr_246_0,0,0,0,0,0,0,0},
|
||||
{cpu_instr_247_0,cpu_instr_247_1,cpu_instr_247_2,cpu_instr_247_3,0,0,0,0},
|
||||
{cpu_instr_248_0,cpu_instr_248_1,cpu_instr_248_2,cpu_instr_248_3,cpu_instr_248_4,0,0,0},
|
||||
{0,0,0,0,0,0,0,0},
|
||||
{cpu_instr_250_0,cpu_instr_250_1,cpu_instr_250_2,cpu_instr_250_3,cpu_instr_250_4,0,0,0},
|
||||
{0,0,0,0,0,0,0,0},
|
||||
{cpu_instr_252_0,cpu_instr_252_1,cpu_instr_252_2,cpu_instr_252_3,cpu_instr_252_4,0,0,0},
|
||||
{0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0},
|
||||
{0,0,0,0,0,0,0,0},
|
||||
{cpu_instr_254_0,cpu_instr_254_1,cpu_instr_254_2,cpu_instr_254_3,0,0,0,0},
|
||||
{cpu_instr_255_0,0,0,0,0,0,0,0},
|
||||
};
|
||||
|
@ -1,4 +1,6 @@
|
||||
|
||||
-- copied from Brick_LuaLogic/bricks/input/keyboard-global.luas
|
||||
|
||||
return {
|
||||
["backspace"] = 8,
|
||||
["tab"] = 9,
|
||||
|
Reference in New Issue
Block a user