Page 1 of 1

Help in knowing when a subroutine is executed.

PostPosted: Mon Dec 12, 2016 10:42 pm
by ramkumar1992sp
Hello,

First of all,I'm sorry about asking so many questions over the last few days.

My question is as below.

In the program below,
After the LTR instruction in GETSEM routine,there is a BP NEXTSEM instruction.Now in NEXTSEM routine,there is BCT R8,GETSEM.

My question is when R8 becomes zero which instruction would be executed next ? Would the control come back to instruction after BP NEXTSEM which is PERLOOP BR RC or would the NEXTMEET AH R8,SIX instruction be executed ?

I'm trying to understand when PERLOOP BR RC instruction is executed.




      PUNCH '      ALIAS  XXXQ71S2'                                  00001100
XXXQ71S1 START 0                                                        00001200
         ENTRY XXXQ71S2                                                 00001300
         EXTRN XXXQVLST                                                 00001400
         USING *,15                                                     00001500
         B     COIBMEND                                                 00001600
*                                                                       00001700

*                                                                       00002000
R0       EQU   0                                                        00002100
R1       EQU   1                            ADDR OF STUDENT ARRAY --    00002200
*                                               ASSIGNED DAYS           00002300
R2       EQU   2                            ADDR OF MEETING TIME TABLE  00002400
R3       EQU   3                            ADDR OF LOOP CONTROL DATA   00002500
R4       EQU   4                            ADDR OF CLASS RECORD        00002600
R5       EQU   5                                                        00002700
R6       EQU   6                                                        00002800
R7       EQU   7                                                        00002900
R8       EQU   8                                                        00003000
R9       EQU   9                                                        00003100
RA       EQU   10                                                       00003200
RB       EQU   11                                                       00003300
RC       EQU   12                           BR REG FOR BIT OPERATION    00003400
RD       EQU   13                                                       00003500
RE       EQU   14                           BR REG FOR NEXT INSTRUCTION 00003600
RF       EQU   15                                                       00003700
*                                                                       00003800
COIBMEND EQU   *                                                        00003900
         SAVE  (14,12)                                                  00004000
         L     RA,=A(XXXQVLST)              LOAD ADDR OF PARAMETER LIST 00004100
         LM    R1,R4,0(RA)                                              00004200
         LA    RF,XXXQ71S2                                              00004300
         USING XXXQ71S2,RF                                              00004400
         LA    RC,TESTBITS                  POINT BR REG TO TM INST     00004500
         LA    RE,ASGNBITS                                              00004600
         B     STARTOP                                                  00004700
XXXQ71S2 SAVE  (14,12)                                                  00004800
         L     RA,=A(XXXQVLST)              LOAD ADDR OF PARAMETER LIST 00004900
         LM    R1,R4,0(RA)                                              00005000
         LA    RC,XORBITS                   POINT BR REQ TO XOR INST    00005100
         LA    RE,RETURNIT                                              00005200
STARTOP  LA    R6,1                         R6 = CONSTANT 1             00005300
         LH    R8,2(R3)                     LOAD LAST SEM BIT VALUE     00005400
         AR    R8,R6                           INCR LAST VALUE BY 1     00005500
         LH    RA,0(R3)                        LOAD FIRST SEM BIT VALUE 00005600
         SR    R8,RA                           SUBT FIRST FROM LAST     00005700
         STH   R8,HLDSEMS                   SAVE NUMB SEMS TO BE        00005800
*                                               PROCESSED               00005900
*                                                                       00006000
*                                                                       00006100
*                                  INIT SUBROUTINE FOR EACH BIT OPER    00006200
*                                                                       00006300
INIT     LH    RB,12(R4)                    LOAD INDEX TO MT TABLE      00006400
*                                               ENTRY                   00006500
         MH    RB,SIX                           MULT INDEX BY SIX       00006600
         AR    RB,R2                            ADD ADDR OF MT TABLE    00006700
         LH    R0,14(R4)                    LOAD NUMB OF MT ENTRIES     00006800
*                                                                       00006900
*                                  PROCESS EACH MT ENTRY CLASS MEETS    00007000
*                                                                       00007100
NEWMEET  MVC   TESTBITS+1(1),1(RB)          INSERT DAYS MET IN BIT      00007200
*                                               INSTRUCTIONS            00007400
         MVC   ORBITS+1(1),1(RB)                                        00007400
         MVC   XORBITS+1(1),1(RB)                                       00007500
         LH    R8,HLDSEMS                   R8 = NUMD SEMS TO PROCESS   00007600
         LH    RA,0(R3)                                                 00007700
         IC    R9,0(RB)                     INSERT SEM BITS IN REG 9    00007800
         SLL   R9,23(RA)                        SHIFT TO FIRST SEM BIT  00007900
         LR    RA,R1                        LOAD ADDR OF STUDN ARRAY    00008000
         LH    R7,4(RB)                     LOAD END PER OF MT ENTRY    00008100
         AR    R7,RA                            ADD ARRAY ADDR          00008200
*                                                                       00008205
*                                  PROCESS EACH SEM MT ENTRY MEETS      00008210
*                                                                       00008215
GETSEM   LH    R5,2(RB)                   LOAD START PER OF MT ENTRY    00008220
         AR    R5,RA                            ADD ARRAY ADDR          00008225
         SLL   R9,1                         SHIFT SEM BIT TO SIGN       00008230
