Add the ability to turn the local echo on or off in the emulator, make the rest of the included programs exit with a non-zero exit code on error, and fix and reword the readme slightly
This commit is contained in:
parent
39e273d575
commit
bcd407e639
4 changed files with 26 additions and 21 deletions
|
@ -36,7 +36,7 @@ begin
|
|||
//Read a program file and check for errors
|
||||
if ParamCount <> 1 then begin
|
||||
writeln ('Usage: disassembler program (> output)');
|
||||
halt;
|
||||
halt (1);
|
||||
end;
|
||||
{$i-}
|
||||
assign (Prog, ParamStr (1));
|
||||
|
@ -44,7 +44,7 @@ begin
|
|||
{$i+}
|
||||
if IOResult <> 0 then begin
|
||||
writeln ('Error: program file cannot be read from');
|
||||
halt;
|
||||
halt (1);
|
||||
end;
|
||||
repeat
|
||||
read (Prog, Bin [BP]);
|
||||
|
@ -52,7 +52,7 @@ begin
|
|||
until (eof (Prog)) or (BP = $fff0);
|
||||
if BP = $fff0 then begin
|
||||
writeln ('Error: memory overflow');
|
||||
halt;
|
||||
halt (1);
|
||||
end;
|
||||
//Save the end point and reinitialise the byte pointer
|
||||
EP := BP;
|
||||
|
|
19
emulator.pas
19
emulator.pas
|
@ -31,7 +31,7 @@ const
|
|||
{$endif}
|
||||
|
||||
var
|
||||
Hlt, Verbose: boolean; //Halt, ASCII, and verbose flags
|
||||
Hlt, Verbose, Echo: boolean; //Halt, verbose, 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
|
||||
|
@ -106,7 +106,7 @@ begin
|
|||
end;
|
||||
end;
|
||||
//Process the keypress
|
||||
Output; //Local echo
|
||||
if Echo then Output; //Local echo
|
||||
B := byte (Ch);
|
||||
end
|
||||
//Tape reader
|
||||
|
@ -166,6 +166,8 @@ begin
|
|||
{$endif}
|
||||
Ch := ansichar (B);
|
||||
Output;
|
||||
if Ch = ansichar ($12) then Echo := true;
|
||||
if Ch = ansichar ($14) then Echo := false;
|
||||
end
|
||||
//Printer
|
||||
{$ifdef printer}
|
||||
|
@ -260,8 +262,9 @@ end;
|
|||
|
||||
begin
|
||||
|
||||
//Initialise the halt flag, the pointers, and the instruction counter
|
||||
//Initialise the halt and echo flags, the pointers, and the instruction counter
|
||||
Hlt := false;
|
||||
Echo := true;
|
||||
IP := 0;
|
||||
RP := LastRAM + 1;
|
||||
IC := 0;
|
||||
|
@ -279,20 +282,20 @@ begin
|
|||
//Check the arguments
|
||||
if ParamCount = 0 then begin
|
||||
writeln ('Usage: emulator (-v) program (2> verbose_output)');
|
||||
halt;
|
||||
halt (1);
|
||||
end;
|
||||
if ParamStr (1) = '-v' then begin
|
||||
Verbose := true;
|
||||
if ParamCount <> 2 then begin
|
||||
writeln ('Usage: emulator (-v) program (2> verbose_output)');
|
||||
halt;
|
||||
halt (1);
|
||||
end;
|
||||
end
|
||||
else begin
|
||||
Verbose := false;
|
||||
if ParamCount <> 1 then begin
|
||||
writeln ('Usage: emulator (-v) program (2> verbose_output)');
|
||||
halt;
|
||||
halt (1);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -303,12 +306,12 @@ begin
|
|||
reset (Prog);
|
||||
if FileSize (Prog) > LastRAM + 1 then begin
|
||||
writeln ('Error: program size cannot exceed ', LastRam + 1, ' bytes');
|
||||
halt;
|
||||
halt (1);
|
||||
end;
|
||||
{$i+}
|
||||
if IOResult <> 0 then begin
|
||||
writeln ('Error: program file cannot be read from');
|
||||
halt;
|
||||
halt (1);
|
||||
end;
|
||||
repeat
|
||||
read (Prog, Mem [IP]);
|
||||
|
|
18
readme.md
18
readme.md
|
@ -12,7 +12,7 @@ The repository includes an emulator implementation of Thingamajig with a
|
|||
control program for the emulated punched tape reader and punch, and an
|
||||
assembler and a disassembler, all written in FreePascal. It also
|
||||
includes couple of simple example programs for Thingamajig written in
|
||||
Assembly.
|
||||
assembly.
|
||||
|
||||
Registers and Memory
|
||||
--------------------
|
||||
|
@ -70,8 +70,8 @@ comment elements are all optional, as is spacing between the arguments.
|
|||
For the arguments of each instruction see the previous section.
|
||||
|
||||
Address arguments can be either absolute addresses or references to or
|
||||
relative to a label. Relative references are of the form LABEL +/- N,
|
||||
the spacing being optional.
|
||||
relative to a label. Relative references are of the form LABEL +/- N;
|
||||
the spacing is optional.
|
||||
|
||||
In addition to the true instructions there are three
|
||||
pseudo-instructions. ORG defines the starting address of the program: it
|
||||
|
@ -93,17 +93,19 @@ Emulator
|
|||
--------
|
||||
|
||||
By default the emulator runs at roughly 500 KIPS, has 2 KiB of RAM, and
|
||||
interacts with memory mapped devices at roughly 1000 CPS. The arguments
|
||||
interacts with memory mapped devices at roughly 1000 B/s. The arguments
|
||||
-dRAM4, -dRAM8, -dRAM16, -dRAM32, and -dRAM64 can be used to compile
|
||||
the emulator with 4, 8, 16, 32, or 64 KiB (minus the reserved addresses)
|
||||
of RAM respectively instead and the speed limitations can be removed
|
||||
with the argument -dfast.
|
||||
|
||||
Input and output are handled by an emulated glass teletype terminal with
|
||||
local echo. Of the control characters only bell, backspace, line feed,
|
||||
and carriage return are used by the terminal. The backspace and delete
|
||||
characters are tied to their respective keys, and non-character keys
|
||||
input null.
|
||||
local echo on by default. Of the control characters bell, backspace,
|
||||
line feed, carriage return, and device control characters two and four
|
||||
are used by the terminal: the device control characters are used to turn
|
||||
the local echo on or off respectively, while the rest have their
|
||||
standard uses. The backspace and delete keys input their respective
|
||||
characters and non-character keys null.
|
||||
|
||||
In Linux the emulator can be compiled with support for a character
|
||||
printer and an emulated punched tape reader and punch with the arguments
|
||||
|
|
|
@ -22,7 +22,7 @@ begin
|
|||
//Check whether to set the reader, the punch, or both
|
||||
if ParamCount <> 1 then begin
|
||||
writeln ('Usage: tapectl reader/punch/both');
|
||||
halt;
|
||||
halt (1);
|
||||
end;
|
||||
if ParamStr (1) = 'reader' then begin
|
||||
DoRead := true;
|
||||
|
@ -38,7 +38,7 @@ begin
|
|||
end
|
||||
else begin
|
||||
writeln ('Usage: tapectl reader/punch/both');
|
||||
halt;
|
||||
halt (1);
|
||||
end;
|
||||
|
||||
//Assign the state file
|
||||
|
|
Loading…
Reference in a new issue