so I recently received a project for a 2nd year computer science module, where we did computer architecture. We were instructed to write ARM Assembly code to output the fibonacci sequence for n=15 as well as n=30.
I have tried checking out multiple resources online, but ARM is not as widely used, nor supported in 2020 anymore. I have been able to compile and run my code, however it tells me "segmentation fault" and outputs the wrong number (139).
I have been stuck for the past weekend, attempting multiple fixes, with no luck. If anyone could just guide me in the right direction, or help me identify my logical or syntax error, it would be great. I will post the code below, and thank you so much in advance!!!
.global main
.func main
main:
LDR R5,=0x50000000 ; load mem address
MOV R1,#5 ; number comparisons
.loop:
LDR R2,[R5] ; load 1st number
ADD R6, R5,#04 ; increment address to next number
LDR R3, [R6] ; load 2nd number
ADD R4, R2, R3
STR R4, [R6,#4] ;store in next mem location
MOV R5, R6
SUBS R1, #01 ; decrement counter
BNE .loop ; loop mechanism
NOP
.endfunc
BX LR