1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-08-18 21:10:19 +00:00

Improve the state of handwritten assembly files (#865)

* Format all handwritten asm and document some

* Use c preprocessor for constants

* Fix

* Fix PI_STATUS_ERROR, some label improvements

* Avoid hi/lo for constants

* Some more comments

* Properly mark functions as functions and their sizes

* Fix merge

* Improvements

* Review suggestions, rework procedure start/end macros to be more like libreultra

* Move IPL3 symbol definitions into ipl3.s

* Fix undefined_syms, add include and language guards to asm.h and fix the comment in gbi.h

* Consistent hex capitalization, add some MIPS builtin defines to CC_CHECK to behave properly

* Add -no-pad-sections assembler option and clean up alignment in gu files and bzero

* Further suggestions and improvements

* Matrix conversion function clarifications

* Fix passing AVOID_UB to gcc

* Suggestions

* Suggestions, global interrupt mask improvements

* Further suggestions, interrupt mask comments

* Comments fixes, rdb.h

* Switch from # comments to // comments, remove unnecesary .set gp=64 directives

* Further review suggestions

* Missed one
This commit is contained in:
Tharo 2022-05-01 00:03:22 +01:00 committed by GitHub
parent b9fded7b4e
commit 7334ffa373
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
62 changed files with 2758 additions and 2083 deletions

View file

@ -1,46 +1,52 @@
.include "macro.inc"
#include "ultra64/asm.h"
#include "ultra64/r4300.h"
# assembler directives
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
.set gp=64 # allow use of 64-bit general purpose registers
.set noat
.set noreorder
.section .text
.balign 16
glabel osInvalICache
/* 006D50 80006150 18A00011 */ blez $a1, .L80006198
/* 006D54 80006154 00000000 */ nop
/* 006D58 80006158 240B4000 */ li $t3, 16384
/* 006D5C 8000615C 00AB082B */ sltu $at, $a1, $t3
/* 006D60 80006160 1020000F */ beqz $at, .L800061A0
/* 006D64 80006164 00000000 */ nop
/* 006D68 80006168 00804025 */ move $t0, $a0
/* 006D6C 8000616C 00854821 */ addu $t1, $a0, $a1
/* 006D70 80006170 0109082B */ sltu $at, $t0, $t1
/* 006D74 80006174 10200008 */ beqz $at, .L80006198
/* 006D78 80006178 00000000 */ nop
/* 006D7C 8000617C 310A001F */ andi $t2, $t0, 0x1f
/* 006D80 80006180 2529FFE0 */ addiu $t1, $t1, -0x20
/* 006D84 80006184 010A4023 */ subu $t0, $t0, $t2
.L80006188:
/* 006D88 80006188 BD100000 */ cache 0x10, ($t0)
/* 006D8C 8000618C 0109082B */ sltu $at, $t0, $t1
/* 006D90 80006190 1420FFFD */ bnez $at, .L80006188
/* 006D94 80006194 25080020 */ addiu $t0, $t0, 0x20
.L80006198:
/* 006D98 80006198 03E00008 */ jr $ra
/* 006D9C 8000619C 00000000 */ nop
.L800061A0:
/* 006DA0 800061A0 3C088000 */ lui $t0, 0x8000
/* 006DA4 800061A4 010B4821 */ addu $t1, $t0, $t3
/* 006DA8 800061A8 2529FFE0 */ addiu $t1, $t1, -0x20
.L800061AC:
/* 006DAC 800061AC BD000000 */ cache 0, ($t0)
/* 006DB0 800061B0 0109082B */ sltu $at, $t0, $t1
/* 006DB4 800061B4 1420FFFD */ bnez $at, .L800061AC
/* 006DB8 800061B8 25080020 */ addiu $t0, 0x20
/* 006DBC 800061BC 03E00008 */ jr $ra
/* 006DC0 800061C0 00000000 */ nop
LEAF(osInvalICache)
// If the amount to invalidate is less than or equal to 0, return immediately
blez $a1, 2f
nop
// If the amount to invalidate is as large as or larger than
// the instruction cache size, invalidate all
li $t3, ICACHE_SIZE
sltu $at, $a1, $t3
beqz $at, 3f
nop
// ensure end address doesn't wrap around and end up smaller
// than the start address
move $t0, $a0
addu $t1, $a0, $a1
sltu $at, $t0, $t1
beqz $at, 2f
nop
// Mask and subtract to align to cache line
andi $t2, $t0, ICACHE_LINEMASK
addiu $t1, $t1, -ICACHE_LINESIZE
subu $t0, $t0, $t2
1:
cache (CACH_PI | C_HINV), ($t0)
sltu $at, $t0, $t1
bnez $at, 1b
addiu $t0, $t0, ICACHE_LINESIZE
2:
jr $ra
nop
3:
li $t0, K0BASE
addu $t1, $t0, $t3
addiu $t1, $t1, -ICACHE_LINESIZE
4:
cache (CACH_PI | C_IINV), ($t0)
sltu $at, $t0, $t1
bnez $at, 4b
addiu $t0, ICACHE_LINESIZE
jr $ra
nop
END(osInvalICache)