Question

Assignment 2

please provide the code sequence of the following instruction: a = x * y + b * c for the five types of instruction sets using mips32 (use three registers R1-R3 where applicable)

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

The MIPS32 instruction set architecture provides several instruction formats, including R-type, I-type, J-type, Load/Store, and Branch instructions. Here's the code sequence for the instruction "a = x * y + b * c" using the MIPS32 instruction set for each type of instruction set:

R-type instruction:

bashCopy codemul R1, $s0, $s1  # Multiply x and y, store result in R1mul R2, $s2, $s3  # Multiply b and c, store result in R2add R3, R1, R2    # Add the results of the previous multiplications, store result in R3sw R3, a          # Store the result in memory location 'a'

I-type instruction:

rCopy codelw R1, x        # Load x into R1lw R2, y        # Load y into R2mul R3, R1, R2  # Multiply x and y, store result in R3lw R1, b        # Load b into R1lw R2, c        # Load c into R2mul R1, R1, R2  # Multiply b and c, store result in R1add R3, R3, R1  # Add the results of the previous multiplications, store result in R3sw R3, a        # Store the result in memory location 'a'

J-type instruction: (J-type instructions are used for jumps and do not apply to this particular instruction)

Load/Store instruction:

rCopy codelw R1, x        # Load x into R1lw R2, y        # Load y into R2mul R3, R1, R2  # Multiply x and y, store result in R3lw R1, b        # Load b into R1lw R2, c        # Load c into R2mul R1, R1, R2  # Multiply b and c, store result in R1add R3, R3, R1  # Add the results of the previous multiplications, store result in R3sw R3, a        # Store the result in memory location 'a'

Branch instruction: (Branch instructions are used for conditional branching and do not apply to this particular instruction)

Note: In the above code sequences, $s0, $s1, $s2, and $s3 represent the registers where the values of x, y, b, and c are stored, respectively. 'lw' stands for load word instruction, 'sw' stands for store word instruction, 'add' stands for add instruction, and 'mul' stands for multiply instruction.


