1. (i) [8] Suppose $s2 contains the value 6. What’s the value of
$s1 after the instruction sll $s1, $s2, 5?
(ii) [6] Convert jalr $s2, $t7 to machine code (binary).
(iii) [6] Find the corresponding MIPS instruction to the following
machine code. You are given that any immediate value is represented
using 2’s complement.
0011010101010111 1111111111111111
2. [20] There is a value stored in $s0. Write a sequence of MIPS
instructions that will place the absolute value of $s0 into
$t0.
3. [30] You are given a memory data segment labeled “chico”. Write
an assembly language program to find the sum of the first 100 words
data in the memory data segment labeled “chico”. Store the
resulting sum in $s0.
4. [30] Write a function FIB(N, &array) to store the first N
elements of the Fibonacci sequence into an array in memory. The
value N is passed in $a0, and the address of the array is passed in
register $a1. The first few numbers of the Fibonacci sequence are:
1, 1, 2, 3, 5, 8, 13, ...
1. (i) [8] Suppose $s2 contains the value 6. What’s the value of $s1 after the...
Question 3 (10 points) Convert the following MIPS assembly code into machine language. Write the instruction in hexadecimal. The opcode for sw 43 (101011). sw St1, -4(St3) Question 4 (10 points) Consider the following MIPS assembly code: addi $s3, $0, 5 addi $s1, S0, 3 addi Ss1, $s1, 2 beq Ss3, Ssl, target addi Ss1, Ss1, 1 target: add Ss3, Ss1, Ssl a. After running the code, what is the value of Ss3? b. If the memory address of the...
Given the following sequence of instructions: lw $s2, 0($s1) //1 lw $s1, 40($s3) //2 sub $s3, $s1, $s2 //3 add $s3, $s2, $s2 //4 or $s4, $s3, $zero //5 sw $s3, 50($s1) //6 a. List the read after write (current instruction is reading certain registers which haven’t been written back yet) data dependencies. As an example , 3 on 1 ($s2) shows instruction 3 has data dependency on instruction 1 since it is reading register $s2. b. Assume the 5...
4. (3 pts. each) Write the hexadecimal representation of each MIPS assembly instruction: (4.1) sub $s3, $t1, $s2 (4.2) bne $t3, $t4, 18 (4.3) sll $s0, $t5, 2 5. (20 pts.) Consider the following C (or java) code: else f=f+2; By storing the value of j in Ss0, write a sequence of MIPS assembly instructions that will execute these lines of code for the following two cases: (5.1) assuming that the values of f, g and h are stored in...
Topics 1. MIPS instruction set architecture (ISA). 2. Performance. 3. MIPS datapath and control. Exercise 1 Consider the memory and register contents shown below. Registers Ox0100 FFF8 13 ($t 5) 14 ($t6) 0x0100 FFFC 0x0101 0000 Memory 0x0000 0000 0x0001 1100 0x0A00 со00 0x1234 4321 OxBAOO OOBB 15 OXAAAA 0000 0x1111 1010 0x7FFF FFFD 0x0100 FFFO 0x0101 0008 (St7) Ox0101 0004 16 ($80) 0x0101 0008 17 ($sl) Show what changes and give the new values in hexadecimal after the following...
Translate each of the following pseudo-instructions into MIPS instructions. You should Produce a minimal sequence of MIPS instructions to accomplish the required computation. (8 Points) 1) bgt $t1, 100, Label # bgt means branch if greater than 2) ble $s2, 10, Next # ble means branch if less than or equal 3) ror $s0, $s4, 7 # ror means rotate right $s4 by 7 bits and store the result in $s0 4) neg $s5, $s4 # $s5 will have the...
CMPS 290 Programming Assignment Arrays and Recursion – Fibonacci Numbers In this programming assignment you will be working with arrays and multiple function calls, including a recursive function call. The goal of the assignment will be to, using a pre-set array of sequence numbers, calculate the Fibonacci sequence number for each value in the array (see the example at the bottom if this isn’t clear). Instructions and Requirements: • Create a program that assembles and runs to find the correct...
NOTE: explain the lines in comments for better understanding Write an assembly program (for x86 processors - Irvine) that has two procedures, a main procedure and a procedure called Fib. The fib procedure is to uses a loop to calculate and printout the first N Fibonacci numbers. Fibonacci sequence is described by the following formula: Fib(1) = 1, Fib(2) = 1, Fib(n) = Fib(n – 1) + Fib(n – 2). The value of N is to be communicated to this...
MIPS - assembly language Task I (1 mark): Write a program to calculate the nth Fibonacci number based on an iterative approach where value n is read from the keyboard and stored in your main program that is calling fib. The main program reads number ‘n’ -- restrict range of ‘n’ to 2-50, and display an error message if this condition is not satisfied. The main program calls fib with parameter passing. Procedure fib should return the calculated...
5 matlab codes
18, Suppose I seed to fetch a mmumerical variable named hours from the user This vaniable needs to be son-orgative Ioe the emaining code in the projert to work property. so before So, we will got the vue of hours fromm the user, and if it is segative, we will tell the user that it ut be non-aegative, and reprompt for a value We will hoep doing this until the uer gots it correct Give the code...
.
please trace the code including the value in every register
1. Express the instruction on line 9 of the program in 32-bit
machine language, and if necessary, refer to the table in the
appendix.
2. Set 000beef00 to $ s0 as input and calculate the value of $
s0 at the end of each step (lines 9, 13, 17, 21, 25) when executing
the above program (binary or Write in hexadecimal).
3. Briefly explain the operation of the above...