Advertising (This ad goes away for registered users. You can Login or Register)

psp mips programming

Forum rules
Forum rule Nº 15 is strictly enforced in this subforum.
$PsPhaKeR
Posts: 85
Joined: Fri Nov 26, 2010 6:18 pm

psp mips programming

Post by $PsPhaKeR »

So I made this Hello World for PSP with assembly mips, now I get a strange error that I cannot comprehend.
I have never programed for the PSP in mips so I am a little confused here.

Code: Select all

psp-gcc -I. -IC:/pspsdk/psp/sdk/include -G0 -Wall -O0 -ggdb  -I. -IC:/pspsdk/psp
/sdk/include -G0 -Wall -O0 -ggdb    -c -o main.o main.S
psp-gcc -I. -IC:/pspsdk/psp/sdk/include -G0 -Wall -O0 -ggdb  -D_PSP_FW_VERSION=1
50  -L. -LC:/pspsdk/psp/sdk/lib -nostartfiles  main.o  -lpspdebug -lpspdisplay -
lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_res
olver -lpsputility -lpspuser -lpspkernel -o hello
c:/pspsdk/bin/../lib/gcc/psp/4.3.5/../../../../psp/bin/ld.exe: warning: cannot f
ind entry symbol _start; defaulting to 0000000008900018
true hello
psp-gcc -I. -IC:/pspsdk/psp/sdk/include -G0 -Wall -O0 -ggdb  -D_PSP_FW_VERSION=1
50  -L. -LC:/pspsdk/psp/sdk/lib -nostartfiles  main.o  -lpspdebug -lpspdisplay -
lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_res
olver -lpsputility -lpspuser -lpspkernel -o world.elf
c:/pspsdk/bin/../lib/gcc/psp/4.3.5/../../../../psp/bin/ld.exe: warning: cannot f
ind entry symbol _start; defaulting to 0000000008900018
true world.elf
mksfo 'Hello World' PARAM.SFO
psp-strip hello world.elf -o hello world_strip.elf
Usage: psp-strip <option(s)> in-file(s)
 Removes symbols and sections from files
 The options are:
  -I --input-target=<bfdname>      Assume input file is in format <bfdname>
  -O --output-target=<bfdname>     Create an output file in format <bfdname>
  -F --target=<bfdname>            Set both input and output format to <bfdname>

  -p --preserve-dates              Copy modified/access timestamps to the output

  -R --remove-section=<name>       Remove section <name> from the output
  -s --strip-all                   Remove all symbol and relocation information
  -g -S -d --strip-debug           Remove all debugging symbols & sections
     --strip-unneeded              Remove all symbols not needed by relocations
     --only-keep-debug             Strip everything but the debug information
  -N --strip-symbol=<name>         Do not copy symbol <name>
  -K --keep-symbol=<name>          Do not strip symbol <name>
     --keep-file-symbols           Do not strip file symbol(s)
  -w --wildcard                    Permit wildcard in symbol comparison
  -x --discard-all                 Remove all non-global symbols
  -X --discard-locals              Remove any compiler-generated symbols
  -v --verbose                     List all object files modified
  -V --version                     Display this program's version number
  -h --help                        Display this output
     --info                        List object formats & architectures supported

  -o <file>                        Place stripped output into <file>
psp-strip: supported targets: elf32-littlemips elf32-bigmips elf64-bigmips elf64
-littlemips elf64-little elf64-big elf32-little elf32-big srec symbolsrec tekhex
 binary ihex
make: *** [EBOOT.PBP] Error 1
main.S

Code: Select all

	.text
main:
	la	$a0, hello
	li	$v0, 4
	syscall

	li	$v0, 10
	syscall

	.data

hello:	.asciiz "Hello World\n"  
makefile

Code: Select all

TARGET = hello world
OBJS = main.o 

INCDIR =
CFLAGS = -G0 -O0 -Wall -ggdb 

CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

LIBDIR =
LDFLAGS = -nostartfiles
LIBS=

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Hello World

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak

FIXUP=true
Advertising
$PsPhaKeR
Posts: 85
Joined: Fri Nov 26, 2010 6:18 pm

Re: psp mips programming

Post by $PsPhaKeR »

*bump*
Advertising
m0skit0
Guru
Posts: 3817
Joined: Mon Sep 27, 2010 6:01 pm

Re: psp mips programming

Post by m0skit0 »

Do not bump threads and do not double post :|

Your assembly program is plain wrong. If you think making a "Hello world" in assembly is this simple, you're completely off the way. Maybe you should get a good MIPS manual or instruction reference.

Code: Select all

la   $a0, hello
I'm not very inclined to use pseudo-instructions. Use LUI and ORI instead of LA.

Code: Select all

li   $v0, 4
This makes no sense. I don't know what do you want to do with this, actually. Parameters are passed on $aX registers, not on $vX. Maybe the parameter for the syscall? If so, it's not that way.

Code: Select all

syscall
And? SYSCALL need a number to know what system call you're calling. And you cannot know what that number would be. Kernel has to resolve them on the stubs section for the ELF. It's way more complicated than what you seem to think.

