forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

minumum hello world asm code for psp-as?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Heimdall



Joined: 10 Nov 2005
Posts: 259
Location: Netherlands

PostPosted: Fri Oct 10, 2008 10:07 pm    Post subject: minumum hello world asm code for psp-as? Reply with quote

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!
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
[wl]



Joined: 05 May 2006
Posts: 16

PostPosted: Fri Oct 10, 2008 10:41 pm    Post subject: Reply with quote

you may get .s file, if u add "-save-temps"(without quotes) flag to CFLAGS in your makefile, to see the "right" structure of program, which can be compiled
Back to top
View user's profile Send private message
Noko



Joined: 06 Sep 2008
Posts: 23

PostPosted: Fri Oct 10, 2008 10:42 pm    Post subject: Reply with quote

Code:
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$
Back to top
View user's profile Send private message
Heimdall



Joined: 10 Nov 2005
Posts: 259
Location: Netherlands

PostPosted: Fri Oct 10, 2008 10:56 pm    Post subject: Reply with quote

Thanks,

Of course, dah!!! i'm really slow today :) i can use GCC to make it!!!
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Sat Oct 11, 2008 6:15 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group