Question: the codes are not complete you have to complete them and write an algorithm and describe the purpose or the used of i. syscall ii.

the codes are not complete you have to complete them and write an algorithm and describe the purpose or the used of

i. syscall ii. move iii. jal iv. sw

2. What is the use of $v0 and $a0 register in syscall

codes

main: li $v0, 4 # system call code for Print String la $a0, INPUT_i # load address of prompt into $a0 syscall # print the input message li $v0, 5 # system call code for Read Integer

syscall # reads the value of N into $v0 move $a0, $v0 beq $a0, 0, OUT_ZERO # i == 0 beq $a0, 1, OUT_ONE # i == 1 jal FUN # i > 1 move $t0, $v0 li $v0, 4 la $a0, result syscall li $v0, 1 move $a0, $t0 syscall b main FUN: addi $sp, $sp, -8 # space for two words sw $ra, 4($sp) move $v0, $a0 blt $a0, 2, FUN_RT # n < 2 sw $a0, 0($sp) # save original i addi $a0,$a0, -1 # i-1 jal FUN lw $a0, 0($sp) sw $v0, 0($sp) # save f(i-1) addi $a0, $a0, -2 # i-2 jal FUN sll $v0, $v0, 1 # f(i-2)*2 lw $v1, 0($sp) # restore f(i-1) sll $v1, $v1, 2 # f(i-1)*4 add $v0, $v0, $v1 # 4*f(i-1) + 2*f(i-2), result is stored in $v0 lw $ra, 4($sp)

addi $sp, $sp, 8 jr $ra

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!