; I am horrible with ARM and I am having problems this is the program I wrote ; but it isn't working the right way it is supposed to do the fibonacci seq ; using indirect addressing it keeps looping back to when i LDR r0 ; what do i do to fix this? thanks AREA FIBSEQ,CODE SRAM_BASE EQU 0x04000000 ;static ram location ENTRY MAIN MOV r1,#0 ;first number used in sequence MOV r2,#1 ;second number used in sequence MOV r3,#0 ;third number used in sequence MOV r4,#1 ;counter LDR r5,=SRAM_BASE ; STR r3,[r5],#0 ;these are supposed to be the first numbers in the ;fib seq ; STR r4,[r5],#1 FIBO ;method that solves for fib up to 18th seq ADD r3,r2,r1 ADD r1,r1,r2 SUB r2,r2,r2 ADD r2,r3,r2 ;also having problems here with logic ADD r4,r4,#1 STR r3, [r5] ;here is where it loops back CMP r4,#18 BNE FIBO stop B stop END
Guest
#2608306
Your Code doesn't compute the Fibonacci numbers because there are logical errors. Code for first 18 Fibonacci numbers:
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 | |
Reply
Please log in before posting.