1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-01-17 14:17:01 +00:00
oot/src/makerom/entry.s

62 lines
1.7 KiB
ArmAsm
Raw Normal View History

#include "ultra64/asm.h"
#include "ultra64/regdef.h"
#include "boot.h"
.text
2025-01-03 04:42:28 +00:00
#if defined(NON_MATCHING) || defined(__sgi)
/* Non-matching builds or IDO */
#define PAD_TO 0x60
#define LA(reg, sym) la reg, sym
#define BOOT_STACK_TOP sBootThreadStack + BOOT_STACK_SIZE
#else
/* EGCS */
#define PAD_TO 0x50
#define LA(reg, sym) \
lui reg, %lo(sym##_HI); \
ori reg, %lo(sym)
#endif
#if !defined(AVOID_UB)
/* Old assembler workarounds: The makerom tool in the N64 SDK was given the bss segment size as a const
* literal, and since this literal was < 0x10000 it was loaded in one instruction. We don't have access
* to the bss segment size until we link everything so we cannot do the same thing. Instead we must load
* only the lower 16 bits of the bss size for matching.
* When AVOID_UB is enabled, don't do this and instead load the full symbol value, otherwise not all of
* bss may be cleared. */
2025-01-03 04:42:28 +00:00
#if defined(__sgi)
#define LOAD_BSS_SIZE(reg) li reg, %half(_bootSegmentBssSize)
#else
2025-01-03 04:42:28 +00:00
#define LOAD_BSS_SIZE(reg) ori reg, zero, %lo(_bootSegmentBssSize)
#endif
#else
#define LOAD_BSS_SIZE(reg) LA(reg, _bootSegmentBssSize)
#endif
LEAF(entrypoint)
/* Clear boot segment .bss */
2025-01-03 04:42:28 +00:00
LA( t0, _bootSegmentBssStart)
LOAD_BSS_SIZE(t1)
.clear_bss:
sw zero, 0(t0)
sw zero, 4(t0)
addi t0, t0, 8
addi t1, t1, -8
bnez t1, .clear_bss
/* Set up stack and enter program code */
2025-01-03 04:42:28 +00:00
LA( sp, BOOT_STACK_TOP)
LA( t2, bootproc)
jr t2
END(entrypoint)
2025-01-03 04:42:28 +00:00
#ifdef __sgi
/* IDO can't take absolute differences of symbols so the size of the above is hardcoded */
.repeat (0x60 - 0x34)
.byte 0
.endr
2025-01-03 04:42:28 +00:00
#else
/* Pad to a total size taking into account the size of the above */
.fill PAD_TO - (. - entrypoint)
#endif