-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhw1_2.s
33 lines (25 loc) · 769 Bytes
/
hw1_2.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
.data
prompt1: .asciiz "PLZ enter the fibonacci sequence deeph as n.\n"
prompt2: .asciiz "ANS is : ";
.text
main:
li $v0, 4 # $v0 = 4;
la $a0, prompt1
syscall
li $v0, 5
syscall
add $s0, $v0, $0 # $s0 = n
andi $t0, $0, 0; # set $t0 = 0; counter
Loop:
beq $s0, $0, Exit # if $s0 == 0 Exit target
add $t0, $t0, $s0
addi $s0, $s0, -1
j Loop # jump to Loop
Exit:
li $v0, 4 # $v0 = 4;
la $a0, prompt2
syscall
li $v0, 1 # $v0 = 1;
or $a0, $0, $t0
syscall
j $ra