*                                               POSITION                00008235
         LTR   R9,R9                       TEST SEM BIT VALUE           00008240
         BZ    NEXTMEET                         NO SEM BITS LEFT        00008245
         BP    NEXTSEM                          SEM BIT = 0             00008250
*                                                                       00008300
*                                  PROCESS ALL PERIODS FOR EACH SEM     00008400
*                                                                       00008500
PERLOOP  BR    RC                           BRANCH TO BIT INSTRUCTIONS  00008600
*                                           TESTBITS - CHECK CONFLICTS  00008605
*                                           ORBITS - ASSIGN SECTION     00008610
*                                           XORBITS - UNASSIGN SECTION  00008615
TESTBITS TM    0(R5),X'00'                  TEST ARRAY FOR CONFLICT     00008700
         BC    5,SETCONFL                                               00008800
LOOPCTL  BXLE  R5,R6,PERLOOP                INCR TO NEXT PERIOD         00008900
*                                                                       00009000
*                                  INCR TO NEXT SEM MT ENTRY MEETS      00009100
*                                                                       00009200
NEXTSEM  AH    RA,4(R3)                                                 00009300
         AH    R7,4(R3)                                                 00009400
         BCT   R8,GETSEM                    ARE ALL SEMESTERS PROCESSED 00009500
*                                                                       00009600
*                                  INCR TO NEXT MT ENTRY CLASS MEETS    00009700
*                                                                       00009800
NEXTMEET AH    RB,SIX                                                   00009900
         BCT   R0,NEWMEET                   ARE ALL MT ENTRIES PROCESSD 00010000
         BR    RE                                                       00010100
SETCONFL MVI   16(R4),C'Y'                  TURN ON CONFLICT SWCH       00010200
RETURNIT RETURN (14,12),RC=0                RETURN TO MAIN LINE     1-5 00010300
*                                                                       00010400
*                                  PROCESS NON CONFLICTING CLASS        00010500
*                                                                       00010600
ASGNBITS LA    RC,ORBITS                    POINT BR REG TO OR INSTR    00010700
         LA    RE,RETURNIT                                              00010800
         B     INIT                                                     00010900
ORBITS   OI    0(R5),X'00'                  ASSIGN MT ENTRY TO STUDN    00011000
*                                               ARRAY                   00011100
         B     LOOPCTL                                                  00011200
*                                                                       00011300
*                                  BACK OUT PERVIOUS ASSIGNMENTS        00011400
*                                                                       00011500
XORBITS  XI    0(R5),X'00'                  UNASSIGN MT ENTRY FROM      00011600
*                                               ARRAY                   00011700
         B     LOOPCTL                                                  00011800
SIX      DC    H'6'                                                     00012000
HLDSEMS  DC    H'0'                                                     00012100
         END                                                            00012200
/*

Re: Help in knowing when a subroutine is executed.

PostPosted: Tue Dec 13, 2016 12:43 am
by Robert Sample
Have you read the documentation on the BCT instruction? If so, you would KNOW -- and not have to guess -- that the next instruction executed when the register becomes zero is THE NEXT INSTRUCTION AFTER THE BCT. And if you haven't read the documentation on it, then why ask here before you start reading?

Re: Help in knowing when a subroutine is executed.

PostPosted: Tue Dec 13, 2016 3:18 am
by ramkumar1992sp
Thanks for the reply Robert.I had read about BCT before posting the question..
If the result is zero, execution continues with the instruction following the BCT"
...

But my main concern was/is with
PERLOOP  BR    RC
I was/still trying to find out how that is executed.I thought may be "BP NEXTSEM" stores the address of the next instruction and then once NEXTSEM subroutine with BCT as its last instruction is executed,It comes back to this next instruction.

Now it looks
PERLOOP  BR    RC
is executed only when LTR gives a condition code of 1 (negative).

Re: Help in knowing when a subroutine is executed.

PostPosted: Tue Dec 13, 2016 3:49 am
by Robert Sample
Yes, only when the LTR indicates the result is negative will the PERLOOP BR RC be executed. This result does not depend upon any other instruction -- just the LTR R9,R9.

Re: Help in knowing when a subroutine is executed.

PostPosted: Tue Dec 13, 2016 4:01 am
by ramkumar1992sp
Thanks Robert..

So far whatever I read about SLL doesn't indicate that it can make the contents of R9 negative..After we shift bits,the least value possible is 0.Correct ?

       SLL   R9,1                      
         LTR   R9,R9                  



Question is would SLL R9,1 make R9 negative so that LTR R9,R9 yields a condition code of 1 (Negative) ?

Re: Help in knowing when a subroutine is executed.

PostPosted: Tue Dec 13, 2016 6:16 am
by Robert Sample
Remember a register is a full-word binary value; hence if bit 0 is a 1 the value is considered negative. If bit 1 is 1 and SLL R9,1 is executed then R9 suddenly has a negative value.

Re: Help in knowing when a subroutine is executed.

PostPosted: Tue Dec 13, 2016 11:16 am
by ramkumar1992sp
Thanks Robert.You have been of immense help!!