[net.micro.cpm] Turbo Pascal Version 3.00

smd@umcp-cs.UUCP (Stanley Dunn) (11/19/85)

Replace this line with your compiler bug

I sat down to write the program for the next project I am going
to give to my Computer Science I class at home on my CPM system
with Turbo Pascal Version 3.00.  The following program illustrates
the problem with the program I wrote:

program junk(input,output);
procedure proca(chita:char); forward;
procedure procb(chitb:char);
begin
     writeln('Entering procb with a ',chitb);
     proca('A');
     writeln('Leaving procb with a ',chitb);
end;
procedure proca;
begin
     writeln('Entering proca with a ',chita);
     if chita = 'I' then procb('I');
     writeln('Leaving proca with a ',chita);
end;
begin
     proca('I');
end.

The output using Turbo Pascal was:

     Entering proca with a I
     Entering procb with a I
     Entering proca with a A
     Leaving proca with a A
     Leaving procb with a I
     Leaving proca with a A

While the output for the same program on a VAX with BSD UNIX,
IBM VM/SP CMS, or a Macintosh with MacPascal was:

     Entering proca with a I
     Entering procb with a I
     Entering proca with a A
     Leaving proca with a A
     Leaving procb with a I
     Leaving proca with a I

as I expected.  Calling Borland Technical Support was no help,
as they wanted a copy of the program on an IBM format disk.
The technical support specialist asked me to send a copy of the
program on a disk.  When I asked "in what format?" she replied
"IBM, of course."  I guess CPM does not exist anymore.

Obviously, I was quite surprised at the output, and now I
wonder how they tested the compiler.  It seems that a program
as simple as the one above should have been tested.

-- Stanley Dunn
   University of Maryland Department of Computer Science

Reno.wbst@XEROX.ARPA (Jim Reno) (11/20/85)

It is possible that when the technical support person for Borland
answered your question the format referred to was the IBM format of
sector information that underlies the CPM operating system format on CPM
disks. In other words sectors are formatted in IBM format. The content
and length of the sectors are defined by CPM.

Reno

SMERESKI.WBST@XEROX.ARPA (11/20/85)

You have written a program with recursive calls.  Turbo Pascal for CP/M does
not generate recursive code in its default mode.  You will get the expected
result by including the compiler directive {$A-}.  This information is in the
manual.

/Dave

------------------------------------------------------------------------------
I sat down to write the program for the next project I am going
to give to my Computer Science I class at home on my CPM system
with Turbo Pascal Version 3.00.  The following program illustrates
the problem with the program I wrote:

program junk(input,output);
procedure proca(chita:char); forward;
procedure procb(chitb:char);
begin
     writeln('Entering procb with a ',chitb);
     proca('A');
     writeln('Leaving procb with a ',chitb);
end;
procedure proca;
begin
     writeln('Entering proca with a ',chita);
     if chita = 'I' then procb('I');
     writeln('Leaving proca with a ',chita);
end;
begin
     proca('I');
end.

The output using Turbo Pascal was:

     Entering proca with a I
     Entering procb with a I
     Entering proca with a A
     Leaving proca with a A

     Leaving procb with a I
     Leaving proca with a A

While the output for the same program on a VAX with BSD UNIX,
IBM VM/SP CMS, or a Macintosh with MacPascal was:

     Entering proca with a I
     Entering procb with a I
     Entering proca with a A
     Leaving proca with a A
     Leaving procb with a I
     Leaving proca with a I

as I expected.  Calling Borland Technical Support was no help,
as they wanted a copy of the program on an IBM format disk.
The technical support specialist asked me to send a copy of the
program on a disk.  When I asked "in what format?" she replied
"IBM, of course."  I guess CPM does not exist anymore.

Obviously, I was quite surprised at the output, and now I
wonder how they tested the compiler.  It seems that a program
as simple as the one above should have been tested.

-- Stanley Dunn
   University of Maryland Department of Computer Science

moews_b@h-sc1.UUCP (david moews) (11/20/85)

In article <2258@umcp-cs.UUCP> Stanley Dunn writes:

> procedure proca(chita:char); forward;
> procedure procb(chitb:char);
> begin
>      writeln('Entering procb with a ',chitb);
>      proca('A');
>      writeln('Leaving procb with a ',chitb);
> end;
> procedure proca;
> begin
>      writeln('Entering proca with a ',chita);
>      if chita = 'I' then procb('I');
>      writeln('Leaving proca with a ',chita);
> end;
> begin
>      proca('I');
> end.
> The output using Turbo Pascal [under CP/M-80] was:
>      Entering proca with a I
>      Entering procb with a I
>      Entering proca with a A
>      Leaving proca with a A
>      Leaving procb with a I
>      Leaving proca with a A
 
   I don't know about Release 3.00, but in Release 2.00 of Turbo Pascal
running under CP/M-80, you must compile recursive procedures and functions
with the {$A-} option for them to work.  Putting a {$A-} line before
the line 'procedure proca(chita:char); forward;' will probably fix this 
problem.   

    David Moews     moews_b%h-sc1@harvard.arpa   ...!harvard!h-sc1!moews_b

