added ZMAC assembler

This commit is contained in:
Steven Hugg 2018-08-28 07:10:59 -07:00
parent 155e119672
commit c7eaedf24b
6 changed files with 173 additions and 1 deletions

View File

@ -0,0 +1,80 @@

_palette = 0x0040
_cellram = 0xe000
_tileram = 0xe800
org $0000
_start::
;<stdin>:19:
LD SP,$E800 ; set up stack pointer
DI ; disable interrupts
;<stdin>:20:
jp _main
;<stdin>:23:
; ---------------------------------
; Function main
; ---------------------------------
_main::
;<stdin>:26:
ld a,0x01
out (_palette),a
;<stdin>:27:
ld hl,_tileram
ld (hl), 0xfe
ld e, l
ld d, h
inc de
ld bc, 0x07ff
ldir
;<stdin>:28:
ld hl,_cellram
ld (hl), 0x00
ld e, l
ld d, h
inc de
ld bc, 0x07ff
ldir
;<stdin>:29:
ld c,0x00
;<stdin>:30:
00112$:
ld a,c
rlca
rlca
rlca
and a,0xf8
ld e,a
ld d,0x00
00106$:
;<stdin>:31:
ld l,d
ld h,0x00
add hl, hl
add hl, hl
add hl, hl
add hl, hl
add hl, hl
ld a,low (_cellram)
add a, l
ld l,a
ld a,high (_cellram)
adc a, h
ld h,a
ld b,0x00
add hl, bc
ld (hl),e
;<stdin>:30:
inc d
ld a,d
sub a, 0x20
jr C,00106$
;<stdin>:29:
inc c
ld a,c
sub a, 0x20
jr C,00112$
;<stdin>:34:
00104$:
jr 00104$

View File

@ -536,7 +536,8 @@ export function getToolForFilename_z80(fn) {
if (fn.endsWith(".s")) return "sdasz80";
if (fn.endsWith(".ns")) return "naken";
if (fn.endsWith(".scc")) return "sccz80";
return "z80asm";
if (fn.endsWith(".zmac")) return "zmac";
return "zmac";
}
////// 6809

27
src/worker/asmjs/zmac.js Normal file

File diff suppressed because one or more lines are too long

14
src/worker/wasm/zmac.js Normal file

File diff suppressed because one or more lines are too long

BIN
src/worker/wasm/zmac.wasm Normal file

Binary file not shown.

View File

@ -1359,6 +1359,55 @@ function compileYosys(step) {
}
}
function assembleZMAC(step) {
loadNative("zmac");
var objout, lstout, symout;
var errors = [];
gatherFiles(step, {mainFilePath:"main.asm"});
var binpath = "zout/" + step.prefix + ".cim";
var lstpath = "zout/" + step.prefix + ".lst";
if (staleFiles(step, [binpath, lstpath])) {
/*
error1.asm(4) : 'l18d4' Undeclared
JP L18D4
error1.asm(11): warning: 'foobar' treated as label (instruction typo?)
Add a colon or move to first column to stop this warning.
1 errors (see listing if no diagnostics appeared here)
*/
var ZMAC = zmac({
instantiateWasm: moduleInstFn('zmac'),
noInitialRun:true,
//logReadFiles:true,
print:print_fn,
printErr:makeErrorMatcher(errors, /([^( ]+)\s*[(](\d+)[)]\s*:\s*(.+)/, 2, 3, step.path),
});
var FS = ZMAC['FS'];
populateFiles(step, FS);
execMain(step, ZMAC, ['-z', '--oo', 'lst,cim', step.path]);
if (errors.length) {
return {errors:errors};
}
objout = FS.readFile(binpath, {encoding:'utf8'});
lstout = FS.readFile(lstpath, {encoding:'utf8'});
putWorkFile(binpath, objout);
putWorkFile(lstpath, lstout);
// 230: 1739+7 017A 1600 L017A: LD D,00h
var listing = parseListing(lstout, /\s*(\d+):\s*(\d+)[+](\d+)\s+([0-9a-f]+)\s+([0-9a-f]+)\s+(.+)/i, 1, 4, 5);
var listings = {};
listings[lstpath] = listing;
return {
output:binpath,
listings:listings,
errors:errors,
//symbolmap:symbolmap
};
}
}
////////////////////////////
var TOOLS = {
'dasm': assembleDASM,
@ -1378,6 +1427,7 @@ var TOOLS = {
'yosys': compileYosys,
//'caspr': compileCASPR,
'jsasm': compileJSASMStep,
'zmac': assembleZMAC,
}
var TOOL_PRELOADFS = {