Question

In MIPS In part 4 you must make an assembly program multiplies a stored value by...

In MIPS

In part 4 you must make an assembly program multiplies a stored value by 26 (start with Multiply.s). Note you CANNOT use the multiply command or a simple looped addition routine, you must write the solution to make use of shifts (both left and/or right) and at most three adds/subs to get the right multiplier of 26. You will print out your total when finished. Name your new file Lastname-Multiply.s Make sure you comment your code so I (and more so you) understand what you are doing

0 0
Add a comment Improve this question Transcribed image text
Answer #1

COPY TO CODE:

# Filename: Multiply.s
# Target: MIPS ISA Simulator
# Author:
# Description: Multiply a hardcoded register value by 30 using only shifts and a simple add
# store preloaded data here if needed (not used in this program).
.data
result_text: .asciiz "The value of the multiplication is: "
# Program body
.text
.globl main
main:

# initilization
addi $s0, $0, 5 # initialize $s0 = 5 Use this value to multiple by 30
sll $s1,$s0,5 #it will multiply number by 32 and store in s1
sll $s2,$s0,1 #it will multiply number by 2 and store in s2
#implement your multipliciation scheme
neg $s2,$s2 #set s2 to negative
add $s0,$s1,$s2 #now add both s1 and s2 and store to s0 32*number - 2*number = 30*number

# Print the result
li $v0,1
move $a0,$s0 #print result
syscall
# program exit

SNIPPET:

Add a comment
Know the answer?
Add Answer to:
In MIPS In part 4 you must make an assembly program multiplies a stored value by...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • MIPS ASSEMBLY PROGRAM: PLEASE Write in MIPS Assembly language. Take strings as input and calculate and...

    MIPS ASSEMBLY PROGRAM: PLEASE Write in MIPS Assembly language. Take strings as input and calculate and print a simple checksum for each string. Make your string long enough to hold 50 characters. Don't forget to leave space for the null byte. Our checksum algorithm will produce a value which you can print with the syscall for printing a character. Stop reading strings when the user enters ".". The syscall to read a string (sycall code 8) adds a newline to...

  • Translate the following C++ program into MAL (MIPS Assembly Langage). Your solution should have all necessary...

    Translate the following C++ program into MAL (MIPS Assembly Langage). Your solution should have all necessary data allocations, input/output instructions etc, and must compile and run correctly in spim. Make sure your loops are efficient (i.e., they should not have unnecessary branches). Given: userInput is in $s0 and index is in $s1. (These variables should not be allocated in the .data section.) You may use any other $s? or $t? registers as temporaries. for (int index = 8; index >...

  • Write and submit a MIPS Assembly Language program which requests an integer (year) from the user...

    Write and submit a MIPS Assembly Language program which requests an integer (year) from the user and then invokes a function to determine the beginning date and time of each season. The program must be properly documented which includes in file comments. Note: This is a Computer Science/Engineering course, not a Physics/Astronomy course. The exact time is not expected. Approximations are acceptable. Document your calculation process in the report. Basically, the intent is that you store a reference date and...

  • Practice Problem [no points]: You should read and understand Fibonacci algorithm, write a code in a...

    Practice Problem [no points]: You should read and understand Fibonacci algorithm, write a code in a high level language of your choice and in Assembly to find a Fibonacci number and check your result. At the end of this assignment a possible solution to this problem is given both in Python and MIPS assembler. Note that it would have been possible to write the Python differently to achieve the same function. . [20 points] Write and debug a MIPS program...

  • Write an assembly program that takes two values, a and b, multiplies them, and then stores...

    Write an assembly program that takes two values, a and b, multiplies them, and then stores the result in c. When the program begins: • a is located in $fp + 1 • b is located in $fp + 2 At the end of the program: • a is located in $fp + 1 • b is located in $fp + 2 • c is located in $fp + 3 In doing this, there must be at least one function,...

  • i need help with a mips program to to covert roman numerals to real numbers Lab 4: Roman Numeral Conversion Part A: Due...

    i need help with a mips program to to covert roman numerals to real numbers Lab 4: Roman Numeral Conversion Part A: Due Sunday, 19 May 2019, 11:59 PM Due Friday, 24 May 2019, 11:59 PM Part B: Minimum Submission Requirements Ensure that your Lab4 folder contains the following files (note the capitalization convention): o Diagram.pdf o Lab4. asm O README.txt Commit and push your repository Lab Objective In this lab, you will develop a more detailed understanding of how...

  • When replying to this discussion below, you must make a MEANINGFUL comment. Maybe this will help:...

    When replying to this discussion below, you must make a MEANINGFUL comment. Maybe this will help: when you read your peers' post, pretend that you are in a classroom and you just heard him or her speak. Your reply must be meaningful enough that in a face to face class, you would raise your hand, wait to be called upon and comment or ask a follow-up question to their answer. Language is never constant, it's always changing and so is...

  • When replying to this discussion below, you must make a MEANINGFUL comment. Maybe this will help:...

    When replying to this discussion below, you must make a MEANINGFUL comment. Maybe this will help: when you read your peers' post, pretend that you are in a classroom and you just heard him or her speak. Your reply must be meaningful enough that in a face to face class, you would raise your hand, wait to be called upon and comment or ask a follow-up question to their answer. I think the "the bird" nonverbal gesture still has its...

  •    MTH 157 Mon, .July 23, 2018 PROBABILITY TEST 4 COUNTING TEOedaesao You must use pencil,...

       MTH 157 Mon, .July 23, 2018 PROBABILITY TEST 4 COUNTING TEOedaesao You must use pencil, erase clearly, be neat and onderty. Yeu must show your steps. What numbers are you using and how are you using them to get your answers. Dem just give m. on.???. Iwill count it totally wrog Allu ers must b. spp ed by your work. Your work must be orgonized so that I can understand how you get from one step to another step....

  • (C++) This is the part 2 of the program. In this program you will use part...

    (C++) This is the part 2 of the program. In this program you will use part 1 and build on it to call getAnswer function which would return a random answer. Remember that you had stored these random answers in a string array. You will pass the array and the possible answers (ideally the size of the array) to getAnswer, and the getAnswer will return a randomly selected answer back to main. This is the starting code (below). Please make...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT