Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
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    Post subject: Question on PL/I source example from PL/I Lang Ref Manual
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

Active Member


Joined: 07 Feb 2009
Posts: 984
Location: Oostende, Belgium

PostPosted: Thu Sep 04, 2014 12:57 am    Post subject:
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    Post subject:
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

Active Member


Joined: 07 Feb 2009
Posts: 984
Location: Oostende, Belgium

PostPosted: Thu Sep 04, 2014 2:55 am    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Fault Analyzer - listings question. egrove IBM Tools 4 Thu Aug 11, 2016 5:31 pm
No new posts dataset copy question - REPRO or some... atulxp TSO/ISPF 2 Wed Aug 03, 2016 10:56 pm
No new posts Query on CICS startup manual roy.x.hu CICS 2 Fri Jul 22, 2016 8:57 pm
This topic is locked: you cannot edit posts or make replies. Locating the source code. Raghur CLIST & REXX 17 Mon Apr 04, 2016 2:29 pm
No new posts SQL Order By related question Joseph K Thomas DB2 8 Fri Mar 18, 2016 12:53 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us