[comp.lang.asm370] Why use an LA instruction?

PGIFFORD@ALLEGVM.BITNET (Pete Gifford) (03/04/91)

I was disassembling a program (not copyrighted!) a while ago and found it
starting with the instructions below.  I understand all of it but the LA.
Can someone shed some light on its purpose?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Pete Gifford           PGIFFORD@ALLEGVM
Systems Manager        PETE@MUSIC.ALLEG.EDU
Allegheny College      (814) 332-5304
Meadville, PA          (814) 332-5366


PROGRAM  BALR  4,0                load base register
         BCTR  4,0                back off one byte to point
         BCTR  4,0                to label at start of program
         LA    4,0(0,4)           ???????

XRJDM@SCFVM.BITNET (Joe McMahon) (03/05/91)

This practice (LA 4,0(0,4)) is Not Recommended in these days of MVS/XA
and 31-bit addressing. On a 24-bit (MVS/370-mode) machine, this would
clear out the high byte (which has stuff put in it by the BALR
instruction - I've forgotten what, exactly, now). On a 31-bit machine,
it simply clears the high bit.

In the current case, it might not be so bad. But why the programmer
didn't just use LR R4,R15 / USING WHATNOT,R4 is beyond me. Perhaps
this is an entry into the Unclear Assembler contest? :-)

 --- Joe M.

REICHETZ@AWIIMC12.BITNET (Christian Reichetzeder) (03/05/91)

On Mon, 4 Mar 91 10:38:14 GMT Pete Gifford said:
>..starting with the instructions below. I understand all of it but the LA.
>Can someone shed some light on its purpose?
>PROGRAM  BALR  4,0                load base register
>         BCTR  4,0                back off one byte to point
>         BCTR  4,0                to label at start of program
>         LA    4,0(0,4)           ???????
Whoever wrote this had something in mind - there're rumors that there's been a
time when one of the major goals  in software writing was "just to confuse the
Russians".
Well, the  LA clears bits 0-7  (24bit mode) or  bit 0 (31bit mode)  to zeroes.
Still this  could be  done without  the BCTR instruction  (given that  you are
happy with the base register offset 2 bytes from the entry point).
Christian

cfor%CIBA-GEIGY.CH@OHSTVMA.IRCC.OHIO-STATE.EDU ("", Rainer Foeppl) (03/07/91)

RFC-822-HEADERS:
Newsgroups: comp.lang.asm370
Organization: Ciba-Geigy AG, Basel, Switzerland

==================

hello

the only effect of the la instruction is to clear bit 0-7, if you are in 24-
bit - addressing mode. if you are in 31-bit addressing mode, then it clears
only bit 0.

if you have any more questions, look at the ibm manual pricnciples of
 operation (sa22-7200-0). there you will find explanations to all valid
instructions of the ibm 370 and 390 architexture.

regards
rainer

foster@ted.cs.uidaho.edu (03/08/91)

It's a trick.  BALR loads the program mask into the lowest nibble of r4...or it used to.   I'll bet the LA 4,0(0,4) is just there to zero out the program mask.
This is not good code, as the program mask being loaded depends on the operating
systems (doesn't work that way in MVS/XA or MVS/ESA).

James 

foster@TED.CS.UIDAHO.EDU (03/08/91)

It's a trick.  BALR loads the program mask into the lowest nibble of r4...or it
        used to.   I'll bet the LA 4,0(0,4) is just there to zero out the
        program mask.
This is not good code, as the program mask being loaded depends on the operating
systems (doesn't work that way in MVS/XA or MVS/ESA).

James

USERALVE@RPITSMTS.BITNET (Brian Eliot) (03/08/91)

If the instruction

         LA    x,0(0,x)

is understood to mean "zero all non-address bits in register x" then
it works perfectly well for all addressing modes and all operating
systems.  In fact it is the best way to accomplish this since it
automatically adjusts to the addressing mode being used.

Brian Eliot
Information Technology Services
Rensselaer Polytechnic Institute

gah@hood.hood.caltech.edu (Glen Herrmannsfeldt) (03/11/91)

PGIFFORD@ALLEGVM.BITNET (Pete Gifford) writes:

>I was disassembling a program (not copyrighted!) a while ago and found it
>starting with the instructions below.  I understand all of it but the LA.
>Can someone shed some light on its purpose?
>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>Pete Gifford           PGIFFORD@ALLEGVM
>Systems Manager        PETE@MUSIC.ALLEG.EDU
>Allegheny College      (814) 332-5304
>Meadville, PA          (814) 332-5366


>PROGRAM  BALR  4,0                load base register
>         BCTR  4,0                back off one byte to point
>         BCTR  4,0                to label at start of program
>         LA    4,0(0,4)           ???????

Well, I believe it throws away the 8 high order bits.

At least it used to, I don't know about in XA.