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

total number of bytes


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

New User


Joined: 22 Jul 2021
Posts: 12
Location: germany

PostPosted: Thu Jul 22, 2021 3:23 pm
Reply with quote

how many bytes will bee allocated for the below variable declaration?


DCL 1 SATZ
3 TAB (2,5),
5 F1 BIN FIXED (15),
5 F2 BIT (16),
5 F3 DEC FIXED (15,7),
5 F4 PIC ‘999V,9‘,
3 F5 PIC ‘(3)9‘;


I found the below but not sure if an array is defined? please help.
F1 = 15 bits
F2 = 16 bits
F3 = 15 bytes
F4 = 4 bytes
F5 = 3 bytes
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1111
Location: Dublin, Ireland

PostPosted: Thu Jul 22, 2021 4:03 pm
Reply with quote

F1 = 16 bits / 4 bytes (allow for the sign bit)
F2 = 16 bits / 4 bytes
F3 = 8 bytes @ 2 digits per byte + the sign nibble
F4 = 5 byte there are 4 digits plus the comma
F5 = 3 bytes

The structure is a two-dimensional array ( TAB (2,5), ) with 10 elements and each instance has the above structure.

Garry
Back to top
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1188

PostPosted: Thu Jul 22, 2021 4:47 pm
Reply with quote

1) 16 bits = 2 bytes, but not 4 of them…

2) even BIN FIXED(5) would require 2 bytes = 16 bits in memory; it’s all rounded to the nearest hardware-supported size

3) DEC FIXED(15,7), and DEC FIXED(14,7) both require the same 8 bytes in memory

4) PIC ‘999’, and PIC ‘S999’ both require the same 3 bytes in memory, because the sign value is compacted with the last digit into the last byte

In general, it is a good idea to learn about data format implementation in the mainframe architecture, to understand this better (if needed).
Back to top
View user's profile Send private message
grasshopper

New User


Joined: 22 Jul 2021
Posts: 12
Location: germany

PostPosted: Sat Jul 24, 2021 9:56 pm
Reply with quote

Garry Carroll wrote:
F1 = 16 bits / 4 bytes (allow for the sign bit)
F2 = 16 bits / 4 bytes
F3 = 8 bytes @ 2 digits per byte + the sign nibble
F4 = 5 byte there are 4 digits plus the comma
F5 = 3 bytes

The structure is a two-dimensional array ( TAB (2,5), ) with 10 elements and each instance has the above structure.

Garry



but F5 is in level 3 which is same level as the array declaration.
only the level 5 elements are inside the level 5 TAB?
please explain. thanks in advance.
Back to top
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1188

PostPosted: Sun Jul 25, 2021 2:20 am
Reply with quote

You need align your code properly, to avoid senseless questions in the future
Code:
 DCL 1 SATZ,
       3 TAB (2,5),      inner group of elements (level 5) repeats 2*5=10 times
         5 F1 BIN FIXED (15),   one element 2 bytes (16 bits)
         5 F2 BIT (16),          one element 2 bytes (16 bits)
         5 F3 DEC FIXED (15,7),   one element 8 bytes
         5 F4 PIC ‘999V,9‘,    one element 5 bytes
       3 F5 PIC ‘(3)9‘;    single element after repeated group, 3 bytes

Now use a calculator, to count the total size.
Take into account the alignment of BIN FIXED(15): if the previous group ended at an odd byte offset, then the following BIN FIXED(15) shall start at the nearest even byte offset, and one extra byte may be skipped. This would not happen when extra attribute UNALIGNED has been used.
Also, a comma was missing in your sample, after SATZ (e.g. SENTENCE?)
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10801
Location: italy

PostPosted: Sun Jul 25, 2021 4:15 am
Reply with quote

did anybody hear about the compile option AGGREGATE icon_cool.gif
read the manual about the borderline cases where the results might be misleading
Back to top
View user's profile Send private message
grasshopper

New User


Joined: 22 Jul 2021
Posts: 12
Location: germany

PostPosted: Sun Jul 25, 2021 12:25 pm
Reply with quote

sergeyken wrote:
You need align your code properly, to avoid senseless questions in the future
Code:
 DCL 1 SATZ,
       3 TAB (2,5),      inner group of elements (level 5) repeats 2*5=10 times
         5 F1 BIN FIXED (15),   one element 2 bytes (16 bits)
         5 F2 BIT (16),          one element 2 bytes (16 bits)
         5 F3 DEC FIXED (15,7),   one element 8 bytes
         5 F4 PIC ‘999V,9‘,    one element 5 bytes
       3 F5 PIC ‘(3)9‘;    single element after repeated group, 3 bytes

Now use a calculator, to count the total size.
Take into account the alignment of BIN FIXED(15): if the previous group ended at an odd byte offset, then the following BIN FIXED(15) shall start at the nearest even byte offset, and one extra byte may be skipped. This would not happen when extra attribute UNALIGNED has been used.
Also, a comma was missing in your sample, after SATZ (e.g. SENTENCE?)



please explain difference between dec fixed and PIC - both are decimal.
what is a packed numeric data? how to define it? THANKS. (am learning PL1)
Back to top
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1188

PostPosted: Sun Jul 25, 2021 5:20 pm
Reply with quote

In that case you need some basic knowledge of Assembler.

DEC FIXED stands for “packed decimal”, or DS P in Assembler.

PIC stands either for “unpacked decimal” (DS Z in Assembler), or for a “character string” (DS C in Assembler).

I doubt this info might help, unless you start learning something from mainframe concepts.
Back to top
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1188

PostPosted: Sun Jul 25, 2021 6:33 pm
Reply with quote

I guess the last time I read any PL/I manual was about 35-40 years ago. But I’m pretty sure all the details you are interested in have been expounded in details in the most part of available manuals.

At least, I personally have got all this information from those manuals - at that time neither web forums, nor Internet itself had been known. 36_11_6.gif 358.gif
Back to top
View user's profile Send private message
grasshopper

New User


Joined: 22 Jul 2021
Posts: 12
Location: germany

PostPosted: Sun Jul 25, 2021 7:37 pm
Reply with quote

sergeyken wrote:
I guess the last time I read any PL/I manual was about 35-40 years ago. But I’m pretty sure all the details you are interested in have been expounded in details in the most part of available manuals.

At least, I personally have got all this information from those manuals - at that time neither web forums, nor Internet itself had been known. 36_11_6.gif 358.gif


if we all have the time and expertise to read manuals all the time, then there is no need for auto repairshops, painters, electricians, even this blog.
u must be feeling unrecognized.
so here i say it, you are a expert in pl1 and have more knowledge than others, i bet. I also say a BIG THANK YOU for taking the time to help me and ohers in this forum. But there is a reason am working on the weekend with no editor with me.
AGAIN a BIG THANK YOU for helping me understand the declarations.
PLEASE continue to do so. THANK YOU.
Back to top
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1188

PostPosted: Sun Jul 25, 2021 9:56 pm
Reply with quote

You might be angry at me, but without a serious learning of the very basic ideas and concepts you are condemned to stuck again and again at every new development step assigned to you.
Just getting a short answer to each separate issue (out of thousands) would not help you to become an expert in any area.
This forum cannot be a schoolbook to explain everything, starting from the very basic concepts.
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 how to convert and use 1 bit hex-numb... COBOL Programming 9
No new posts Build a trailer with total an count SYNCSORT 6
No new posts Merge a variable number of records fr... DFSORT/ICETOOL 5
No new posts Chained RPL - How to get RRN number. JCL & VSAM 0
No new posts how to list the number of backup data... JCL & VSAM 3
Search our Forums:

Back to Top