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

Other questions on the subject: Business

image
Business, 22.06.2019 07:00, Maria3737
For the past six years, the price of slippery rock stock has been increasing at a rate of 8.21 percent a year. currently, the stock is priced at $43.40 a share and has a required return of 11.65 percent. what is the dividend yield? 3.20 percent 2.75 percent 3.69 percent
Answers: 3
image
Business, 22.06.2019 18:30, saneayahsimmons
What historical context does wiesel convey using the allusion of a fiery sky? he compares the sky to hell. the fires from air raids during world war ii the cremation of jews in the concentration camps the outbreak of forest fires from bombs in world war ii
Answers: 1
image
Business, 22.06.2019 20:00, krystynas799
In myanmar, six laborers, each making the equivalent of $ 2.50 per day, can produce 40 units per day. in china, ten laborers, each making the equivalent of $ 2.25 per day, can produce 48 units. in billings comma montana, two laborers, each making $ 60.00 per day, can make 102 units. based on labor cost per unit only, the most economical location to produce the item is china , with a labor cost per unit of $ . 05. (enter your response rounded to two decimal places.)
Answers: 3
image
Business, 22.06.2019 20:20, wavymoney77yt
Direct materials (4.2 x $15) $ 63direct labor ($12 x 17.5) $210manufacturing overhead ($2.40 x 17.5) $42total job cost $ 315dougan, inc. allocates overhead based on a predetermined overhead rate of $2.40 per direct labor hour. employees are paid $12.00 per hour. job 24 requires 4.2 pounds of direct materials at a cost of $15.00 per pound. employees worked a total of 17.5 hours to complete the job. actual manufacturing overhead costs totaled $80,000 for the year for the company. how much is the cost of job 24?
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 in other subjects:

Konu
Chemistry, 14.01.2021 20:10
Konu
Chemistry, 14.01.2021 20:10