1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-12-21 06:29:48 +00:00

added acme assembler

vcslib: increased # of lines in kernel
This commit is contained in:
Steven Hugg 2023-11-13 12:17:54 -06:00
parent f6452a719f
commit 44271fe9b8
12 changed files with 166 additions and 4 deletions

View File

@ -0,0 +1,7 @@
* = $0801
!word Start
!byte $00,$00,$9e
!text "2066"
!byte $00,$00,$00
* = $0812

18
presets/c64/skeleton.acme Normal file
View File

@ -0,0 +1,18 @@
!src "basicheader.acme"
Start:
jsr $e544 ; clear screen
ldy #0
Loop:
lda Message,y ; load message byte
beq EOM ; 0 = end of string
sta $400+41,y ; store to screen
iny
bne Loop ; next character
EOM:
jmp EOM ; infinite loop
Message:
!scr "hello world!", 0

View File

@ -161,8 +161,8 @@ extern void tinyfont48_build(byte* dest, const char str[12]);
#define OVERSCAN_TIM64 _TIM64(_CYCLES(36))
#else
#define VBLANK_TIM64 _TIM64(_CYCLES(37))
#define KERNAL_TIM64 _TIM64(_CYCLES(194))
#define OVERSCAN_TIM64 _TIM64(_CYCLES(32))
#define KERNAL_TIM64 _TIM64(_CYCLES(198))
#define OVERSCAN_TIM64 _TIM64(_CYCLES(28))
#endif
#define JOY_UP(plyr) (!(RIOT.swcha & ((plyr) ? 0x1 : ~MOVE_UP)))

View File

@ -888,7 +888,9 @@ export abstract class BaseMachinePlatform<T extends Machine> extends BaseDebugPl
const {x,y} = this.machine.getRasterCanvasPosition();
if (x >= 0 || y >= 0) {
const ctx = this.video.getContext();
drawCrosshair(ctx, x, y, 1);
if (ctx) {
drawCrosshair(ctx, x, y, 1);
}
}
}
}

View File

@ -217,6 +217,11 @@ export class CodeProject {
while (m = re6.exec(text)) {
this.pushAllFiles(files, m[2]);
}
// for acme
let re7 = /^[!]src\s+"(.+?)"/gmi;
while (m = re7.exec(text)) {
this.pushAllFiles(files, m[1]);
}
}
return files;
}

View File

