] > Conditional Branching

6.7 Conditional Branching

switch(i){  
   case 11.0:  temp = newtemp()  
               switch( INFO[top-4] ){  
       /*  = */  case  0: NEWQUAD(1, SYMTBL[ temp, 3],  
                                     SYMTBL[ INFO[top-5], 3],  
                                     SYMTBL[ INFO[top-3], 3])  
                          op = 6  
       /*  > */  case  1: NEWQUAD(1, SYMTBL[ temp, 3],  
                                     SYMTBL[ INFO[top-5], 3],  
                                     SYMTBL[ INFO[top-3], 3])  
                          op = 7  
       /*  < */  case  2: NEWQUAD(1, SYMTBL[ temp, 3],  
                                     SYMTBL[ INFO[top-3], 3],  
                                     SYMTBL[ INFO[top-5], 3])  
                          op = 7  
       /* >= */  case  3: NEWQUAD(1, SYMTBL[ temp, 3],  
                                     SYMTBL[ INFO[top-5], 3],  
                                     SYMTBL[ INFO[top-3], 3])  
                          NEWQUAD(0, SYMTBL[ temp, 3],  
                                     SYMTBL[ temp, 3],  
                                       - loc_of_1_in_int_tbl)  
                          op = 7  
       /* <= */  case  4: NEWQUAD(1, SYMTBL[ temp, 3],  
                                     SYMTBL[ INFO[top-3], 3],  
                                     SYMTBL[ INFO[top-5], 3])  
                          NEWQUAD(0, SYMTBL[ temp, 3],  
                                     SYMTBL[ temp, 3],  
                                       - loc_of_1_in_int_tbl)  
                          op = 7  
       /* <> */  case  5: NEWQUAD(1, SYMTBL[ temp, 3],  
                                     SYMTBL[ INFO[top-3], 3],  
                                     SYMTBL[ INFO[top-5], 3])  
                          NEWQUAD(6, ADDR+8,  
                                     SYMTBL[ temp, 3], 0)  
                          op = 5  
               }  
               switch( SYMTBL[ INFO[top], 2] ){  
                 case undef:  
                          SYMTBL[ INFO[top], 2] = future-label  
                          NEWQUAD(op, -1, SYMTBL[temp,3], 0)  
                          SYMTBL[ INFO[top], 3] = ADDR - 3  
                 case future_label:  
                          NEWQUAD(op, SYMTBL[ INFO[top], 3], SYMTBL[temp,3], 0)  
                          SYMTBL[ INFO[top], 3] = ADDR - 3  
                 case label:  
                          NEWQUAD(op, SYMTBL[ INFO[top], 3], SYMTBL[temp,3], 0)  
                 default:  
                          error()  
               }  
               top--  
   case 18.0:  
   case 19.0:  INFO[top] = 0  
}

11.<stat1> IF <expr> <relop> <expr> THEN GOTO <id>
18.<relop> <relop1>
19. =
                                   MEM  
                                  +-----+  
+--------+---------+------+       |  5  |  
| SYMBOL |   TYPE  | ADDR |    +->| -1  |  
+--------+---------+------+    |  |  -  |  
|        |         |      |    |  |  -  |  
|  L1    | forward |      |    |  +-----+  
|        |  label  |   -----+  |  |  .  |  
|        |         |      | |  |  |  .  |  
|        |         |      | |  |  |  .  |  
+--------+---------+------+ |  |  +-----+  
                            |  |  |  6  |  
                            |  +------  |<-+  
                            |     |  -  |  |  
                            |     |  -  |  |  
                            |     +-----+  |  
                            |     |  .  |  |  
                            |     |  .  |  |  
                            |     |  .  |  |  
                            |     +-----+  |  
                            |     |  7  |  |  
                            +---->|  ------+  
                                  |  -  |  
                                  |  -  |  
                                  +-----+  
                              L1: |     |  
                                  |     |






Instruction
Interpretation





5OP1LC OP1
6OP1OP2if MEM[OP2+BR]=0 then LC OP1
7OP1OP2if MEM[OP2+BR] >0 then LC OP1





The ‘op’ variable tells which MINI MACHINE branching instruction is to be used. The ‘temp’ variable represents the summary condition to be checked by the conditional branching instructions. For instance, in the case of the equality based L756 instruction

IF x = y THEN GOTO L

the temp variable is assigned the value

temp = y - x

and the MINI MACHINE instruction op = 6 checks the temp variable for a 0 value.