@ -31,7 +31,7 @@ const
{$endif}
var
Hlt, Verbose, Echo: boolean; //Halt, verbose, and echo flags
Hlt, Echo: boolean; //Halt and echo flags
Op, Regs: 0 .. $f; //Opcode
X, Y: 0 .. 3; //Register arguments
Addr, IP, RP: word; //Immediate or address argument and instruction and return pointers
@ -43,7 +43,7 @@ var
State: file of Tape; //File storing the states of the tape reader and punch
{$endif}
Ch, Scan: ansichar; //Character for input and output and scancode for non-ASCII keys
IC, LFX: integer; //Instruction counter for CPU speed
Verbose, IC, LFX: integer; //Verbose flag, instruction counter for CPU speed, and line feed position marker
Fetched: byte; //Fetched byte
//Terminal output
@ -288,14 +288,21 @@ begin
halt (1);
end;
if ParamStr (1) = '-v' then begin
Verbose := true;
Verbose := 1;
if ParamCount <> 2 then begin
writeln ('Usage: emulator (-v) program (2> verbose_output)');
halt (1);
end;
end
else if ParamStr (2) = '-v' then begin
Verbose := 2;
if ParamCount <> 2 then begin
writeln ('Usage: emulator (-v) program (2> verbose_output)');
halt (1);
end;
end
else begin
Verbose := false;
Verbose := 0 ;
if ParamCount <> 1 then begin
writeln ('Usage: emulator (-v) program (2> verbose_output)');
halt (1);
@ -304,7 +311,7 @@ begin
//Read a program file and check for errors
{$i-}
if Verbose = true then assign (Prog, ParamStr (2))
if Verbose = 1 then assign (Prog, ParamStr (2))
else assign (Prog, ParamStr (1));
reset (Prog);
if FileSize (Prog) > LastRAM + 1 then begin
@ -329,7 +336,7 @@ begin
while Hlt = false do begin
//Print the CPU state to StdErr
if Verbose = true then writeln (StdErr, 'IR: ', IntToHex (Op, 1), IntToHex (Regs, 1), IntToHex (Addr, 4), '; IP: ', IntToHex (IP, 4), ', RP: ', IntToHex (RP, 4), '; R0: ', IntToHex (R[0], 2), ', R1: ', IntToHex (R[1], 2), ', R2: ', IntToHex (R[2], 2), ', R3: ', IntToHex (R[3], 2), ansichar ($d));
if Verbose <> 0 then writeln (StdErr, 'IR: ', IntToHex (Op, 1), IntToHex (Regs, 1), IntToHex (Addr, 4), '; IP: ', IntToHex (IP, 4), ', RP: ', IntToHex (RP, 4), '; R0: ', IntToHex (R[0], 2), ', R1: ', IntToHex (R[1], 2), ', R2: ', IntToHex (R[2], 2), ', R3: ', IntToHex (R[3], 2), ansichar ($d));
//Fetch the instruction and increment the instruction pointer
//Fetch the opcode and register arguments