From 8b421eb27b43f6061eed3652a6be150fbe996512 Mon Sep 17 00:00:00 2001 From: Warren Toomey Date: Sun, 13 Mar 2016 21:08:43 +1000 Subject: [PATCH] I've commited a change to as7 to use the C pre-processor. Not sure if it's to everybody's taste. --- build/Makefile | 6 ++-- src/sys/s7.s | 78 ++++++++++++++++++++++++++------------------------ tools/as7 | 18 ++++++++++-- 3 files changed, 60 insertions(+), 42 deletions(-) diff --git a/build/Makefile b/build/Makefile index 9afa5e3..f5aa4d2 100644 --- a/build/Makefile +++ b/build/Makefile @@ -1,6 +1,8 @@ # Build the kernel, the filesystem and run SimH +# Put any defines for as7 here +#DEFINES= -AS=../tools/as7 +AS=../tools/as7 $(DEFINES) MKFS=../tools/mkfs7 SYS=../src/sys @@ -18,7 +20,7 @@ coldboot: $(AS) -f list -o a.lst $(SYS)/sop.s $(SYS)/s[1-9].s image.fs: - $(MKFS) --debug --format simh proto + $(MKFS) --format simh proto clean: rm -f a.rim image.fs a.lst diff --git a/src/sys/s7.s b/src/sys/s7.s index a3f9cc1..f175a46 100644 --- a/src/sys/s7.s +++ b/src/sys/s7.s @@ -5,26 +5,28 @@ pibreak: " priority interrupt break processing "chain" dac .ac " save interrupt AC "** CROSSED OUT.... - " dpsf " Warren commented this code out to try and - " jmp 1f " disable the Graphics-2 I/O +#ifdef GRAPHICS2 + dpsf + jmp 1f " disable the Graphics-2 I/O - " dpcf - " dprs - " dac dpstat - " sma ral - " jmp 2f - " dprc - " dac dpchar - " -1 - " dac dpread - " lac dpstat - " ral -" 2: - " sma - " jmp piret - " -1 - " dac dpwrite - " jmp piret "** END OF CROSSOUT + dpcf + dprs + dac dpstat + sma ral + jmp 2f + dprc + dac dpchar + -1 + dac dpread + lac dpstat + ral +2: + sma + jmp piret + -1 + dac dpwrite + jmp piret "** END OF CROSSOUT +#endif 1: clsf " clock overflow (line frequency ticks)? jmp 1f " no @@ -88,26 +90,26 @@ cnop: " fetched as constant in iread dac .dspb jmp piret dsprestart: - " Warren commented this out to try and - " disable the Graphics-2 I/O - " lac d1 - " dac .dspb " set .dsbp = 1 - " lac dspbufp " load display buf pointer - " beg " start display processor - " -10 - " dac .dsptm " set .dsptm = -10 (10 ticks) - " jmp piret +#ifdef GRAPHICS2 + lac d1 + dac .dspb " set .dsbp = 1 + lac dspbufp " load display buf pointer + beg " start display processor + -10 + dac .dsptm " set .dsptm = -10 (10 ticks) + jmp piret -" 1: sna ral " dataphone flag set (bit 7)?? - " jmp .+3 " no - " raef " XXX: fix comment - " jmp piret " return - " sma " light pen flags (bit 2) - " jmp 1f " no - " lda " G-2: load display address - " dac .lpba " save - " rlpd " G-2: resume after light pen stop - " jmp piret +1: sna ral " dataphone flag set (bit 7)?? + jmp .+3 " no + raef " XXX: fix comment + jmp piret " return + sma " light pen flags (bit 2) + jmp 1f " no + lda " G-2: load display address + dac .lpba " save + rlpd " G-2: resume after light pen stop + jmp piret +#endif 1: ksf " (TTY) keyboard flag set? jmp 1f " no diff --git a/tools/as7 b/tools/as7 index ef15e2f..bd449ca 100755 --- a/tools/as7 +++ b/tools/as7 @@ -38,10 +38,13 @@ my $debug = 0; # Run in debug mode my $format = 'a7out'; # output format my $namelist = 0; # output n.out file my $output = 'a.out'; # output file +my @cppdefs; # C pre-processor defines +my @cppundefs; # C pre-processor undefines # keep this near the GetOptions call to make it easy to add documentation! sub usage { - die("Usage: $0 [--debug] [--format=a7out|list|ptr|rim ] [--out file] file1.s [file2.s ...]\n") + die("Usage: $0 [-Dmacro] [-Umacro] [--debug] [--format=a7out|list|ptr|rim ]\n" . + "\t[--out file] file1.s [file2.s ...]\n"); } GetOptions( @@ -49,6 +52,8 @@ GetOptions( 'format|f=s' => \$format, 'namelist|n' => \$namelist, 'output|o=s' => \$output, + 'D|D=s' => \@cppdefs, + 'U|U=s' => \@cppundefs, ) or usage(); usage() if ( @ARGV < 1 ); @@ -265,9 +270,18 @@ sub err { # Open and parse the given file sub parse_file { $file = shift; - open( my $IN, "<", $file ) || die("Cannot read $file: $!\n"); + + # Get the C pre-processor command-line arguments + my $defines= join(' ', map { "-D$_" } @cppdefs) || ""; + my $undefines= join(' ', map { "-U$_" } @cppundefs) || ""; + + open( my $IN, "-|", "cpp -trigraphs $defines $undefines $file" ) + || die("Cannot pipe cpp $file: $!\n"); $lineno = 0; while ( $line = <$IN> ) { + # Lose any C pre-processor comment lines + next if ($line=~ m{^#}); + $lineno++; chomp($line); # Lose the end of line $origline = $line;