ICM - Set Condition Code? 
Author Message
 ICM - Set Condition Code?

In the course of reviewing an Assembler (MVS) program for
modifications, I have come upon the following snippet of code which is
supposed to do a binary search of a table loaded in core:

         USING  LKPREQ,R3
         USING  AXTABLE,R4
         .
         .
BEGBIN   DS     0H
         LA     WORKREG,AXBLSMP1  FIRST BINARY SEARCH DISPLACEMENT
         AH     SSRDETRG,0(WORKREG) ENTRY IN THE MIDDLE
         XC     FDBNTRY,FDBNTRY     CLEAR
         LA     R0,AXBLDLEN        GET RECORD LENGTH
         STH    R0,NTRYLEN         SAVE
         BAL    RETRG,FNDLGTH      FIND ACTUAL DATA FIELD LENGTH
         L      R15,LNGTH          LENGTH RETURNED FROM SUBROUTINE
         BCTR   R15,0              DECREMENT FOR COMPARE
BINLOOP  DS     0H
         EX     R15,EXCLKP         COMPARE CURRENT MIDPOINT TO REQUEST
         BE     BINFOUND           EQUAL - EXIT ROUTINE
         BH     BINHI              HIGH - TRY ANOTHER
         CLC    0(L'AXBLSMP1,WORKREG),NTRYLEN   ONLY 1 ENTRY LEFT?
         BNH    BINEND             YES - GET PREVIOUS ENTRY, IF ANY
         SH     SSRDETRG,0(WORKREG)  SUBTRACT TO HIGHER ENTRIES
         B      BINLOOP              REITERATE TO COMPARE
BINHI    DS     0H
         ST     SSRDETRG,FDBNTRY     SAVE IN CASE THIS IS IT
         CLC    0(L'AXBLSMP1,WORKREG),NTRYLEN   ONLY 1 ENTRY LEFT?
         BNH    BINEND               YES - GET PREVIOUS IF ANY
         LA     WORKREG,L'AXBLSMP1(WORKREG)  GET NEXT MIDPT IN TABLE
         AH     SSRDETRG,0(WORKREG)  ADD TO HIGHER ENTRIES
         B      BINLOOP              REITERATE TO COMPARE
BINFOUND DS     0H
         ST     SSRDETRG,FDBNTRY     SAVE FOUND ENTRY
BINEND   DS     0H
         ICM    SSRDETRG,X'F',FDBNTRY   WAS ANY ENTRY LOWER OR EQUAL?
         BP     CHKRETNT                YES - EXIT ROUTINE
         .
         .
EXCLKP   CLC    LKPFCTLS(1),AXBLDFTL    COMPARE REQUEST VS RECORD
         .
         .
         .
SSRDETRG EQU    6
WORKREG  EQU    7
FDBNTRY  DC     A(0)
NTRYLEN  DC     H'0'
         .
         .

My question involves the ICM instruction and the BP following it.  I
have been unable to find any documentation in any manual I have looked
at that says the ICM instruction sets the condition code.  And I've
found that BP is valid only after arithmetic instructions.  If
anything, the branch after an ICM should be BO or BM or BNO etc based
on the fact that a TM instruction does set the condition code.  Can
any of you confirm that the ICM does or does not set the condition
code?  Thanks in advance for any and all help.

Regards,

          ////
         (o o)
-oOO--(_)--OOo-
I love defenseless animals, especially in good gravy.
 Steve



Sat, 25 Nov 2000 03:00:00 GMT  
 ICM - Set Condition Code?

[snip]
: My question involves the ICM instruction and the BP following it.  I
: have been unable to find any documentation in any manual I have looked
: at that says the ICM instruction sets the condition code.

There's only one place you should be looking for information about S/390
hardware instructions: ESA/390 Principals of Operation.  In that book,
there is a detailed description of the ICM instruction.  The third
paragraph says:

"The resulting condition code is based on the mask and on the value of the
 bits inserted.  When the mask is zero or when all inserted bits are zeros,
 the condition code is set to 0.  When the inserted bits are not all zeros,
 the code is set according to the leftmost bit of the storage operand:  if
 this bit is one, the code is set to 1; if this bit is zero, the code is
 set to 2."

--
| Edward E. Jaffe                | Voice:      (310) 338-0400 x318     |
| Mgr., Research & Development   | Facsimile:  (310) 338-0801          |

| 9841 Airport Blvd, Suite 700   | IBM Mail:   USS24J24 at IBMMAIL     |        
| Los Angeles, CA 90045          | Web page:   www.phoenixsoftware.com |



Sat, 25 Nov 2000 03:00:00 GMT  
 ICM - Set Condition Code?



Quote:
>        ICM    SSRDETRG,X'F',FDBNTRY  WAS ANY ENTRY LOWER OR EQUAL?
>        BP     CHKRETNT               YES - EXIT ROUTINE

Is equivalent to:

         L      SSRDETRG,FDBNTRY       Load entry addr
         LTR    SSRDETRG,SSRDETRG      WAS ANY ENTRY LOWER OR EQUAL?
         BP     CHKRETNT               YES - EXIT ROUTINE




Sat, 25 Nov 2000 03:00:00 GMT  
 ICM - Set Condition Code?

Quote:

>My question involves the ICM instruction and the BP following it.  I
>have been unable to find any documentation in any manual I have looked
>at that says the ICM instruction sets the condition code.  And I've
>found that BP is valid only after arithmetic instructions.  If
>anything, the branch after an ICM should be BO or BM or BNO etc based
>on the fact that a TM instruction does set the condition code.  Can
>any of you confirm that the ICM does or does not set the condition
>code?  Thanks in advance for any and all help.

As another post stated, you need to look in Priniciples of Operation.

In that case, ICM does set the condition code.  The description of the
codes set are not so easy to understand, though.  In your case, though,
with the mask of X'F', it is stated that the codes are the same as returned
by LOAD AND TEST, which uses the same codes as arithmetic instructions.

The BO, BM and BNO codes are for the TM instruction only.  Well, even worse
than that.

Some arithmetic instructions set the condition code for zero, positive,
negative, and overflow.  

CC=0   Zero
CC=1   Negative
CC=2   Positive
CC=3   Overflow

The extended instructions BZ, BM, BP, BO correspond to those four
choices, and assemble as BC 8,x  BC 4.x  BC 2,x and BC 1,x respectively.

In the case of the TM (test under mask) instruction, the condition codes are

CC=0   Selected bits all zero, or mask is zero.
CC=1   Selected bits are mixed ones and zeros.
CC=2  
CC=3   Selected bits all ones.

This is the instruction that uses  BZ, BM, and BO.  Now, notice that BZ
(Branch if Zero(s)) has a similar meaning.  BM mean Branch if Minus for
arithmetic, but Branch if mixed for TM.  Even worse, BO, Branch if Overflow
now means Branch if Ones.  

You will not find these branch instructions in Principles of Operation.
The real instruction is BC (and BCR), with the appropriate condition mask.
All the extended branch instructions are defined on the reference card,
though, as are the condition codes and instructions that generate them.

Hope this helps,

-- glen



Sat, 25 Nov 2000 03:00:00 GMT  
 ICM - Set Condition Code?

BZ, BNZ are also valid when using ICM. BP is also perfectly valid.

ICM is great for testing a 4-byte label (aligned or unaligned), such as
EIBTRMID:

    ICM    R1,B'1111',EIBTRMID    DOES A TERMINAL EXIST?
    BNZ    CICSRETN                    YES, ELVIS HAS LEFT THE BUILDING

CICSRETN    DS    0H

                    EXEC  CICS RETURN,

Cheers,

WOB

Quote:

>In the course of reviewing an Assembler (MVS) program for
>modifications, I have come upon the following snippet of code which is
>supposed to do a binary search of a table loaded in core:

>         USING  LKPREQ,R3
>         USING  AXTABLE,R4
>         .
>         .
>BEGBIN   DS     0H
>         LA     WORKREG,AXBLSMP1  FIRST BINARY SEARCH DISPLACEMENT
>         AH     SSRDETRG,0(WORKREG) ENTRY IN THE MIDDLE
>         XC     FDBNTRY,FDBNTRY     CLEAR
>         LA     R0,AXBLDLEN        GET RECORD LENGTH
>         STH    R0,NTRYLEN         SAVE
>         BAL    RETRG,FNDLGTH      FIND ACTUAL DATA FIELD LENGTH
>         L      R15,LNGTH          LENGTH RETURNED FROM SUBROUTINE
>         BCTR   R15,0              DECREMENT FOR COMPARE
>BINLOOP  DS     0H
>         EX     R15,EXCLKP         COMPARE CURRENT MIDPOINT TO REQUEST
>         BE     BINFOUND           EQUAL - EXIT ROUTINE
>         BH     BINHI              HIGH - TRY ANOTHER
>         CLC    0(L'AXBLSMP1,WORKREG),NTRYLEN   ONLY 1 ENTRY LEFT?
>         BNH    BINEND             YES - GET PREVIOUS ENTRY, IF ANY
>         SH     SSRDETRG,0(WORKREG)  SUBTRACT TO HIGHER ENTRIES
>         B      BINLOOP              REITERATE TO COMPARE
>BINHI    DS     0H
>         ST     SSRDETRG,FDBNTRY     SAVE IN CASE THIS IS IT
>         CLC    0(L'AXBLSMP1,WORKREG),NTRYLEN   ONLY 1 ENTRY LEFT?
>         BNH    BINEND               YES - GET PREVIOUS IF ANY
>         LA     WORKREG,L'AXBLSMP1(WORKREG)  GET NEXT MIDPT IN TABLE
>         AH     SSRDETRG,0(WORKREG)  ADD TO HIGHER ENTRIES
>         B      BINLOOP              REITERATE TO COMPARE
>BINFOUND DS     0H
>         ST     SSRDETRG,FDBNTRY     SAVE FOUND ENTRY
>BINEND   DS     0H
>         ICM    SSRDETRG,X'F',FDBNTRY   WAS ANY ENTRY LOWER OR EQUAL?
>         BP     CHKRETNT                YES - EXIT ROUTINE
>         .
>         .
>EXCLKP   CLC    LKPFCTLS(1),AXBLDFTL    COMPARE REQUEST VS RECORD
>         .
>         .
>         .
>SSRDETRG EQU    6
>WORKREG  EQU    7
>FDBNTRY  DC     A(0)
>NTRYLEN  DC     H'0'
>         .
>         .

>My question involves the ICM instruction and the BP following it.  I
>have been unable to find any documentation in any manual I have looked
>at that says the ICM instruction sets the condition code.  And I've
>found that BP is valid only after arithmetic instructions.  If
>anything, the branch after an ICM should be BO or BM or BNO etc based
>on the fact that a TM instruction does set the condition code.  Can
>any of you confirm that the ICM does or does not set the condition
>code?  Thanks in advance for any and all help.

>Regards,

>          ////
>         (o o)
>-oOO--(_)--OOo-
>I love defenseless animals, especially in good gravy.
> Steve



Sat, 25 Nov 2000 03:00:00 GMT  
 ICM - Set Condition Code?

Quote:

> ICM is great for testing a 4-byte label (aligned or unaligned), such
>  as EIBTRMID:

>     ICM    R1,B'1111',EIBTRMID    DOES A TERMINAL EXIST?
>     BNZ    CICSRETN               YES, ELVIS HAS LEFT THE BUILDING

> CICSRETN    DS    0H

>             EXEC  CICS RETURN,

This use of ICM for a checking a field for zeros is new to me.
*Sounds* like it should be speedier than the method *I* have used
all these years:

      NC    EIBCALEN,EIBCALEN       Is there a COMMAREA?
      BZ    No#CommA                No, this is 1st entry
      ..
The point in favor of NC of course is that it can be used to check
any sized field (up to 256 bytes) fo hex zeros.

Regards,
Bal
-----

http://www.geocities.com/~oberoi/mainfrme.html
-----
"The universe is full of magical things,
patiently waiting for our wits to grow sharper." - Eden Phillpotts



Sun, 26 Nov 2000 03:00:00 GMT  
 ICM - Set Condition Code?

Quote:

> This use of ICM for a checking a field for zeros is new to me.

Geez, where've you been???

Quote:
> *Sounds* like it should be speedier than the method *I* have used
> all these years:

>       NC    EIBCALEN,EIBCALEN       Is there a COMMAREA?
>       BZ    No#CommA                No, this is 1st entry
>       ..
> The point in favor of NC of course is that it can be used to check
> any sized field (up to 256 bytes) fo hex zeros.

This could 0C4 if the storage is not read/write-able to the program.
I've seen OC used before for this purpose, but not NC. I suppose that
either one would work. (I wonder if the OC/NC with identical operands
was ever fast-pathed?)

Used to be, in the days of yore, that a sequence of L/LH followed
by Load-And-Test was faster than the ICM. But now that's not the
case; ICM is just as fast as Load.

--
Bill



Sun, 26 Nov 2000 03:00:00 GMT  
 ICM - Set Condition Code?


insane enough to write:

Quote:

>> ICM is great for testing a 4-byte label (aligned or unaligned), such
>>  as EIBTRMID:

>>     ICM    R1,B'1111',EIBTRMID    DOES A TERMINAL EXIST?
>>     BNZ    CICSRETN               YES, ELVIS HAS LEFT THE BUILDING

>> CICSRETN    DS    0H

>>             EXEC  CICS RETURN,

>This use of ICM for a checking a field for zeros is new to me.
>*Sounds* like it should be speedier than the method *I* have used
>all these years:

>      NC    EIBCALEN,EIBCALEN       Is there a COMMAREA?
>      BZ    No#CommA                No, this is 1st entry
>      ..
>The point in favor of NC of course is that it can be used to check
>any sized field (up to 256 bytes) fo hex zeros.

>Regards,
>Bal
>-----

>http://www.geocities.com/~oberoi/mainfrme.html
>-----
>"The universe is full of magical things,
>patiently waiting for our wits to grow sharper." - Eden Phillpotts

Much thanks to Edward, Gilbert, Glen and WOB for all the information.
Unfortunately I don't have access to the Principles of Operation
manual, so I couldn't use it in my research.  I only have my
handy-dandy yellow card and an MVS Assembler Language book from
McQuillen Prince.  Even after 20 years coding Assembler and Cobol one
can still learn new things.

Regards,

          ////
         (o o)
-oOO--(_)--OOo-
Support bacteria - they're the only culture some people have.
 Steve



Sun, 26 Nov 2000 03:00:00 GMT  
 ICM - Set Condition Code?


Quote:

>> ICM is great for testing a 4-byte label (aligned or unaligned), such
>>  as EIBTRMID:

>>     ICM    R1,B'1111',EIBTRMID    DOES A TERMINAL EXIST?
>>     BNZ    CICSRETN               YES, ELVIS HAS LEFT THE BUILDING

>> CICSRETN    DS    0H

>>             EXEC  CICS RETURN,

>This use of ICM for a checking a field for zeros is new to me.
>*Sounds* like it should be speedier than the method *I* have used
>all these years:

>      NC    EIBCALEN,EIBCALEN       Is there a COMMAREA?
>      BZ    No#CommA                No, this is 1st entry
>      ..
>The point in favor of NC of course is that it can be used to check
>any sized field (up to 256 bytes) fo hex zeros.

The problem with NC and OC is that you can't use them against storage
in a different protect key.  In that case you can try ICM if you have
a spare register, or you're forced to use CLC or CLCL.

LAter,
Ray

--
M. Ray Mullins (http://www.lerctr.org/~mrm/) from Roseville, California
(which has better transit service than Arlington TX, and 1/5 the population)
TIPs: http://socaltip.lerctr.org, norcaltip.lerctr.org, cencaltip.lerctr.org



Sun, 26 Nov 2000 03:00:00 GMT  
 ICM - Set Condition Code?

(snip related to NC/OC and not ICM)

Quote:
>Used to be, in the days of yore, that a sequence of L/LH followed
>by Load-And-Test was faster than the ICM. But now that's not the
>case; ICM is just as fast as Load.

P of Op. specifies that the condition code with mask X'F' is just like
L and LTR, suggesting that one should use it.  Though P of Op. rarely
suggests that some code is faster than some other code.  It would be
interesting to know in which edition this note appeared.  

I always believed that ICM appeared because of the need to load AL3()
address constants (in 24 bit addressing days).  
In that case, it should at least be faster than L R,somewhere  N R,=X'00FFFFFF'

-- glen



Sun, 26 Nov 2000 03:00:00 GMT  
 ICM - Set Condition Code?

Quote:

>Much thanks to Edward, Gilbert, Glen and WOB for all the information.
>Unfortunately I don't have access to the Principles of Operation
>manual, so I couldn't use it in my research.  I only have my
>handy-dandy yellow card and an MVS Assembler Language book from
>McQuillen Prince.  Even after 20 years coding Assembler and Cobol one
>can still learn new things.
>Regards,

I believe that this is on the yellow card.  At least it should be.  

As I don't have a yellow card here, or POp, I use:

http://ppdbooks.pok.ibm.com/cgi-bin/bookmgr/bookmgr.cmd/BOOKS/DZ9AR00...

(put a bookmark in your web browser).

-- glen



Sun, 26 Nov 2000 03:00:00 GMT  
 ICM - Set Condition Code?

Quote:

> .... I don't have access to the Principles of Operation
> manual, so I couldn't use it in my research.  I only have my
> handy-dandy yellow card and an MVS Assembler Language book from
> McQuillen Prince

It can be a bit slow, but POP *is* accessible over the web:
http://ppdbooks.pok.ibm.com:80/cgi-bin/bookmgr/bookmgr.cmd/BOOKS/DZ9A...

Regards,
Bal
-----

http://www.geocities.com/~oberoi/mainfrme.html
-----
"The universe is full of magical things,
patiently waiting for our wits to grow sharper." - Eden Phillpotts



Sun, 26 Nov 2000 03:00:00 GMT  
 ICM - Set Condition Code?


says...

Quote:

> > This use of ICM for a checking a field for zeros is new to me.

> Geez, where've you been???

> > *Sounds* like it should be speedier than the method *I* have used
> > all these years:

> >       NC    EIBCALEN,EIBCALEN       Is there a COMMAREA?
> >       BZ    No#CommA                No, this is 1st entry
> >       ..
> > The point in favor of NC of course is that it can be used to check
> > any sized field (up to 256 bytes) fo hex zeros.

> This could 0C4 if the storage is not read/write-able to the program.
> I've seen OC used before for this purpose, but not NC. I suppose that
> either one would work. (I wonder if the OC/NC with identical operands
> was ever fast-pathed?)

> Used to be, in the days of yore, that a sequence of L/LH followed
> by Load-And-Test was faster than the ICM. But now that's not the
> case; ICM is just as fast as Load.

> --
> Bill

If storage is not write-protected, NC is also slower since the CPU
needs to write the "updated" storage back out the the cache and main
storage. ICM only requires fetch, no store.

--
Robert Ngan
CSC Financial Services Group



Sun, 26 Nov 2000 03:00:00 GMT  
 ICM - Set Condition Code?

: This use of ICM for a checking a field for zeros is new to me.
: *Sounds* like it should be speedier than the method *I* have used
: all these years:

:       NC    EIBCALEN,EIBCALEN       Is there a COMMAREA?
:       BZ    No#CommA                No, this is 1st entry
:       ..
: The point in favor of NC of course is that it can be used to check
: any sized field (up to 256 bytes) fo hex zeros.

These two techniques are not the least bit similar and should be used for
completely different purposes.  Using NC (or OC) requires WRITE ACCESS to
the storage.  This is a MAJOR restriction.  You can't use this technique
to check if a word in, say the MVS CVT, is non-zero.  Also, after your
test, if the data is non-zero and it's a word you want loaded, you have to
turn around and issue the L instruction anyway.  The NC/L takes 10 bytes.

ICM on a 4-byte area replaces the L/LTR sequence.  After the ICM is done,
the address is in a register and the condition code is set.  The ICM takes
only 4 bytes (a 60% savings over NC/L and only requires read access to the
storage).

--
| Edward E. Jaffe                | Voice:      (310) 338-0400 x318     |
| Mgr., Research & Development   | Facsimile:  (310) 338-0801          |

| 9841 Airport Blvd, Suite 700   | IBM Mail:   USS24J24 at IBMMAIL     |        
| Los Angeles, CA 90045          | Web page:   www.phoenixsoftware.com |



Sun, 26 Nov 2000 03:00:00 GMT  
 ICM - Set Condition Code?


- ICM on a 4-byte area replaces the L/LTR sequence.  After the ICM is done,
- the address is in a register and the condition code is set.  The ICM takes
- only 4 bytes (a 60% savings over NC/L and only requires read access to the
- storage.

I think that, for the most part, readability is more important than code
size, so for writable fields of over four bytes, I like NC or OC better.



Sun, 26 Nov 2000 03:00:00 GMT  
 
 [ 51 post ]  Go to page: [1] [2] [3] [4]

 Relevant Pages 

1. Killing yourself with Virtual Storage (was ICM - Set Condition code?)

2. Track for last record after set filter to a condition

3. How to set initial value depending on condition

4. Splitting 'and' conditions into multiple conditions

5. Order of evaluation of conditions in a combined condition

6. Order of evaluation of conditions in a combined condition/PMAP

7. Pre-condition vs. Post-condition

8. Pre-condition vs. Post-condition

9. Pre-condition vs Post-condition

10. "BIG E vs little e", was pre-condition vs post-condition

11. pre-condition vs post-condition

12. Pre- and post-conditions (was Commenting code)

 

 
Powered by phpBB® Forum Software