@ -129,6 +129,7 @@ const TOOL_TO_SOURCE_STYLE = {
'remote:llvm-mos': 'text/x-csrc',
}
// TODO: move into tool class
const TOOL_TO_HELPURL = {
'dasm': 'https://raw.githubusercontent.com/sehugg/dasm/master/doc/dasm.txt',
'cc65': 'https://cc65.github.io/doc/cc65.html',
@ -142,6 +143,7 @@ const TOOL_TO_HELPURL = {
'zmac': "https://raw.githubusercontent.com/sehugg/zmac/master/doc.txt",
'cmoc': "http://perso.b2b2c.ca/~sarrazip/dev/cmoc.html",
'remote:llvm-mos': 'https://llvm-mos.org/wiki/Welcome',
'acme': 'https://raw.githubusercontent.com/sehugg/acme/main/docs/QuickRef.txt',
}
function gaEvent(category:string, action:string, label?:string, value?:string) {
@ -1895,6 +1897,8 @@ function _addIncludeFile() {
addFileToProject("Include", ".wiz", (s) => { return 'import "'+s+'";' });
else if (tool == 'ecs')
addFileToProject("Include", ".ecs", (s) => { return 'import "'+s+'"' });
else if (tool == 'acme')
addFileToProject("Include", ".acme", (s) => { return '!src "'+s+'"' });
else
alertError("Can't add include file to this project type (" + tool + ")");
}

View File

@ -62,6 +62,7 @@ function getToolForFilename_vcs(fn: string) {
if (fn.endsWith(".wiz")) return "wiz";
if (fn.endsWith(".bb") || fn.endsWith(".bas")) return "bataribasic";
if (fn.endsWith(".ca65")) return "ca65";
if (fn.endsWith(".acme")) return "acme";
//if (fn.endsWith(".inc")) return "ca65";
if (fn.endsWith(".c")) return "cc65";
//if (fn.endsWith(".h")) return "cc65";

96
src/worker/tools/acme.ts Normal file
View File

@ -0,0 +1,96 @@
import { CodeListing, CodeListingMap } from "../../common/workertypes";
import { BuildStep, BuildStepResult, emglobal, execMain, fixParamsWithDefines, gatherFiles, loadNative, makeErrorMatcher, moduleInstFn, msvcErrorMatcher, populateFiles, print_fn, putWorkFile, setupFS, staleFiles } from "../workermain";
import { EmscriptenModule } from "../workermain"
function parseACMESymbolTable(text: string) {
var symbolmap = {};
var lines = text.split("\n");
for (var i = 0; i < lines.length; ++i) {
var line = lines[i].trim();
// init_text = $81b ; ?
var m = line.match(/(\w+)\s*=\s*[$]([0-9a-f]+)/i);
if (m) {
symbolmap[m[1]] = parseInt(m[2], 16);
}
}
return symbolmap;
}
function parseACMEReportFile(text: string) {
var listings : CodeListingMap = {};
var listing : CodeListing;
var lines = text.split("\n");
for (var i = 0; i < lines.length; ++i) {
var line = lines[i].trim();
// ; ******** Source: hello.acme
var m1 = line.match(/^;\s*[*]+\s*Source: (.+)$/);
if (m1) {
var file = m1[1];
listings[file] = listing = {
lines: [],
};
continue;
}
// 15 0815 201b08 jsr init_text ; write line of text
var m2 = line.match(/^(\d+)\s+([0-9a-f]+)\s+([0-9a-f]+)/i);
if (m2) {
if (listing) {
listing.lines.push({
line: parseInt(m2[1]),
offset: parseInt(m2[2], 16),
insns: m2[3],
});
}
}
}
return listings;
}
export function assembleACME(step: BuildStep): BuildStepResult {
loadNative("acme");
var errors = [];
gatherFiles(step, { mainFilePath: "main.acme" });
var binpath = step.prefix + ".bin";
var lstpath = step.prefix + ".lst";
var sympath = step.prefix + ".sym";
if (staleFiles(step, [binpath, lstpath])) {
var binout, lstout, symout;
var ACME: EmscriptenModule = emglobal.acme({
instantiateWasm: moduleInstFn('acme'),
noInitialRun: true,
print: print_fn,
printErr: msvcErrorMatcher(errors),
//printErr: makeErrorMatcher(errors, /(Error|Warning) - File (.+?), line (\d+)[^:]+: (.+)/, 3, 4, step.path, 2),
});
var FS = ACME.FS;
populateFiles(step, FS);
fixParamsWithDefines(step.path, step.params);
var args = ['--msvc', '--initmem', '0', '-o', binpath, '-r', lstpath, '-l', sympath, step.path];
if (step.params?.acmeargs) {
args.unshift.apply(args, step.params.acmeargs);
} else {
args.unshift.apply(args, ['-f', 'plain']);
}
args.unshift.apply(args, ["-D__8BITWORKSHOP__=1"]);
if (step.mainfile) {
args.unshift.apply(args, ["-D__MAIN__=1"]);
}
execMain(step, ACME, args);
if (errors.length) {
let listings: CodeListingMap = {};
return { errors, listings };
}
binout = FS.readFile(binpath, { encoding: 'binary' });
lstout = FS.readFile(lstpath, { encoding: 'utf8' });
symout = FS.readFile(sympath, { encoding: 'utf8' });
putWorkFile(binpath, binout);
putWorkFile(lstpath, lstout);
putWorkFile(sympath, symout);
return {
output: binout,
listings: parseACMEReportFile(lstout),
errors: errors,
symbolmap: parseACMESymbolTable(symout),
};
}
}

21
src/worker/wasm/acme.js Normal file

File diff suppressed because one or more lines are too long

BIN
src/worker/wasm/acme.wasm Executable file

Binary file not shown.

View File

@ -252,12 +252,14 @@ var PLATFORM_PARAMS = {
libargs: [ '--lib-path', '/share/target/apple2/drv', '-D', '__EXEHDR__=0', 'apple2.lib'],
__CODE_RUN__: 16384,
code_start: 0x803,
acmeargs: ['-f', 'apple'],
},
'apple2-e': {
arch: '6502',
define: ['__APPLE2__'],
cfgfile: 'apple2.cfg',
libargs: ['apple2.lib'],
acmeargs: ['-f', 'apple'],
},
'atari8-800xl.disk': {
arch: '6502',
@ -327,6 +329,7 @@ var PLATFORM_PARAMS = {
define: ['__CBM__', '__C64__'],
cfgfile: 'c64.cfg', // SYS 2061
libargs: ['c64.lib'],
acmeargs: ['-f', 'cbm'],
//extra_link_files: ['c64-cart.cfg'],
},
'vic20': {
@ -334,6 +337,7 @@ var PLATFORM_PARAMS = {
define: ['__CBM__', '__VIC20__'],
cfgfile: 'vic20.cfg',
libargs: ['vic20.lib'],
acmeargs: ['-f', 'cbm'],
//extra_link_files: ['c64-cart.cfg'],
},
'kim1': {
@ -1135,10 +1139,11 @@ import * as x86 from './tools/x86'
import * as arm from './tools/arm'
import * as ecs from './tools/ecs'
import * as remote from './tools/remote'
import * as acme from './tools/acme'
var TOOLS = {
'dasm': dasm.assembleDASM,
//'acme': assembleACME,
'acme': acme.assembleACME,
'cc65': cc65.compileCC65,
'ca65': cc65.assembleCA65,
'ld65': cc65.linkLD65,

View File

@ -265,6 +265,9 @@ describe('Worker', function() {
compile('cc65', '#define CC65_FLAGS -Or,-g,-j\nint main() {\nint x=1;\nreturn x+2;\n}', 'apple2', done, 416, 3);
});
/*
it('should compile ACME', function(done) {
compile('acme', 'nop', 'c64', done, 416, 3);
});
it('should compile CMOC', function(done) {
compile('cmoc', 'int foo=0; // comment\n#if defined(__8BITWORKSHOP__) && defined(__MAIN__)\nint main(int argc) {\nint x=1;\nint y=2+argc;\nreturn x+y+argc;\n}\n#endif\n', 'williams', done, 8192, 3, 0, {filename:'test.c'});
});