In: Computer Science
Create a MIPS program that will "hard code an integer" (meaning declared in .data) and read in another integer, multiply them together, and print out the results.
Used MARS 4.5 Version
code below ::
.data
var1: .word 3 #A hard code integer declared in .data using
word
prompt: .asciiz "Enter your number"
.text
addi $s1,$zero,0 #clear $s1 register
lw $s1,var1 #load contents of Ram
location into register $s1
#to display the prompt
li $v0,4 #used for display
la $a0,prompt #$a0 used for argument to be
displayed
syscall
li $v0,5 #get input from the user (read in
user input)
syscall
move $t0,$v0 #move the input integer to
$t0
mul $t0,$s1,$t0 #multiply
contents of $s1 and $t0 and store it in $t0
#display the multiplied value
li $v0,1
add $a0,$zero,$t0
syscall
OUTPUT:
Execute the code by pressing F3 or compiling.