write a MIPS program that calculates d=a*b-a*c without using mult instruction --- just for practicing your MIPS assembly.

1. • Hint: use loop of additions to replace mult.
2. • Practice SPIM system calls to input values for a, b and c, as well as printout the value of d.

## All 3 Replies

If you signed up for piano lessons, but then decided that you didn't feel like taking them, would you ask somebody to go in your place?

``````###################################################
# author: Andor Pásztor
###################################################

#################################################
#		text segment	  								   #
#################################################
.text
.globl main
main:

la \$a0, str1
li \$v0, 4
syscall
li \$v0, 5
syscall
or \$t0, \$v0, \$v0

la \$a0, str2
li \$v0, 4
syscall
li \$v0, 5
syscall

la \$a0, str3
li \$v0, 4
syscall
li \$v0, 5
syscall

startMul: # mult loop
blez \$t7, endMult
sub \$t7, \$t7, 1
j startMul

endMult:
sub \$t5, \$t3, \$t4
la \$a0, str4
li \$v0, 4
syscall
move \$a0, \$t5
li \$v0, 1
syscall

li \$v0, 10
syscall

#################################################
#     	 	data segment								#
#################################################
.data

str1: .asciiz "input a = "
str2: .asciiz "input b = "
str3: .asciiz "input c = "
str4: .asciiz "The result is "``````

You can also use google groups.There is always many solutions to a problem.

``http://groups.google.com/``

Good luck.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.