From de6c9c617692d6b6298fbfc8e722f1948ad8df23 Mon Sep 17 00:00:00 2001 From: Martin Griffin Date: Mon, 11 Aug 2025 09:06:23 +0100 Subject: [PATCH] Hacky support for enums in C asm statements (#7494) --- include/test/overworld_script.h | 1 - tools/preproc/asm_file.cpp | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/test/overworld_script.h b/include/test/overworld_script.h index e849f87e0c..a5bee797b2 100644 --- a/include/test/overworld_script.h +++ b/include/test/overworld_script.h @@ -51,7 +51,6 @@ asm(".set FALSE, 0\n" ".set VARS_END, " STR(VARS_END) "\n" ".set SPECIAL_VARS_START, " STR(SPECIAL_VARS_START) "\n" ".set SPECIAL_VARS_END, " STR(SPECIAL_VARS_END) "\n"); -asm(".include \"constants/gba_constants.inc\"\n"); // Make overworld script macros available. asm(".include \"constants/gba_constants.inc\"\n" diff --git a/tools/preproc/asm_file.cpp b/tools/preproc/asm_file.cpp index 83e84a6fde..10330f1774 100644 --- a/tools/preproc/asm_file.cpp +++ b/tools/preproc/asm_file.cpp @@ -620,6 +620,10 @@ bool AsmFile::ParseEnum() } enumCounter = 0; } + // HACK(#7394): Make the definitions global so that C 'asm' + // statements are able to reference them (if they happen to + // be available in an assembled object file). + std::printf(".global %s; ", currentIdentName.c_str()); std::printf(".equiv %s, (%s) + %ld\n", currentIdentName.c_str(), enumBase.c_str(), enumCounter); enumCounter++; symbolCount++;