Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!csun!news
From: abcscnuk@csunb.csun.edu (Naoto Kimura (ACM))
Newsgroups: comp.lang.pascal
Subject: Compiling TP 4.0 programs under TP 3.0 ?!?!?!
Keywords: code written by a really sick mind...
Message-ID: <1990Oct11.103806.14257@csun.edu>
Date: 11 Oct 90 10:38:06 GMT
Sender: news@csun.edu (News Administrator)
Organization: csun
Lines: 518
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/$2F00/ { mov ax,2f00h }
X $CD/$21/ { int 21h }
X $8C/$46/$1A00/ { mov ax,1a00h }
X $C5/$56/$4E00/ { mov ax,4E00h }
X $8A/$4E/DosError/ { mov [DosError],ax }
X $EB/$2C/ { jmp SHORT Continue }
X $C7/$06/ {Ok: }
X >DosError/
X >$0000/ { mov [DosError],0 }
X $C4/$5E/$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/$1A00/ { mov ax,1a00h }
X $CD/$21/ { int 21h }
X $8E/$5E/$2F00/ { mov ax,2f00h }
X $CD/$21/ { int 21h }
X $8C/$46/$1A00/ { mov ax,1a00h }
X $C5/$56/$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/DosError/ { mov [DosError],ax }
X $EB/$2C/ { jmp SHORT Continue }
X $C7/$06/ {Ok: }
X >DosError/
X >$0000/ { mov [DosError],0 }
X $C4/$5E/$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/$1A00/ { mov ax,1a00h }
X $CD/$21/ { int 21h }
X $8E/$5E/