1) The next PC value will be 0040002c (32 bits in hexa decimal notation). Next PC is current PC + 4 for a non jump linear instruction.
2) move dest-reg src-reg, is internally translated into addu dest-reg $0 src-reg, i.e, adding 0 to unsigned value of src-reg and saving to dest-reg
3) The previous instruction was ori $t1 $0 10,
$t1 represents register R9
ori stands for or immediate, this instruction takes or with 0 and 10 and saves into R9
10 represented in hexa decimal is 'a'
Hence, R9 have a 'a'.
4) Currently,
R9 = 10
After, ori $t2 $0 11,
R9 = 10
R10 = 11 or 0 = 11
After, add $t3 $t2 $t1,
R9 = 10
R10 = 11
R11 = 11 + 10 = 21
After, move $t4 $t3,
R9 = 10
R10 = 11
R11 = 21
R12 = R11 = 21
5. Consider the SPIM code below. globl main .text main: ori $t1, $0, 10 ori $t2,...
2. Q2 [25 points) Consider the MIPS code given in the following. main: addi Ssp, Ssp, -4 addi Sa0, $0, 2 sw $a0, 4(Ss1) addi Sal, $0, 3 sw Sal, 8(Ss1) jal dofsum sw SvO, 16(8s1) lw Sra, O(Ssp) addi Ssp, Ssp, 4 jr Sra dofsum: jal sum jr Sra sum: add SvO, Sa0, Sal jr Sra Draw the snapshot of the stack before, during, and after dofsum) function call. As- sume SSP, 0x45fff00 before dofsum() function call.
.text main: ori $s7,$0,4097 # put a memory location in $s7 sll $s7,$s7,16 # ori $s0,$0,0x2 # put 2 into $s0 and $s0,$s0,$zero # clear $s0 ori $s0,$zero,0x2 # put 2 back into $s0 nor $s0,$s0, $zero # complement $s0 ori $s0,$zero,0x2 # put 2 back into $s0 ori $s1,$0,0x3 # put 3 into $s1 add $s2,$s0,$s1 # add beq $s2,$zero, exit sw $s2, 4($s7) # store the result...
what is the output of the following assembly code ? .data A: .word 84 111 116 97 108 32 105 115 32 . text main:li $v0, 1l li $s0,0 la $s1, A li $t3, 0 loop: slti $t0, $s0, 17 beq: $t0, $zero, end sll $t1, $s0 2 add $t2 $s1 $t1 syscall addi $s0, $s0, 1 j loop end: li $v0, 1 add $a0, $zero, $t3 syscall
1. What would be the output of the following MIPS code? .globl main main addu $s7, $0, $ra add $s3, $0,$0 addi $s4, $0, 1 $s5, $0,$0 $s6, save add . data .align 2 .globl save # the next line creates an array of 10 words that can be re ferred to as "save" # the array is initialized to the 10 values after .wo rd # so the first array entry is a 0 and the last entry is...
I want to calculate Y[2]=X[3]+X[4] I'm not sure that I wrote right codes. .text main . la $50, x #get base address of x la $s1, y #get base address of y lw $to, 12 ($50)#get data from memory of x[3] lw $t1 , 1 6($50) #get data from memory of x[4] add $t2, $t0, $t1 sw $t2, 8($51 ) #store result to y[2] li $v0, 10 #exit program syscall data x: word 5, 1, 17,-4, 6, 3 y: .word...
I have this MIPS program and I'm having trouble with it. This program is user inputs numbers until zero and sorts and print the numbers in order. Please soove this issue. You can use any sorting algorithm except bubble sort. Need it as soon as possible. Here is the code:.datanum: .word 0space: .byte ' ' .text main: # la $t0, val # loads val into a register # li $t1, 0 #keeps track of how many numbers entered la $a0,...
.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,...
Complete count_bits function. You are given an 32-bits integer stored in $t0. Count the number of 1's in the given number. For example: 1111 0000 should return 4 j main ############################################################### # Data Section .data # new_line: .asciiz "\n" space: .asciiz " " double_range_lbl: .asciiz "\nDouble range (Decimal Values) \nExpected output:\n1200 -690 104\nObtained output:\n" swap_bits_lbl: .asciiz "\nSwap bits (Hexadecimal Values)\nExpected output:\n75757575 FD5775DF 064B9A83\nObtained output:\n" count_bits_lbl: .asciiz "\nCount bits \nExpected output:\n20 24 13\nObtained output:\n" swap_bits_test_data: .word 0xBABABABA, 0xFEABBAEF, 0x09876543 swap_bits_expected_data: .word...
im trying to complete mips program code about a calculator program that can calculate integer addition / subtraction written using the MIPS assembler. im having hard times to debug this. The input is given to the array of Formula char (base address $ s0) in the form of a formula. The null character (\ 0, ASCII code 0) is placed at the end. The calculation result is given to the register $ s1 and the overflow is ignored. For example,...
The MIPS assembly program given here is expected to find the sum of elements in array "myArr. Even though the code is syntactically correct, there are four bugs because of which the program is not glving the required output. With the help of the line numbers given identify the bug. Write the line number where you find the bug and give how the correct statement to eliminate the corresponding logical error (10 points partial points given for partial correct answers)...