(MIPS Assembly language)
Ask user for two decimal numbers and save to memory (not registers). Multiply these two numbers using adding and shifting only, not the "mul" instruction and print the product to the user as both a base-10 and base-32 (again, no using div/mul/rem). Save the output to a txt file. The program should run 5 times, with no user input needed to continue the program.
Program:
.data
textout:.asciiz "please enter 2 numbers "
textout1:.asciiz "The product of the numbers in base10 is: "
textout2:.asciiz "\nThe product of the numbers in base32 is:
"
.text
main:
li $s2,0 #result initialized too zero
la $a0 textout #print prompt string
li $v0 4
syscall
li $v0 5
syscall
move $s0,$v0
li $v0 5
syscall
move $s1,$v0
j multiply
multiply: beqz $s1,end
andi $t1,$s1,1
beqz $t1,add_s
add $s2,$s2,$s0
add_s: sll $s0,$s0,1
srl $s1,$s1,1
j multiply
end: la $a0 textout1
li $v0 4
syscall
move $a0,$s2 #print result
li $v0,1
syscall
la $a0 textout2
li $v0 4
syscall
move $a0,$s2 #print result
li $v0,36
syscall
Output:
Get Answers For Free
Most questions answered within 1 hours.