In Arm language. Please use Codeblocks.
Please be in gcd.s file format
Write an assembler program that will calculate the n-th Fibonacci number. Your program should detect when the overflow occurs and print out the value of n for when overflow does occur.
SOURCE CODE
AREA RESET, CODE, READONLY ENTRY start MOV R1, #16 ; n = 16 MOV R3, #0 ; fn1 = 0 MOV R0, #1 ; fn = 1 MOV R2, #1 ; i = 1 whn CMP R2, R1 ; while (i < n) BHS endwhn ; { ADD R2, R2, #1 ; i = i + 1 MOV R4, R0 ; tmp = fn ADD R0, R0, R3 ; fn = fn + fn1 MOV R3, R4 ; fn1 = tmp B whn ; } endwhn STOP B STOP END
please give a upvote if u feel helpful.
Get Answers For Free
Most questions answered within 1 hours.