$title('MP/M II V2.0 Stop Spooler Program')
stopsplr:
do;

$include (copyrt.lit)
/*
  Revised:
    14 Sept 81  by Thomas Rolander
*/

/*
    Common Literals
*/

  declare true literally '0FFFFH';
  declare false literally '0';
  declare forever literally 'while true';
  declare boolean literally 'byte';

  declare start label;
  declare jmp$to$start structure (
    jmp$instr byte,
    jmp$location address ) data (
    0c3h,
    .start-3);

  declare fcb (1) byte external;
  mon1:
    procedure (func,info) external;
      declare func byte;
      declare info address;
    end mon1;

  mon2:
    procedure (func,info) byte external;
      declare func byte;
      declare info address;
    end mon2;

  print$console$buffer:
    procedure (buff$adr);
      declare buff$adr address;
      call mon1 (9,buff$adr);
    end print$console$buffer;

  system$reset:
    procedure;
      call mon1 (0,0);
    end system$reset;

  console$number:
    procedure byte;
      return mon2 (153,0);
    end console$number;

  abort$process:
    procedure (abort$pb$adr) byte;
      declare abort$pb$adr address;
      return mon2 (157,abort$pb$adr);
    end abort$process;

  declare abort$param$block structure (
    pdadr address,
    param address,
    pname (8) byte,
    console byte ) initial (
    0,00ffh,'SPOOL   ',0);

  declare last$dseg$byte byte
    initial (0);


/*
  stopsplr:
*/

start:

  if fcb(1) = ' ' then
  do;
    abort$param$block.console = console$number;
  end;
  else
  do;
    if (fcb(1):=fcb(1)-'0') > 9 then
    do;
      fcb(1) = fcb(1) + '0' - 'A' + 10;
    end;
    abort$param$block.console = fcb(1);
  end;
  if abort$process (.abort$param$block) = 0 then
  do;
    do while abort$process (.abort$param$block) = 0;
      ;
    end;
    call print$console$buffer (.(
           'Spooler aborted','$'));
  end;
  else
  do;
    call print$console$buffer (.(
           'Spooler not running','$'));
  end;
  call system$reset;

end stopsplr;
