1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-08-10 17:00: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,60 @@
.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 osWritebackDCache
/* 0052C0 800046C0 18A00011 */ blez $a1, .L80004708
/* 0052C4 800046C4 00000000 */ nop
/* 0052C8 800046C8 240B2000 */ li $t3, 8192
/* 0052CC 800046CC 00AB082B */ sltu $at, $a1, $t3
/* 0052D0 800046D0 1020000F */ beqz $at, .L80004710
/* 0052D4 800046D4 00000000 */ nop
/* 0052D8 800046D8 00804025 */ move $t0, $a0
/* 0052DC 800046DC 00854821 */ addu $t1, $a0, $a1
/* 0052E0 800046E0 0109082B */ sltu $at, $t0, $t1
/* 0052E4 800046E4 10200008 */ beqz $at, .L80004708
/* 0052E8 800046E8 00000000 */ nop
/* 0052EC 800046EC 310A000F */ andi $t2, $t0, 0xf
/* 0052F0 800046F0 2529FFF0 */ addiu $t1, $t1, -0x10
/* 0052F4 800046F4 010A4023 */ subu $t0, $t0, $t2
.L800046F8:
/* 0052F8 800046F8 BD190000 */ cache 0x19, ($t0)
/* 0052FC 800046FC 0109082B */ sltu $at, $t0, $t1
/* 005300 80004700 1420FFFD */ bnez $at, .L800046F8
/* 005304 80004704 25080010 */ addiu $t0, $t0, 0x10
.L80004708:
/* 005308 80004708 03E00008 */ jr $ra
/* 00530C 8000470C 00000000 */ nop
/**
* void osWritebackDCache(void* vaddr, s32 nbytes);
*
* Writes back the contents of the data cache to main memory for `nbytes` at `vaddr`.
* If `nbytes` is as large as or larger than the data cache size, the entire cache is
* written back.
*/
LEAF(osWritebackDCache)
// If the amount to write back is less than or equal to 0, return immediately
blez $a1, .ret
nop
// If the amount to write back is as large as or larger than
// the data cache size, write back all
li $t3, DCACHE_SIZE
sltu $at, $a1, $t3
beqz $at, .all
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, .ret
nop
// Mask and subtract to align to cache line
andi $t2, $t0, DCACHE_LINEMASK
addiu $t1, $t1, -DCACHE_LINESIZE
subu $t0, $t0, $t2
1:
cache (CACH_PD | C_HWB), ($t0)
sltu $at, $t0, $t1
bnez $at, 1b
addiu $t0, $t0, DCACHE_LINESIZE
.ret:
jr $ra
nop
.L80004710:
/* 005310 80004710 3C088000 */ lui $t0, 0x8000
/* 005314 80004714 010B4821 */ addu $t1, $t0, $t3
/* 005318 80004718 2529FFF0 */ addiu $t1, $t1, -0x10
.L8000471C:
/* 00531C 8000471C BD010000 */ cache 1, ($t0)
/* 005320 80004720 0109082B */ sltu $at, $t0, $t1
/* 005324 80004724 1420FFFD */ bnez $at, .L8000471C
/* 005328 80004728 25080010 */ addiu $t0, 0x10
/* 00532C 8000472C 03E00008 */ jr $ra
/* 005330 80004730 00000000 */ nop
// same as osWritebackDCacheAll in operation
.all:
li $t0, K0BASE
addu $t1, $t0, $t3
addiu $t1, $t1, -DCACHE_LINESIZE
1:
cache (CACH_PD | C_IWBINV), ($t0)
sltu $at, $t0, $t1
bnez $at, 1b
addiu $t0, DCACHE_LINESIZE
jr $ra
nop
END(osWritebackDCache)