diff --git a/Makefile b/Makefile index 754ecebe360c..0ae0ccd325de 100644 --- a/Makefile +++ b/Makefile @@ -123,7 +123,7 @@ else MODERNCC := $(PREFIX)gcc PATH_MODERNCC := PATH="$(PATH)" $(MODERNCC) CC1 := $(shell $(PATH_MODERNCC) --print-prog-name=cc1) -quiet - override CFLAGS += -mthumb -mthumb-interwork -O$(O_LEVEL) -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -Wno-pointer-to-int-cast + override CFLAGS += -mthumb -mthumb-interwork -O$(O_LEVEL) -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-strict-aliasing -Wno-pointer-to-int-cast LIBPATH := -L "$(dir $(shell $(PATH_MODERNCC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(PATH_MODERNCC) -mthumb -print-file-name=libnosys.a))" -L "$(dir $(shell $(PATH_MODERNCC) -mthumb -print-file-name=libc.a))" LIB := $(LIBPATH) -lc -lnosys -lgcc -L../../libagbsyscall -lagbsyscall endif @@ -293,7 +293,9 @@ $(C_BUILDDIR)/record_mixing.o: CFLAGS += -ffreestanding $(C_BUILDDIR)/librfu_intr.o: CC1 := $(TOOLS_DIR)/agbcc/bin/agbcc_arm$(EXE) $(C_BUILDDIR)/librfu_intr.o: CFLAGS := -O2 -mthumb-interwork -quiet else -$(C_BUILDDIR)/librfu_intr.o: CFLAGS := -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -Wno-pointer-to-int-cast +$(C_BUILDDIR)/m4a.o: CFLAGS += -fno-toplevel-reorder +$(C_BUILDDIR)/librfu_intr.o: CFLAGS := -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -fno-strict-aliasing -Wno-pointer-to-int-cast +$(C_BUILDDIR)/agb_flash.o: CFLAGS += -fno-toplevel-reorder $(C_BUILDDIR)/berry_crush.o: override CFLAGS += -Wno-address-of-packed-member endif diff --git a/include/gba/types.h b/include/gba/types.h index 2e92bbe86e56..1308846a99e5 100644 --- a/include/gba/types.h +++ b/include/gba/types.h @@ -2,6 +2,7 @@ #define GUARD_GBA_TYPES_H #include +#include "gba/defines.h" typedef uint8_t u8; typedef uint16_t u16; @@ -69,7 +70,7 @@ struct OamData u16 priority:2; // 0x400, 0x800 -> 0xC00 u16 paletteNum:4; /*0x06*/ u16 affineParam; -}; +} ALIGNED(4); // Modern compilers will use wrong align-of sometimes. #define ST_OAM_HFLIP 0x08 #define ST_OAM_VFLIP 0x10 diff --git a/include/global.h b/include/global.h index bdfc426fb93c..93b13872aac6 100644 --- a/include/global.h +++ b/include/global.h @@ -17,11 +17,12 @@ #include "constants/easy_chat.h" #include "constants/trainer_hill.h" -// Prevent cross-jump optimization. -#define BLOCK_CROSS_JUMP asm(""); - -// to help in decompiling +// Unified Thumb/ARM asm. Modern (Clang): no .syntax divided — Clang rejects it. Legacy agbcc output still expects divided after the block. +#if MODERN +#define asm_unified(x) asm(".syntax unified\n" x) +#else #define asm_unified(x) asm(".syntax unified\n" x "\n.syntax divided") +#endif #define NAKED __attribute__((naked)) #if MODERN diff --git a/src/multiboot.c b/src/multiboot.c index 15b062ed65ee..f452616521d6 100644 --- a/src/multiboot.c +++ b/src/multiboot.c @@ -441,16 +441,16 @@ static void MultiBootWaitCycles(u32 cycles) { asm_unified("\ mov r2, pc\n\ - lsrs r2, 24\n\ - movs r1, 12\n\ - cmp r2, 2\n\ + lsrs r2, r2, #24\n\ + movs r1, #12\n\ + cmp r2, #2\n\ beq MultiBootWaitCyclesLoop\n\ - movs r1, 13\n\ - cmp r2, 8\n\ + movs r1, #13\n\ + cmp r2, #8\n\ beq MultiBootWaitCyclesLoop\n\ - movs r1, 4\n\ + movs r1, #4\n\ MultiBootWaitCyclesLoop:\n\ - subs r0, r1\n\ + subs r0, r0, r1\n\ bgt MultiBootWaitCyclesLoop\n\ bx lr\n"); }