9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] return vlong
@ 2005-05-20 14:53 Sergey Reva
  2005-05-20 15:00 ` Russ Cox
  2005-05-20 15:15 ` C H Forsyth
  0 siblings, 2 replies; 4+ messages in thread
From: Sergey Reva @ 2005-05-20 14:53 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Hello Fans,

Where I can get information about Plan 9 C call conversion.
Especially, how return uvlong value?

TEXT rdtsc(SB),0,$0
        BYTE $0x0F
        BYTE $0x31

        MOVL .ret+0(FP),BX
        MOVL AX,(BX)
        MOVL DX,4(BX)
        RET

I borrow last 3 lines (not including RET) from C compiler
output (-S flag), and seems it work (CPU freq calculation)
but I not understand what is '.ret', where it's placed.

Sergey
-- 
http://rs-rlab.narod.ru                          mailto:rs_rlab@mail.ru



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

* Re: [9fans] return vlong
  2005-05-20 14:53 [9fans] return vlong Sergey Reva
@ 2005-05-20 15:00 ` Russ Cox
  2005-05-20 15:07   ` jmk
  2005-05-20 15:15 ` C H Forsyth
  1 sibling, 1 reply; 4+ messages in thread
From: Russ Cox @ 2005-05-20 15:00 UTC (permalink / raw)
  To: Sergey Reva, Fans of the OS Plan 9 from Bell Labs

a call to a function that returns a vlong or structure
passes an invisible (to the c programmer) first argument
that is a pointer to somewhere to write the return value.
so the following two functions have equivalent assembly
(but different c types):

vlong
return0(void)
{
    return 0;
}

void
return0(vlong *v)
{
    *v = 0;
}

russ


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

* Re: [9fans] return vlong
  2005-05-20 15:00 ` Russ Cox
@ 2005-05-20 15:07   ` jmk
  0 siblings, 0 replies; 4+ messages in thread
From: jmk @ 2005-05-20 15:07 UTC (permalink / raw)
  To: russcox, 9fans

that's on the 386. other architectures may return the value
in one or two registers.

On Fri May 20 11:01:27 EDT 2005, russcox@gmail.com wrote:
> a call to a function that returns a vlong or structure
> passes an invisible (to the c programmer) first argument
> that is a pointer to somewhere to write the return value.
> so the following two functions have equivalent assembly
> (but different c types):
> 
> vlong
> return0(void)
> {
>     return 0;
> }
> 
> void
> return0(vlong *v)
> {
>     *v = 0;
> }
> 
> russ


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

* Re: [9fans] return vlong
  2005-05-20 14:53 [9fans] return vlong Sergey Reva
  2005-05-20 15:00 ` Russ Cox
@ 2005-05-20 15:15 ` C H Forsyth
  1 sibling, 0 replies; 4+ messages in thread
From: C H Forsyth @ 2005-05-20 15:15 UTC (permalink / raw)
  To: rs_rlab, 9fans

>>        MOVL .ret+0(FP),BX
>>but I not understand what is '.ret', where it's placed.

it's put in the symbol table as the name for the value at 0 offset from
the virtual frame pointer (actually 4(SP) on the 386, the offset of the first parameter,
since 0(SP) has the return address).
otherwise the name has no significance.



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

end of thread, other threads:[~2005-05-20 15:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-20 14:53 [9fans] return vlong Sergey Reva
2005-05-20 15:00 ` Russ Cox
2005-05-20 15:07   ` jmk
2005-05-20 15:15 ` C H Forsyth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).