pression f = g*23 to MIPs assembly language Assume that f and g are allocated in s0 an

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Translate the C expression f = g*23 to MIPs assembly language

Assume that f and g are allocated in s0 and s1.

do not use multiplication instruction.

Expert Solution
Program Explanation
  • Define the segment for mentioning the data variables/registers
  • Define registers $s0, $s1, 23, $t0 and $t1 and store them into the CPU with lw command
  • Define segment where the code will be present
  • Initialize the output to 0, register t0 to 1 and t1 to 0
  • Define the .loop segment
  • Define the Multiplication_loop function
  • Use beq to check if the multiplier is 0 or not.
  • Use and operator to get the LSB value when the multiplier is not 0
  • Use beq to add the multiplicand to the output only if LSB is not zero
  • Use beq to check if LSB is not zero, and if this satisfies then apply the multiplication shift function
  • Define Multipliction_do_add function
  • Immediately add the multiplicand to the result in this case and store it in the output register which is $s1
  • Define Multiplication_do_shift function
  • Use sll command to left shift the multiplicand
  • Use srl to right shift the multiplier
  • With j command return back to the multiplication loop
  • Return the output in the $s1 register with jr command.
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY