abcscnuk@csunb.csun.edu (Naoto Kimura (ACM)) (10/11/90)
I know this sounds a bit perverse, but here are some of the include
files I created to allow one to compile some (but not all) code written
for version 4.0 of Turbo Pascal while still using version 3.0 !
The modification dates are quite recent because I spent some time
cleaning up some of the code and added some internal documentation.
There were some real boners in part of the code that I had to fix
to make sure that nothing really scewy happened in certain cases.
For those who are wondering why I would ever need or even want to do
such things. I needed to do this because I had some persons who wanted
to use some of the code I wrote for version 4.0, but didn't want to
spend the money upgrade their version 3.0... I also used a slightly
different version of this same code when I was transporting a 40000+
line program to version 4.0 and I wanted to make the transition as easy
as possible.
If there are enough requests, I shall be making quickie modifications
of this code to allow some compatibilty with version 5.0 and perhaps
even 5.5... (gee this guy must be REALLY bored!)
In a few days I am considering posting some of the BGI interface
routines and OOP extensions for version 3.0 of Turbo Pascal.
:-) :-) :-) :-) :-) :-) :-) :-) :-) :-) :-) :-) :-) :-) :-) :-) :-)
--- CUT HERE ------ CUT HERE ------ CUT HERE ------ CUT HERE ------ CUT HERE ---
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
# system.inc
# tp4_dos.inc
# This archive created: Thu Oct 11 04:10:17 1990
export PATH; PATH=/bin:$PATH
echo shar: extracting "'system.inc'" '(1931 characters)'
if test -f 'system.inc'
then
echo shar: will not over-write existing file "'system.inc'"
else
sed 's/^ X//' << \SHAR_EOF > 'system.inc'
X(*====================================================================*\
X|| MODULE NAME: System.INC ||
X|| ||
X|| DESCRIPTION: This file contains the declaration and routines that ||
X|| use long integers for Turbo 3.0x ||
X|| ||
X|| DEPENDENCIES: (none) ||
X|| ||
X|| LAST MOD ON: 07/02/90 ||
X\*====================================================================*)
Xtype
X _String = String[255];
X Pointer = ^byte;
X
Xconst
X X10000 = 65536.0; (* hex 10000 *)
X X8000 = 32768.0; (* hex 8000 *)
X
Xtype
X longint = record
X lo_part, hi_part : integer
X end;
X
Xprocedure mpy ( a,b : integer;
X var l : longint );
X var
X t0,t1 : integer;
X ll,ml,mh : integer;
X begin
X ll := lo(a)*lo(b);
X t0 := hi(a)*lo(b);
X t1 := hi(b)*lo(a);
X ml := hi(ll) + lo(t0) + lo(t1);
X mh := hi(t0) + hi(t1) + hi(ml);
X l.lo_part := lo(ll) + (lo(ml) shl 8);
X l.hi_part := hi(a)*hi(b) + mh
X end; (* mpy *)
X
Xfunction unsigned_val ( i : integer ) : real;
X begin
X unsigned_val := hi(i) * 256.0 + lo(i)
X end; (* unsigned_val *)
X
Xprocedure incr_long ( var l : longint );
X begin
X with l do begin
X lo_part := lo_part + 1;
X if lo_part = 0 then hi_part := hi_part + 1
X end;
X end; (* incr_long *)
X
Xfunction signed_long_val ( l : longint ) : real;
X begin
X signed_long_val := l.hi_part * X10000 + unsigned_val(l.lo_part);
X end;
X
Xfunction unsigned_long_val ( l : longint ) : real;
X begin
X unsigned_long_val := hi(l.hi_part) * X10000 * 256.0
X + lo(l.hi_part) * X10000
X + unsigned_val(l.lo_part);
X end; (* unsigned_long_val *)
X
SHAR_EOF
if test 1931 -ne "`wc -c < 'system.inc'`"
then
echo shar: error transmitting "'system.inc'" '(should have been 1931 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'tp4_dos.inc'" '(15174 characters)'
if test -f 'tp4_dos.inc'
then
echo shar: will not over-write existing file "'tp4_dos.inc'"
else
sed 's/^ X//' << \SHAR_EOF > 'tp4_dos.inc'
X(*====================================================================*\
X|| MODULE NAME: TP4_DOS.INC ||
X|| ||
X|| DESCRIPTION: This is a library of DOS service routines. ||
X|| Some things declared here are for compatibility with ||
X|| Turbo Pascal 4 (these are marked with the comment ||
X|| TP4). ||
X|| ||
X|| DEPENDENCIES: System.INC ||
X|| ||
X|| LAST MOD ON: 07/02/90 ||
X\*====================================================================*)
X
Xtype
X registers = record
X case integer of
X 1: (AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags : integer);
X 2: (AL,AH,BL,BH,CL,CH,DL,DH : byte)
X end;
X
Xconst
X FCarry = $0001;
X FParity = $0004;
X FAuxiliary = $0010;
X FZero = $0040;
X FSign = $0080;
X FOverflow = $0800;
X
Xconst (*TP4*)
X Archive = $20;
X Directory = $10;
X Volume = $08; (* These constants are declared *)
X SysFile = $04; (* in the Turbo Pascal 4.0 *)
X Hidden = $02; (* DOS unit file *)
X ReadOnly = $01; (* They describe file attributes *)
X AnyFile = $3F;
X
Xtype (*TP4*)
X ComStr = String[127]; (* Command line string *)
X PathStr = String[79]; (* Full file path string *)
X DirStr = String[67]; (* Drive and directory string *)
X NameStr = String[8]; (* File name string *)
X ExtStr = String[4]; (* File extension string *)
X
X SearchRec = record
X Fill : array [1..21] of byte;
X Attr : byte;
X Time : longint;
X Size : longint;
X Name : string[12]
X end;
X
X DateTime = record
X Year,
X Month,
X Day,
X Hour,
X Min,
X Sec : integer
X end;
X
Xvar (*TP4*)
X DOSError : integer;
X
X(*TP4*)
Xprocedure GetTime ( var Hour, Minute, Second, Sec100 : integer );
X begin
X Inline( $1E/ { push ds }
X $B4/$2C/ { mov ah,2ch }
X $CD/$21/ { int 21h }
X $33/$C0/ { xor ax,ax }
X $8A/$C5/ { mov al,ch }
X $C4/$7E/<Hour/ { les di,[Hour] }
X $26/$89/$05/ { mov [es:di],ax }
X $C4/$7E/<Minute/ { les di,[Minute] }
X $8A/$C1/ { mov al,cl }
X $26/$89/$05/ { mov [es:di],ax }
X $C4/$7E/<Second/ { les di,[Second] }
X $8A/$C6/ { mov al,dh }
X $26/$89/$05/ { mov [es:di],ax }
X $C4/$7E/<Sec100/ { les di,[Sec100] }
X $8A/$C2/ { mov al,dl }
X $26/$89/$05/ { mov [es:di],ax }
X $1F) { pop ds }
X end;
X
X(*TP4*)
Xprocedure GetDate ( var Year, Month, Day, DayofWeek : integer );
X begin
X Inline( $B4/$2A/ { mov ah,2ah }
X $CD/$21/ { int 21h }
X $32/$E4/ { xor ah,ah }
X $C4/$7E/<DayOfWeek/ { les di,[DayOfWeek]}
X $26/$89/$05/ { mov [es:di],ax }
X $C4/$7E/<Day/ { les di,[Day] }
X $8A/$C2/ { mov al,dl }
X $26/$89/$05/ { mov [es:di],ax }
X $C4/$7E/<Month/ { les di,[Month] }
X $8A/$C6/ { mov al,dh }
X $26/$89/$05/ { mov [es:di],ax }
X $C4/$7E/<Year/ { les di,[Year] }
X $26/$89/$0D) { mov [es:di],cx }
X end;
X
X(*TP4*)
Xprocedure DiskSize (
X Drive : integer;
X var result : longint );
X var
X TmpH,
X TmpL : Integer;
X begin
X Inline( $B4/$36/ { mov ah,36h }
X $8B/$56/<Drive/ { mov dx,[Drive] }
X $CD/$21/ { int 21h }
X $C4/$7E/<Result/{ les di,[Result] }
X $3D/$FFFF/ { cmp ax,0ffffh }
X $75/$06/ { jne @@NoErr }
X $33/$C0/ { xor ax,ax }
X $AB/ { stosw }
X $AB/ { stosw }
X $EB/$1B/ { jmp @@Done }
X { ; tmp = AX*DX }
X $F7/$E2/ {@@NoErr:mul dx }
X $89/$46/<TmpL/ { mov [TmpL],ax }
X $89/$56/<TmpH/ { mov [TmpH],dx }
X { ; result = tmp.lo*CX }
X $F7/$E1/ { mul cx }
X $26/$89/$05/ { mov [es:di],ax }
X $26/$89/$55/$02/{ mov [es:di+2],dx }
X $8B/$46/<TmpH/ { mov ax,[TmpH] }
X { ; dx,ax = tmp.hi*CX }
X $F7/$E1/ { mul cx }
X { ; result.hi += ax }
X $26/$01/$45/$02){ add [es:di+2],ax }
X end;
X
X(*TP4*)
Xprocedure DiskFree (
X Drive : integer;
X var result : longint );
X var
X TmpH,
X TmpL : Integer;
X begin
X Inline( $B4/$36/ { mov ah,36h }
X $8B/$56/<Drive/ { mov dx,[Drive] }
X $CD/$21/ { int 21h }
X $C4/$7E/<Result/{ les di,[Result] }
X $3D/$FFFF/ { cmp ax,0ffffh }
X $75/$06/ { jne @@NoErr }
X $33/$C0/ { xor ax,ax }
X $AB/ { stosw }
X $AB/ { stosw }
X $EB/$1B/ { jmp @@Done }
X { ; tmp = AX*DX }
X $F7/$E3/ {@@NoErr:mul bx }
X $89/$46/<TmpL/ { mov [TmpL],ax }
X $89/$56/<TmpH/ { mov [TmpH],dx }
X { ; result = tmp.lo*CX }
X $F7/$E1/ { mul cx }
X $26/$89/$05/ { mov [es:di],ax }
X $26/$89/$55/$02/{ mov [es:di+2],dx }
X $8B/$46/<TmpH/ { mov ax,[TmpH] }
X { ; dx,ax = tmp.hi*CX }
X $F7/$E1/ { mul cx }
X { ; result.hi += ax }
X $26/$01/$45/$02){ add [es:di+2],ax }
X end;
X
X(*TP4*)
Xprocedure UnpackTime (
X t : longint;
X var DT : DateTime );
X begin
X DT.Day := (t.hi_part and 511) and 31;
X DT.Month := (t.hi_part and 511) shr 5;
X DT.Year := (t.hi_part shr 9) + 1980;
X DT.Hour := (t.lo_part shr 11);
X DT.Min := (t.lo_part and 2047) shr 5;
X DT.Sec := (t.lo_part and 31) * 2
X end;
X
X(*TP4*)
Xprocedure PackTime (
X var DT : DateTime;
X var t : longint );
X begin
X t.hi_part := ((DT.Year-1980) shl 9) or (DT.Month shl 5)
X or (DT.Day);
X t.lo_part := (DT.Hour shl 11) or (DT.Min shl 6)
X or (DT.Sec div 2)
X end;
X
X(*TP4*)
Xprocedure FindFirst (
X s : _string;
X attr: byte;
X var srec: SearchRec );
X var
X OldOfs,
X OldSeg,
X DS_Save : Integer;
X begin
X inline( $33/$C0/ { xor ax,ax }
X $8C/$5E/<DS_Save/{ mov [DS_Save],ds }
X $B8/>$2F00/ { mov ax,2f00h }
X $CD/$21/ { int 21h }
X $8C/$46/<OldSeg/{ mov [OldSeg],es }
X $89/$5E/<OldOfs/{ mov [OldOfs],bx }
X $B8/>$1A00/ { mov ax,1a00h }
X $C5/$56/<Srec/ { lds dx,[SRec] }
X $CD/$21); { int 21h }
X { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.
X : Now we do the stuff we started out to do :
X : 1) Change the filename from a TP string into an ASCIIZ string:
X `- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
X inline( $8C/$D0/ { mov ax,ss }
X $8E/$D8/ { mov ds,ax }
X $8E/$C0/ { mov es,ax }
X $8D/$76/<S/ { lea si,[S] }
X $8B/$FE/ { mov di,si }
X $33/$C0/ { xor ax,ax }
X $FC/ { cld }
X $AC/ { lodsb }
X $8B/$C8/ { mov cx,ax }
X $F3/$A4/ { rep movsb }
X $26/$C6/$05/$00);{ mov [BYTE es:di],0 }
X { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.
X : 2) Send modified string to DOS's FindFirst function :
X `- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
X inline( $8D/$56/<S/ { lea dx,[S] }
X $B8/>$4E00/ { mov ax,4E00h }
X $8A/$4E/<Attr/ { mov cl,[Attr] }
X $CD/$21); { int 21h }
X { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.
X : 3) Set return code and adjust FName entry in the search :
X : record from ASCIIZ to TP string format if return code :
X : idicated no error. :
X `- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
X inline( $8E/$5E/<DS_Save/{ mov ds,[DS_Save] }
X $73/$05/ { jnc Ok }
X $A3/>DosError/ { mov [DosError],ax }
X $EB/$2C/ { jmp SHORT Continue }
X $C7/$06/ {Ok: }
X >DosError/
X >$0000/ { mov [DosError],0 }
X $C4/$5E/<SRec/ { les bx,[SRec] }
X $8D/$7F/$1E/ { lea di,[(SearchRec bx).FName] }
X $8C/$C0/ { mov ax,es }
X $8E/$D8/ { mov ds,ax }
X $BA/>$000C/ { mov dx,12 }
X $8B/$CA/ { mov cx,dx }
X $32/$C0/ { xor al,al }
X $F2/$AE/ { repne scasb }
X $74/$02/ { je Found }
X $47/ { inc di }
X $49/ { dec cx }
X {Found: }
X $41/ { inc cx }
X $2B/$D1/ { sub dx,cx }
X $8B/$CA/ { mov cx,dx }
X $8B/$C1/ { mov ax,cx }
X $4F/ { dec di }
X $8B/$F7/ { mov si,di }
X $4E/ { dec si }
X $FD/ { std }
X $F3/$A4/ { rep movsb }
X $AA); { stosb }
X {Continue: }
X { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.
X : Restore DTA address to what it was before we entered this :
X : routine. :
X `- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
X inline( $8E/$5E/<OldSeg/{ mov ds,[OldSeg] }
X $8B/$56/<OldOfs/{ mov dx,[OldOfs] }
X $B8/>$1A00/ { mov ax,1a00h }
X $CD/$21/ { int 21h }
X $8E/$5E/<DS_Save){ mov ds,[DS_Save] }
X end; (* FindFirst *)
X
X(*TP4*)
Xprocedure FindNext (var srec : SearchRec );
X var
X OldOfs,
X OldSeg,
X DS_Save : Integer;
X begin
X inline( $8C/$5E/<DS_Save/{ mov [DS_Save],ds }
X $B8/>$2F00/ { mov ax,2f00h }
X $CD/$21/ { int 21h }
X $8C/$46/<OldSeg/{ mov [OldSeg],es }
X $89/$5E/<OldOfs/{ mov [OldOfs],bx }
X $B8/>$1A00/ { mov ax,1a00h }
X $C5/$56/<Srec/ { lds dx,[SRec] }
X $CD/$21); { int 21h }
X { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.
X : Now we do the stuff we started out to do :
X : 1) Adjust the FName entry in the search record from Turbo :
X : pascal string format to ASCIIZ format. :
X `- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
X inline( $C5/$5E/<Srec/ { lds bx,[SRec] }
X $8D/$77/$1E/ { lea si,[(SearchRec bx).FName] }
X $8C/$D8/ { mov ax,ds }
X $8E/$C0/ { mov es,ax }
X $8B/$FE/ { mov di,si }
X $33/$C0/ { xor ax,ax }
X $FC/ { cld }
X $AC/ { lodsb }
X $8B/$C8/ { mov cx,ax }
X $F3/$A4/ { rep movsb }
X $26/$C6/$05/$00);{ mov [BYTE es:di],0 }
X { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.
X : 2) Pass the adjusted search record to DOS's FindNext system :
X : service (address was previously set in setting DTA) :
X `- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
X inline( $B8/>$4F00/ { mov ax,4f00h }
X $CD/$21); { int 21h }
X { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.
X : 3) Set return code and adjust FName entry in the search :
X : record from ASCIIZ to TP string format if return code :
X : idicated no error. :
X `- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
X inline( $8E/$5E/<DS_Save/{ mov ds,[DS_Save] }
X $73/$05/ { jnc Ok }
X $A3/>DosError/ { mov [DosError],ax }
X $EB/$2C/ { jmp SHORT Continue }
X $C7/$06/ {Ok: }
X >DosError/
X >$0000/ { mov [DosError],0 }
X $C4/$5E/<SRec/ { les bx,[SRec] }
X $8D/$7F/$1E/ { lea di,[(SearchRec bx).FName] }
X $8C/$C0/ { mov ax,es }
X $8E/$D8/ { mov ds,ax }
X $BA/>$000C/ { mov dx,12 }
X $8B/$CA/ { mov cx,dx }
X $32/$C0/ { xor al,al }
X $F2/$AE/ { repne scasb }
X $74/$02/ { je Found }
X $47/ { inc di }
X $49/ { dec cx }
X {Found: }
X $41/ { inc cx }
X $2B/$D1/ { sub dx,cx }
X $8B/$CA/ { mov cx,dx }
X $8B/$C1/ { mov ax,cx }
X $4F/ { dec di }
X $8B/$F7/ { mov si,di }
X $4E/ { dec si }
X $FD/ { std }
X $F3/$A4/ { rep movsb }
X $AA); { stosb }
X {Continue: }
X { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.
X : Restore DTA address to what it was before we entered this :
X : routine. :
X `- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
X inline( $8E/$5E/<OldSeg/{ mov ds,[OldSeg] }
X $8B/$56/<OldOfs/{ mov dx,[OldOfs] }
X $B8/>$1A00/ { mov ax,1a00h }
X $CD/$21/ { int 21h }
X $8E/$5E/<DS_Save){ mov ds,[DS_Save] }
X end; (* FindNext *)
X
X(*TP4*)
Xprocedure GetIntVec( IntNo:Byte; var Vector:Pointer );
X begin
X Inline( $1E/ { push ds }
X $B4/$35/ { mov ah,35h }
X $8A/$46/<IntNo/ { mov al,[IntNo] }
X $CD/$21/ { int 21h }
X $C5/$76/<Vector/ { lds si,[Vector] }
X $89/$1C/ { mov [si],bx }
X $8C/$44/$02/ { mov [si+2],es }
X $1F) { pop ds }
X end; (* GetIntVec *)
X
X(*TP4*)
Xprocedure SetIntVec( IntNo:Byte; var Vector:Pointer );
X begin
X Inline( $1E/ { push ds }
X $B4/$25/ { mov ah,25h }
X $8A/$46/<IntNo/ { mov al,[IntNo] }
X $C5/$56/<Vector/ { lds dx,[Vector] }
X $CD/$21/ { int 21h }
X $1F) { pop ds }
X end; (* GetIntVec *)
SHAR_EOF
if test 15174 -ne "`wc -c < 'tp4_dos.inc'`"
then
echo shar: error transmitting "'tp4_dos.inc'" '(should have been 15174 characters)'
fi
fi # end of overwriting check
# End of shell archive
exit 0
--- CUT HERE ------ CUT HERE ------ CUT HERE ------ CUT HERE ------ CUT HERE ---
//-n-\\ Naoto Kimura
_____---=======---_____ (abcscnuk@csuna.csun.edu)
====____\ /.. ..\ /____====
// ---\__O__/--- \\ Enterprise... Surrender or we'll
\_\ /_/ send back your *&^$% tribbles !!