IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Question on PL/I source example from PL/I Lang Ref Manual


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Duncan Sharppe

New User


Joined: 13 Dec 2013
Posts: 20
Location: USA

PostPosted: Wed Sep 03, 2014 11:40 pm
Reply with quote

Hello people of the forum!

The following text is from the PL/I Language Reference (SC14-7285-02)
page 450.

AVAILABLEAREA returns a FIXED BINARY(31,0) value.
The value returned by AVAILABLEAREA is the size of the largest
single allocation that can be obtained from the area x.

The example cited in the book on page 450 is:

{Note that I've added the line numbers for ease of reference.)

1 ... dcl Uarea area(1000);
2 ... dcl Pz ptr;
3 ... dcl C99z char(99) varyingz based(Pz);
4 ... dcl (SizeBefore, SizeAfter) fixed bin(31);
5 ... SizeBefore = availablearea(Uarea); /* returns 1000 */
6 ... Alloc C99z in(Uarea);
7 ... SizeAfter = availablearea(Uarea); /* returns 896 */
8 ... dcl C9 char(896) based(Pz);
9 ... Alloc C9 in(Uarea);

From my understanding the allocate in statement number (6) allocated 100
bytes in area (Uarea) qualified by the based variable (C99z).

The returned value from availablearea in statement (7) is said to be
896; I believe this is incorrect it should be 900 as the varible (C99z)
has been the only thing allocate in area (Uarea).

It appears that the writer has assumed the pointer(Pz) been allocated
in the area as well. Or has mistakenly added the additional 4-bytes
of the pointer to the allocation and thus cites the number 896 in
the comments of line 8 as the remaining free space.

Is my understanding correct or I am missing something obvious.

TIA for any clirafications.

friarDuncan
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Thu Sep 04, 2014 12:57 am
Reply with quote

The example is correct, the size of variables allocated inside an area is rounded up to the next multiple of 8 bytes.
Back to top
View user's profile Send private message
Duncan Sharppe

New User


Joined: 13 Dec 2013
Posts: 20
Location: USA

PostPosted: Thu Sep 04, 2014 1:44 am
Reply with quote

Thank you!

I think I'll write ASM some code to examine the area and the "allocated data" within it or if I feel bolder I will TEST the proc and ASM code in TSO.

Whew!

friarDuncan
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Thu Sep 04, 2014 2:55 am
Reply with quote

This should get you started, no assembler required:

Code:
dcl 1 * union,
      2 area(1000),
      2 ar_ea,                         /* Overlay on area            */
        3 use_list  bit        (1),    /* Free list in use           */
        3 filler    char       (3),
        3 nab       fixed bin (31),    /* Next available byte        */
        3 ffree     fixed bin (31),    /* Offset of first free byte  */
        3 eol       fixed bin (31),    /* Always 0, end of free list */
        3 contents  char    (1000);    /* Contents                   */
Back to top
View user's profile Send private message
Duncan Sharppe

New User


Joined: 13 Dec 2013
Posts: 20
Location: USA

PostPosted: Thu Sep 11, 2014 2:54 am
Reply with quote

Hehehe...

Sorry for not getting back to you sooner...

That is some code!!!

I really like your knowledge set and I love learning about internals.

Much Thanks.

friarDuncan
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Question for file manager IBM Tools 7
No new posts question for Pedro TSO/ISPF 2
No new posts Discrepancy between source code and o... COBOL Programming 7
No new posts question on Outrec and sort #Digvijay DFSORT/ICETOOL 20
No new posts panel creation question TSO/ISPF 12
Search our Forums:

Back to Top