Instruction of the week - BXLE 
Author Message
 Instruction of the week - BXLE

Someone suggest we discuss an "instruction of the week". So I'll start.

I could never remember how to code BXLE. So being lazy I always relied
on the basic instructions even when BXLE would really be a better
choice. Then a friend showed me the following technique for doing a
table lookup with BXLE. It is really easy to remember.

         LM    R5,R7,TABLE
PIAS     DS    0H
         CLC   =C'THINGIE',0(R5)
         BE    FOUNDIT
         BXLE  R5,R6,PIAS
NOTFOUND DS    0H
FOUNDIT  DS    0H
         ...
TABLE    DC    A(FIRST,INCR,LAST)
FIRST    DS    0D
         DC    CL8'ABLE   ',A(1,2,3,4)
INCR     EQU   *-FIRST
         DC    CL8'BAKER  ',A(4,5,6,7)
         DC    CL8'THINGIE',A(1,2,3,4)
LAST     EQU   *-INCR

Do the Load Multiple for 3 registers starting with an odd register.
R15,R1 would even work because of wrap around. The registers get loaded
with the address of the first row, the length of a row (fixed) and the
address of the last row (not the byte after the end of the last row).

In my example the DC for A(1,2,3,4) etc. is just to demonstrate that
there can be multiple values declared in a row.

In a real program I wouldn't code the 0(R5). I would be using a DSECT.

Also note the use of the literal as the first parameter. Many
programmers still code this as:

         CLC 0(7,R5),=C'THINGIE'

I don't like it because it causes you to code the length. Too annoying
for my tastes.

--

Beyond Software, Inc.       http://www.*-*-*.com/
"Transforming Legacy Applications"



Mon, 04 Dec 2000 03:00:00 GMT  
 Instruction of the week - BXLE

I agree with Wayne.  However, IMO, it is safer to code

         CLC   =CL8'THINGIE',0(R5)

unless the idea is the match THINGIEA, THINGIE2, etc.  Of
course, you are still entering the length!

--Steve Myers


Quote:
>Someone suggest we discuss an "instruction of the week". So I'll start.
[snip]
>         CLC   =C'THINGIE',0(R5)
>         BE    FOUNDIT
[snip]
>Also note the use of the literal as the first parameter. Many
>programmers still code this as:

>         CLC 0(7,R5),=C'THINGIE'

>I don't like it because it causes you to code the length. Too annoying
>for my tastes.

>--

>Beyond Software, Inc.      http://www.beyond-software.com
>"Transforming Legacy Applications"

-- Steve Myers

The E-mail addresses in this message are private property.  Any use of them
to  send  unsolicited  E-mail  messages  of  a  commerical  nature  will be
considered trespassing,  and the originator of the message will be  sued in
small claims court in Camden County,  New Jersey,  for the  maximum penalty
allowed by law.



Mon, 04 Dec 2000 03:00:00 GMT  
 Instruction of the week - BXLE

BXLE or BXH could also be used for other things, such as stepping through a
string (incr=1) or deblocking a block of FB records (incr=lrecl). (I use BXH
for deblocking data or directory entries retrieved from the LIBR access macros
under VSE.)

And, yes, BXLE is perfect for sequentially searching a table!

Mark A. Young



Mon, 04 Dec 2000 03:00:00 GMT  
 Instruction of the week - BXLE

Quote:

> BXLE or BXH could also be used for other things, such as stepping through a
> string (incr=1) or deblocking a block of FB records (incr=lrecl). (I use BXH
> for deblocking data or directory entries retrieved from the LIBR access macros
> under VSE.)

> And, yes, BXLE is perfect for sequentially searching a table!

In a HLL course, I had an assignment to code a routine to generate
and display the first n Fibonacci numbers up to the max positive
integer of a 370. The next Fibonacci number, F[x] is
        F[x] = F[x-1] + F[x-2]
One usually begins with 0 and 1 and go on from there.
You get 0 1 1 2 3 5 ....

I was a good boy and did the assignment. The HLL listing showed
the equivalent assembler. It went on for pages. A lot of it was
symbols, not really working code, but even so, the working code
was a lot.

How could I do this in assembler, I asked myself. Then it hit me,
the BXLE, of course.

        LM      RI,RC,INIT  Load index, increment, and comparand
FIB     DS      0H
        XR      RI,RC   Swap index and increment
        XR      RC,RI
        XR      RI,RC
        PRINT   (RI)    (A convenient print macro)
        BXLE    RI,RA,FIB
DONE    DS      0H

INIT    F       1,0,MAXVAL

