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