1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
lianna [129]
3 years ago
15

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
Business
1 answer:
Vanyuwa [196]3 years ago
6 0

Answer:

Answer explained below

Explanation:

<u>Program </u>

#Data declaration part

.data

  #assign 2 values for f and g

  f_ten: .word 49026

  g_ten: .word 13122

  #Result display messages

  h_quotient: .asciiz "h_quotient = "

  h_remainder: .asciiz "h_remainder = "

  i_mod: .asciiz "i_mod = "

#Program starts here

.text

  #Get f and g values into s0 and s1 registers

  lw $s0,f_ten

  lw $s1,g_ten

  #find f+g and store in s2 register

  add $s2,$s0,$s1

  #Variables for quotient and remainder

  li $t0,0

  li $t1,0

#loop for division f/g

Div:

   ble $s0,0,nextComp

   #f-g

   sub $s0,$s0,$s1

   #quotient

   addi $t0,$t0,1

   #Remainder

   move $t1,$s0

   j Div

nextComp:

  beq $s0,0,printDiv

  #If f goes to negative then remainder and quotient change

  addi $t0,$t0,-1

  add $t1,$s0,$s1

#Display qoutient and remainder in f/g

printDiv:

  #Quotient display

  li $v0,4

  la $a0,h_quotient

  syscall

  li $v0,1

  move $a0,$t0

  syscall

  #Next line

  li $v0,11

  li $a0,10

  syscall

  #Remainder display

  li $v0,4

  la $a0,h_remainder

  syscall

   li $v0,1

  move $a0,$t1

  syscall

  #mod calculation

  li $t1,0

#Subtraction use to find mode

loopMod:

   ble $s2,0,nextMod

   sub $s2,$s2,$t0

   move $t1,$s2

   j loopMod

#if negative then add

nextMod:

   beq $s2,0,printMode

   add $t1,$t1,$s2

#Print mod details

printMode:

  li $v0,11

  li $a0,10

  syscall

  li $v0,4

  la $a0,i_mod

  syscall

  li $v0,1

  move $a0,$t1

  syscall

  #end of the program

  li $v0,10

  syscall

-----------------

Output

h_quotient = 3

h_remainder = 9660

i_mod = 0

-- program is finished running --

You might be interested in
What determines how the burden of tax is divided between buyers and sellers? Why?
Artemon [7]

Answer:

Explanation:

Taxation is the means by which the government  gets most of its  revenue so it is the duties of private or publicly owned organizations and also the citizen to pay their taxes used by the government to fund all its projects. the taxes generated by the government are then divided among buyers and sellers.

The elasticity of demand is the main determinant of how burden of tax is divided between buyers and sellers.

6 0
4 years ago
Read 2 more answers
If you draw a card with a value of three or less from a standard deck of cards, I will pay you $146. If not, you pay me $24. (Ac
Rainbow [258]

Answer: Expected value = $2.034

Explanation:

Total outcome = 52

Favorable Outcome = 8

Probability of drawing a card with a value of three or less = \frac{Favorable\ outcome}{Total\ outcome}

= \frac{8}{52}

=  \frac{2}{13}

Probability of drawing a card with a value of more than three = 1 -  \frac{2}{13}

=  \frac{11}{13}

Hence,

Expected value = 146 \times \frac{2}{13} + (-24) \times \frac{11}{13}

= 22.338 - 20.304

= $2.034

7 0
3 years ago
What are the leading economic indicators supposed to predict?
DiKsa [7]

The correct answer is: business cycle

6 0
3 years ago
Read 2 more answers
The purpose of a lease is _____.
REY [17]
The purpose of a lease is a rent. When you "lease" something, that's the business term of renting something ;-)
7 0
3 years ago
A company has net working capital of $0, current liabilities of $25 and total assets equal to $100. What is its current ratio?
kap26 [50]
I believe the answer is B) 1.0
6 0
4 years ago
Other questions:
  • Mirage Inc., a management consulting firm, plans to increase its profits by expanding its services to target new customers. It w
    15·1 answer
  • A merit rating system for SUTA means        A. FUTA will increase.   B. state rates will always be lower.   C. rate varies with
    14·1 answer
  • Sarah opened her last month's bank statement, today, to find she had an ending bank balance according to First Bank of Broad Rip
    14·1 answer
  • Drake enters into a contract with Eve, who claims to have access to a stock-trading algorithm that will multiply an investment m
    10·1 answer
  • a system of accounting for production operations that produces timely information about inventories and manufactyring cost per u
    15·1 answer
  • The economic principle that helps ensure that scarce resources are allocated efficiently is
    9·1 answer
  • Care sunt avantajele si dezavantajele serviciului de transport din bucuresti REATB
    9·1 answer
  • On its December 31, 2017, balance sheet, Calgary Industries reports equipment of $470,000 and accumulated depreciation of $94,00
    11·1 answer
  • The rate of unemployment when the economy is not in recession, meaning it is producing full-potential GDP, is called the natural
    9·1 answer
  • What would a central bank need to do to reverse the effects of a favorable supply shock on inflation? what would its reaction do
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!