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
 

 

Efficient COBOL coding

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
kalaignar_S
Warnings : 1

New User


Joined: 06 Jan 2006
Posts: 21

PostPosted: Wed May 10, 2006 4:22 pm    Post subject: Efficient COBOL coding
Reply with quote

Which one is the efficient COBOL coding, has been mentioned below??
Why??


MOVE A TO B.

COMPUTE B = A.

If anybodies know this let me know the reason..


Thanks
Kalaignar
Back to top
View user's profile Send private message

ralph_v

New User


Joined: 07 Jul 2005
Posts: 27

PostPosted: Wed May 10, 2006 5:06 pm    Post subject: Re: efficient coding
Reply with quote

COMPUTE B = A is efficient coding because you can check for truncation using ONSIZE ERROR clause.
Back to top
View user's profile Send private message
parikshit123

Active User


Joined: 01 Jul 2005
Posts: 269
Location: India

PostPosted: Wed May 10, 2006 5:27 pm    Post subject:
Reply with quote

Well,

When you say 'efficient coding', offcourse COMPUTE should be a better choice. You can do more with that. for example you can check for size or even overflow....

But, when it comes to "efficient code", if you ignore exceptions, MOVE is efficient. as it maps to less number of instructions.


I hope the difference between "efficient coding" and "efficient code" is clear.
Back to top
View user's profile Send private message
parikshit123

Active User


Joined: 01 Jul 2005
Posts: 269
Location: India

PostPosted: Wed May 10, 2006 5:28 pm    Post subject:
Reply with quote

Also,
I would suggest you to choose a good title for the topic.

I feel that "Efficient Coding" is too general for this topic.

However, it was really a nice question.

Thanks,
Parikshit
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Wed May 10, 2006 10:05 pm    Post subject: Re: efficient coding
Reply with quote

Kalaignar,

It's interesting that in the specific example you give, the compiler generates the exact same code for move and compute.

Code:

WORKING-STORAGE SECTION.                             
01  A                        PIC S9(5)    VALUE 123.
01  B                        PIC S9(5)    VALUE 345.
PROCEDURE DIVISION.   
.000028  MOVE A                      TO B.                                                                       
.   000234  F224 D0E8 8000          PACK  232(3,13),0(5,8)        TS2=0       
.   00023A  F822 D0E8 D0E8          ZAP   232(3,13),232(3,13)     TS2=0       
.   000240  F342 8008 D0E8          UNPK  8(5,8),232(3,13)        B           
.000029  COMPUTE B = A.                                                               
.   000246  F224 D0E8 8000          PACK  232(3,13),0(5,8)        TS2=0       
.   00024C  F822 D0E8 D0E8          ZAP   232(3,13),232(3,13)     TS2=0       
.   000252  F342 8008 D0E8          UNPK  8(5,8),232(3,13)        B           
.000031  GOBACK                                                               
Back to top
View user's profile Send private message
parikshit123

Active User


Joined: 01 Jul 2005
Posts: 269
Location: India

PostPosted: Thu May 11, 2006 4:12 pm    Post subject:
Reply with quote

Hi David,

Thats correct!
the specific example generates the same code.

Now, suppose if you are using ONSIZE ERROR clause then compiler will definitely generate more number of instructions. isn't it?

So, only an assignment is your need, offcourse simple move is a better choice.

Any further ideas.. seems to be a nice topic isn't it?

Thanks,
Parikshit.
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm
No new posts COBOL Programming Sandpit? jodrisco COBOL Programming 6 Wed Apr 12, 2017 3:47 am


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