go to previous page   go to home page   go to next page

How could you compute 4× $8 + $8 ?

Answer:

Multiply $8 by four by shifting left two positions, then add it the original $8 .

Example Program

Here is the program. Unfortunately, there are a few blanks. This would be a good time to use that scratch pad and pencil next to your keyboard.

## slowMult.asm
## 
## Program to calculate 5 × x - 74
##
## Register Use:
##  $8   x
##  $9   result

        .text
        .globl  main

main:
        ori      $8, $0, 12           # put x into $8
        
        sll      $, $,       # $ <—— 4x
        
        addu     $, $, $     # $ = 5x
        
        addiu    $, $,-74         # $ = 5x - 74

## End of file

QUESTION 13:

Fill in the blanks to finish the program. The final result should be in register $9 .