How to create Conditional Loops ?



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

How to create Conditional Loops ?

Postby noha_nabil » Sun Jul 01, 2012 5:47 pm

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.
noha_nabil
 
Posts: 14
Joined: Wed Jun 27, 2012 4:46 pm
Has thanked: 5 times
Been thanked: 0 time

Re: How to create Conditional Loops ?

Postby noha_nabil » Sun Jul 01, 2012 6:08 pm

I am working with IBM System VSE/ESA System 390.
noha_nabil
 
Posts: 14
Joined: Wed Jun 27, 2012 4:46 pm
Has thanked: 5 times
Been thanked: 0 time

Re: How to create Conditional Loops ?

Postby steve-myers » Sun Jul 01, 2012 9:39 pm

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
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: How to create Conditional Loops ?

Postby noha_nabil » Mon Jul 02, 2012 6:47 pm

steve-myers, Thank you.
noha_nabil
 
Posts: 14
Joined: Wed Jun 27, 2012 4:46 pm
Has thanked: 5 times
Been thanked: 0 time


Return to Assembler

 


  • Related topics
    Replies
    Views
    Last post