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

Equiavlent Assembler Copybook for Cobol


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

New User


Joined: 03 Aug 2011
Posts: 9
Location: Bangalore

PostPosted: Sat May 16, 2015 8:48 pm
Reply with quote

Hi Everyone

Need help in creating Assembler copybook equivalent of Cobol in which there is a occurs with in Occurs.

Here is an example of cobol copyboook

Code:
01 A_array
    15 A      occurs 6 times
          20 B   PIC S9(07) COMP-3
          20 C   PIC S9(07) COMP-3
          20 D   PIC  X(03)
          20 E   occurs 12 times
               25 F  pic  X(12)
          20 G   PIC X(03)


I coded like below in assembler

Code:
A _ARRAY  DSECT
A     DS   6CL158
       ORG A
B     DS   PL4
C     DS   PL4
D     DS   CL3
E     DS    12CL12
       ORG  E
EA   DS    CL6
EB   DS    CL6
       DS    11CL12
F     DS    CL3
AL   DS    (*-A)  ==> Length of one array
      DS    5CL158==> 5 remaining entries
AN  DS    ((*-A)/L'A)==> NUMBER OF ARRAY ENTRIES



Could you please correct me if I am wrong. Thanks much for your help in advance!

Code'd
Back to top
View user's profile Send private message
ravi243

New User


Joined: 03 Aug 2011
Posts: 9
Location: Bangalore

PostPosted: Mon May 18, 2015 12:49 pm
Reply with quote

Some one please correct me, there is something wrong with my changes but could not find the exact mistake. Thank you for your help!
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon May 18, 2015 12:51 pm
Reply with quote

If something is wrong, paste your output and any diagnostic messages.

This doesn't look good: AL DS (*-A)
Back to top
View user's profile Send private message
ravi243

New User


Joined: 03 Aug 2011
Posts: 9
Location: Bangalore

PostPosted: Mon May 18, 2015 3:14 pm
Reply with quote

Thanks Bill for your reply,

We have some Compaction and expansion for the ASM layout. while compiling those modules I am getting below Error. SO I am not sure if there is an issue with Module or my layout change. Could you please help me in this. Thanks.

61310+*,ERROR: OP = 5CL158, OPL = 011CL12
** ASMA254I *** MNOTE *** 61311+ 8,ERROR: UNLABELED DS DOES PROPERLY END ARRAY

Thank You
Ravi
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon May 18, 2015 3:27 pm
Reply with quote

Please paste the full DSECT from the Assembler output listing, including any embedded messages, and any later messages on the listing.

Please also use the Code Tags to preserve spacing.

Look at the line I mentioned. If you want to Define Storage, you will need to do more. Do you instead just want to EQUate a value? And for the next one two lines later?
Back to top
View user's profile Send private message
ravi243

New User


Joined: 03 Aug 2011
Posts: 9
Location: Bangalore

PostPosted: Sat May 23, 2015 8:15 pm
Reply with quote

Hi Bill, Thanks much for your response, I am not sure If I can post assembler source here.. Sorry for that..SO I have tried changing like below code and it worked.


Code:
A     DS   6CL158
       ORG A
B     DS   PL4
C     DS   PL4
D     DS   CL3
E     DS    0CL144
       ORG  E
EA   DS    CL6
EB   DS    CL6
       DS    CL132
F     DS    CL3
AL   DS    (*-A)  ==> Length of one array
      DS    5CL158==> 5 remaining entries
AN  DS    ((*-A)/L'A)==> NUMBER OF ARRAY ENTRIES


Code'd
Back to top
View user's profile Send private message
steve-myers

Active Member


Joined: 30 Nov 2013
Posts: 917
Location: The Universe

PostPosted: Sun May 24, 2015 3:26 am
Reply with quote

ravi243 wrote:
Hi Bill, Thanks much for your response, I am not sure If I can post assembler source here.. Sorry for that..SO I have tried changing like below code and it worked.


Code:
A     DS   6CL158
       ORG A
B     DS   PL4
C     DS   PL4
D     DS   CL3
E     DS    0CL144
       ORG  E
EA   DS    CL6
EB   DS    CL6
       DS    CL132
F     DS    CL3
AL   DS    (*-A)  ==> Length of one array
      DS    5CL158==> 5 remaining entries
AN  DS    ((*-A)/L'A)==> NUMBER OF ARRAY ENTRIES
Most assuredly, that code did not work. There are two Assembler errors in the code, and 1 completely unnecessary statement.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sun May 24, 2015 3:55 am
Reply with quote

Please show the documentation which would allow you to use a DS without a type.

You have an unnamed DS which is within the storage of the field referenced by the ORG. How are you aiming to use that?

How do you want to use the AL and AN symbols?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Sun May 24, 2015 4:09 am
Reply with quote

IMNSHO icon_cool.gif the proper way is ...

Code:

 ****** ***************************** Top of Data ******************************
 - - -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  8 Line(s) not Displayed
 000009 DSECTE   DSECT
 000010 F        DS    CL12
 000011 SIZEOFE  EQU   (*-DSECTE)
 000012 *
 000013 DSECTA   DSECT
 000014 B        DS    PL4
 000015 C        DS    PL4
 000016 D        DS    CL3
 000017 E        DS    12CL(SIZEOFE)
 000018 G        DS    CL3
 000019 SIZEOFA  EQU   (*-DSECTA)
 000020 *
 000021 S        DS    6CL(SIZEOFA)
 000022 SIZEOFS  EQU   (*-S)
 000023          END
 ****** **************************** Bottom of Data ****************************


to get
Code:

 ****** ***************************** Top of Data ******************************
 - - -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 60 Line(s) not Displayed
 000057  D-Loc  Object Code    Addr1 Addr2  Stmt   Source Statement
 000058  000000                00000 0000C     1 DSECTE   DSECT
 000059  000000                                2 F        DS    CL12
 000060                        0000C           3 SIZEOFE  EQU   (*-DSECTE)
 000061                                        4 *
 000062  000000                00000 00452     5 DSECTA   DSECT
 000063  000000                                6 B        DS    PL4
 000064  000004                                7 C        DS    PL4
 000065  000008                                8 D        DS    CL3
 000066  00000B                                9 E        DS    12CL(SIZEOFE)
 000067  00009B                               10 G        DS    CL3
 000068                        0009E          11 SIZEOFA  EQU   (*-DSECTA)
 000069                                       12 *
 000070  00009E                               13 S        DS    6CL(SIZEOFA)
 000071                        003B4          14 SIZEOFS  EQU   (*-S)
 000072                                       15          END
 - - -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 53 Line(s) not Displayed
 ****** **************************** Bottom of Data ****************************


if You change something in the inner dsects the final ds will be automatically adjusted
and You will need TWO register to navigate the inner ARRAYS/OCCURS

or even better
Code:

 ****** ***************************** Top of Data ******************************
 - - -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 10 Line(s) not Displayed
 000009 ECOUNT   EQU   12
 000010 DSECTE   DSECT
 000011 F        DS    CL12
 000012 SIZEOFE  EQU   (*-DSECTE)
 000013 *
 000014 ACOUNT   EQU   6
 000015 DSECTA   DSECT
 000016 B        DS    PL4
 000017 C        DS    PL4
 000018 D        DS    CL3
 000019 E        DS    (ECOUNT)CL(SIZEOFE)
 000020 G        DS    CL3
 000021 SIZEOFA  EQU   (*-DSECTA)
 000022 *
 000023 S        DS    (ACOUNT)CL(SIZEOFA)
 000024 SIZEOFS  EQU   (*-S)
 000025          END
 ****** **************************** Bottom of Data ****************************


to get the same result

Code:

 ****** ***************************** Top of Data ******************************
 - - -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 64 Line(s) not Displayed
 000061    Loc  Object Code    Addr1 Addr2  Stmt   Source Statement
 000062                        0000C           1 ECOUNT   EQU   12
 000063  000000                00000 0000C     2 DSECTE   DSECT
 000064  000000                                3 F        DS    CL12
 000065                        0000C           4 SIZEOFE  EQU   (*-DSECTE)
 000066                                        5 *
 000067                        00006           6 ACOUNT   EQU   6
 000068  000000                00000 00452     7 DSECTA   DSECT
 000069  000000                                8 B        DS    PL4
 000070  000004                                9 C        DS    PL4
 000071  000008                               10 D        DS    CL3
 000072  00000B                               11 E        DS    (ECOUNT)CL(SIZEO
 000073  00009B                               12 G        DS    CL3
 000074                        0009E          13 SIZEOFA  EQU   (*-DSECTA)
 000075                                       14 *
 000076  00009E                               15 S        DS    (ACOUNT)CL(SIZEO
 000077                        003B4          16 SIZEOFS  EQU   (*-S)
 000078                                       17          END
 - - -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 55 Line(s) not Displayed
 ****** **************************** Bottom of Data ****************************
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Sun May 24, 2015 4:26 am
Reply with quote

sorry I had a finger check ...

in both examples add something like

Code:
 
...
...
...
000023 MAIN     CSECT
000024 S        DS    (ACOUNT)CL(SIZEOFA)
000025 SIZEOFS  EQU   (*-S)
...
...
...


to get
Code:

...
...
...
000077  000000                00000 003B4    15 MAIN     CSECT
000078  000000                               16 S        DS    (ACOUNT)CL(SIZEO
000079                        003B4          17 SIZEOFS  EQU   (*-S)
...
...
...


S the main <container> should be in a csect to reserve space
Back to top
View user's profile Send private message
ravi243

New User


Joined: 03 Aug 2011
Posts: 9
Location: Bangalore

PostPosted: Tue May 26, 2015 12:18 am
Reply with quote

Hi Bill,

Sorry to confuse you with sample code, Below Is the ACTUAL code Which I used

Code:
MQWERT_ARRAY DSECT     
MQWERT   DS    6CL188 
         ORG   MQWERT
MQCTUVLU DS    PL4     
MQCTUFVL DS    PL4     
MQCTUPRD DS    CL3     
MQCTUTYP DS    PL1     
MQCTUQTY DS    PL4     
MQCTUSES DS    PL4     
MQCTUSEA DS    0CL144 
MQCTUYR  DS   CL4     
MQCTUMNT DS   CL2     
MQCTUDAY DS   CL2     
MQCTUHR  DS   CL2     
MQCTUMIN DS   CL2           
MQCTPKS    DS   CL132                                         
*                                                             
MQCTUSTR DS    CL12         TYPE OF LAST EFFORT SENT           
MQCTUEND DS    CL12         TYPE OF LAST EFFORT SENT           
MQCTUAL  EQU   (*-MQWERT) LENGTH OF ONE ENTRY                 
         DS    5CL188       5 REMAINING ENTRIES               
MQCTUAN EQU   ((*-MQWERT)/L'MQWERT) NUMBER OF ARRAY ENTRIES


Code'd again
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue May 26, 2015 5:15 am
Reply with quote

Code:
01  MQWERT_ARRAY.   
    05  MQWERT OCCURS 6 TIMES.
        10  MQCTUVLU COMP-3 PIC 9(7).
        10  MQCTUFVL COMP-3 PIC 9(7).
        10  MQCTUPRD PIC XXX.
        10  MQCTUTYP COMP-3 PIC 9.
        10  MQCTUQTY COMP-3 PIC 9(7).
        10  MQCTUSES COMP-3 PIC 9(7).
        10  MQCTUSEA.
            15  MQCTUYR  PIC X(4).     
            15  MQCTUMNT PIC XX.
            15  MQCTUDAY PIC XX.     
            15  MQCTUHR  PIC XX.     
            15  MQCTUMIN PIC XX.           
            15  MQCTPKS    PIC X(132).                                         
        10  MQCTUSTR PIC X(12).
        10  MQCTUEND PIC X(12).


Is that approximately (excluding decimal places) how you expect your COBOL record-layout to look?
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Tue May 26, 2015 7:38 pm
Reply with quote

One little tidbit to watch out for in the future (so you don't get burned) are Assembler aligned fields, such as halfwords (H), fullwords (F) and doublewords (D). Their counterparts in COBOL must be suffixed with SYNC.

HTH....
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top