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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started