Hacky support for enums in C asm statements (#7494)

This commit is contained in:
Martin Griffin
2025-08-11 09:06:23 +01:00
committed by GitHub
parent 93bfa23142
commit de6c9c6176
2 changed files with 4 additions and 1 deletions

View File

@@ -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"

View File

@@ -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++;