A coder named Sergio (University of Madrid) wrote a patch / modified the
compiler and I can now run all of my Borland Turbo Pascal v.7 programs under
Windows XP Professional. He also wrote a Unit for printing; it also prints the
screen (*.bmp / *.jpg). Hope this helps ... Regards, George
----- Original Message ----
From: Nicky <rnmclean@...>
To: turbopascalprogramming2@yahoogroups.com
Sent: Sunday, 7 January, 2007 11:43:27 AM
Subject: [TurboPascalProgramming] Keeping Pascal alive...
I still use Turbo Pascal, as when some data is to be assaulted in a way too
tedious or tricky or risky for a text editor session (even if it has its own
scripting language, usually weird) and so worthy of a simple special-purpose
programme. I still find use for a file comparison prog. supplied by Byte
Magazine in 1988 (M.J. Mefford) and the old List prog. since both really do show
what is in the file. Many modern progs. are ambiguous over tabs, spaces,
trailing spaces, etc.
I use TP7b, the "b" because I have made the patch offered via some web sites
that adjusts the calibration of TP's "delay" feature to succeed without a divide
by zero (which happens on any cpu faster than about 250MHz), though it doesn't
deal very well with long file names. I have found a Free Pascal from Berczi
Gabor, Pierre Muller and Peter Vreman, and a Virtual Pascal via vpascal.com,
which offer much the same interface as TP7 but alas haven't had much time to
investigate the opportunities. The FreePascal does handle long file names, so
that's one problem solved, however the code file for small progs. is about five
times the size of that from TP7! It also handles the waiting for a keystroke
better: tp7 seems to generate a loop continuously testing for a keypress,
consuming cpu time that I'd rather went to the Climate Prediction cruncher, etc.
The main problem is that my more interesting progs. in Pascal all involve
graphics, and the .bgi interface has long since been left behind by more recent
screen sizes and the notion of windows within the screen not controlled by the
Pascal prog. Re-jiggering them to work in Delphi would require some time, nor
have I found the time to mess with whatever is offered by FreePascal and
VirtualPascal.
I started with TP3, following a colleague who used it more extensively. The
first prog. was to adjust a file so that the sequence 0<FormFeed> became
<CR><LF> because a Landis&Gyr data logger terminated records with a form feed
character (one record, if printed, would consume most of a page), but the DOS
system of course uses <CR><LF> to mark the end of a record. Since before the
FormFeed was a field that was always zero, one digit could be sacrificed and the
file zapped without the tedium of copy, delete, rename. So much for work. Our
next prog. was a collaboration on the notorious Mandelbrot crunch. That was when
340 dots to a line was regarded as high resolution. Even with a most cunningly
coded assembler sequence for the Mandelbrot crunch loop, images often took hours
to compute. Hi ho.
Regards,
Nicky.
{=========== ========= ======Mandelbrot calculation= ========= ========= ======}
{$IFOPT N+}
{C:\ASM\ITERATE4. OBJ used to be the source, separately prepared for TP4...}
{Function Iterate(four, cx,cy:real; Maxit: integer):integer; external;
{Careful! TP4 passes fp parameters to functions on the 8087's stack,
and yes, this causes failure when you try for many parameters, or
exuberantly nested expressions. The assembler programme expects the
TP4 style, and will fail if TP5's protocol is used instead.}
Function Iterate(fcx, fcy: extended; Maxit: Integer): Integer; assembler;
Label crunch,test, out;
asm {With TP7, the in-line assembler is easier to use...}
{The TP7 assembler doesn't seem to accept STn for floating-point ops..}
{Watch out!!! DW here doesn't accept 0xD0C1, and I must put $0C1D0....}
{At least I can be sure that no FWAIT ops are interpolated for me.}
{Oh for a FMANDEL operation, or the ability to load a sequence into
the fp. processor.}
{ This routine was a rewrite in the absence of the source for ITERATE4.ASM
and the loop contains 13 f-ops, rather than ITERATE4's 15 f-ops....
But a FMANDEL op code would still be better.}
MOV AX,Maxit {Limit is 32766, not 32767, to allow Maxit + 1.}
MOV CX,AX {Iteration count, down to zero.}
FINIT {TP3 sent FP params via FPStk: 0 1 2 3 4 5 6 7}
FLD Four {But TP7 doesn't 4}
FLD fcx {So grab. cx, 4}
FLD fcy {And go. cy, cx, 4}
DW $0C1D9 {FLD ST1 ; cx=zx, cy, cx, 4}
DW $0C1D9 {FLD ST1 ; cy=zy, zx, cy, cx, 4}
{Consider the initial value, Z = C, or (zx,zy) = (cx,cy) for |Z| > 2.}
DW $0C0D9 {FLD ST0 ; zy, zy, zx, cy, cx, 4}
DW $0C8D8 {FMUL ST0,ST0 ; zy2, zy, zx, cy, cx, 4}
DW $0C2D9 {FLD ST2 ; zx,zy2, zy, zx, cy, cx, 4}
DW $0C8D8 {FMUL ST0,ST0 ; zx2,zy2, zy, zx, cy, cx, 4}
DW $0C0D9 {FLD ST0 ; zx2,zx2,zy2, zy, zx, cy, cx, 4}
DW $0C2D8 {FADD ST0,ST2 ;zx2+zy2,zx2, zy2, zy, zx, cy, cx, 4}
DW $0F7DF {FCOMIP ST0,ST7 ;-4? zx2,zy2, zy, zx, cy, cx, 4}
JA Out {J if ST0 > ST7. |C| > 4 to start with? 0 iterations.}
INC AX {Hence attain 1:Maxit + 1, rather than 0:Maxit.}
Crunch: {Arrive here with; zx2,zy2, zy, zx, cy, cx, 4}
DW $0E1DE {FSUBP?R?ST0, ST1 ;zx2-zy2, zy, zx, cy, cx, 4: I want ST0:=ST0 - ST1}
DW $0C4D8 {FADD ST0,ST4 ; +cx=ZX, zy, zx, cy, cx, 4: The new ZX computed.}
DW $0CAD9 {FXCH ST0,ST2 ; zx, zy, ZX, cy, cx, 4: Swap with the old, zx.}
DW $0C9DE {FMULP ST0,ST1 ; zx*zy, ZX, cy, cx, 4: Using the old zx again}
DW $0C0D8 {FADD ST0,ST0 ;2*zx*zy, ZX, cy, cx, 4: For the new ZY}
DW $0C2D8 {FADD ST0,ST2 ; +cy=ZY, ZX, cy, cx, 4: New Z to test, as above.}
Test:DW $0C0D9 {FLD ST0 ;zy2:=zy, zy, zx, cy, cx, 4: Get zy.}
DW $0C8D8 {FMUL ST0,ST0 ; zy2, zy, zx, cy, cx, 4: Square it.}
DW $0C2D9 {FLD ST2 ;zx2:=zx,zy2, zy, zx, cy, cx, 4: Get zx.}
DW $0C8D8 {FMUL ST0,ST0 ; zx2,zy2, zy, zx, cy, cx, 4: Square it.}
DW $0C0D9 {FLD ST0 ; zx2,zx2,zy2, zy, zx, cy, cx, 4: Duplicate.}
DW $0C2D8 {FADD ST0,ST2 ;zx2+zy2,zx2, zy2, zy, zx, cy, cx, 4: Add zy2.}
DW $0F7DF {FCOMIP ST0,ST7 ;-4? zx2,zy2, zy, zx, cy, cx, 4: Compare with 4.}
JA Out {J if ST0 > ST7. JG fails, the sign flag is not set.}
LOOP Crunch {Decrement CX, if not zero then go to Crunch.}
Out:SUB AX,CX {Maxit - (Maxit - n) = n, like.}
FINIT {Clear the deck.}
End; {of Iterate: the Integer function result is in AX}
{$ENDIF}
{$IFOPT N-}
{ Test runs show a factor of ten to twelve speedup in calculation when
the fp-hardware is available and is exercised by the assembler version.
Further, the precision of calculation is much better; even with 'only'
sixty iterations as the limit, there are differences in the results
for the base picture (from -2 to +2). Using software-calculated higher
precision variables would be slower still, so there is not much point
in chasing around high iteration areas...
That applied with TP3, a separate assembler, and 286 machines.
With TP7 and the above assembler on a pentium II mishmash the assembler
version runs about two and a half times faster on the same 'Home' calc.
with EGAVGA and 64 as the iteration limit. There was no apparent change
when an earlier version of the loop with 16 f-ops was used instead of the
13 above. Who knows what sort of compound op was being concocted by the
CPU's internal trickery. The TP3 assembler version had its timing quirks
also, related especially to its version of the FCOMIP f-op, not available
then despite the obvious need. Ah, but separate chips...
I have not tried the 8087-in-software emulation opportunity for a more
accurate comparison of software vs. f-op that would compare calculations
of the same precision.
Subsequent tests, enabled when 1024x768 dots and 256 colours could be
used had Boydel complete the "home" picture in 5·63 minutes (iteration limit
now 1,016 with the greater number of colours) vs. Mandel at 27·68 secs,
a factor of 12·2. This would have spent more time crunching rather than
spending time placing the dots since a lot more time would have been spent
on the high-iteration black centre. So, the merit of assembler remains high.}
Function Iterate(cx,cy: real; MaxIt: integer): integer;
var zx,zy,zx2,zy2: real; n:integer;
{ C = (cx,cy)
Z 0 to start with.
Repeat
Z Zý + C, with complex numbers.
until |Z| > 2}
Label l;
Begin
n:=0;
zx:=cx; zy:=cy; {Since Z is zero to start.}
zx2:=zx*zx; zy2:=zy*zy; {Repeated code, so as not to worry the compiler.}
if zx2 + zy2 <= 4 then {Otherwise, a Goto the zx2:= below.}
begin
l:n:=n + 1;
if n > Maxit then begin Iterate:=maxit + 1; Exit; end;
zy:=2*zx*zy + cy; {The }
zx:=zx2 - zy2 + cx; { crunch.}
zx2:=zx*zx; {Then}
zy2:=zy*zy; { test.}
if zx2 + zy2 <= 4 then goto l;
end;
Iterate:=n;
{So n = 0 if |C| > 2 (ie, no iterations are required to exceed 2)
= 1:limit
= limit + 1 if |Z| <= 2 even after iterating to the limit.
Note that (-2,0) iterates forever, thus the > 4 rather than >= 4...}
End; {Of Iterate}
{$ENDIF}
--- In turbopascalprogramm ing2@yahoogroups .com, "Anil M. S." <anilms@...>
wrote:
>
> :) I started off with TP 1 for DOS 1 back in 1985. I have used every version
of Turbo Pascal and later on switched over to Delphi. Turbo Delphi is free and
is equally good. I still use old style file handling functions in Delphi (Object
Pascal).
>
> BTW, my favorite is TP 3.x - all versions. I still have TP 3.x on my computer
and I use it to teach my daughter Pascal programming.
>
> You can also check out Morfik (www.morfik. com). They have a Web Development
environment, AJAX and all. There is a free personal version which most TP and
Delphi guys love as it uses Delphi's Object Pascal.
>
> One of my favorite TP tricks was in date validation. I would just store the
system date, then push in user entered date into a few registers and call an
interrupt function. If it was successful, you knew the date was valid. If it
returned an error in one of the registers, you could display an Invalid date
message. Finally, you would set the system date back.
>
> I am soon starting a project where we have to move TP code on DOS to Delphi. I
know I will enjoy working on that project.
>
> It makes me feel happy that there are still old timers out there who love TP.
>
> Long Live TP
>
Send instant messages to your online friends http://uk.messenger.yahoo.com
[Non-text portions of this message have been removed]