Page 1 of 1

RX Instructions

PostPosted: Wed Dec 21, 2016 5:59 pm
by tanu_2302
Hi all,
I need clarification on the use of index Reg and displacement. When we use RX instruction, we define second operand by giving index,base and displacement. Can any one tell me how displacement and index works? why we are using them? Individual significance of index,displacement and base.
Thanks in advance :)

Re: RX Instructions

PostPosted: Wed Dec 21, 2016 7:54 pm
by steve-myers
The concept of calculating a data area address using a "displacement" and a "base register" is described in Assembler text books and I won't repeat this here.

When you specify an "index register" in an RX instruction the computer adds the contents of the register to the address computed by using the displacement and base register.

Re: RX Instructions

PostPosted: Fri Dec 30, 2016 8:13 pm
by steve-myers
The following program uses an index register twice -
INDEXR   RSECT
         USING *,2
         SAVE  (14,2)
         LR    2,15
         TIME  BIN
         SR    0,0
         STM   0,1,64(13)
         CVB   1,64(,13)
         D     0,=F'1000'
         LA    14,1900(,1)
         LR    15,14
         LR    1,0
         LA    0,B'11'
         NR    14,0
         BNZ   NOTLEAP
         D     14,=F'100'
         LTR   14,14
         BNZ   ISLEAP
         NR    15,0
         BZ    ISLEAP
NOTLEAP  CH    1,=AL2(31+28)
         BNH   ISLEAP
         LA    1,1(,1)
ISLEAP   IC    14,TAB1(1)  <- First use of an index register
         SLL   14,1
         SH    1,TAB2(14)  <- Second use of an index register
         LR    15,1
         RETURN (14,2),RC=(15)
         LTORG ,
TAB2     EQU   *-2
         DC    AL2(0)
         DC    AL2(31)
         DC    AL2(31+29)
         DC    AL2(31+29+31)
         DC    AL2(31+29+31+30)
         DC    AL2(31+29+31+30+31)
         DC    AL2(31+29+31+30+31+30)
         DC    AL2(31+29+31+30+31+30+31)
         DC    AL2(31+29+31+30+31+30+31+31)
         DC    AL2(31+29+31+30+31+30+31+31+30)
         DC    AL2(31+29+31+30+31+30+31+31+30+31)
         DC    AL2(31+29+31+30+31+30+31+31+30+31+30)
TAB1     EQU   *-1
         DC    31AL1(1),29AL1(2),31AL1(3)
         DC    30AL1(4),31AL1(5),30AL1(6)
         DC    31AL1(7),31AL1(8),30AL1(9)
         DC    31AL1(10),30AL1(11),31AL1(12)
         END   INDEXR

If someone out there makes an honest attempt to understand this program, what will be in register 15 when the program returns when it is run December 30, 2016?