Skip to content

Commit

Permalink
Add ASM define to wrap mwerks asm keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
LagoLunatic committed Dec 28, 2024
1 parent f18e2b1 commit f543b7b
Show file tree
Hide file tree
Showing 15 changed files with 83 additions and 78 deletions.
2 changes: 2 additions & 0 deletions include/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@
#define ALIGN_DECL(ALIGNMENT) __attribute__((aligned(ALIGNMENT)))
#define SECTION_DATA __declspec(section ".data")
#define SECTION_INIT __declspec(section ".init")
#define ASM asm
#else
#define STATIC_ASSERT(...)
#define ALIGN_DECL(...)
#define SECTION_DATA
#define SECTION_INIT
#define ASM
#endif

extern int __cntlzw(uint);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "NMWException.h"
#include "__ppc_eabi_linker.h"
#include "global.h"

#if __MWERKS__
#pragma exceptions off
Expand All @@ -20,7 +21,7 @@ extern void __fini_cpp_exceptions(void);
static int fragmentID = -2;

/* clang-format off */
static asm char* GetR2() {
static ASM char* GetR2() {
nofralloc;
mr r3, r2
blr
Expand Down
7 changes: 4 additions & 3 deletions src/PowerPC_EABI_Support/Runtime/Src/ptmf.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#include "ptmf.h"
#include "global.h"

const __ptmf __ptmf_null = { 0, 0, 0 };

asm long __ptmf_test(register __ptmf* ptmf) {
ASM long __ptmf_test(register __ptmf* ptmf) {
lwz r5, __ptmf.this_delta(ptmf)
lwz r6, __ptmf.v_offset(ptmf)
lwz r7, __ptmf.f_data(ptmf)
Expand All @@ -17,7 +18,7 @@ asm long __ptmf_test(register __ptmf* ptmf) {
blr
};

asm void __ptmf_cmpr(register __ptmf* lhs, register __ptmf* rhs) {
ASM void __ptmf_cmpr(register __ptmf* lhs, register __ptmf* rhs) {
lwz r5, __ptmf.this_delta(lhs)
lwz r6, __ptmf.this_delta(rhs)
lwz r7, __ptmf.v_offset(lhs)
Expand All @@ -35,7 +36,7 @@ asm void __ptmf_cmpr(register __ptmf* lhs, register __ptmf* rhs) {
blr
};

asm void __ptmf_scall(...) {
ASM void __ptmf_scall(...) {
nofralloc;
lwz r0, __ptmf.this_delta(r12)
lwz r11, __ptmf.v_offset(r12)
Expand Down
45 changes: 23 additions & 22 deletions src/PowerPC_EABI_Support/Runtime/Src/runtime.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "PowerPC_EABI_Support/Runtime/Inc/runtime.h"
#include "global.h"

#ifdef __cplusplus
extern "C" {
Expand All @@ -17,14 +18,14 @@ extern "C" {

#define save_restore_reg r11

asm void __div2u(void);
asm void __div2i(void);
asm void __mod2u(void);
asm void __mod2i(void);
asm void __shl2i(void);
asm void __shr2u(void);
asm void __shr2i(void);
asm void __cvt_dbl_usll(void);
ASM void __div2u(void);
ASM void __div2i(void);
ASM void __mod2u(void);
ASM void __mod2i(void);
ASM void __shl2i(void);
ASM void __shr2u(void);
ASM void __shr2i(void);
ASM void __cvt_dbl_usll(void);

void SAVE_FPR(14)(void);
void SAVE_FPR(15)(void);
Expand Down Expand Up @@ -110,7 +111,7 @@ static const u32 __constants[] = {
* @note Address: 0x800C1B4C
* @note Size: 0x5C
*/
asm u32 __cvt_fp2unsigned(register f64 d)
ASM u32 __cvt_fp2unsigned(register f64 d)
{
#ifdef __MWERKS__ // clang-format off
nofralloc
Expand Down Expand Up @@ -145,7 +146,7 @@ asm u32 __cvt_fp2unsigned(register f64 d)
* @note Address: 0x800C1BA8
* @note Size: 0x4C
*/
asm static void __save_fpr(void) {
ASM static void __save_fpr(void) {
#ifdef __MWERKS__ // clang-format off
nofralloc
stfd fp14,-144(save_restore_reg)
Expand Down Expand Up @@ -178,7 +179,7 @@ asm static void __save_fpr(void) {
* @note Address: 0x800C1BF4
* @note Size: 0x4C
*/
asm static void __restore_fpr(void) {
ASM static void __restore_fpr(void) {
#ifdef __MWERKS__ // clang-format off
nofralloc
lfd fp14,-144(save_restore_reg)
Expand Down Expand Up @@ -211,7 +212,7 @@ asm static void __restore_fpr(void) {
* @note Address: 0x800C1C40
* @note Size: 0x4C
*/
asm static void __save_gpr(void) {
ASM static void __save_gpr(void) {
#ifdef __MWERKS__ // clang-format off
nofralloc
ENTRY_SAVE_GPR(14)
Expand Down Expand Up @@ -256,7 +257,7 @@ asm static void __save_gpr(void) {
* @note Address: 0x800C1C8C
* @note Size: 0x4C
*/
asm static void __restore_gpr(void) {
ASM static void __restore_gpr(void) {
#ifdef __MWERKS__ // clang-format off
nofralloc
ENTRY_RESTORE_GPR(14)
Expand Down Expand Up @@ -301,7 +302,7 @@ asm static void __restore_gpr(void) {
* @note Address: 0x800C1CD8
* @note Size: 0xEC
*/
asm void __div2u(void) {
ASM void __div2u(void) {
#ifdef __MWERKS__ // clang-format off
nofralloc
cmpwi cr0,r3,0
Expand Down Expand Up @@ -379,7 +380,7 @@ asm void __div2u(void) {
* @note Address: 0x800C1DC4
* @note Size: 0x138
*/
asm void __div2i(void) {
ASM void __div2i(void) {
#ifdef __MWERKS__ // clang-format off
nofralloc
stwu r1,-16(r1)
Expand Down Expand Up @@ -482,7 +483,7 @@ asm void __div2i(void) {
* @note Address: 0x800C1EFC
* @note Size: 0xE4
*/
asm void __mod2u(void) {
ASM void __mod2u(void) {
#ifdef __MWERKS__ // clang-format off
nofralloc
cmpwi cr0,r3,0
Expand Down Expand Up @@ -558,7 +559,7 @@ asm void __mod2u(void) {
* @note Address: 0x800C1FE0
* @note Size: 0x10C
*/
asm void __mod2i(void) {
ASM void __mod2i(void) {
#ifdef __MWERKS__ // clang-format off
nofralloc

Expand Down Expand Up @@ -648,7 +649,7 @@ asm void __mod2i(void) {
* @note Address: 0x800C20EC
* @note Size: 0x24
*/
asm void __shl2i(void) {
ASM void __shl2i(void) {
#ifdef __MWERKS__ // clang-format off
nofralloc
subfic r8,r5,32
Expand All @@ -667,7 +668,7 @@ asm void __shl2i(void) {
* @note Address: 0x800C2110
* @note Size: 0x24
*/
asm void __shr2u(void) {
ASM void __shr2u(void) {
#ifdef __MWERKS__ // clang-format off
nofralloc
subfic r8,r5,32
Expand All @@ -686,7 +687,7 @@ asm void __shr2u(void) {
* @note Address: 0x800C2134
* @note Size: 0x28
*/
asm void __shr2i(void) {
ASM void __shr2i(void) {
#ifdef __MWERKS__ // clang-format off
nofralloc
subfic r8, r5, 0x20
Expand All @@ -707,7 +708,7 @@ asm void __shr2i(void) {
* @note Address: 0x800C21F8
* @note Size: 0xCC
*/
asm void __cvt_dbl_usll(void)
ASM void __cvt_dbl_usll(void)
{
#ifdef __MWERKS__ // clang-format off
nofralloc
Expand Down Expand Up @@ -774,4 +775,4 @@ asm void __cvt_dbl_usll(void)

#ifdef __cplusplus
}
#endif
#endif
12 changes: 6 additions & 6 deletions src/dolphin/os/OS.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ f64 ZeroPS;
extern f64 ZeroF;
f64 ZeroF;

asm void __OSFPRInit(void) {
ASM void __OSFPRInit(void) {
// clang-format off
nofralloc

Expand Down Expand Up @@ -451,7 +451,7 @@ static void OSExceptionInit(void) {
DBPrintf("Exceptions initialized...\n");
}

asm void __OSDBIntegrator(void) {
ASM void __OSDBIntegrator(void) {
// clang-format off
nofralloc

Expand All @@ -469,7 +469,7 @@ entry __OSDBINTEND
// clang-format on
}

asm void __OSDBJump(void){
ASM void __OSDBJump(void){
// clang-format off
nofralloc

Expand All @@ -489,7 +489,7 @@ OSExceptionHandler __OSGetExceptionHandler(__OSException exception) {
return OSExceptionTable[exception];
}

static asm void OSExceptionVector(void) {
static ASM void OSExceptionVector(void) {
// clang-format off
nofralloc

Expand Down Expand Up @@ -573,7 +573,7 @@ entry __OSEVEnd
// clang-format on
}

static asm void OSDefaultExceptionHandler(register __OSException exception,
static ASM void OSDefaultExceptionHandler(register __OSException exception,
register OSContext* context) {
// clang-format off
nofralloc
Expand Down Expand Up @@ -605,7 +605,7 @@ static asm void OSDefaultExceptionHandler(register __OSException exception,
// clang-format on
}

asm void __OSPSInit(void){
ASM void __OSPSInit(void){
// clang-format off
nofralloc

Expand Down
4 changes: 2 additions & 2 deletions src/dolphin/os/OSAlarm.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void OSCreateAlarm(OSAlarm* alarm) {
alarm->tag = 0;
}

static inline SetTimer(OSAlarm* alarm) {
static void SetTimer(OSAlarm* alarm) {
OSTime delta;

delta = alarm->fire_time - __OSGetSystemTime();
Expand Down Expand Up @@ -177,7 +177,7 @@ static void DecrementerExceptionCallback(register __OSException exception,
OSLoadContext(context);
}

static asm void DecrementerExceptionHandler(register __OSException exception,
static ASM void DecrementerExceptionHandler(register __OSException exception,
register OSContext* context) {
// clang-format off
nofralloc
Expand Down
Loading

0 comments on commit f543b7b

Please sign in to comment.