home *** CD-ROM | disk | FTP | other *** search
- -- An exact copy of this module appears in both the Pascal and C libraries.
- {*********************************************************************
- (C) Copyright 1983-1992 MetaWare Incorporated; Santa Cruz, CA 95060.
- *********************************************************************}
-
- Export(System,MSDOS,Fileh_type);
- pragma include('STATUS.pf');
- pragma include('SYSTEM.pf');
- pragma include('MSDOS.pf');
- pragma fragmented_implementation(System);
- pragma fragmented_implementation(MSDOS);
- with Status;
-
- program Implement_DOS_interface;
- pragma Alias(Implement_DOS_interface,Implement.RTE || 'dos_interface1');
-
-
- with Registers;
- with Loopholes:[Address,Adr,Retype,&];
- { Interface with the dos calls.
- For each MS DOS call, certain registers must be set, and certain
- registers retrieved. Here we "set" these registers by storing into
- a data area common with an assembly language routine that picks up
- the data and places it into the registers. After the call to the DOS,
- the assembly language routine places the value of the registers back
- into the data area. Thus the precise contents of the registers,
- as required by the DOS calls, is implemented in this module;
- the chore of calling DOS is placed upon a single assembly routine.
- }
-
- procedure DOS(I:Byte);
- begin
- Ax.h := I; { Load the function byte. }
- CALLDOS;
- { Carry set (error occurred)? }
- if Odd(Flags) then begin
- Errno := Ax.R %Retype Error_type;
- AX.R := 0; CX.R := 0; DX.R := 0;
- { Guard against user forgetting to inspect errno. }
- end
- -- When compiling with the proper "implemen.pf", PPLIB is true.
- #if PPLIB
- else Errno := No_error_occurred;
- #endif
- end;
-
- procedure Load_ptr(var Rs,Rd: register; A:Address);
- var R: record case boolean of true:(Rd,Rs:register);
- false:(A:Address); end;
- { Pointers are: <displacement> <segment> }
- with Loopholes:[Address,Longptr,Adr];
- var L:Longptr(Integer);
- type Seg_offset = record Off:Implement.Byte_count; Seg: Cardinal; end;
- begin
- -- We can't use retypes here because we'd have to include
- -- both small and large data cases, and the compiler would
- -- complain about one or the other being of the wrong size.
- R.A := A;
- if Loopholes.Sizeof(A) < Loopholes.Sizeof(L) then begin
- -- Small data model. DS is always the segment.
- -- Address something in the static area to get DS put into L.
- L := Adr(AX) %Retype Typeof(L);
- Rs.R := (L %Retype Seg_offset).Seg;
- -- Rs.R := GETDS(); -- old code. We can get DS from longptr now.
- end
- else Rs := R.Rs;
- Rd := R.Rd;
- end;
-
- procedure Load_DS_DX(A:Address);
- begin Load_ptr(DS,DX,A);
- end;
-
- procedure Close(F: File_handle);
- begin
- BX.R := F; DOS(62);
- end;
-
- (* -- Never used; removed.
- function CurrentDir(WhichDrive:integer):CurrentDirString;
- var S:^integer; I,Len:integer;
- begin
- DX.L := WhichDrive;
- Load_ptr(DS,SI,Adr(CurrentDir[1]));
- DOS(71);
- S := Retype(Adr(CurrentDir),Typeof(S));
- { Get rid of [1] and -2 when compiler is fixed. }
- Len := 64;
- if Errno <> 0 then
- for I := 1 to 64 do if CurrentDir[I] = chr(0) then begin
- Len := I-1; exit;
- end;
- S^ := Len;
- end;
- *)
-
- -- (C) Copyright 1983,84,85 MetaWare Incorporated; Santa Cruz, CA 95060.
-
-