building hello world on osx, startup.s error

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
shifty
Posts: 32
Joined: Thu Jun 16, 2005 8:59 am
Location: MIT
Contact:

building hello world on osx, startup.s error

Post by shifty »

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?
MrHTFord
Posts: 35
Joined: Tue Feb 10, 2004 2:04 am
Location: England

Post by MrHTFord »

Try searching for, oh, say "illegal operands" using the forum search facility.
wulf
Posts: 81
Joined: Wed Apr 13, 2005 6:56 pm

Post by wulf »


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]
shifty
Posts: 32
Joined: Thu Jun 16, 2005 8:59 am
Location: MIT
Contact:

built hello world on osx

Post by shifty »

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 . . .
wulf
Posts: 81
Joined: Wed Apr 13, 2005 6:56 pm

Post by wulf »

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.
wulf
Posts: 81
Joined: Wed Apr 13, 2005 6:56 pm

Post by wulf »

btw : a tip
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]
Guest

Post by Guest »

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...
pixel
Posts: 791
Joined: Fri Jan 30, 2004 11:43 pm

Post by pixel »

... 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.
Guest

Post by Guest »

Ok,

In outpatch.cpp, make these mods:

First add this function:

Code: Select all

u_int32_t le32(u_int32_t bits)
{
        u_int8_t *bytes;
        bytes = (u_int8_t*)&bits;
        return&#40;bytes&#91;0&#93; | &#40;bytes&#91;1&#93;<<8&#41; | &#40;bytes&#91;2&#93;<<16&#41; | &#40;bytes&#91;3&#93;<<24&#41;&#41;;
&#125;
And then change one line (I am sure you can find it):

Code: Select all

        *&#40;unsigned long *&#41;&#40;buf+0x40&#41;=le32&#40;ofs_modulename-4&#41;;
That should get you going on OSX with respect to using outpatch.
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

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.
wulf
Posts: 81
Joined: Wed Apr 13, 2005 6:56 pm

Post by wulf »

Thank you, mrbrown!

that little bit o help at the end was all I needed :)
joostp
Posts: 29
Joined: Fri Jun 17, 2005 8:43 pm

Post by joostp »

In case anyone needs it, here's a quick patch (unified diff) to make elf2pbp run on mac osx.
Post Reply