1 # Copyright 2009-2010, Ifcaro, jimmikaelkael & Polo
2 # Copyright 2006-2008 Polo
3 # Licenced under Academic Free License version 3.0
4 # Review OPNPS2LD README & LICENSE files for further details.
6 # Copyright 2001-2004, ps2dev - http://www.ps2dev.org
7 # Licenced under Academic Free License version 2.0
8 # Review ps2sdk README & LICENSE files for further details.
11 # Remove _ps2sdk_args_parse, _ps2sdk_libc_init and _ps2sdk_libc_deinit weak functions for size optimization
14 .type _init, @function
17 .type _fini, @function
52 # store eventual loader arguments (passed via a0)
58 # setup current thread
67 syscall
# SetupThread(_gp, _stack, _stack_size, _args, _root)
75 syscall
# SetupHeap(_end, _heap_size)
77 # writeback data cache
81 syscall
# FlushCache(0)
84 # call global constructors (weak)
98 jal main
# main(argc, argv)
103 j _exit
# _exit(retval)
117 # call global destructors (weak)
126 # conditional exit (depending on if we got arguments through the loader or not)
136 # called from a loader, close thread
139 sw $
0, ($
7) # clear thread id
142 syscall
# ExitDeleteThread() (noreturn)
145 # not called from a loader, return to browser
148 syscall
# Exit(retval) (noreturn)
155 syscall
# ExitThread() (noreturn)
160 # check normal arguments
167 # check for arguments passed by a loader
179 jr $ra
# $4 = argc, $5 = argv
186 .space 4+16*4+256 # argc, 16 arguments, 256 bytes payload
188 .space 4 # pointer to loader arguments: thread id, argc, argv