Hi guys, any of you can help me how and post a simple piece of asm code that i can build directly using psp-as?
I mean i'm not interested in gcc asm, i want the real deal :) I want to research some code generation stuff, but i'm kind of stuck on how to bootstrap my application.
Thanks!
			
			
									
									
						minumum hello world asm code for psp-as?
Code: Select all
Andrey:/cygdrive/b/src/noscript$ cat>hello.c
#include "stdio.h"
int main(int argc,char **argv){
        printf("Hello world!\n");
        return 0;
}
[1]+  Stopped                 cat > hello.c
Andrey:/cygdrive/b/src/noscript$ psp-gcc hello.c -S -o hello.S
Andrey:/cygdrive/b/src/noscript$ cat hello.S
        .file   1 "hello.c"
        .section .mdebug.eabi32
        .section .gcc_compiled_long32
        .previous
        .rdata
        .align  2
$LC0:
        .ascii  "Hello world!\000"
        .text
        .align  2
        .globl  main
        .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)
        lui     $2,%hi($LC0)
        addiu   $4,$2,%lo($LC0)
        jal     puts
        nop
        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.1.0 (PSPDEV 20060507)"
Andrey:/cygdrive/b/src/noscript$ psp-as hello.S -o hello.o
Andrey:/cygdrive/b/src/noscript$ 
Calling the sdk from assembly is easy - just put the arguments into a0-a3, and t0-t3. If you have more than 8 args (not often, but does sometimes happen), put the rest on the stack. Then just do "jal sdk_fn_name". jal has a delay slot, so don't forget that. Also don't forget the ABI... many registers may be destroyed by the called function. Only s0-s8 and a couple other regs won't be walked on.