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 13:40
Horace society is planning its annual western fair raceway gala. the gala committee has assembled the following expected costs for the event: dinner (per person) $10 gaming token and program (per person) $2 prize payouts $4,300 tickets and advertising $800 private box suite rental $1,700 lottery licenses $200 the committee members would like to charge $40 per person for the evening’s activities.required: 1. what is the break-even point for the dinner-dance (in terms of the number of persons who must attend)? 2. assume that last year only 200 persons attended the dinner-dance. if the same number attend this year, what price per ticket must be charged in order to break even? 3. refer to the original data ($40 ticket price per person). prepare a cvp graph for the dinner- dance from zero tickets up to 600 tickets sold.
Answers: 2
question
Business, 22.06.2019 19:00
In north korea, a farmer’s income is the same as a dentist’s income. in a country with a mixed or market economy, the difference between those two professions might be more than 5 times different. how can you explain the fact that individuals doing the same work in different countries do not earn comparable salaries?
Answers: 1
question
Business, 22.06.2019 23:00
Draw a flowchart for a process of interest to you, such as a quick oil-change service, a factory process you might have worked in, ordering a pizza, renting a car or truck, buying products on the internet, or applying for an automobile loan. identify the points where something (people, information) waits for service or is held in work-in-process inventory, the estimated time to accomplish each activity in the process, and the total flow time. evaluate how well the process worked and what might be done to improve it.
Answers: 2
question
Business, 22.06.2019 23:10
Which investment has the liquidity and can be converted into cash easily?
Answers: 2
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, 17.06.2020 14:57
question
Mathematics, 17.06.2020 14:57
question
Social Studies, 17.06.2020 14:57
question
Mathematics, 17.06.2020 14:57
question
Mathematics, 17.06.2020 14:57
Questions on the website: 13722360