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:10
Wilson company paid $5,000 for a 4-month insurance premium in advance on november 1, with coverage beginning on that date. the balance in the prepaid insurance account before adjustment at the end of the year is $5,000, and no adjustments had been made previously. the adjusting entry required on december 31 is: (a) debit cash. $5,000: credit prepaid insurance. $5,000. (b) debit prepaid insurance. $2,500: credit insurance expense. $2500. (c) debit prepaid insurance. $1250: credit insurance expense. $1250. (d) debit insurance expense. $1250: credit prepaid insurance. $1250. (e) debit insurance expense. $2500: credit prepaid insurance. $2500.
Answers: 1
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 22:00
Miami incorporated estimates that its retained earnings break point (bpre) is $21 million, and its wacc is 13.40 percent if common equity comes from retained earnings. however, if the company issues new stock to raise new common equity, it estimates that its wacc will rise to 13.88 percent. the company is considering the following investment projects: project size irr a $4 million 14.00% b 5 million 15.10 c 4 million 16.20 d 6 million 14.20 e 1 million 13.42 f 6 million 13.75 what is the firm's optimal capital budget?
Answers: 3
question
Business, 23.06.2019 00:10
Many years ago, sprint telecommunications aired an advertisement intended to demonstrate the clarity of reception sprint customers could expect. the ad showed a rancher, who had used a different company, complaining that he had ordered 100 oxen from his supplier and instead received 100 dachshunds. the mix-up was probably due to the presence of in the communication process.
Answers: 3
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
Mathematics, 24.06.2020 21:01
question
Mathematics, 24.06.2020 21:01
question
Mathematics, 24.06.2020 21:01
question
Biology, 24.06.2020 21:01
Questions on the website: 13722359