ScreenShot
-------------------------------------------------------------------------------------------------------
Program
#variable declaration
.data
i: .asciiz "Please enter value
of i:"
j: .asciiz "Please enter value
of j:"
k: .asciiz "Please enter value
of k:"
f: .asciiz "f=i+j-k-1="
#main function
.text
.globl main
main:
#prompt user for i value
la $a0,i
li $v0,4
syscall
#read i value
li $v0,5
syscall
#store in a1
move $a1,$v0
#prompt user for j value
la $a0,j
li $v0,4
syscall
#read j value
li $v0,5
syscall
#store in a2
move $a2,$v0
#prompt user for k value
la $a0,k
li $v0,4
syscall
#read i value
li $v0,5
syscall
#store in a0
move $a3,$v0
#result prompt
la $a0,f
li $v0,4
syscall
#function call
jal Example
#result print
move $a0,$v0
li $v0,1
syscall
#exit
li $v0,10
syscall
#function definition
Example:
#clear register s2 for f
add $s2,$0,$0
#s2=i+j
add $s2,$a1,$a2
#s2=i+j-k
sub $s2,$s2,$a3
#s2=i+j-k-1
sub $s2,$s2,1
#move value into v0 to
return
move $v0,$s2
#return to main program
jr $ra
Problem #2 (20pts) Please write the MIPS assembly code corresponding to the following C code segment....
Please answer the following questions involving MIPS assembly code: A) For the C statement below, what is the corresponding MIPS assembly code? Assume f, g are stored in S1 and S2. f = g + (-f -5) B) For the C statement below, what is the corresponding MIPS assembly code? Assume i and j are assigned in registers S1 and S2 respectively and base of address of arrays A and B are in registers S6 and S7. B[8] = A[i...
For the following C statement, what is the corresponding MIPS assembly code? Assume that the variables i, and j are assigned to registers $s0, $s1, respectively. Assume that the base address of the arrays A and B are in registers $s2 and $s3, respectively. B[i] = A[i] - 10
B2. Convert the C code to MIPS assembly with only 2 efficient instructions: Register assignment: timer-v0 int timer = 0x0AC8 0001; B3. Write MIPS assembly code segment for the following C code snippet for (i - 0, i < 100; i++) -array Register assignment: i-) $ao Base of array -> $s0 array [ i+1] [i] / 2;
B2. Convert the C code to MIPS assembly with only 2 efficient instructions: Register assignment: timer-v0 int timer = 0x0AC8 0001; B3. Write...
1. (15 pts) For the following C statement, what is the corresponding MIPS assembly code? Assume f, g, h correspond to $80, $s1, and $s2, respectively. f=g+(h-5) 2. (15 pts) For the following pseudo-MIPS assembly instructions, what is the corresponding C code? add f, g, h add f,i, f 3. (30 pts) Provide the instruction type, assembly language instruction, and binary representation of the instruction described by the following MIPS fields: a. op = 0, rs = 18, rt=9, rd...
In MIPS assembly, write an assembly language version of the following C code segment: int A[100], B[100]; for (i=1; i < 100; i++) { A[i] = A[i-1] + B[i]; }
Assembly Langauge.
Q6. (4 marks) : For the following C statement, what is the corresponding MIPS assembly code? Assume that the variables a, b, and c are assigned to register $s0, $s1, and $s2, respectively.
1. [2 points] Write a MIPS assembly language program of the following C function and the code to call the function: int leaf_example (int g, h, i, j) { int f; f = (g + h) - (i + j); return f; مهه Arguments g, h, i, and j are passed to the function in registers $a0, $al, Şa2, and $a3, respectively while f in $50 (hence, need to save $50 on stack), and the result is to be stored...
what is the corresponding MIPS assembly code for the statements shown below that written in C. Assume that the variables sum and n assigned to register $t1 and $t2 respectively, and the base address of the array A is in register $t0. int sum = 0 for(n=100 ; n>=0; n=n-5) { if(A[n]>0 sum = a[n] +3 }
CDA-3101 – MIPS Assembly Programming 1. Write the following code segment in MIPS assembly language code: 3. Write a MIPS program to find the sum of squares from 1 to n. Where n=10. For example, the sum of squares for 10 is as follows: 12+22+32+……+n2=385
For the following C statement, what is the corresponding MIPS assembly code? Assume that the variables i andj are assigned to registers $50 and $s1, respectively and the base address of the arrays A and B are in registers $s6 and $57, respectively. B[i] = A[B[j]+12];