diff options
author | Michael Panzlaff <michael.panzlaff@fau.de> | 2020-10-02 12:12:31 +0200 |
---|---|---|
committer | Michael Panzlaff <michael.panzlaff@fau.de> | 2020-10-02 12:27:16 +0200 |
commit | 187c96d6e5558208266fa0ca81e41e38854ab568 (patch) | |
tree | 964c7de61a310fd9b2eb7a002f72980246d90f40 /src | |
parent | 52598983250fd8ad7b66ff2b9d77046859f169c8 (diff) |
rewrite MultiBootWaitCycles as naked function
Before, when compiling MultiBootWaitCycles with O3 and MODERN=1, you
might have run into problems during optimizations when the compiler tried
to optimize the function, even if declared NOINLINE.
When rewriting this function as NAKED function, this no longer happens
as the optimizer will treat it as black box and compilation will resume.
Diffstat (limited to 'src')
-rw-r--r-- | src/multiboot.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/multiboot.c b/src/multiboot.c index c7e14392e..19245b5b3 100644 --- a/src/multiboot.c +++ b/src/multiboot.c @@ -1,3 +1,4 @@ +#include "global.h" #include "gba/gba.h" #include "multiboot.h" @@ -435,23 +436,23 @@ static int MultiBootHandShake(struct MultiBootParam *mp) #undef must_data } -static NOINLINE void MultiBootWaitCycles(u32 cycles) +NAKED +static void MultiBootWaitCycles(u32 cycles) { - asm("mov r2, pc"); - asm("lsr r2, #24"); - asm("mov r1, #12"); - asm("cmp r2, #0x02"); - asm("beq MultiBootWaitCyclesLoop"); - - asm("mov r1, #13"); - asm("cmp r2, #0x08"); - asm("beq MultiBootWaitCyclesLoop"); - - asm("mov r1, #4"); - - asm("MultiBootWaitCyclesLoop:"); - asm("sub r0, r1"); - asm("bgt MultiBootWaitCyclesLoop"); + asm_unified("\ + mov r2, pc\n\ + lsrs r2, 24\n\ + movs r1, 12\n\ + cmp r2, 2\n\ + beq MultiBootWaitCyclesLoop\n\ + movs r1, 13\n\ + cmp r2, 8\n\ + beq MultiBootWaitCyclesLoop\n\ + movs r1, 4\n\ +MultiBootWaitCyclesLoop:\n\ + subs r0, r1\n\ + bgt MultiBootWaitCyclesLoop\n\ + bx lr\n"); } static void MultiBootWaitSendDone(void) |