From 7b9eed22ac3bd885b1f700188748aaa710434e2a Mon Sep 17 00:00:00 2001 From: wfjm Date: Thu, 11 Aug 2022 08:42:31 +0200 Subject: [PATCH] asm-11: add -E,-M option --- doc/CHANGELOG.md | 2 +- tools/bin/asm-11 | 16 +++++++++++++--- tools/man/man1/asm-11.1 | 35 +++++++++++++++++++++++++++++------ 3 files changed, 43 insertions(+), 10 deletions(-) diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index c9e12e21..aca4bc0c 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -44,7 +44,7 @@ The full set of tests is only run for tagged releases. - ci.yml: define TBW_GHDL_OPTS and suppress IEEE package warnings at t=0ms - **/tbrun.yml: since nexys4 not longer available switch to nexys4d - tools/bin - - asm-11: limited macro support (.macro,.endm) + - asm-11: limited macro support (.macro,.endm); added -E,-M option - create_disk: -help: print byte size of disk - njobihtm: add -n and -h options - tbrun_tbwrri: fully implement --r(l|b)mon diff --git a/tools/bin/asm-11 b/tools/bin/asm-11 index 977964c3..892f395f 100755 --- a/tools/bin/asm-11 +++ b/tools/bin/asm-11 @@ -1,10 +1,11 @@ #!/usr/bin/perl -w -# $Id: asm-11 1262 2022-07-25 09:44:55Z mueller $ +# $Id: asm-11 1264 2022-07-30 07:42:17Z mueller $ # SPDX-License-Identifier: GPL-3.0-or-later # Copyright 2013-2022 by Walter F.J. Mueller # # Revision History: # Date Rev Version Comment +# 2022-07-28 1264 1.1.3 add -E and -M options # 2022-07-23 1262 1.1.2 BUGFIX: '100(pc)' was compiled as '100' # 2019-07-13 1189 1.1.1 drop superfluous exists for $opts # 2019-05-25 1152 1.1 add .macro,.endm,.list,.nlist @@ -33,7 +34,7 @@ use constant TMASK_MACROARG => 0x0004; my %opts = (); -GetOptions(\%opts, "help", +GetOptions(\%opts, "help", "E", "M", "tpass1", "tpass2", "dsym1", "dsym2", "ttoken", "tparse", "temit", "tout", @@ -257,7 +258,7 @@ my @mdefstk; # open .macro,.rept defs stack my $mautolbl = 30000; # auto-generated label my @flist; # list of filenames -my $fstem; # stem or last file name +my $fstem; # stem of last file name my $lst_do; # generate listing my $lst_fname; # listing file name my $lda_do; # generate lda output @@ -317,6 +318,7 @@ $pass = 1; foreach my $fname (@ARGV) { read_file($fname); } +exit 0 if $opts{E} || $opts{M}; # stop after pass1 for -E -M dump_sym() if $opts{dsym1}; # prepare pass 2 @@ -379,12 +381,19 @@ sub read_file { } push @flist, $fname; + if ($opts{M}) { + printf "%s : %s\n", create_fname($opts{olda},'.lda'), $fname; + printf "%s : %s\n", create_fname($opts{olda},'.lst'), $fname; + } my $lineno = 0; my $fileno = scalar(@flist); while (<$fh>) { chomp; my $line = $_; + if ($opts{E} && $line !~ m/\s*\.include/) { # if -E and not .include + printf "$line\n"; # write to stdout + } $lineno += 1; pass1_line($fileno, $lineno, $line); } @@ -2705,6 +2714,7 @@ sub bailout { sub print_help { print "usage: asm-11 [OPTIONS]... [FILE]...\n"; print " --I=path adds path to the .include search path\n"; + print " --E write .include processed input to stdout\n"; print " --lst create listing (default file name)\n"; print " --olst=fnam create listing (concrete file name)\n"; print " --lda create absolute loader output (default file name)\n"; diff --git a/tools/man/man1/asm-11.1 b/tools/man/man1/asm-11.1 index 75e7b735..a26a21c3 100644 --- a/tools/man/man1/asm-11.1 +++ b/tools/man/man1/asm-11.1 @@ -1,5 +1,5 @@ .\" -*- nroff -*- -.\" $Id: asm-11.1 1262 2022-07-25 09:44:55Z mueller $ +.\" $Id: asm-11.1 1264 2022-07-30 07:42:17Z mueller $ .\" SPDX-License-Identifier: GPL-3.0-or-later .\" Copyright 2013-2022 by Walter F.J. Mueller .\" @@ -97,11 +97,29 @@ no .mexit, .mdelete, .mcall support . .\" ---------------------------------------------- .IP "\fB\-I\fI path\fR" -adds path to the .include search path. +adds \fIpath\fP to the .include search path. +The default search path is '.' plus \fI$RETROBASE/tools/asm-11\fP if +\fBRETROBASE\fP is defined. Each \fB\-I\fP adds \fIpath\P after '.'. +\fB\-I\fP can be given multiple times und must have a single path name. +. +.\" ---------------------------------------------- +.IP "\fB\-E\fR" +write .include processed code to \fIstdout\fP and stop after 1st pass. +No other outputs are created, options like \fB\-\-lst\fR are ignored. +Useful for the generation of self-contained macro files that are free +of .include directives and thus free of external references. Was inspired +by the -E option of gcc(1). +. +.\" ---------------------------------------------- +.IP "\fB\-M\fR" +write rules to \fIstdout\fP suitable for \fBmake\fP(1) describing the +dependencies of generated .lda and .lst files from the source files. +Outputs for .lda and .lst targets one rule per input or included file. +Only useful when \fIFILE\fP is not '-'. Was inspired by the -M option of gcc(1). . .\" ---------------------------------------------- .IP "\fB\-\-lst\fR" -create listing with a default file name built from the basename of the first +create listing with a default file name built from the basename of the last \fIFILE\fP plus a \fI.lst\fP extension. If \fIFILE\fP is '-' the output is written to \fIstdout\fP. . @@ -113,7 +131,7 @@ If \fIfnam\fP is '-' the listing is written to \fIstdout\fP. .\" ---------------------------------------------- .IP "\fB\-\-lda\fR" create absolute loader output in \fBlda-11\fP(5) format with a default file name -built from the basename of the first \fIFILE\fP plus a \fI.lda\fP extension. +built from the basename of the last \fIFILE\fP plus a \fI.lda\fP extension. If \fIFILE\fP is '-' the output is written to \fIstdout\fP. . @@ -126,7 +144,7 @@ If \fIfnam\fP is '-' the compound output is written to \fIstdout\fP. .\" ---------------------------------------------- .IP "\fB\-\-cof\fR" create compound output in \fBcof-11\fP(5) format with a default file name -built from the basename of the first \fIFILE\fP plus a \fI.cof\fP extension. +built from the basename of the last \fIFILE\fP plus a \fI.cof\fP extension. If \fIFILE\fP is '-' the output is written to \fIstdout\fP. . .\" ---------------------------------------------- @@ -139,7 +157,7 @@ output comes first, followed by the compound output. .\" ---------------------------------------------- .IP "\fB\-\-lsm\fR" create lsmem style memory dump in \fBlsm-11\fP(5) format with a default file -name built from the basename of the first \fIFILE\fP plus a \fI.lsm\fP extension. +name built from the basename of the last \fIFILE\fP plus a \fI.lsm\fP extension. If \fIFILE\fP is '-' the output is written to \fIstdout\fP. . .\" ---------------------------------------------- @@ -188,6 +206,11 @@ trace code emit. trace output file write. . .\" ------------------------------------------------------------------ +.SH ENVIRONMENT +.IP \fBRETROBASE\fP +If defined adds an include path to the \fBasm-11\fP standard library. +. +.\" ------------------------------------------------------------------ .SH EXIT STATUS If files can't be opened or an assembler error is detected an exit status 1 is returned.