db21@ihuxk.UUCP (Dave Beyerl) (11/21/85)

> Replace this line with your compiler bug
> 
> I sat down to write the program for the next project I am going
> to give to my Computer Science I class at home on my CPM system
> with Turbo Pascal Version 3.00.  The following program illustrates
> the problem with the program I wrote:
> 
> program junk(input,output);
> procedure proca(chita:char); forward;
> procedure procb(chitb:char);
> begin
>      writeln('Entering procb with a ',chitb);
>      proca('A');
>      writeln('Leaving procb with a ',chitb);
> end;
> procedure proca;
> begin
>      writeln('Entering proca with a ',chita);
>      if chita = 'I' then procb('I');
>      writeln('Leaving proca with a ',chita);
> end;
> begin
>      proca('I');
> end.
> 
> The output using Turbo Pascal was:
> 
>      Entering proca with a I
>      Entering procb with a I
>      Entering proca with a A
>      Leaving proca with a A
>      Leaving procb with a I
>      Leaving proca with a A
> 
> While the output for the same program on a VAX with BSD UNIX,
> IBM VM/SP CMS, or a Macintosh with MacPascal was:
> 
>      Entering proca with a I
>      Entering procb with a I
>      Entering proca with a A
>      Leaving proca with a A
>      Leaving procb with a I
>      Leaving proca with a I
> 
> as I expected.  Calling Borland Technical Support was no help,
> as they wanted a copy of the program on an IBM format disk.
> The technical support specialist asked me to send a copy of the
> program on a disk.  When I asked "in what format?" she replied
> "IBM, of course."  I guess CPM does not exist anymore.
> 
> Obviously, I was quite surprised at the output, and now I
> wonder how they tested the compiler.  It seems that a program
> as simple as the one above should have been tested.
> 
> -- Stanley Dunn
>    University of Maryland Department of Computer Science

	Because I happened to have a copy of my Turbo Pascal
compiler handy, I tried the above program in Turbo.  When I ran
the program, I received the second set of outputs given in the
above article.  The version of Turbo that I have is identified
as ver. 3.01A for the IBM.  Apparently, Borland either corrected
this problem in the subsequent point (.01) release or there is 
a significant difference between the CP/M and IBM versions of 
Turbo.  Hopes this helps in tracking down the problem.

For every problem there is one           	Dave Beyerl
solution which is simple, neat,                 ihuxk!db21
and wrong!

knovak@uiucme.uiucme (11/21/85)

 The problem is simple!! Turbo does not default to
recusion on. They do this to gain some speed. To
turn on recusion use the directive

 {$A-}

 Turbo is just doing what you told it to do.

                        Kevin J. Novak
             

johnson@noscvax.UUCP (Timothy A. Johnson) (11/23/85)

> Replace this line with your compiler bug
> 
> I sat down to write the program for the next project I am going
> to give to my Computer Science I class at home on my CPM system
> with Turbo Pascal Version 3.00.  The following program illustrates
> the problem with the program I wrote:
> 
> program junk(input,output);
> procedure proca(chita:char); forward;
> procedure procb(chitb:char);
> begin
>      writeln('Entering procb with a ',chitb);
>      proca('A');
>      writeln('Leaving procb with a ',chitb);
> end;
> procedure proca;
> begin
>      writeln('Entering proca with a ',chita);
>      if chita = 'I' then procb('I');
>      writeln('Leaving proca with a ',chita);
> end;
> begin
>      proca('I');
> end.
> 
> The output using Turbo Pascal was:
> 
>      Entering proca with a I
>      Entering procb with a I
>      Entering proca with a A
>      Leaving proca with a A
>      Leaving procb with a I
>      Leaving proca with a A
> 
> While the output for the same program on a VAX with BSD UNIX,
> IBM VM/SP CMS, or a Macintosh with MacPascal was:
> 
>      Entering proca with a I
>      Entering procb with a I
>      Entering proca with a A
>      Leaving proca with a A
>      Leaving procb with a I
>      Leaving proca with a I
> 
> as I expected.  Calling Borland Technical Support was no help,
> as they wanted a copy of the program on an IBM format disk.
> The technical support specialist asked me to send a copy of the
> program on a disk.  When I asked "in what format?" she replied
> "IBM, of course."  I guess CPM does not exist anymore.
> 
> Obviously, I was quite surprised at the output, and now I
> wonder how they tested the compiler.  It seems that a program
> as simple as the one above should have been tested.
> 
> -- Stanley Dunn
>    University of Maryland Department of Computer Science

Under the PC-DOS version of Turbo 3.0, the program runs correctly with
the same output as you have given for the other Pascals. The problem
may be associated with the CP/M-80 Compiler Directive "A". The default
is "A+" which inhibits recursive code. Switching to "A-" may solve your
problem. This is documented on or about page 318 in the 3.0 manual.

Timothy A. Johnson
Computer Sciences Corporation