Page 1 of 1

How to create Conditional Loops ?

PostPosted: Sun Jul 01, 2012 5:47 pm
by noha_nabil
Dear All

I am now learning IBM Assembler Basics!

I have an issue but cannot resolve it.

I have a table stored in memory [ x1 , y1 , x2 , y2 , x3 , y3 ]

and I want to loop this table and check y1 or y2 or y3 if equal 25 or not?

if I found y1 or y2 or y3 = 25, I want to exit the loop.


Thanks and waiting your help.

Re: How to create Conditional Loops ?

PostPosted: Sun Jul 01, 2012 6:08 pm
by noha_nabil
I am working with IBM System VSE/ESA System 390.

Re: How to create Conditional Loops ?

PostPosted: Sun Jul 01, 2012 9:39 pm
by steve-myers
Your description is clear as mud. I presume the table is defined like this -
TABLE    DC    F'X1,Y1'
         DC    F'X2,Y2'
TABEND   DC    F'X3,Y3'
NUMTAB   EQU   (*-TABLE)/8

This definition will work for either example loop. The NUMTAB symbol calculates the number of entries in the table.

Most beginners are more comfortable with something like this -
         LA    3,TABLE
         LA    0,NUMTAB
         LA    1,25
LOOP1    C     1,4(,3)
         BE    FOUND
         LA    3,8(,3)
         BCT   0,LOOP1
         ...
FOUND    ...

More advanced programmers tend to prefer something like this -
         LA    3,TABLE
         LA    4,8
         LA    5,TABEND
         LA    1,25
LOOP2    C     1,4(,3)
         BE    FOUND
         BXLE  3,4,LOOP2
         ...
FOUND    ...

In both loops, register 1 is set to the test condition, Another way to code the test would be -
LOOP     L     1,4(,3)
         C     1,=F'25'
         BE    FOUND

Re: How to create Conditional Loops ?

PostPosted: Mon Jul 02, 2012 6:47 pm
by noha_nabil
steve-myers, Thank you.