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

Which will execute fast: COMP or COMP-3


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
prabeesh
Currently Banned

New User


Joined: 07 Dec 2006
Posts: 9
Location: chennai

PostPosted: Wed Feb 28, 2007 4:40 pm
Reply with quote

10)Which one will execute the fastest ?

Working-Storage Section.
77Field1 Pic S9(5) comp.
77Field2 Pic S9(9) comp-3.
77Field3 Pic S9(9) comp.
77 Field4 Pic S9(5) comp-3.

a) Move Field1 to Field2 b) Move Field1 to Field3
c)Move Field2 to Field3 d) Move Field2 to Field4
Back to top
View user's profile Send private message
hikaps14

Active User


Joined: 02 Sep 2005
Posts: 189
Location: Noida

PostPosted: Wed Feb 28, 2007 5:34 pm
Reply with quote

Hi ,

The answer should be
D)
according to the memmory efficiency...

U replies are welcome if u have any different ideas.

Thanks,
-kapil.
Back to top
View user's profile Send private message
prabeesh
Currently Banned

New User


Joined: 07 Dec 2006
Posts: 9
Location: chennai

PostPosted: Wed Feb 28, 2007 6:09 pm
Reply with quote

sorry i don't have any idea about the answer . can u explain more about ur answer
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Wed Feb 28, 2007 8:18 pm
Reply with quote

Here is the assembly code listing of the 4 move statements
Code:

000025  MOVE                                                             
   0002EE  5840 912C               L     4,300(0,9)              BLW=0   
   0002F2  5830 4000               L     3,0(0,4)                FIELD1   
   0002F6  4E30 D0F0               CVD   3,240(0,13)             TS2=0   
   0002FA  D204 4008 D0F3          MVC   8(5,4),243(13)          FIELD2   
000026  MOVE                                                             
   000300  F874 D0F0 4008          ZAP   240(8,13),8(5,4)        TS2=0   
   000306  4F30 D0F0               CVB   3,240(0,13)             TS2=0   
   00030A  5030 4010               ST    3,16(0,4)               FIELD3   
000027  MOVE     
   00030E  D203 4010 4000          MVC   16(4,4),0(4)            FIELD3                                                         
000028  MOVE                                                                   
   000314  F822 4018 400A          ZAP   24(3,4),10(3,4)         FIELD4       
   00031A  9120 D084               TM    132(13),X'20'           DSAFIXD+132   
   00031E  47E0 B0D0               BC    14,208(0,11)            GN=2(00032C) 
   000322  58F0 20F4               L     15,244(0,2)             V(IGZCMSG )   
   000326  4110 A0AD               LA    1,173(0,10)             PGMLIT AT +165


I guess it is pretty clear now as MOVE FIELD1 TO FIELD3. has generated only 1 machine instruction so it will execute fastest out of 4.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Feb 28, 2007 9:46 pm
Reply with quote

Hello,

The assembly code posted is incorrect. You cannot move a comp field to a comp-3 field in one move. Something must convert from one format to the other. You can move a comp field to another comp field of the "same" size in one move - in the posted question both comp fields take 4 bytes.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Wed Feb 28, 2007 10:53 pm
Reply with quote

The singler MVC is comp to comp.
The last one is slightly misleading, because it is only the ZAP. The additional code is not part of the move.
The other two clearly show CVB abd CVD.
Now which is faster, a ZAP of 3 bytes or an MVC of 4 bytes?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Mar 01, 2007 1:27 am
Reply with quote

Hello,

If memory serves, the MVC is faster.

A straight move is faster than an arithmetic operation.
Back to top
View user's profile Send private message
hikaps14

Active User


Joined: 02 Sep 2005
Posts: 189
Location: Noida

PostPosted: Thu Mar 01, 2007 12:43 pm
Reply with quote

Hi Dick,

May be you are correct .
I still have a doubt on your line.
'A straight move is faster than an arithmetic operation'.

Actually I would have easily agreed if both the moves had same size fields.
Here Comp-3 field move is of 3 bytes.
whereas comp of 4 bytes.

Thanks,
-kapil.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Mar 01, 2007 9:55 pm
Reply with quote

Hello,

Please do a bit research on instruction speed. You will clear your doubt.

Moves (on every hardware platform i've supported) use less cpu resources than arithmetic operations. Add and subrtact are faster than multiply and divide, but all of them are slower than a direct move.
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Execute secondary panel of sdsf with ... CLIST & REXX 1
No new posts Fetch data from programs execute (dat... DB2 3
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
This topic is locked: you cannot edit posts or make replies. How To Write, Compile and Execute Cob... COBOL Programming 5
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
Search our Forums:

Back to Top