And same goes for the remaining 2 instructions. I suggest you take a look at MARS, a MIPS simulator. Try to practice there before trying on the PSP.

Also for programming assembly on PSP, I still recommend to wrap it inside C code, because PSPSDK does a lot of initializations and creates the ELF structure you need for your homebrew to be run. Either use asm() inside C (be aware that you should respect psp-as syntax, look for examples) or have your homebrew load a binary file and jump to it, like an exploit would do.

And again, PSP is not a good platform to learn.
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"
FrEdDy
HBL Collaborator
Posts: 243
Joined: Mon Sep 27, 2010 7:08 pm
Contact:

Re: psp mips programming

Post by FrEdDy »

m0skit0 wrote:Do not bump threads and do not double post :|

Your assembly program is plain wrong. If you think making a "Hello world" in assembly is this simple, you're completely off the way. Maybe you should get a good MIPS manual or instruction reference.

Code: Select all

la   $a0, hello
I'm not very inclined to use pseudo-instructions. Use LUI and ORI instead of LA.

Code: Select all

li   $v0, 4
This makes no sense. I don't know what do you want to do with this, actually. Parameters are passed on $aX registers, not on $vX. Maybe the parameter for the syscall? If so, it's not that way.

Code: Select all

syscall
And? SYSCALL need a number to know what system call you're calling. And you cannot know what that number would be. Kernel has to resolve them on the stubs section for the ELF. It's way more complicated than what you seem to think.

And same goes for the remaining 2 instructions. I suggest you take a look at MARS, a MIPS simulator. Try to practice there before trying on the PSP.

Also for programming assembly on PSP, I still recommend to wrap it inside C code, because PSPSDK does a lot of initializations and creates the ELF structure you need for your homebrew to be run. Either use asm() inside C (be aware that you should respect psp-as syntax, look for examples) or have your homebrew load a binary file and jump to it, like an exploit would do.

And again, PSP is not a good platform to learn.
He learned MIPS R2000/3000,where syscall value is passed in v0,but,still,I quote m0skit0: psp is not a good platform to learn.
https://github.com/freddy-156
<@n00b81> FREDDY CUTTIES
m0skit0
Guru
Posts: 3817
Joined: Mon Sep 27, 2010 6:01 pm

Re: psp mips programming

Post by m0skit0 »

Anyways PSP is MIPS IV. He should at least know that if he's attempting to code in assembly :roll:
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"
m0skit0
Guru
Posts: 3817
Joined: Mon Sep 27, 2010 6:01 pm

Re: psp mips programming

Post by m0skit0 »

Assemble a normal "hello world" in C and look at the .s files. Or you can also disasm the typical "hello world" exploits as well.

And again, the PSP is not a good platform for learning. Check the MIPS simulator I linked you to (that if you actually read my post :roll: )
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"
grief3r
Posts: 358
Joined: Sat Nov 09, 2013 4:12 am

Re: psp mips programming

Post by grief3r »

lol i have a question,

lets say i was playing a random game on my psp, is it possible to use an existing function such as sound etc and use
tempAR to write a subroutine for a simple hello world?

thanks in advance
PSV1001 2.61 FieldRunners
PSP1001 6.60 Pro-C
PSP 3001 6.20 Pro-C2
frostegater
Guru
Posts: 426
Joined: Mon Jan 24, 2011 1:54 pm
Location: Russia

Re: psp mips programming

Post by frostegater »

FrEdDy wrote:I quote m0skit0: psp is not a good platform to learn.
:D all the same, PSP is my first platform and C is my first language. Noone believes me.

BTW, guys, who can remember what means "sra" and "ext" in C?
Our hearts will beating on 333MHz 'till we die
noname120
Developer
Posts: 777
Joined: Thu Oct 07, 2010 4:29 pm

Re: psp mips programming

Post by noname120 »

frostegater wrote:
FrEdDy wrote:I quote m0skit0: psp is not a good platform to learn.
:D all the same, PSP is my first platform and C is my first language. Noone believes me.
Same here.
BTW, guys, who can remember what means "sra" and "ext" in C?
In C? No idea... However, in MIPS IV, sra means "Shift Right Arithmetic", but I've no idea of what ext means.
Funny stuff
<yifanlu> I enjoy being loud and obnoxious
<yifanlu> rooting an android is like getting a hooker pregnant
<xerpi> I sometimes think I should leave all this stressing **** and be a farmer instead
qwikrazor87
Guru
Posts: 2874
Joined: Sat Apr 21, 2012 1:23 pm
Location: The North Pole

Re: psp mips programming

Post by qwikrazor87 »

noname120 wrote:but I've no idea of what ext means.
extract
http://code.google.com/p/pops-gte/wiki/DisasmHints
PSP 2001 - TA-085 - 6.61 PRO-C2
PS Vita 3G - PCH-1101 - 3.65 HENkaku Ensō
Alcatel phone - Android 8.1.0
Laptop - Toshiba Satellite L305D-S5974 - Ubuntu 16.04 LTS
Locked

Return to “Programming and Security”