Any ideas?
Code: Select all
R2: 1
Segmentation fault
Code: Select all
print_r2:
...
POP {R1} @ goes back to here
POP {R0} @ goes here
BX LR @ issue starts here goes to POP {R1}... second time it goes back to POP {R1} ... to infinity
Code: Select all
.global _start
_start:
PUSH {R11, LR}
MOV R1, #0 @ A
MOV R2, #1 @ B
@ R3 just holds add temporarily
MOV R4, #0 @ Total
MOV R5, #10
@LDR R5, =0x003D0900 @ 4 million, max
BL print_r2
main_loop:
BL fib
ADD R4, R2
CMP R2, R5 @ largest value with max
BL print_r2
BGT end
B main_loop
end:
LDR R0, =format
MOV R1, R4 @ move total to print it
BL printf
MOV R7, #1
SWI #0
POP {R11, PC}
print_r2:
PUSH {R0}
PUSH {R1}
MOV R1, R2
LDR R0, =regval
BL printf
POP {R1}
POP {R0}
BX LR
fib:
MOV R3, R2
ADD R3, R1
MOV R1, R2
MOV R2, R3
BX LR
.data
format: .ascii "The result is: %d\n"
regval: .ascii "R2: %d\n"