diff --git a/src/cmd/ed1.s b/src/cmd/ed1.s index 3210d09..1a05695 100644 --- a/src/cmd/ed1.s +++ b/src/cmd/ed1.s @@ -70,28 +70,28 @@ chkwrp: jmp error comand: - lac char + lac char " Get the character entered sad o141 - jmp ca + jmp ca " a command, append lines of text sad o143 - jmp cc + jmp cc " c command, change lines of text sad o144 - jmp cd + jmp cd " d command, delete lines of text sad o160 - jmp cp + jmp cp " p command, print lines of text sad o161 - jmp cq + jmp cq " q command, quit the editor sad o162 - jmp cr + jmp cr " r command, read in a file sad o163 - jmp cs + jmp cs " s command, substitute text sad o167 - jmp cw + jmp cw " w command, write out the file sad o12 - jmp cnl + jmp cnl " newline sad o75 - jmp ceq - jmp error + jmp ceq " = command + jmp error " unrecognised, give an error ca: jms newline jms setfl @@ -334,10 +334,10 @@ setfl: 0 jmp i setfl newline: 0 - jms getsc; tal + jms getsc; tal " Get a character into tal sad o12 - jmp i newline - jmp error + jmp i newline " Return if a newline + jmp error " else an error addres: 0 dzm minflg "..) [stray scan mark?] @@ -768,4 +768,4 @@ error: sys write; 1f; 1 jmp advanc 1: - 077012 \ No newline at end of file + 077012 diff --git a/tools/a7out b/tools/a7out index eeb81c7..ceab567 100755 --- a/tools/a7out +++ b/tools/a7out @@ -13,8 +13,10 @@ use Data::Dumper; ### Global variables ### my $debug = 0; # Debug flag my $singlestep = 0; # Are we running in single-step mode? +my $coverage = 0; # Print out code coverage my %Breakpoint; # Hash of defined breakpoints my @Mem; # 8K 18-bit words of main memory +my @CC; # Code coverage: what addrs executed instructions my @FD; # Array of open filehandles my @ISBINARY; # Array of filehandle flags: ASCII or binary files? @@ -49,10 +51,16 @@ while ( defined( $ARGV[0] ) && ( $ARGV[0] =~ m{^-} ) ) { shift(@ARGV); $Breakpoint{ oct( shift(@ARGV) ) } = 1; } + + # -c: print out code coverage + if ( $ARGV[0] eq "-c" ) { + shift(@ARGV); + $coverage= 1; + } } # Check the arguments -die("Usage: $0 [-d] [-b breakpoint] a.outfile [arg1 arg2 ...]\n") +die("Usage: $0 [-c] [-d] [-b breakpoint] a.outfile [arg1 arg2 ...]\n") if ( @ARGV < 1 ); # Load the a.out file into memory @@ -63,8 +71,16 @@ set_arguments(); #dump_memory(0, MAXADDR, 0); #exit(0); simulate(); +print_coverage() if ($coverage); exit(0); +# Print out the code coverage +sub print_coverage { + foreach my $addr (0 .. MAXADDR ) { + printf("%06o: %d\n", $addr, $CC[$addr]) if ($CC[$addr]); + } +} + ### Load the a.out file into memory sub load_code { my $filename = shift; @@ -212,7 +228,8 @@ sub simulate { while (1) { # Get the instruction pointed to by PC and decode it - my $instruction = $Mem[$PC]; + # Also do code coverage + my $instruction = $Mem[$PC]; $CC[$PC]++; my $opcode = ( $instruction >> 12 ) & 074; my $indirect = ( $instruction >> 13 ) & 1; my $addr = $instruction & MAXADDR; @@ -694,6 +711,7 @@ sub cal { # Exit system call sub sys_exit { dprintf( "exit system call, pid %06o\n", $$ ); + print_coverage() if ($coverage); exit(0); }