subject
Business, 07.03.2020 05:36 ghostboy2001

You are tasked to use the same positive integers from Part A to also compute: h = f/g; i = (f+g) MOD h_quotient; More formally, write MIPS code to output the result of above expression of h and i without using any built-in MIPS/MARS instructions for multiplication or division. The values already entered for Part A for a, b, c, and d shall be used. Output the value of h and i in {quotient with remainder} in a format as separate decimal integers. Indicate the denominator for the remainder. To receive credit, no multiplication, no division, and no shift instructions shall be used. Namely, do not use any of {mul, mul. d, mul. s, mulo, mulou, mult, multu, mulu, div, divu, rem, sll, sllv, sra, srav, srl, srlv}. The goal is to compose your own division technique. In addition, use of a loop is required for credit to realize the division code. It is part of the project points to design a way to realize division using a loop. Do not use of Macro, Subroutines, or Functions in this project. You can refer to the definition of division and how division works. For example, given a positive integer X, and a positive integer Y where X>Y then the division X/Y is computed such that unique integers Q and R satisify X=( Y * Q + R) where 0 ≤ R < Y. The value Q is called the quotient and R is called the remainder. Some examples are: {X = 7, Y = 2} then 7 = 2 * 3 + 1 so Q=3 and R=1 {X = 8, Y = 4} then 8 = 4 * 2 + 0 so Q=2 and R=0 {X = 13, Y = 5} then 13 = 5 * 2 + 3 so Q=2 and R=3

Sample output for Part B is:

f_ten = 49026

g_ten = 13122

h_quotient = 3

h_remainder = 9660

i_mod = 0

Please, may I have the c-language version of this program. I already solved it in MIPS language and it works.

thank you:

.data
#declare the variables
f: .word 49026
g: .word 13122
#Result display messages
f_ten: .asciiz "f_ten = "
g_ten: .asciiz "g_ten = "
h_quotient: .asciiz "h_quotient = "
h_remainder: .asciiz "h_remainder = "
i_mod: .asciiz "i_mod = "
newLine: .asciiz "\n"
#text section
.text

lw $s0,f #assign the value of f to $s0

li $v0,4 #print the string f_ten
la $a0, f_ten
syscall

li $v0,1 #print the value of f_ten
move $a0,$s0
syscall

li $v0,4 #print a new line
la $a0, newLine
syscall

lw $s1,g #assign the value of g to $s1

li $v0,4 #print the string g_ten
la $a0, g_ten
syscall

li $v0,1 #print the value of g
move $a0,$s1
syscall
li $v0,4

la $a0, newLine #print a new line
syscall

#find f+g and store in s2 register
add $s2,$s0,$s1
#assign the registers t0 and t1 with 0 for quotient and remainder
li $t0,0
li $t1,0

#loop for finding division f/g
findDivision:
#if $s0 is less than or equal to zero go to nextComp
ble $s0,0,next
sub $s0,$s0,$s1 # $s0 = f-g
move $t1,$s0 #store value of s0 to get the remainder.
addi $t0,$t0,1 #increment the value of $t0 to get the quotient
j findDivision

next:
beq $s0,0,printDivision
addi $t0,$t0,-1 #decrement the value $t0 by 1
add $t1,$s0,$s1 #add s0 and s1

#Prints the values of qoutient and remainder in f/g
printDivision:
#print the string h_quotient
li $v0,4
la $a0,h_quotient
syscall
#print the value $t0
li $v0,1
move $a0,$t0
syscall
#print a new line
li $v0,4
la $a0, newLine
syscall
#print the string h_remainder
li $v0,4
la $a0, h_remainder
syscall
#print the vale $t0 (h_remainder)
li $v0,1
move $a0,$t1
syscall

#assign $t1 to 0 for mod calculation
li $t1,0

#Subtraction use to find mode
calculateMod:
#if s2 value is less than equal to 0, then go to nextMod
ble $s2,0,nextMod
sub $s2,$s2,$t0 # s2 = s2-t0
move $t1,$s2 #store the value of $s2 in $t1
j calculateMod

#if negative then add
nextMod:
beq $s2,0,displayMod
add $t1,$t1,$s2

#displays the value of mod
displayMod:
#print a new line
li $v0,4
la $a0, newLine
syscall
#print the string i_mod
li $v0,4
la $a0,i_mod
syscall
#print the value of $t1 (i_mod)
li $v0,1
move $a0,$t1
syscall
#end of the program
li $v0,10
syscall

ansver
Answers: 1

Another question on Business

question
Business, 22.06.2019 11:20
Ardmore farm and seed has an inventory dilemma. they have been selling a brand of very popular insect spray for the past year. they have never really analyzed the costs incurred from ordering and holding the inventory and currently fave a large stock of the insecticide in the warehouse. they estimate that it costs $25 to place an order, and it costs $0.25 per gallon to hold the spray. the annual requirements total 80,000 gallons for a 365 day year.a. assuming that 10,000 gallons are ordered each time an order is placed, estimate the annual inventory costs.b. calculate the eoq.c. given the eoq calculated in part b., how many orders should be placed and what is the average inventory balance? d. if it takes seven days to receive an order from suppliers, at what inventory level should ardmore place another order?
Answers: 2
question
Business, 22.06.2019 16:30
Penelope summers received certain income benefits in 2018. she received $1,400 of state unemployment insurance benefits, $2,000 from a federal unemployment trust fund and $3,700 workers’ compensation received for an occupational injury. what amount of the compensation must penelope include in her income
Answers: 1
question
Business, 22.06.2019 20:00
With the slowdown of business, how can starbucks ensure that the importance of leadership development does not get overlooked?
Answers: 3
question
Business, 23.06.2019 01:00
"consists of larger societal forces that affect how a company engages and serves its customers."
Answers: 1
You know the right answer?
You are tasked to use the same positive integers from Part A to also compute: h = f/g; i = (f+g) MOD...
Questions
question
Social Studies, 16.11.2019 06:31
Questions on the website: 13722362