Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .data
- fn_2: .word 0
- fn_1: .word 1
- fn: .word 0
- n: .word 0
- spaceInsert: .asciiz " "
- prompt: .asciiz "Please enter a positive integer: "
- test: .asciiz "testing..."
- .text
- .globl main
- main:
- li $v0, 4 # load instructions to output a string
- la $a0, prompt # prompt for n
- syscall
- li $v0, 5 # load instructions to read an int
- la $a0, n # read in n
- syscall
- lw $t0, n # st0re n into $t0
- lw $s0, fn_2 # store fn_2 into register $s0
- lw $s1, fn_1 # store fn_1 into register $s1
- lw $s2, fn # store fn into $s0
- add $t1, $zero, 1 # this is the counter, i
- LOOP: add $s2, $s1, $s0
- li $v0, 4 # load instructions to output a string
- la $a0, spaceInsert # output space
- syscall
- li $v0, 1 # load instructions to output an int
- move $a0, $s2 # output fn
- syscall
- move $s0, $s1 # fn_2 = fn_1
- move $s1, $s2 # fn_1 = fn
- add $t1, $t1, 1 # i++
- bne $t1, $t0, LOOP
- Exit:
- li $v0, 10
- syscall
Add Comment
Please, Sign In to add comment