## Learning AP instruction - need some help

High Level Assembler(HLASM) for MVS & VM & VSE

### Re: Learning AP instruction - need some help

cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator

Posts: 2495
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 119 times

### Re: Learning AP instruction - need some help

fast_learner wrote:... Please note - I have assumed that Z would be first filled with zeroes using ZAP and then it will be used to store the addition of W+X+Y.
That will work, but why not use ZAP (Zero and Add decimal) to just "copy" W to Z?
steve-myers
Global moderator

Posts: 1773
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 168 times

### Re: Learning AP instruction - need some help

steve-myers wrote:There are two "ringers" here.[list]
Mr. Scherrer's analysis about packed decimal signs is incorrect. There is no such thing as a hexadecimal O (character O, not digit 0). A packed decimal sign is the last 4 bits (1 hexadecimal digit) of a packed decimal value. There are two classes of packed decimal signs.[list]
[*]"Preferred" signs: C for positive and D for negative. The packed decimal instructions always generate a "preferred" sign. To a lazy eye, D often looks like O,
[*]Alternate signs: A, B, E and F. The only one I have memorized is F, which is considered to be positive.

I believe that that is not entirely the case. F is considered unsigned, although it is treated as positive in arithmetic calculations. A COBOL variable declared S9(n) COMP-3 will have a C in the sign nybble; one that is declared 9(n) COMP-3 will have an F. Obviously in a bitwise comparison they will be found to be different; in a HLL arithmetic comparison, I'm not sure (I'll give it a try tomorrow).
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day

Akatsukami
Global moderator

Posts: 997
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 48 times

### Re: Learning AP instruction - need some help

An AP (or any of he decimal instructions) will accept non-preferred signs "on the way in". The non-preferred signs are treated as either positive or negative by the machine code. F is treated as positive.

Only preferred signs (C and D) will appear in any result. Where the F appears in Cobol (or anywhere else) is only in those situations where the compiler (or coder, for instance in Assembler) has generated the code to make the result have an F.

The field-definitions in Cobol are how Cobol does it, not how anything happens natively with the machine instructions.

Your "give it a try" might take longer than you yet imagine, as in Cobol you have to concern yourself with the results for NUMPROC(PFD) and NUMPROC(NOPFD) (forget MIG). However, it is moot, as it does not relate to the decimal instructions. No matter what goes in, AP and cousins (those that can cause a S0C7) will never generate an F in a result. It is only with knowledge of the desired result and the code needed to then achieve it that an F ever appears. Down to the compiler/coder.
BillyBoyo
Global moderator

Posts: 3738
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 255 times

### Re: Learning AP instruction - need some help

Hi Guys,

As i mentioned earlier (and didn't get corrected before others got here and found the mistake), i have no idea where that rather silly reply originated

Must have been interleaving with something going on in my room at the time . . .

Will surely try to not repreat

d

dick scherrer
Global moderator

Posts: 6308
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 90 times

### Re: Learning AP instruction - need some help

hi can anyone tell me how to post in this forum?not as areply as a new topic?
sindhu1

Posts: 3
Joined: Fri Aug 03, 2012 11:42 pm
Has thanked: 0 time
Been thanked: 0 time

### Re: Learning AP instruction - need some help

If you click on the forum name, which gives you a list of topics, you should see the button on the left towards the top.
BillyBoyo
Global moderator

Posts: 3738
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 255 times

Previous