It's been so long since I did that assignment, I may not have it
quite right, but you know what I mean.

The instructor allowed that it was the tightest Fibonacci generator
offered to him by a student.

I also showed it to the guy who got me started programming (many many
years ago). He examined it for a few minutes, you do have to stop
to think. He handed me back my sample and said "Now, that's how
God meant computers to be programmed."

That was the highest praise I ever had.



Mon, 04 Dec 2000 03:00:00 GMT  
 Instruction of the week - BXLE

Quote:

> In a HLL course, I had an assignment to code a routine to generate
> and display the first n Fibonacci numbers up to the max positive
> integer of a 370. The next Fibonacci number, F[x] is
>         F[x] = F[x-1] + F[x-2]
> One usually begins with 0 and 1 and go on from there.
> You get 0 1 1 2 3 5 ....

> I was a good boy and did the assignment. The HLL listing showed
> the equivalent assembler. It went on for pages. A lot of it was
> symbols, not really working code, but even so, the working code
> was a lot.

> How could I do this in assembler, I asked myself. Then it hit me,
> the BXLE, of course.

>         LM      RI,RC,INIT  Load index, increment, and comparand
> FIB     DS      0H       ..RI,RA,RC        
>         XR      RI,RA   Swap index and increment
>         XR      RA,RI
>         XR      RI,RA
>         PRINT   (RI)    (A convenient print macro)
>         BXLE    RI,RA,FIB
> DONE    DS      0H

> INIT    DC      F'1,0,MAXVAL'

> It's been so long since I did that assignment, I may not have it
> quite right, but you know what I mean.

> The instructor allowed that it was the tightest Fibonacci generator
> offered to him by a student.

> I also showed it to the guy who got me started programming (many many
> years ago). He examined it for a few minutes, you do have to stop
> to think. He handed me back my sample and said "Now, that's how
> God meant computers to be programmed."

> That was the highest praise I ever had.

Minor corrections. It *has* been a long time.


Mon, 04 Dec 2000 03:00:00 GMT  
 Instruction of the week - BXLE


[Goetz gave us code for using BXLE to compute Fibonacci numbers.]

Thanks.  Nice example of non-traditional use of BXLE.

At one time I thought of using BXLE for a heap sort.  In the usual
heap sort, you go through a stage of repeatedly doubling an index.
It occured to me that you could use BXLE for this, where the register
being incremented, and the icrement amount, were both the same
register.

Alas, I never did write the program.  If the sort size was small, it
would not be worth the trouble.  And for large sorts, heap sort is a
poor algorithm in a virtual storage system due to bad page reference
behavior.



Mon, 04 Dec 2000 03:00:00 GMT  
 Instruction of the week - BXLE


Quote:

>Fibonacci numbers

Intriging! That is indeed the most creative use of BXLE I have seen!

Mark A. Young



Tue, 05 Dec 2000 03:00:00 GMT  
 Instruction of the week - BXLE

Bubble sort --

         LM    R3,R5,=A(START,LEN,END)
S0100    LR    R2,R3
         BXH   R2,R4,S0400
S0200    compare
         BC    whatever,S0300
         swap
S0300    BXLE  R2,R4,S0200
         BXLE  R3,R4,S0100
         DC    H'0'
S0400    .
         .

This works very well for small (e.g., less than 1000 elements) sorts,
mainly because of the the very low path count in the stepping instructions.
Yes, I have better sort subroutines in my collection, but for small sorts,
or where I'm in a hurry for a one shotter and don't want to figure out
how to call my better sort routines, this one works very, very well.  The
double BXLE I have always found intriguing.

-- Steve Myers

The E-mail addresses in this message are private property.  Any use of them
to  send  unsolicited  E-mail  messages  of  a  commerical  nature  will be
considered trespassing,  and the originator of the message will be  sued in
small claims court in Camden County,  New Jersey,  for the  maximum penalty
allowed by law.



Tue, 05 Dec 2000 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Instructions of the week -- LA and EX

2. Proposed D & DR instructions of the week

3. Instructions of the week -- LA and EX

4. Instruction for next week: BC

5. Instruction of the Week--LOCTR anyone?

6. Instruction of the week -- EDMK

7. BXLE R0,R0,* ?

8. Week number + firstDay of week

9. DAY OF THE WEEK ROUTINE - day-week.txt (1/1)

10. DAY OF THE WEEK ROUTINE - day-week.txt (0/1)

11. Instruction Speed and instruction availability

12. emclean gone for 2 weeks

 

 
Powered by phpBB® Forum Software