building hello world on osx, startup.s error
building hello world on osx, startup.s error
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?
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?
I found this in another thread, but I couldn't figure out how to properly include it, so I found the file at
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.
/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]
built hello world on osx
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 . . .
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 . . .
btw : a tip
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]
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...I also ran elf2pbp on my pc cuz the
version i compiled on osx seg faulted.
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]
... 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.
Ok,
In outpatch.cpp, make these mods:
First add this function:
And then change one line (I am sure you can find it):
That should get you going on OSX with respect to using outpatch.
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(bytes[0] | (bytes[1]<<8) | (bytes[2]<<16) | (bytes[3]<<24));
}
Code: Select all
*(unsigned long *)(buf+0x40)=le32(ofs_modulename-4);
No thanks, I'd rather get the toolchain working properly before adding in a bunch of cosmetic changes.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.
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.