Megalextoria
Retro computing and gaming, sci-fi books, tv and movies and other geeky stuff.

Home » Archive » net.micro.cpm » Packed variables in Turbo Pascal
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Packed variables in Turbo Pascal [message #112289] Mon, 16 September 2013 13:42 Go to next message
hall is currently offline  hall
Messages: 49
Registered: May 2013
Karma: 0
Member
Message-ID: <492@ittral.UUCP>
Date: Sun, 6-Jan-85 14:09:04 EST
Article-I.D.: ittral.492
Posted: Sun Jan  6 14:09:04 1985
Date-Received: Tue, 8-Jan-85 02:48:41 EST
Lines: 33
Xref: watmath net.lang.pascal:171 net.micro.cpm:3304

While messing around with Turbo Pascal last night I typed in the
following short program:

|    program testvars;
|
|    var a : packed array [0..15] of boolean;
|        b : set of 0..15;
|
|    begin
|    writeln(sizeof(a),' ',sizeof(b));
|    end.

The result was that variable 'a' took 16 bytes and 'b' took 2 bytes. A
quick check of the manual revealed that the word 'packed' is ignored
in Turbo; packing occurs automatically whenever possible. It certainly
seems possible for packing to occur here. There is a compiler
directive (*X- *) which supposedly causes the code size for arrays to
be minimized, but the size is unchanged when I use this. It appears
that Turbo is tuned for maximum speed, not minimum code size. Sets,
however, use one bit per element, just as in UCSD Pascal.

Could someone try this on the 8088/8086 version of Turbo? I'm using
the CP/M version on an Apple //e with a Z-80 card.

While we're on the subject, has anyone received info on new compilers
from Borland? I keep hearing rumors of a Modula-2 compiler and an
upgraded version of the Pascal compiler. Any news?


Douglas Hall
ITT Telecom Products
Raleigh, NC
ittvax!ittral!hall
Re: Packed variables in Turbo Pascal [message #112303 is a reply to message #112289] Mon, 16 September 2013 13:42 Go to previous messageGo to next message
Alastair Milne is currently offline  Alastair Milne
Messages: 9
Registered: June 2013
Karma: 0
Junior Member
Message-ID: <7113@brl-tgr.ARPA>
Date: Tue, 8-Jan-85 15:06:01 EST
Article-I.D.: brl-tgr.7113
Posted: Tue Jan  8 15:06:01 1985
Date-Received: Fri, 11-Jan-85 07:20:50 EST
Sender: news@brl-tgr.ARPA
Organization: Ballistic Research Lab
Lines: 58


 >     While messing around with Turbo Pascal last night I typed in the
 >     following short program:

 >     |    program testvars;
 >     |
 >     |    var a : packed array [0..15] of boolean;
 >     |        b : set of 0..15;
 >     |
 >     |    begin
 >     |    writeln(sizeof(a),' ',sizeof(b));
 >     |    end.

 >     The result was that variable 'a' took 16 bytes and 'b' took 2 bytes. A
 >     quick check of the manual revealed that the word 'packed' is ignored
 >     in Turbo; packing occurs automatically whenever possible. It certainly
 >     seems possible for packing to occur here. There is a compiler
 >     directive (*X- *) which supposedly causes the code size for arrays to
 >     be minimized, but the size is unchanged when I use this. It appears
 >     that Turbo is tuned for maximum speed, not minimum code size. Sets,
 >     however, use one bit per element, just as in UCSD Pascal.

 >     Could someone try this on the 8088/8086 version of Turbo? I'm using
 >     the CP/M version on an Apple //e with a Z-80 card.

 >     While we're on the subject, has anyone received info on new compilers
 >     from Borland? I keep hearing rumors of a Modula-2 compiler and an
 >     upgraded version of the Pascal compiler. Any news?


 >     Douglas Hall
 >     ITT Telecom Products
 >     Raleigh, NC
 >     ittvax!ittral!hall
----------------

   I have Turbo on an 8088.  It's the same story.  Turbo packs to the byte 
level only; I'm told this is typical of Pascal implementations.  UCSD is 
one of the few that packs to the bit level.  I did my test in a different 
way: a case variant record where one variation was an array of boolean, by which
I wanted to access the bits of the other variation.  No good.  I had an 
array of bytes where I wanted bits.

   Yes, Turbo's optimisation is definitely for speed; I believe they state as
much.  I'm not sure, though, whether $X- is the right setting for optimised
arrays.  Are sure that's not actually the default setting?

   As far as I'm aware Turbo's sets are bit vectors.  I think (hope, 
certainly) that this is also typical of Pascal implementations (else why 
impose such a ridiculous restriction as a 32-element set?).

   I too am eagerly awaiting reports of Borland's Modula-2.  Having separately
compilable modules will make a great difference to me.  And with luck, the
reams of additional features stuffed into Turbo will be separated into
modules.  (Have you considered what the Turbo compiler's symbol must look
like, not to mention the code to initialize it?!)

			A. Milne
Re: Packed variables in Turbo Pascal [message #112317 is a reply to message #112289] Mon, 16 September 2013 13:42 Go to previous message
lowans.henr is currently offline  lowans.henr
Messages: 7
Registered: June 2013
Karma: 0
Junior Member
Message-ID: <7169@brl-tgr.ARPA>
Date: Thu, 10-Jan-85 07:58:55 EST
Article-I.D.: brl-tgr.7169
Posted: Thu Jan 10 07:58:55 1985
Date-Received: Sat, 12-Jan-85 06:58:32 EST
Sender: news@brl-tgr.ARPA
Organization: Ballistic Research Lab
Lines: 4


	I have a NEC APC which runs on a 8086 and CP/M-86. I ran your program
on my Turbo and got the same answer.
										Paul
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: TURBO Pascal
Next Topic: CP/M Stock Management software wanted
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Apr 19 14:39:30 EDT 2024

Total time taken to generate the page: 0.04548 seconds