22c:060 - Homework 4


    1. LIS     R1, #01       ; R1 = 1
      LIS     R2, #02       ; R2 = 2
      LIL     R3, #000003   ; (LIL is 2 halfwords)
                            ; R3 = 3
      MOVE    R4, R1        ; R4 = R1     (R4 = 1)
      ADDSI   R4, #03       ; R4 = R4 + 3 (R4 = 1 + 3 = 4)
      ADDI    R5, R2, #0003 ; R5 = R2 + 3 (R5 = 2 + 3 = 5)
      
      

    2. The final values in the registers after the instructions are run are:

      R1 1
      R2 2
      R3 3
      R4 4
      R5 5

    1. The contents of the memory locations after running the CONFUSE macro are:

      0x0100 2
      0x0104 1
      0x0108 4
      0x0112 3

    2. The macro CONFUSE saves the PC (initial memory location) in the variable confuse. The the PC is incremented (skips forward) by 1 word. A is stored in this memory location. The PC then goes back to the initial memory location that was saved in confuse. B is stored in this memory location. (The PC is incremented by 1 word automatically in the store as part of the fetch-execute cycle, so is at the location where A was stored.) The PC is incremented by 1 word so that it ends up at the memory location after A.