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 

building hello world on osx, startup.s error

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



Joined: 16 Jun 2005
Posts: 32
Location: MIT

PostPosted: Thu Jun 16, 2005 9:05 am    Post subject: building hello world on osx, startup.s error Reply with quote

greetz, everyone.

i got the 20050613 pspdev toolchain built fine under osx.
i'm trying to build hello world from saturn exploraction committee
http://anon.ug.to/sec/index.html


and I get this as an error:

~/psp/hellopsp_src>/usr/local/pspdev/psp/bin/psp-gcc -march=r4000 -g -mgp32 -c -xassembler -O -o startup.o startup.s
startup.s: Assembler messages:
startup.s:17: Error: illegal operands `la $v0,_gp'
startup.s:18: Error: illegal operands `move'
startup.s:23: Error: illegal operands `li $v0,1'
startup.s:70: Warning: setting incorrect section attributes for .rodata.entrytable
~/psp/hellopsp_src>

any thoughts?
Back to top
View user's profile Send private message Visit poster's website
MrHTFord



Joined: 10 Feb 2004
Posts: 35
Location: England

PostPosted: Thu Jun 16, 2005 10:54 am    Post subject: Reply with quote

Try searching for, oh, say "illegal operands" using the forum search facility.
Back to top
View user's profile Send private message Send e-mail
wulf



Joined: 13 Apr 2005
Posts: 81

PostPosted: Thu Jun 16, 2005 2:06 pm    Post subject: Reply with quote

Quote:

ee-as has code which provides symbolic names for MIPS registers. psp-as doesn't have this code. When accessing registers, you will have to use the register number, so instead of $v0 you'll need to use $2.

If you search for a regdef.h header file (newlib has one) and include it, you can get the symbolic names through the C preprocessor.


I found this in another thread, but I couldn't figure out how to properly include it, so I found the file at

/usr/local/pspdev/psp/include/machine/regdef.h

and I opened it up.

it's just a bunch of includes, but since I am obviously about as smart as a braindead yak, I still couldn't massage the compiler into believing that I needed the info in that file to.... work or whatever.

so my solution was to manually "preprocess" the startup.s file:
I manually edited all the code that matched the defines int what it should be ie:
anywhere in startup.s I found $v0, I removed and put $2.

kind of a dumb method, but it works..

BTW, if anyone can tell me the easy way to "include" regdef.h, I'd be eternally grateful. [/quote]
Back to top
View user's profile Send private message
shifty



Joined: 16 Jun 2005
Posts: 32
Location: MIT

PostPosted: Thu Jun 16, 2005 3:19 pm    Post subject: built hello world on osx Reply with quote

okay, i tried what they said on the other part, too...i used the
include and changed the filename to startup.S, but it still didn't
work for me, so i changed the file by hand. really easy to do, just
change three instances of $v0 to $2:

la $2,_gp
move $gp,$2

jal xmain
nop
jr $ra
li $2, 1


also, I created this primitive makefile for helloworld
Make sure those are tabs in the lines below all:


LOC = /usr/local/pspdev/psp/bin

GCC = psp-gcc
LD = psp-ld

all: hellopsp.o
$(LOC)/$(GCC) -march=r4000 -g -mgp32 -mlong32 -c hellopsp.c
$(LOC)/$(GCC) -march=r4000 -g -mgp32 -mlong32 -c pg.c
$(LOC)/$(GCC) -march=r4000 -g -mgp32 -c -xassembler -O -o startup.o startup.s
$(LOC)/$(LD) -O0 startup.o hellopsp.o pg.o -M -Ttext 8900000 -q -o out > hellopsp.map

# outpatch not yet built right on osx...
#./outpatch
#echo you got outp as psp elf

As you can see in the comments, outpatch(.exe, etc.) does not build
for me correctly yet under osx. i made a few forceful changes to
get it to compile, but they were too roughshod :) i had to run
outpatch.exe on my pc. I also ran elf2pbp on my pc cuz the
version i compiled on osx seg faulted. Then ran
mswap, and poof! i'm running hello world. this rocks!

. . . thx MrHTFord and all others in the scene at this time . . .
Back to top
View user's profile Send private message Visit poster's website
wulf



Joined: 13 Apr 2005
Posts: 81

PostPosted: Thu Jun 16, 2005 3:53 pm    Post subject: Reply with quote

you might try recompiling outpatch.cpp ... it's just a command line tool.
the only issue is that it uses stdafx.h, which is for windows.
I'm pretty sure the unix equiv is stdio.h, but i could be wrong.. this kind of swapout was discussed somewhere else in this forum, but I can't be sure where.
Back to top
View user's profile Send private message
wulf



Joined: 13 Apr 2005
Posts: 81

PostPosted: Thu Jun 16, 2005 4:06 pm    Post subject: Reply with quote

btw : a tip
Quote:
I also ran elf2pbp on my pc cuz the
version i compiled on osx seg faulted.


just so you know, you don't have to pack the elf into the pbp then extract it every time, if that's what you're doing...
you can just set up one directory on ms1 with the "empty-ish" EBOOT.PBP, and copy and rename that directory everytime you have a new game. you would then just rename outp to EBOOT.PBP, and copy it to ms2 in the approp. dir.

note that if you want the name of each "game" on ms1 to be different, you would have to use pdc's prog on windows to change the PARAM.SFO file for each dir...
[/quote]
Back to top
View user's profile Send private message
Guest






PostPosted: Thu Jun 16, 2005 5:44 pm    Post subject: Reply with quote

BTW, I recall having a fix an endian issue with outpatch.exe in order to use it on Mac OS X. If you don't fix it, its unlikely anything that it is needed for will run.

When I get back home I can let you know what I had to change. Or you can try to figure it out in the meantime...
Back to top
pixel



Joined: 30 Jan 2004
Posts: 791

PostPosted: Thu Jun 16, 2005 7:37 pm    Post subject: Reply with quote

... If any of the psptoolchain maintainers wants me to shift the register aliases patch from the ps2 toolchain to the psp toolchain, just poke me on IRC or so.
_________________
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
Back to top
View user's profile Send private message
Guest






PostPosted: Thu Jun 16, 2005 8:35 pm    Post subject: Reply with quote

Ok,

In outpatch.cpp, make these mods:

First add this function:

Code:
u_int32_t le32(u_int32_t bits)
{
        u_int8_t *bytes;
        bytes = (u_int8_t*)&bits;
        return(bytes[0] | (bytes[1]<<8) | (bytes[2]<<16) | (bytes[3]<<24));
}


And then change one line (I am sure you can find it):

Code:
        *(unsigned long *)(buf+0x40)=le32(ofs_modulename-4);


That should get you going on OSX with respect to using outpatch.
Back to top
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Thu Jun 16, 2005 10:11 pm    Post subject: Reply with quote

pixel wrote:
... If any of the psptoolchain maintainers wants me to shift the register aliases patch from the ps2 toolchain to the psp toolchain, just poke me on IRC or so.


No thanks, I'd rather get the toolchain working properly before adding in a bunch of cosmetic changes.

People just need to learn how to use the forum search feature, how to #include <machine/regdef.h>, and how to compile their assembler source with psp-gcc so that it's preprocessed like any other C source.
Back to top
View user's profile Send private message
wulf



Joined: 13 Apr 2005
Posts: 81

PostPosted: Fri Jun 17, 2005 12:08 am    Post subject: Reply with quote

Thank you, mrbrown!

that little bit o help at the end was all I needed :)
Back to top
View user's profile Send private message
joostp



Joined: 17 Jun 2005
Posts: 29

PostPosted: Fri Jun 17, 2005 8:54 pm    Post subject: Reply with quote

In case anyone needs it, here's a quick patch (unified diff) to make elf2pbp run on mac osx.
Back to top
View user's profile Send private message
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