diff --git a/src/toolsrc/codegen.pla b/src/toolsrc/codegen.pla index 17172d9..3d0d11a 100644 --- a/src/toolsrc/codegen.pla +++ b/src/toolsrc/codegen.pla @@ -383,7 +383,7 @@ end // // Emit lambda function // -def emit_lambdafunc(tag, namestr, cparms, lambda_seq)#0 +def emit_lambdafunc(tag, cparms, lambda_seq)#0 emit_ctag(tag) framesize = cparms * 2 emit_enter(cparms) @@ -759,3 +759,19 @@ def gen_bop(tkn, seq) op->opgroup = STACK_GROUP return seq end +// +// Write REL file +// +def writemodule(refnum)#0 + // + // Build module header + // + + // + // Write data/code buffer + // + + // + // Write relocation directory + // +end diff --git a/src/toolsrc/parse.pla b/src/toolsrc/parse.pla index 7311d1c..26e3239 100644 --- a/src/toolsrc/parse.pla +++ b/src/toolsrc/parse.pla @@ -1179,7 +1179,7 @@ def parse_defs return TRUE while lambda_cnt lambda_cnt-- - emit_lambdafunc(lambda_tag[lambda_cnt], @lambda_id[lambda_cnt * 8], lambda_cparms[lambda_cnt], lambda_seq[lambda_cnt]) + emit_lambdafunc(lambda_tag[lambda_cnt], lambda_cparms[lambda_cnt], lambda_seq[lambda_cnt]) loop fin return token == EOL_TKN ?? TRUE :: FALSE diff --git a/src/toolsrc/plasm.pla b/src/toolsrc/plasm.pla index 19f578f..f581933 100644 --- a/src/toolsrc/plasm.pla +++ b/src/toolsrc/plasm.pla @@ -262,11 +262,10 @@ word srcline // Saved source line number // // Scanner variables // -//const inbuff = $0200 -//const instr = $01FF -//word scanptr = inbuff +const inbuff = $0200 +const instr = $01FF +word scanptr = inbuff byte token = EOL_TKN -word instr, inbuff, scanptr byte scanchr, tknlen word tknptr, parserrln word constval @@ -389,8 +388,6 @@ end // Include code to reduce size of this file // include "toolsrc/codegen.pla" -//include "toolsrc/codeopt.pla" -//include "toolsrc/writerel.pla" include "toolsrc/lex.pla" include "toolsrc/parse.pla" // @@ -429,8 +426,23 @@ fin if arg strcpy(@srcfile, arg) arg = argNext(arg) - if arg + if arg and ^arg strcpy(@relfile, arg) + else + strcpy(@relfile, @srcfile) + // + // Strip trailing extension + // + while relfile and relfile[relfile] <> '.' + relfile-- + loop + if relfile; relfile--; fin // Strip '.' + if not relfile + // + // Copy default name over + // + strcpy(@relfile, "A.OUT") + fin fin fin if srcfile and relfile @@ -439,9 +451,7 @@ if srcfile and relfile fileio:newline(srcref, $7F, $0D) refnum = srcref parsefile = @srcfile - instr = heapalloc(128) *instr = 0 - inbuff = instr + 1 scanptr = inbuff exit = heapalloc(t_longjmp) if not setjmp(exit) @@ -458,7 +468,7 @@ if srcfile and relfile fileio:create(@relfile, $FE, $1000) // full access, REL file srcref = fileio:open(@relfile) if srcref - //writerel(srcref) + writemodule(srcref) fileio:close(srcref) else puts("\nError opening: "); puts(@relfile); putln @@ -468,6 +478,6 @@ if srcfile and relfile puts("\nError opening: "); puts(@srcfile); putln fin else - puts("Usage:+PLASM [-[W][O[2]][N]] \n") + puts("Usage:+PLASM [-[W][O[2]][N]] [out]\n") fin done