1
0
mirror of https://github.com/DoctorWkt/pdp7-unix.git synced 2026-01-25 11:47:35 +00:00

tools/a7out: Added the jms instruction.

This commit is contained in:
Warren Toomey
2016-02-27 15:55:40 +10:00
parent bc8caf1577
commit ea7cd8da28

View File

@@ -16,7 +16,7 @@ my @FD; # Array of open filehandles
# Registers
my $PC = 0; # Program counter
my $AC; # Accumulator
my $LINK; # Link register
my $LINK = 0; # Link register
my $MQ; # MQ register
# Constants
@@ -134,6 +134,7 @@ sub simulate {
# List of opcodes that we can simulate
my %Oplist = (
oct("004") => \&dac,
oct("010") => \&jms,
oct("020") => \&lac,
oct("034") => \&tad,
oct("054") => \&sad,
@@ -153,8 +154,8 @@ sub simulate {
# Work out what any indirect address would be
my $indaddr= ($indirect) ? $Mem[$addr] & MAXADDR : $addr;
dprintf( "PC %06o: instr %06o, op %03o, ind %o, addr %06o ind %06o\n",
$PC, $instruction, $opcode, $indirect, $addr, $indaddr );
#dprintf( "PC %06o: instr %06o, op %03o, in %o, addr %06o indaddr %06o\n",
# $PC, $instruction, $opcode, $indirect, $addr, $indaddr );
# Simulate the instruction. Each subroutine updates the $PC
if ( defined( $Oplist{$opcode} ) ) {
@@ -215,6 +216,16 @@ sub jmp {
$PC = $indaddr;
}
# Jump to subroutine
sub jms {
my ( $instruction, $addr, $indaddr ) = @_;
dprintf( "PC %06o: jms %06o\n", $PC, $indaddr );
# Save the LINK and current PC into the $indaddr location
$Mem[$indaddr++]= $PC+1 | (($LINK) ? 0400000 : 0);
$PC= $indaddr;
}
# Special instructions
sub special {
my $instruction = shift;