Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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

Senior Member


Joined: 07 Feb 2009
Posts: 1047
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

Senior Member


Joined: 07 Feb 2009
Posts: 1047
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 Question related to Data dictionary f... rexx77 SYNCSORT 3 Thu Aug 31, 2017 7:23 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm
No new posts QUESTION: RETURN CHANNEL pahiker CA Products 21 Thu Apr 20, 2017 12:31 am
No new posts The Last Two Question For You To Ask ... CaptBill Mainframe Interview Questions 0 Fri Apr 14, 2017 5:42 am
No new posts Asynchronous CICS Processing Question moezbud CICS 1 Mon Mar 06, 2017 6:13 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us