Solved
Assembly Language: multiplying
Posted on 2007-04-11
I am writing a program in MIPS assembly language with PCSpim. I want it to be able to Divide. Here is what I have. Any suggestions?
.data
.globl firstNum
.globl secondNum
firstNum: .asciiz"\nWhat is the First Number?\n"
secondNum: .asciiz"\nWhat is the Second Number?\n"
space: .asciiz"\n"
remainder: .asciiz" Remainder: "
.text
.globl main
main:
addu $s7, $0, $ra
#Queries user for first number
li $v0, 4
la $a0, firstNum
syscall
li $v0, 5
syscall
add $t1,$v0,$zero
#Asks for the second number
li $v0, 4
la $a0, secondNum
syscall
li $v0, 5
syscall
add $t2,$v0,$zero
div $t1,$t2
mfhi $t4
mflo $t5
#Space
li $v0, 4
la $a0, space
syscall
add $a0,$t5,$zero
li $v0, 1
syscall
#Remainder
li $v0, 4
la $a0, remainder
syscall
add $a0,$t4,$zero
li $v0, 1
syscall
addu $ra, $0, $s7
jr $ra
add $0, $0, $0