3 ms·
That's 24 bytes because gas is using Thumb2 mov.w instructions to initialize r1 and r2. It took me a long time to figure out that the problem was mov vs. movs;
by kragen 1y ago
That's 24 bytes because gas is using Thumb2 mov.w instructions to initialize r1 and r2. It took me a long time to figure out that the problem was mov vs. movs; this is the correct 20-byte version:
.cpu cortex-m4
.thumb
.syntax unified
.thumb_func
.globl fib
fib: movs r1, #1
movs r2, #1
1: subs r0, #1
itt lo
movlo r0, r1
bxlo lr
mov r3, r2
adds r2, r1
mov r1, r3
b 1b
I swear, I keep making the same n00b mistakes, year after year!
It might be possible to get it down to 18 bytes, but I don't see how.