answered by: Mayre Yıldırım
Add a comment
Know the answer?
Add Answer to:
Assignment 2
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
  • Assume the program counter (PC) is initially equal to n. Assume that the word length of...

    Assume the program counter (PC) is initially equal to n. Assume that the word length of the processor is 1. a)      How many fetches are required to make PC equal to m if there are no branch instructions between n and m? b)      What is the content of the instruction register (IR) when the PC’s value is n+k? Justify your answer. Why we are not using a hundred pipeline stages if anoperation can be divided up into a hundred steps,...

  • 2. (25 pts) (a) How one can use a single LC-3 instruction to move the value...

    2. (25 pts) (a) How one can use a single LC-3 instruction to move the value of R2 into R3? (b) The LC-3 has no subtract instruction. Write an LC-3 code that could perform the following operation: R1 = R2-R3 (c) Using only one LC-3 instruction and without changing the contents of any register, how could one set the condition codes based on the value that resides in RI? (d) Write LC-3 instruction that clears the contents of R2? (e)...

  • 2. a)Write the ARM ALP conditional code snippet for the following statements written in C-language. Assume R1 to Rn as06 variables Let R1, R2, R3 contain the starting addresses of arrays X, Y and Z r...

    2. a)Write the ARM ALP conditional code snippet for the following statements written in C-language. Assume R1 to Rn as06 variables Let R1, R2, R3 contain the starting addresses of arrays X, Y and Z respectively Use Register R4 for variable i. Display appropriate messages. While (i+10) else Z[i] XiYi; b)i Write a program to display a message "This is an examination Question" on the screen using 06 a function sub program Note the following Address of the string to...

  • Section B - ARM Assembly Language (25 marks) An ARM instruction set summary is provided at...

    Section B - ARM Assembly Language (25 marks) An ARM instruction set summary is provided at the end of this paper 1. (5 marks) Consider the following assembly instruction STMFD r13!, (r5-6} Before executing this instruction, registers hold the following values: Register Value Register r9 Value r4 0x00400040 0x00000000 r5 r10 0x11223344 0x00800080 r6 0x55667788 r11 0x10001000 r7 0x99aabbcc r12 0x20002000 r8 exddeeff00 r13 ex40004000 What memory locations are affected after executing the above instruction? In a table, with a...

  • Assignment 4: Answer the following questions with reference to the assembly program below. Before the code...

    Assignment 4: Answer the following questions with reference to the assembly program below. Before the code is executed, the initial content of memory and registers is shown in the figure below memory 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 address Use BIG ENDIAN, and 0x2000.0000 0x2000.0001 0x2000.0002 show all steps register 0x2000.0000RO Ox2000.0003 0x2000.0004 0x2000.0005 0xFFFF.FFFF R2 ox2000.0006 0x1234.5678 R3 0x2000.0007 Ox0000.0000 R1 LDRH R1, [R0 , #2]! LDRH R2 , [R0 , #2)! ADD R3, R1, R2 STR...

  • You are given a homework processor (HPro) capable of addressing 32 8-bit (1 byte) wide registers....

    You are given a homework processor (HPro) capable of addressing 32 8-bit (1 byte) wide registers. However, it has only 29 physical registers. Register RO, R1 and R31 are not physically implemented. Instead, every read from RO, R1 and R31 will return a constant zero (00000000), constant one (00000001) and all ones (11111111), respectively. Every write to RO, R1 and R31 will go to null (dummy write). Assume that all other registers have initially unknown (X) state (This in fact...

  • * Let φ : R3-+ R be a continuous function. The level sets of φ are the sets 4:-{(z, y, z) e R3 Id(z, y, z) =c); where c is a real constant (c) Use the setup in this problem to argue that a seq...

    * Let φ : R3-+ R be a continuous function. The level sets of φ are the sets 4:-{(z, y, z) e R3 Id(z, y, z) =c); where c is a real constant (c) Use the setup in this problem to argue that a sequence on the unit sphere x E R31 (- is the standard Euclidean norm) cannot converge to a point that is not an element of the unit sphere. * Let φ : R3-+ R be a...

  • Exercise 2 (4 pts) Here is a logical instruction that is not included in the ARM...

    Exercise 2 (4 pts) Here is a logical instruction that is not included in the ARM instruction set. ANDN rl, r2, r3 @bit-wise AND of r2 and Ir3 (r2 and not r3) (2 pts) Provide a minimal set of ARM instructions that may be used in place of ANDN. 1ldr r2,0x0OFFASA5 2 ldr r3,OxFFFF003C 4 (2 pts) The above snippet starts with loading registers r2 and r3 with some values using instruction LDR. Why don't we use the instruction MOV?

  • The Fibonacci sequence F is defined as F(1) = F(2) = 1 and for n>= 2,...

    The Fibonacci sequence F is defined as F(1) = F(2) = 1 and for n>= 2, F(n + 1) = F(n) + F(n − 1) i.e., the (n + 1)th value is given by the sum of the nth value and the (n − 1)th value. 1. Write an assembly program typical of RISC machines for computing the kth value F(k), where k is a natural number greater than 2 loaded from a memory location M, and storing the result...

  • Assembly code time

    Consider the following assembly language code:I0: add $R4,$R1,$R0                             //ADD R4 = R1 + R0;I1: lw $R1,100($R3)                             //LDW R1 = MEM[R3 + 100];I2: lw $R9,4,($R1)                                // LDW R9 = MEM[R1 + 4];I3: add $R3,$R4,$R9                             //ADD R3 = R4 + R9;I4: lw $R1,0($R3)                                 //LDW R1 = MEM[R3 + 0];I5: sub $R3,$R1,$R4                             //SUB R3 = R1 - R4;I6: and $R9,$R9,$R7                             //AND R9 = R9 & R7;I7: sw $R2,100($R4)                             //STW MEM[R4 + 100] = R2;I8: and $R4,$R2,$R1                             //AND R4 = R2 & R1;I9: add...

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
ADVERTISEMENT