4.
What will be in $8 after execution?
Assume $9 contains a valid RAM address.
.data
A: 5 10 15
.text
Main:
la $9, A
addi $10, $0, 5
sw $10, 8($9)
addi $9, $9, 8
lw $8, 0($9)
SOLUTION-
For this assembly code , $8 will contain 5.
la $9, A ---> ; $9 will contain base address of array A
addi $10, $0, 5 ---> ; $10 = 0 + 5 = 5
sw $10, 8($9) ---> ;8($9) that is A[2] = $10 = 5 that is 15 would be replaced by 5
addi $9, $9, 8 -----> ; adding 8 to the base address of the array A that is $9 = A[2]
lw $8, 0($9) -----> ; $8 = base of $9 that is A[2] so would store 5
IF YOU HAVE ANY DOUBT PLEASE COMMENT DOWN BELOW I
WILL SOLVE IT FOR YOU:)
----------------PLEASE RATE THE ANSWER-----------THANK
YOU!!!!!!!!----------
4. What will be in $8 after execution? Assume $9 contains a valid RAM address. .data...
4. What will be in $8 after execution? Assume $9 contains a valid RAM address. .data A: 5 10 15 .text Main: la $9, A addi $10, $0,5 sw $10, 8($9) addi $9, $9,8 w_$8,0($9)
3. What will be in $8 after execution? addi $8, $0,5 sil_$8, $8,2 // shifting $8 left twice (logical shift- assume no sign) 4. What will be in $8 after execution? Assume $9 contains a valid RAM address. .data A: 5 10 15 .text Main: la $9, A addi $10, $0,5 sw $10, 8($9) addi $9, $9,8 lw_$8, 0($9)
1. Consider the following java code. int x 5 X++ Give equivalent MIPS ISA. Assume compiler will keep x in $s0 ($16) 2. What will be in $8 after executing the following statements? addi $8, $0, 5 add $8, $8, $8 What will be in $8 after execution? 2. addi $8, $0, 5 sll $8, $8, 2 shifting $8 left twice (logical shift- assume no sign) 4. What will be in $8 after execution? Assume $9 contains a valid RAM...
can someone explain how you get the answer to this question? 1. Based on the following code segment what values are in the runtime stack immediately after the fourth time the instruction labeled Rec is executed .text li Sa0, 7 jai Fact #assume the address of this instruction is 2000 fother code not shown Fact: addi Ssp, Ssp, -8 sw Sra, 4(Ssp) sw Sa0, 0(Ssp) slti St0, Sa0, 1 beq St0, Szero, Rec li SvO, 1 addi $sp, Ssp, 8...
Question 4) (12 Marks) This question is based on the MIPS assembly code shown below. data the Array: space 160 main: li $t6, 1 li $17, 4. sw $17, the Array($0) sw $17, theArray($17) li $t0, 8 loop: addi $t3, $t0, -8 addi $t4, $t0, -4 lw 1, the Array($t3) lw $12, the Array(St4) add $15, $t1, $t2 sw $15, theArray($to) addi $t0, $t0, 4 blt $t0, 160, loop jr Sra. Question 4 Assembly code a) what is the contents...
4. Study the following example, and determine the addressing mode used in each instruction: .data Arr: .word 10 .word 20 .text globl main main la $s0, Arr lw $t0, 0(Ss0) lw St1, 4(Ss0) add St2, $t0, $t1 addi $t2, $t2, 1 sll $t2, $t2, 1 4. Study the following example, and determine the addressing mode used in each instruction: .data Arr: .word 10 .word 20 .text globl main main la $s0, Arr lw $t0, 0(Ss0) lw St1, 4(Ss0) add St2,...
1. It is desired to load A[10] into $8, i.e., "lw $8, X($9)". Assume $9 contains the base address of array A. Address Memory content lw $8, X($9) 0x0001 0000 Ox0001 0004 0x0001 0008 Ox0001 000c 0x0001 00101 Ox0001 0014 0x0001 0018 Ox0001 001c 0x0001 00201 0x0001 0024 0x0001 0028 A[O] A[1] $9 contains the based address of array A (i.e., $9 = 0x0001 001c) (a) What is the memory address for A[10]? Answer in hexadecimal number. Hint: Remember that...
.data prompt: .asciiz "Input an integer x:\n" result: .asciiz "Fact(x) = " .text main: # show prompt li $v0, 4 la $a0, prompt syscall # read x li $v0, 5 syscall # function call move $a0, $v0 jal factorial # jump factorial and save position to $ra move $t0, $v0 # $t0 = $v0 # show prompt li $v0, 4 la $a0, result syscall # print the result li $v0, 1 # system call #1 - print int move $a0,...
8- For this question, assume that there are no pipeline stalls and that the breakdown of executed instructions is as follows: (8 pts add 10% addi 15% not 0% beq 30% lw 30% SW 15% a- In what fraction of all cycles is the data memory used? b- In what fraction of all cycles is the input of the sign-extend circuit needed?
$s 10) if $si and $$2 are to be saved on the stack which of the following would accomplish the (10Pts) task? A) addi sp, sp, 8 sw $s1, 0($sp) sw $s2, 4($sp) B) addi sp, sp, 8 lw $s1, 8($sp) lw $s2, 4($sp) addi sp, sp, -8 C) sw $s1, 0($sp) sw $s2, 4(Ssp) D) addi sp, sp, -8 lw $s1, 8($sp) lw $s2, 4($sp) 11) What instruction would be used to call a procedure called square? (5Pts) 12)...