Groups | Search | Server Info | Login | Register


Groups > alt.sys.pdp10 > #9924

TOPS Pascal questions

From jayjwa <jayjwa@atr2.ath.cx.invalid>
Newsgroups alt.sys.pdp10
Subject TOPS Pascal questions
Date 2026-03-27 22:39 -0400
Organization atr2net 2026
Message-ID <87341kbrt8.fsf@atr2.ath.cx> (permalink)

Show all headers | View raw


I kind of forgot about Pascal, but then I remembered there is Pascal on
TOPS. Working with it, I have a couple of questions.

1. Looking at doc:pascal.doc on TOPS-20 Panda, I see:
 4.0  COMPILER OPTIONS
 Compiler options are selected by placing carefully formatted
 comments in the source program.  The format is,
     %$f+,f-,f-,f+ ANY FURTHER COMMENT\

Yet my program doesn't seem to use the flags and no addition files are
produced on compilation.

@type expon.pas
%$L+,O+ Compiler options for Listing and Assembly output\
(* Demo exponents on TOPS-20 Pascal *)
program expon( OUTPUT );

var
        num1, num2 : integer;

begin
        num1 := 3;
        num2 := 5;
        (* Square both numbers. Both '**' and sqr() should work
         * as per TOPS-20 Pascal Primer and Pascal Language
         * Manual Ver 1 Sep 83
         *)
        { num1 := num1**2; This one will not compile }
        num2 := sqr( num2 );
        writeln( 'The numbers are', num1:2, ' and ', num2:2 );
end.

@compile expon.pas
@exec expon
LINK:   Loading
[LNKXCT EXPON execution]
OUTPUT     : 
The numbers are 3 and 25

How to give compiler options for listing and assembly output, etc? The
pascal compiler is very disagreeable, not even allowing "/exit".

@pascal
PASCAL>bskara.pas
No error detected

Highseg:   2P
Lowseg :   1P
Runtime:   0: 0. 16
PASCAL>/exit
? Does not match switch or keyword - exit
PASCAL>exit
? File not found - 
PASCAL>^C


2. Staying with the above example, x**y is not "x to the y power" as the
docs say it should be. Why? Is there a way to do this without writing my
own function (basically pow() in C)?

@compile expon.pas
PASCAL: EXPON 
   16           num1 := num1**2; {This one will not compile }
P*  1**                      ^                               
1.^:  Error in factor
?error detected

I wanted it for the below, but instead I can just use sqr(). 

Surprisingly, to me at least, TOPS-10 will run the same program, as long
as I pre-load the input. I think I saw a way to make it work without
pre-loading the data input; I'll check the docs again tomorrow.

.compile bskara.pas                                       
PASCAL: BSKARA

.exec bskara
LINK:   Loading
[LNKXCT BSKARA execution]
INPUT      : 
OUTPUT     : 
[INPUT, end with ^Z: ]
1 3 -4^Z
ax^2 + bx + c = 0 : Quadratic Equation Solver
Enter three numbers to solve your quadratic
equation as A B C for coefficients and constant: 
The roots rounded to four places are  1.0000 and  -4.0000

EXIT

.type bskara.pas
(* Second-order polynomial equation solver for 'x', in the from
 * ax^2+bx+c=0. The user should enter numbers for A B and C 
 * with a space between them as: A B C
 * Ex: 1 -4 2
 * Does not work with imaginary numbers. 
 *)

(* On TOPS-20, just hit 'Enter' twice to signify both input/output 
 * goes from/to the keyboard/TTY.
 *)
program bskara ( INPUT, OUTPUT );

var
	a, b, c : real;		(* Coefficients and constant *)
	root1, root2 : real;	(* The solutions *)

begin
	(* Get user input in the form ax^2+bx+c *)
	writeln( 'ax^2 + bx + c = 0 : Quadratic Equation Solver' );
	writeln( 'Enter three numbers to solve your quadratic' );
	write( 'equation as A B C for coefficients and constant: ' );
	read( a, b, c );
	writeln;

	(* Check if it is possible to find the roots. Not
	 * equal is "<>" in Pascal. x**y (exponent) does not
	 * work, despite what both Pascal manuals say.
	 *)
	if ( (sqr( b ) - 4*a*c > 0) and ( a <> 0 ) ) then
		begin
		root1 := ( -b + sqrt( sqr( b ) - 4*a*c ) ) / ( 2*a );
		root2 := ( -b - sqrt( sqr( b ) - 4*a*c ) ) / ( 2*a );
		(* Round to 4 places *)
		writeln( 'The roots rounded to four places are ', root1:4:4, ' and ', root2:4:4 )
		end
	else
		(* Not possible to find real num roots *)
		writeln( 'The problem has no real number solution.' );
end.


(Actually, there's cases where there's one real root but the purpose of
this exercise was to see if I could port my Compaq C program over to
TOPS-10 in Pascal. I might improve the program later.)

-- 
PGP Key ID: 781C A3E2 C6ED 70A6 B356  7AF5 B510 542E D460 5CAE
       "The Internet should always be the Wild West!"

Back to alt.sys.pdp10 | Previous | NextNext in thread | Find similar


Thread

TOPS Pascal questions jayjwa <jayjwa@atr2.ath.cx.invalid> - 2026-03-27 22:39 -0400
  Re: TOPS Pascal questions Rich Alderson <news@alderson.users.panix.com> - 2026-03-28 21:05 -0400
  Re: TOPS Pascal questions Rich Alderson <news@alderson.users.panix.com> - 2026-03-28 21:10 -0400
    Re: TOPS Pascal questions Lars Brinkhoff <lars.spam@nocrew.org> - 2026-03-30 10:38 +0000
      Re: TOPS Pascal questions jayjwa <jayjwa@atr2.ath.cx.invalid> - 2026-03-30 13:05 -0400
        Re: TOPS Pascal questions Lars Brinkhoff <lars.spam@nocrew.org> - 2026-03-31 04:30 +0000
  Re: TOPS Pascal questions jayjwa <jayjwa@atr2.ath.cx.invalid> - 2026-04-01 17:21 -0400
    Re: TOPS Pascal questions Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-04-01 23:54 +0000

csiph-web