Category : Modula II Source Code
Archive   : MODULA-2.ZIP
Filename : EXEC.MOD

 
Output of file : EXEC.MOD contained in archive : MODULA-2.ZIP
IMPLEMENTATION MODULE Exec;

(**********************************************************)
(* ROLLINS MEDICAL/DENTAL SYSTEMS *)
(* 360 CLAUSEN BUILDING *)
(* 23100 PROVIDENCE DRIVE *)
(* SOUTHFIELD, MI 48075-3677 *)
(* *)
(* Module: EXEC.MOD *)
(* *)
(* ------------------------------------------------- *)
(* | | *)
(* | Call Dos Programs From Modula-2 Application. | *)
(* | | *)
(* ------------------------------------------------- *)
(* *)
(* Version: 01.00 a Last Edit: 04/02/1986 *)
(* *)
(* Programmer: J. Tal *)
(* *)
(**********************************************************)




FROM SYSTEM IMPORT AX,BX,CX,DX,ES,SETREG,GETREG,CODE,SWI,WORD,BYTE,ADR,
ADDRESS,DOSCALL;
FROM DOS3 IMPORT GetProgramSegmentPrefix;
FROM Strings IMPORT Concat,Copy,Length;


PROCEDURE Shell( COMMAND : ARRAY OF CHAR; VAR Error : CARDINAL);
VAR
pspPTR,memTopPTR : POINTER TO CARDINAL;
pspPTR2 : POINTER TO ARRAY[0..64] OF CHAR;
Comaddr,pspadr,psp2adr,ComspecAdr,memTOPadr : ADDRESS;
paramblock : ARRAY[0..6] OF WORD;
Command : ARRAY[0..128] OF CHAR;
Comspec : ARRAY[0..32] OF CHAR;
PSPsegment,error,fctval,newBlockSize : WORD;
psp,z,i,memTOP,memBOT,memAvail,newMemSize : CARDINAL;
cr : CHAR;
BEGIN
fctval := WORD(0);
cr := CHR(13);


(* --- prep Command Line for Param block --- *)


Command := '/C ';
Concat(Command,COMMAND,Command);
z := Length(Command);

Concat(Command,cr,Command); (* append 0DH on end *)

FOR i := (z+1) TO 1 BY -1 DO (* shift string from end *)
Command[i] := Command[i-1];
END;

Command[0] := CHR(z); (* first byte must be length *)
Command[z+2] := CHR(0);

Comaddr := ADR(Command);


(* ---------------- get PSP --------------- *)

GetProgramSegmentPrefix(PSPsegment);
psp := CARDINAL(PSPsegment);

pspadr.SEGMENT := psp;
pspadr.OFFSET := 02CH;


(* ---- calc total memory used right now by Modula-2 ------ *)

memBOT := psp;

memTOPadr.SEGMENT := psp; (* PSP:02H points to memtop *)
memTOPadr.OFFSET := 02H;

memTopPTR := memTOPadr;

memTOP := memTopPTR^;

memAvail := memTOP - memBOT;

newMemSize := memAvail - 1000H; (* snatch 64K away from application *)


(* ---------- Go get COMSPEC = ------------- *)


pspPTR := pspadr; (* points to PSP + 2CH *)

psp2adr.SEGMENT := pspPTR^;
psp2adr.OFFSET := 0;

pspPTR2 := psp2adr; (* points to COMSPEC = *)



(* ------- copy comspec to local area ------ *)


Copy(pspPTR2^,8,24,Comspec);
ComspecAdr := ADR(Comspec);


(* ------- setup paramater block ----------- *)


paramblock[0] := WORD(psp2adr.SEGMENT); (* environment string *)
paramblock[1] := WORD(Comaddr.OFFSET); (* command line *)
paramblock[2] := WORD(Comaddr.SEGMENT); (* command line *)
paramblock[3] := WORD(05CH); (* PSP defaults *)
paramblock[4] := WORD(PSPsegment); (* " *)
paramblock[5] := WORD(06CH); (* " *)
paramblock[6] := WORD(PSPsegment); (* " *)



(* --- Shrink memory by 64K to allow second Command.com --- *)

newBlockSize := WORD(newMemSize);
DOSCALL(4AH,pspadr,newBlockSize,error);


(* ----------- if ok then EXEC ------------- *)

Error := CARDINAL(error);
IF Error = 0 THEN
DOSCALL(4BH,ComspecAdr,ADR(paramblock),fctval,error); (* EXEC - 4BH *)
Error := CARDINAL(error);

(* -- Restore memory (block) to original size -- *)

newBlockSize := WORD(memAvail);
DOSCALL(4AH,pspadr,newBlockSize,error);
END;


END Shell;

END Exec.


  3 Responses to “Category : Modula II Source Code
Archive   : MODULA-2.ZIP
Filename : EXEC.MOD

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/