Otra forma es tomar un "hello world" y dejar que gcc te genere un desensamblado en mips, asi podrias usarlo de template para cualquier cosa que quieras hacer, por ejemplo:
#include <pspkernel.h>
PSP_MODULE_INFO("ASM Test", 0, 1, 0);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
int main(int argc, char *argv[])
{
pspDebugScreenInit();
pspDebugScreenPrintf("hello world\n");
sceKernelDelayThread(5000000);
sceKernelExitGame();
return 0;
}
Que llevado a mips seria:
.file 1 "main.c"
.section .mdebug.eabi32
.previous
.section .gcc_compiled_long32
.previous
.globl module_info
.section .rodata.sceModuleInfo,"a",@progbits
.align 4
.type module_info, @object
.size module_info, 52
module_info:
.half 0
.byte 0
.byte 1
.ascii "MIPS Test\000"
.space 17
.byte 0
.word _gp
.word __lib_ent_top
.word __lib_ent_bottom
.word __lib_stub_top
.word __lib_stub_bottom
.globl sce_newlib_attribute
.section .sdata,"aw",@progbits
.align 2
.type sce_newlib_attribute, @object
.size sce_newlib_attribute, 4
sce_newlib_attribute:
.word -2147483648
#APP
.set push
.section .lib.ent.top, "a", @progbits
.align 2
.word 0
__lib_ent_top:
.section .lib.ent.btm, "a", @progbits
.align 2
__lib_ent_bottom:
.word 0
.section .lib.stub.top, "a", @progbits
.align 2
.word 0
__lib_stub_top:
.section .lib.stub.btm, "a", @progbits
.align 2
__lib_stub_bottom:
.word 0
.set pop
.text
.rdata
.align 2
$LC0:
.ascii "Hello world\012\000"
#NO_APP
.text
.align 2
.globl main
.set nomips16
.ent main
main:
.frame $fp,16,$31 # vars= 8, regs= 2/0, args= 0, gp= 0
.mask 0xc0000000,-4
.fmask 0x00000000,0
.set noreorder
.set nomacro
addiu $sp,$sp,-16
sw $31,12($sp)
sw $fp,8($sp)
move $fp,$sp
sw $4,0($fp)
sw $5,4($fp)
// inicio del programa
jal pspDebugScreenInit
nop
lui $2,%hi($LC0)
addiu $4,$2,%lo($LC0)
jal pspDebugScreenPrintf
nop
li $2,4980736 # 0x4c0000
ori $4,$2,0x4b40
jal sceKernelDelayThread
nop
jal sceKernelExitGame
nop
// fin del programa
move $2,$0
move $sp,$fp
lw $31,12($sp)
lw $fp,8($sp)
addiu $sp,$sp,16
j $31
nop
.set macro
.set reorder
.end main
.size main, .-main
.ident "GCC: (GNU) 4.3.2"
la parte dentro del main seria (sin contar la inicialización del stack):
....
.rdata
.align 2
$LC0:
.ascii "Hello world\012\000"
....
.text
....
jal pspDebugScreenInit
nop
lui $2,%hi($LC0)
addiu $4,$2,%lo($LC0)
jal pspDebugScreenPrintf
nop
li $2,4980736 # 0x4c0000
ori $4,$2,0x4b40
jal sceKernelDelayThread
nop
jal sceKernelExitGame
nop
que vendria a ser lo siguiente en C:
pspDebugScreenInit();
pspDebugScreenPrintf("hello world\n");
sceKernelDelayThread(5000000);
sceKernelExitGame();