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
 
MOVING S9(3) COMP-3 TO S9(3) ?

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

New User


Joined: 09 Jan 2006
Posts: 20

PostPosted: Mon Jan 30, 2006 7:54 pm    Post subject: MOVING S9(3) COMP-3 TO S9(3) ?
Reply with quote

WHAT WILL BE THE RESULT WHEN I AM MOVING S9(3) COMP-3 TO
S9(3).WHAT ARE THE RULES THAT THIS MOVE WOULD FOLLOW ? icon_sad.gif
Back to top
View user's profile Send private message

jon_s_rice

Active User


Joined: 24 Mar 2005
Posts: 102
Location: Douglasville, GA USA

PostPosted: Tue Jan 31, 2006 8:16 am    Post subject:
Reply with quote

S9(3) is a zone signed field. Thlast character contains the last digit and the sign.

+0 hex C0
+1 A
+2 B
+3 C
+4 D
+5 E
+6 F
+7 G
+8 H
+9 I

-0 hex D0
+1 J
+2 K
+3 L
+4 M
+5 N
+6 O
+7 P
+8 Q
+9 R
Back to top
View user's profile Send private message
senthils

Active User


Joined: 15 Nov 2005
Posts: 117
Location: Chennai, India

PostPosted: Tue Jan 31, 2006 3:32 pm    Post subject:
Reply with quote

Any necessary conversion of data from one form of internal representation
to another takes place during the move, along with any specified editing
in, or de-editing implied by, the receiving item.

Ex:

01 A PIC S9(3) COMP-3 VALUE 123.
02 B PIC S9(3).


MOVE A TO B.

Now if we display B the output will be 12L
Back to top
View user's profile Send private message
ulfnsc

New User


Joined: 15 Jan 2004
Posts: 19
Location: Stockholm, SWEDEN

PostPosted: Wed Feb 01, 2006 6:40 pm    Post subject:
Reply with quote

Quote:
01 A PIC S9(3) COMP-3 VALUE 123.
02 B PIC S9(3).


MOVE A TO B.


The output of B will be 123.
Back to top
View user's profile Send private message
senthils

Active User


Joined: 15 Nov 2005
Posts: 117
Location: Chennai, India

PostPosted: Thu Feb 02, 2006 11:47 am    Post subject:
Reply with quote

the actual value of B will be 123 but B is a signed variable. So as jon_s_rice said the sign will be over-punched on the last digit. So when you try to DISPLAY B the output will be 12L
Back to top
View user's profile Send private message
wooyoo

New User


Joined: 08 Mar 2006
Posts: 6

PostPosted: Sat Mar 18, 2006 1:33 pm    Post subject:
Reply with quote

i have to say i dont understand jon_s_rice 's table , anybody can give a detail explanation?
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Mar 18, 2006 10:01 pm    Post subject:
Reply with quote

Hi wooyoo,

When a packed field (comp-3) is moved to a DISPLAY format field the assembler instructions generated by the compiler do the following:

The packed field looks like this in memory "nnns", where "n" is any 4 bit digit from 0 to 9 and "s" is either a 4 bit "C" (1100) the sign for a positive value or "D" (1101) the sign for a negative value. If there's no sign in the PIC, the "s" is "F" (1111).

When the move takes place each "n" (except for the last) is expanded to 8 bits by appending a 4 bit "F" (1111) before it, resulting in "FnFn" in the receiving DISPLAY format field.

Now for the last (low order) "n". The low order 4 bit digit of a paced field is handled differently from the other digits. It and the 4 bit sign are "flipped" resulting in "sn" so, the packed data resides in the receiving DISPLAY field as "FnFnFnSn".

For example a packed "123D" (-123) looks like "F1F2D3" after the move, "123C" (+123) looks like "F1F2C3", "123F" (123 - no sign in the PIC) looks like "F1F2F3".

Which brings us to Jon's comments. When the low order digit and the sign are flipped, a minus 3 displays as an "L", a plus 3 as a "C", and so on.

Jon probably copied the 1st set of numbers and forgot to change the sign from + to - and that's what confused you.

Anyway, it's not an easy concept to explain, but once you get the idea it's not that bad.

One other thing:

Because packed fields ALWAYS use the sign position, even if it's not included in the PIC, a pic 9(2) comp-3 will use 3 4 bit digits in memory plus the sign 4 bits, for a total of 2 bytes. It's always best to use an odd
number of 9s in the PIC. It's more efficient. The compiler has to generate more assembler code to handle even 9 PICs.

HTH
Back to top
View user's profile Send private message
wooyoo

New User


Joined: 08 Mar 2006
Posts: 6

PostPosted: Sun Mar 19, 2006 10:32 am    Post subject:
Reply with quote

Hi ,mmwife
Now i understand ,Thanks for your patience .
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 Moving UDB database to Db2 on z/OS Keith Hooley DB2 4 Wed Sep 27, 2017 12:38 am
No new posts Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts Moving a PD to PD spoorni DFSORT/ICETOOL 8 Fri Oct 07, 2016 9:52 pm
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm

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