Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cobol Assembler data type equivalents

Status
Not open for further replies.

ellykutty

Programmer
Feb 19, 2002
2
US
ellykutty (Programmer) Nov 6, 2002
Hi, I am working on Mainframe Cobol, but I am totally new to Assembler

I am writing a Cobol Program and I have to steal an Assembler layout to read a file, if any one could help me to understand these Assembler data types in Cobol terms (character, numeric, binary and packed decimal) or point to resources, I would greatly appreciate it, thank you

BL2
BL3
BL4
CL(L'IRBMOB)
CL1
CL1
CL10
PL1
PL2
X'04'
XL12
XL2
ZL1
ZL12
ZL2
0CL(#CRLEN

 
Hi ellykutty,

The explanation for the assembler symbols is at:

Look for:
9.3 Data Attributes
B.0 Appendix B. Summary of Constants

Its been a while since I used ALC but, briefly, in first position:
B is binary digits
C is characters
P is decimal digits - packed decimal (?)
X is hex digits
Z is decimal digits

In second and third position is the symbol for Length and the length.

My translation to COBOL data types:
BL2 S9(04) COMP
BL3 BINARY 3 (?)
BL4 S9(08) COMP
CL(L'IRBMOB) character array of length IRBMOB
CL1 X(01)
CL10 X(10)
PL1 9(01) packed decimal (?)
PL2 9(02)
X'04' X'04'
XL12 X'00 00 00 00 00 00 00 00 00 00 00 00' (ignore space)
XL2 X'00 00'
ZL1 9(01)
ZL12 9(12)
ZL2 9(02)
0CL(#CRLEN this could indicate an address offset (?)

(?) = I am not sure, as I am doing this from fuzzy memory. The manual linked to here will be a lot more helpful.

Dimandja
 
0CL is similar to a COBOL group item, so a report line might be defined as:

rptline ds 0CL133
ds cl1
rlname ds cl25
ds cl1
rladdr ds 0CL100
rladdr1 ds cl25
rladdr2 ds cl25
rladdr3 ds cl25
rladdr4 ds cl25
ds cl6

major difference between cobol is that you have to explicitly define the storage under the 0CL, since any reference to rptline will automatically address the next 133 bytes.

The (L'fld-name) is equivalent to the COBOL LENGTH OF function. Speaking of LENGTH OF, i find it very useful for controlling table processing in cobol programs. A sample follows:

01 ws-generic-TABLE-AREA.
05 ws-gta-max-entries pic 9(04) comp.
05 ws-gta-entries pic 9(04) comp.
05 gtasub pic 9(04) comp.
05 ws-gta-table.
10 ws-gta-table-entry occurs 100 times.
15 ws-gta-name pic x(25).
15 ws-gta-address pic x(100).
15 ws-gta-phone-number pic x(10).

in program initialization:

move 0 to ws-gta-entries
compute ws-gta-max-entries
= (length of ws-gta-table)
/ (length of ws-gta-table-entry (1))

When adding entries to the table, I increment ws-gta-entries, and return an error if the value is greater than
Ws-gta-max-entries.

when searching the table i use ws-gta-entries to control end of table logic.

this construct saves me from searching working-storage or procedure division code for literal values when the number of entries in a table changes.





 
ellykutty,

The manual Dimandja points you to is certainly the definitive resource. Note the general form for layout of data areas is covered by the DS directive which is very similar to the DC directive. Some of the variations are quite esoteric, but you'll generally see most definitions in the form:

repetition type length

When not specified, repitition is 1. The default length depends on what is being defined. Here are some common ones:

B - 1 byte
P - 1 byte
F - 4 bytes align on Fullword
H - 2 bytes align on halfword
D - 8 bytes align on doubleword
C - 1 byte
X - 1 byte
A - 4 bytes
Y - 4 bytes
Z - 1 byte

Make sure you watch the alignment as it can introduce slack bytes between data fields (e.g. DS 0H forces the next item to be on a halfword boundary)!

An assembly listing with a map can help you figure out the alignment/size issues. If you then compare it to your COBOL compile listing with the MAP, you can make sure you have things lined up OK.

Also note Dimandja was a bit off on the Packed fields. It's bytes not digits. PL3 could be S9(5) COMP-3 for instance (obviously the implied decimal could be anywhere - you can't tell that from the definition alone in Assembler).

Good luck!

Glenn
Brainbench MVP for COBOL II
 
BL2 PIC 9(04) COMP. (BINARY 2 BYTES)
or PIC X(02).

BL3 PIC X(03)
BL4 Pic X(04)
CL(L'IRBMOB) PIC X(LENGTH OF IRBMOB).
CL1 PIC X(1)
CL1 pic x(1)
CL10 PIC X(01)
PL1 PIC 9(01) COMP-3. (PACKED 1 BYTE)
PL2 PIC 9(03) COMP-3. (PACKED 2 BYTE)
X'04' PIC X(01) VALUE X.
**(turn hex on and replace X with a hex 04.
XL12 PIC X(12)
XL2 PIC X(02)
ZL1 PIC X(01)
ZL12 PIC X(12)
ZL2 PIC X(02)
0CL(#CRLEN Same as a group clause in COBOL.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top