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

Which Extended Mnemonic?


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Oct 23, 2013 6:30 pm
Reply with quote

I'm having a debate, regarding the proper CC to use after an Assembler LTR instruction. I want the branch to go to the label for processing when the result is non-zero. The result will always be an absolute value of zero or greater. The issue is that the coded branch used is a BP (Branch Positive/Plus), which indicates branch on a positive value, but as far as I've found in various manuals, the result COULD be ZERO, which the code uses in a BCT. So upon the first BCT, the register goes to X'FFFFFFFF' when the register is ZERO and we raise a S0C4. I've recommended to change the BP to BNZ as the result is never negative, but I'm hitting resistance.

Any perspective on a BP as to whether this CC includes ZERO would be helpful.

Regards,
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Oct 23, 2013 7:44 pm
Reply with quote

just to be picky icon_wink.gif
BP ( from the manual ) means for IBM BRANCH IF PLUS ( BC 2 )

so the proper extended would be ...
BNM ==> BRANCH IF NOT MINUS ( BC 11 )
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Oct 23, 2013 7:59 pm
Reply with quote

Enrico,

Yes, I broke down the CC's, but the explanation of BP did not include any discussion of ZERO as being a valid PLUS value.

The LTR being issued is after a "DR", with the quotient ALWAYS resulting in an absolute value, never negative. This is why a BNZ would make more sense and would be clearer to the next person.

In the interim, an external colleague has told me that a BP does NOT include a result of ZERO. So, this branch will work after the LTR, with a value that exceeds ZERO. I still prefer the BNZ, but it looks like the BP will remain.

Lesson learned but, confusing at best.... icon_wink.gif
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Oct 23, 2013 8:04 pm
Reply with quote

Quote:
Any perspective on a BP as to whether this CC includes ZERO would be helpful.


icon_redface.gif my bad I had not read completely Your post
I can confirm that BP does not include 0 icon_smile.gif

for a full insight You will need both the HLASM manual
which tells what CC(combination of) is assigned to the extended mnemonics

and the Principle of operation for the explanation of the CC set after each instruction
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Oct 23, 2013 9:04 pm
Reply with quote

Enrico,

Yes, I refer to both of these manuals regularly, but like I said, neither were clear on the BP as to whether ZERO was a consideration in the CC. After all, ZERO is always considered a positive/plus value. Hence, the confusion and the raising of a false positive.

Thanks,
Back to top
View user's profile Send private message
steve-myers

Active Member


Joined: 30 Nov 2013
Posts: 917
Location: The Universe

PostPosted: Sun Dec 01, 2013 10:32 am
Reply with quote

What you have to do is go to Principles of Operation and check the condition codes set by the instruction that immediately precedes your branch. Most (not all) arithmetic instructions set 4 possible condition codes
  • Value is positive
  • Value is 0
  • Value is negative
  • Value overflowed
Your problem is you want to think of a 0 result as positive - there is no such thing as a negative 0 in the 2s complement binary arithmetic done for most arithmetic operations - so you have to think out of the box a little. If you ignore overflow, you do not want to branch if the value is negative, but 0 and positive are OK, so think negative: not minus, so your instruction should be BNM, branch not minus.

This raises another question: at least in theory, packed decimal and floating point arithmetic can come up with a -0 result. I don't know
  • Does the hardware set a -0 value?
  • If the hardware sets a -0 value, is the condition code set to B'00' (the usual condition code for a 0 result) or something else?
I'm guessing here, but I'd bet the hardware sets +0 and the condition code as B'00'.
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: Mon Dec 02, 2013 6:28 am
Reply with quote

Hi Bill,

Quote:
I've recommended to change the BP to BNZ as the result is never negative, but I'm hitting resistance.
Is this just an emotional response (i.e we always do it this way). or does someone have some kind of technical reason?

Hi Steve welcome to the forum,

Good to "see" you over here icon_smile.gif

d
Back to top
View user's profile Send private message
steve-myers

Active Member


Joined: 30 Nov 2013
Posts: 917
Location: The Universe

PostPosted: Mon Dec 02, 2013 7:13 am
Reply with quote

Thanks Dick. I like your avatar.

I've been doing a little experimenting. Other than SRP, I think the only instructions that can store a -0 result are MP and DP and the floating point multiply and divide instructions.

As far as I can tell, none of the multiply and divide instructions alter the condition code. I remember a bug I induced many years ago when I thought, incorrectly, that the multiply instruction set the condition code and I did a BZ (or was it a BNZ, who can remember after 40 years?) after the multiply. This makes sense for the non-floating point divide instructions; they produce two results, so which result should set the condition code?

This code -
Code:
         MP    X,=P'0'
         ...
X        DC    PL4'-30'

stores PL4'-0', which one would expect. I ran into trouble with SRP, and I fear I may have found a Hercules issue.

This code produces a +0 result and sets the condition code to 0.
Code:
         SRP   X,64-1,0
         ...
X        DC    P'-3'
If I read Principle of Operation correctly, it should result in -0 and, I presume, a condition code of 0. The key phrase is, "... Only its digit portion is shifted; the sign position does not participate in the shifting. ..." If you start with -30, you wind up with -3, which makes perfect sense and follows the phrase in Principles of Operation. Perhaps someone can try it with real hardware and let us know the result.
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 -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts RPLDDDD field for extended VSAM - ESDS JCL & VSAM 1
This topic is locked: you cannot edit posts or make replies. VSAM I/O - Extended Addressability - ... JCL & VSAM 12
No new posts Blue zone error with an invalid exten... CICS 3
No new posts How to browse RECFM=VBS DSORG=PSE seq... JCL & VSAM 7
No new posts "Extended Monitor Facility" All Other Mainframe Topics 4
Search our Forums:

Back to Top