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

MOVING S9(3) COMP-3 TO S9(3) ?


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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
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
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
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts Interviewers are surprised with my an... Mainframe Interview Questions 6
No new posts Cobol COMP-2 fields getting scrambled... Java & MQSeries 6
Search our Forums:

Back to Top