 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
sauron_le_noir
Joined: 05 Jul 2008 Posts: 229
|
Posted: Wed Jul 15, 2009 7:53 am Post subject: Mips specific psp question |
|
|
I'm currently learning mips assembler but i have some question specific to the psp
as described in the module tutorial from Anissian every prx containt a module info
When i generate a S file from a helloworld c file i've got this
| Code: | .globl module_info
.section .rodata.sceModuleInfo,"a",@progbits
.align 4
.type module_info, @object
.size module_info, 52
module_info:
.half 0
.byte 1
.byte 1
.ascii "Hello world\000"
.space 15
.byte 0
.word _gp
.word __lib_ent_top
.word __lib_ent_bottom
.word __lib_stub_top
.word __lib_stub_bottom
.set push
.section .lib.ent.top, "a", @progbits
.align 2
.word 0
etc.....
|
what is the meaning of the "a" and @progbits in the section .rodata.sceModuleInfo
is the name sceModuleInfo specific to the sdk or is it spectific to the psp prx loader
is the _gp sybmol related to this or is it another specific psp thing
Gp-Relative Addressing
A consequence of the way the MIPS instruction set is crammed into 32-bit
operations is that accesses to compiled-in locations usually require at least two
instructions, for example:
lw $2, addr => lui at, %hi(addr)
lw $2, %lo(addr)(at)
In programs that make a lot of use of global or static data, this can make the
compiled code significantly fatter and slower.
Early MIPS compilers introduced a fix for this, which has been carried into
most MIPS toolchains. It’s usually called gp-relative addressing. This technique
requires the cooperation of the compiler, assembler, linker, and start-up code to
pool all of the “small” variables and constants into a single memory region; then
it sets register $28 (known as the global pointer or gp register) to point to the
middle of this region. (The linker creates a special symbol, gp, whose address
is the middle of this region. The address of gpmust then be loaded into the gp
register by the start-up code, before any load or store instructions are used.) So
long as all the variables together take up no more than 64 KB of space, all the
data items are now within 32 KB of the midpoint, so a load turns into:
lw $2, addr => lw $2, addr - _gp(at)
The problem is that the compiler and assembler must decide which variables
can be accessed via gp at the time the individual modules are compiled.
The usual test is to include all objects of less than a certain size (eight bytes
is the usual default). This limit can usually be controlled by the “-G n” compiler/
assembler option; specifying “-G 0”will switch this optimization off altogether.
While it is a useful trick, there are some pitfalls to watch out for. You must
take special care when writing assembly code to declare global data items consistently
and correctly:
does someone have a working hello world in asm for a kernel 3.x
minifire is for kernel 1.x ou 1.5 only
if i want to use a sceKernelExitGame is this declaration correct ?
would the nid resolver patch (in memory )correctly a code declared with this 2 macros ?
IMPORT_START "LoadExecForKernel",0x00010000
IMPORT_FUNC "LoadExecForKernel",0x05572A5F,sceKernelExitGame
called with this
| Code: |
jal sceKernelExitGame
nop |
|
|
| Back to top |
|
 |
m0skit0
Joined: 02 Jun 2009 Posts: 226
|
Posted: Thu Jul 16, 2009 1:04 am Post subject: |
|
|
You should check a good ELF refrence, as the "a" and "PROGBITS" are ELF-specific, not MIPS-specific. _________________
| The Incredible Bill Gates wrote: | | The obvious mathematical breakthrough would be development of an easy way to factor large prime numbers. |
|
|
| Back to top |
|
 |
sauron_le_noir
Joined: 05 Jul 2008 Posts: 229
|
Posted: Thu Jul 16, 2009 10:28 am Post subject: |
|
|
thx i have indeed found the meaning of progbits into elf documentation
]ELF Section Attributes
progbits
is stored in the disk image, as opposed to allocated and initialized at load. |
|
| Back to top |
|
 |
|
|
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
|