Exit the assembler with a non-zero exit code on error

This commit is contained in:
Juhani Krekelä 2022-08-18 15:06:53 +03:00 committed by CrazyEttin
parent b3d043d43c
commit c3151c5113
1 changed files with 9 additions and 9 deletions

View File

@ -48,28 +48,28 @@ end;
procedure LblError; procedure LblError;
begin begin
writeln ('Error (line ', LP, '): illegal label'); writeln ('Error (line ', LP, '): illegal label');
halt; halt (1);
end; end;
//Print a reference error and abort //Print a reference error and abort
procedure RefError; procedure RefError;
begin begin
writeln ('Error (line ', LP, '): illegal reference(s) relative to this line'); writeln ('Error (line ', LP, '): illegal reference(s) relative to this line');
halt; halt (1);
end; end;
//Print an argument error and abort //Print an argument error and abort
procedure ArgError; procedure ArgError;
begin begin
writeln ('Error (line ', LP, '): illegal argument(s)'); writeln ('Error (line ', LP, '): illegal argument(s)');
halt; halt (1);
end; end;
//Print a memory error and abort if the assembler is about to write beyond available memory //Print a memory error and abort if the assembler is about to write beyond available memory
procedure MemError; procedure MemError;
begin begin
writeln ('Error (line ', LP, '): memory overflow'); writeln ('Error (line ', LP, '): memory overflow');
halt; halt (1);
end; end;
//Assemble a single register argument //Assemble a single register argument
@ -163,7 +163,7 @@ begin
//Check for and set up a program file //Check for and set up a program file
if ParamCount <> 1 then begin if ParamCount <> 1 then begin
writeln ('Usage: assembler program (< input)'); writeln ('Usage: assembler program (< input)');
halt; halt (1);
end; end;
//Initialise the byte and start pointers //Initialise the byte and start pointers
@ -259,7 +259,7 @@ begin
end end
else begin else begin
writeln ('Error (line ', LP, '): ORG must be the first instruction'); writeln ('Error (line ', LP, '): ORG must be the first instruction');
halt; halt (1);
end; end;
end end
@ -321,7 +321,7 @@ begin
else if CompareText (Elem [1], 'CLNEQ') = 0 then Bin [BP] := $f0 else if CompareText (Elem [1], 'CLNEQ') = 0 then Bin [BP] := $f0
else begin else begin
writeln ('Error (line ', LP, '): no such instruction'); writeln ('Error (line ', LP, '): no such instruction');
halt; halt (1);
end; end;
//Check for incorrect number of arguments //Check for incorrect number of arguments
@ -389,7 +389,7 @@ begin
end; end;
Count := Count + 1; Count := Count + 1;
end; end;
if AllRefsResolved = false then halt; if AllRefsResolved = false then halt (1);
//Set the end pointer and reset the byte pointer to the start of the program //Set the end pointer and reset the byte pointer to the start of the program
EP := BP; EP := BP;
@ -402,7 +402,7 @@ begin
{$i+} {$i+}
if IOResult <> 0 then begin if IOResult <> 0 then begin
writeln ('Error: program file cannot be written to'); writeln ('Error: program file cannot be written to');
halt; halt (1);
end; end;
repeat repeat
write (Prog, Bin [BP]); write (Prog, Bin [BP]);