Download lines starting with this symbol are comments, and are ignored during

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
#LINES STARTING WITH THIS SYMBOL ARE COMMENTS, AND ARE IGNORED DURING ASSEMBLY
#INSTRUCTS THE ASSEMBLE TO PRESERVE THE ORDER OF THE INSTRUCTIONS
.set noreorder
#ASSEMBLY DIRECTIVE TO NOTIFY THE ASSEMBLER THAT THE FOLLOWING LINES REPRESENT DATA LOCATIONS
.data
N: .word 0x0f
Y: .word
#ASSEMBLY DIRECTIVE TO NOTIFY THE ASSEMBLER THAT THE FOLLOWING LINES REPRESENT THE CODE
.text
#ASSEMBLY DIRECTIVE TO DENOTE A GLOBAL SYMBOL
.globl start
#ASSEMBLY DIRECTIVE TO DENOTE THE START OF THE PROGRAM CODE
.ent start
start:
again:
done:
lw $12, N
li $8,0
li $9,0
li $10,1
li $11, 1
addi $11, $11, 1
add $8, $9, $0
add $9, $10, $0
add $10,$8, $9
bne $11, $12, again
nop
sw $10, Y
nop
#keep the value of N in register $12
#keep the value of F(i-2) in register $8
#keep the value of F(i-1) in register $9
#keep the value of F(i) in register $10
#keep the value of i in register $11
#i=*i+1, where *i is the old value of i
#F(i-2)=F(*i-1)
#F(i-1)=F(*i)
#compute F(i)
# if i is not equal to N, keep on increasing i
#ASSEMBLY DIRECTIVE TO DENOTE THE END OF THE PROGRAM
.end start
#IMPORTANT TO NOTE!!! PLACE A NOP INSTRUCTION AFTER A BRANCH INSTRUCTION