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
 
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
No new posts IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am
No new posts ALPHABETIC check in COBOL vidyaa COBOL Programming 8 Thu Aug 17, 2017 7:13 pm
No new posts XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm

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