Linux MIPS Architecture development
 help / color / mirror / Atom feed
* Setting gp on pic code
@ 2006-01-16 10:04 Alex Gonzalez
  2006-01-16 12:11 ` Brett Foster
  0 siblings, 1 reply; 3+ messages in thread
From: Alex Gonzalez @ 2006-01-16 10:04 UTC (permalink / raw)
  To: linux-mips

Hi,

I am trying to set the gp register on pic code as follows:

"la gp,_gp"

Disassembling the resulting code,

"lw gp,0(gp)"

I am confused as to why it uses a gp-relative address instead of an
absolute address for _gp. How I am supposed to reset gp then?

A bit of background. I am working on a dual core chip, with each core
running independently. They both boot from the same startup code, then
the second core waits until the first one sets all the hardware and
loads a pic binary into a shared memory region.

The second core is then released and should reset gp and jump to the
new binary (which is compiled separately from the startup code).

This arrangement seems to work OK if the binary is compiled non-pic,
but for pic code  the gp register is not set to the correct value.

Any insight into this appreciated.

Thanks,
Alex

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Setting gp on pic code
  2006-01-16 10:04 Setting gp on pic code Alex Gonzalez
@ 2006-01-16 12:11 ` Brett Foster
  2006-01-16 17:09   ` Alex Gonzalez
  0 siblings, 1 reply; 3+ messages in thread
From: Brett Foster @ 2006-01-16 12:11 UTC (permalink / raw)
  To: Alex Gonzalez; +Cc: linux-mips

Alex Gonzalez wrote:

>Hi,
>
>I am trying to set the gp register on pic code as follows:
>
>"la gp,_gp"
>
>Disassembling the resulting code,
>
>"lw gp,0(gp)"
>  
>
Yes, this is normal... Use the following to set up the GP:
        //init GP
        lui     gp,%HI(_gp)
        ori     gp,%LO(_gp)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Setting gp on pic code
  2006-01-16 12:11 ` Brett Foster
@ 2006-01-16 17:09   ` Alex Gonzalez
  0 siblings, 0 replies; 3+ messages in thread
From: Alex Gonzalez @ 2006-01-16 17:09 UTC (permalink / raw)
  To: Brett Foster; +Cc: linux-mips

Thanks, that works.

Just for completeness, it needed to be addiu instead of ori as follows:

    lui     $28,%HI(_gp)
    addiu   $28,%LO(_gp)

because %LO is a signed 16 bit number.

Alex

On 1/16/06, Brett Foster <fosterb@uoguelph.ca> wrote:
> Alex Gonzalez wrote:
>
> >Hi,
> >
> >I am trying to set the gp register on pic code as follows:
> >
> >"la gp,_gp"
> >
> >Disassembling the resulting code,
> >
> >"lw gp,0(gp)"
> >
> >
> Yes, this is normal... Use the following to set up the GP:
>         //init GP
>         lui     gp,%HI(_gp)
>         ori     gp,%LO(_gp)
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-01-16 17:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-16 10:04 Setting gp on pic code Alex Gonzalez
2006-01-16 12:11 ` Brett Foster
2006-01-16 17:09   ` Alex Gonzalez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox