All of lore.kernel.org
 help / color / mirror / Atom feed
* some question about Extended Asm
@ 2010-01-06  7:13 loody
  2010-01-06 12:48 ` Maciej W. Rozycki
  0 siblings, 1 reply; 5+ messages in thread
From: loody @ 2010-01-06  7:13 UTC (permalink / raw)
  To: Linux MIPS Mailing List

Dear all:
I write an assembly in c at the end of letter.
I try to
  "or %0, count\n", where count is $a1.
so I write %1 as count and write
  "or %0, %1\n" and assign %1 as count in input section.

But the result is not what I expect.
the result is "   or      v1,v1,v0"
Did I miss something or the only way to meet what I need is directly write
 "or %0, $a1\n"?
appreciate your help,
miloody

void cpuperformanceEvent11_initial(unsigned int mode,unsigned count)
{
bf0106d8:       27bdfff0        addiu   sp,sp,-16
bf0106dc:       afbe0008        sw      s8,8(sp)
bf0106e0:       03a0f021        move    s8,sp
bf0106e4:       afc40010        sw      a0,16(s8)
bf0106e8:       afc50014        sw      a1,20(s8)
        unsigned int temp;
        asm(
bf0106ec:       8fc30010        lw      v1,16(s8)
bf0106f0:       8fc20014        lw      v0,20(s8)
bf0106f4:       4003c801        mfc0    v1,c0_perfcnt,1
bf0106f8:       00621825        or      v1,v1,v0
bf0106fc:       4083c801        mtc0    v1,c0_perfcnt,1
                "mfc0 %0, $25, 1\n"
                "or %0, %1\n"
                "mtc0 %0, $25, 1\n"
                :
                :"r" (mode), "r" (count)
        );
}


void cpuperformanceEvent0_initial(unsigned int mode,unsigned count)
{
	unsigned int temp;
	asm(
		"mfc0 %0, $25, 1\n"
		"or %0, %1\n"
		"mtc0 %0, $25, 1\n"
		:
		:"r" (mode), "r" (count)
	);
}

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

* Re: some question about Extended Asm
  2010-01-06  7:13 some question about Extended Asm loody
@ 2010-01-06 12:48 ` Maciej W. Rozycki
  2010-01-10 16:09   ` loody
  0 siblings, 1 reply; 5+ messages in thread
From: Maciej W. Rozycki @ 2010-01-06 12:48 UTC (permalink / raw)
  To: loody; +Cc: Linux MIPS Mailing List

On Wed, 6 Jan 2010, loody wrote:

> I try to
>   "or %0, count\n", where count is $a1.
> so I write %1 as count and write
>   "or %0, %1\n" and assign %1 as count in input section.
> 
> But the result is not what I expect.
> the result is "   or      v1,v1,v0"
> Did I miss something or the only way to meet what I need is directly write
>  "or %0, $a1\n"?

 As you can figure out from the semantics:

	or	v1, v0

is a shorthand for:

	or	v1, v1, v0

There is no two-argument register OR instruction in the standard MIPS 
instruction set (nor there is a need for one).

  Maciej

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

* Re: some question about Extended Asm
  2010-01-06 12:48 ` Maciej W. Rozycki
@ 2010-01-10 16:09   ` loody
  2010-01-10 17:14     ` Maciej W. Rozycki
  0 siblings, 1 reply; 5+ messages in thread
From: loody @ 2010-01-10 16:09 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: Linux MIPS Mailing List

Hi:
Thanks for your help.

2010/1/6 Maciej W. Rozycki <macro@linux-mips.org>:
> On Wed, 6 Jan 2010, loody wrote:
>
>> I try to
>>   "or %0, count\n", where count is $a1.
>> so I write %1 as count and write
>>   "or %0, %1\n" and assign %1 as count in input section.
>>
>> But the result is not what I expect.
>> the result is "   or      v1,v1,v0"
>> Did I miss something or the only way to meet what I need is directly write
>>  "or %0, $a1\n"?
>
>  As you can figure out from the semantics:
>
>        or      v1, v0
>
> is a shorthand for:
>
>        or      v1, v1, v0
>There is no two-argument register OR instruction in the standard MIPS
>instruction set (nor there is a need for one).
I have some question about extended assembly in mips
1. is mips assembly in AT&T syntax?
    from the document I google from the web, they emphasize that the
GNU C compiler use AT&T syntax, and they list some example about intel
instructions.
But when I write the extended assembly in mips, I find it seem not AT&T syntax.
The order of input and output is still the same as original mips instructions.
Does that mean GNU compiler for mips doesn't use AT&T syntax?

2. how do we know which parameter is for %0,%1,etc?

suppose my src is as below
 asm(
                "add %0, %1, %2\n"
                "sub %0,%2, %1\n"
                :"=r" (count)
                :"r" (temp), "r" (count)
        );
how do I know which parameter is %0, %1 and %2?
there 2 variable, count and temp above, but in assembly it use 3 parameters.
how to match them?

appreciate your kind help,
miloody

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

* Re: some question about Extended Asm
  2010-01-10 16:09   ` loody
@ 2010-01-10 17:14     ` Maciej W. Rozycki
  2010-01-10 17:17       ` Geert Uytterhoeven
  0 siblings, 1 reply; 5+ messages in thread
From: Maciej W. Rozycki @ 2010-01-10 17:14 UTC (permalink / raw)
  To: loody; +Cc: Linux MIPS Mailing List

On Mon, 11 Jan 2010, loody wrote:

> I have some question about extended assembly in mips
> 1. is mips assembly in AT&T syntax?
>     from the document I google from the web, they emphasize that the
> GNU C compiler use AT&T syntax, and they list some example about intel
> instructions.

 I'm not sure if the "AT&T syntax" term has any meaning except for Intel 
architecture processors.

> But when I write the extended assembly in mips, I find it seem not AT&T syntax.
> The order of input and output is still the same as original mips instructions.
> Does that mean GNU compiler for mips doesn't use AT&T syntax?

 GNU as for MIPS processors uses the same syntax original tools provided 
by MIPS Computer Systems and Silicon Graphics companies used.  This syntax 
is used throughout all the documentation available and has nothing to do 
with the syntax used for Intel architecture processors (in particular, the 
specific instruction and not the data flow direction determines the order 
of operands).

> 2. how do we know which parameter is for %0,%1,etc?
> 
> suppose my src is as below
>  asm(
>                 "add %0, %1, %2\n"
>                 "sub %0,%2, %1\n"
>                 :"=r" (count)
>                 :"r" (temp), "r" (count)
>         );
> how do I know which parameter is %0, %1 and %2?
> there 2 variable, count and temp above, but in assembly it use 3 parameters.
> how to match them?

 See the Extended Asm chapter of the GCC manual.

  Maciej

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

* Re: some question about Extended Asm
  2010-01-10 17:14     ` Maciej W. Rozycki
@ 2010-01-10 17:17       ` Geert Uytterhoeven
  0 siblings, 0 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2010-01-10 17:17 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: loody, Linux MIPS Mailing List

On Sun, Jan 10, 2010 at 18:14, Maciej W. Rozycki <macro@linux-mips.org> wrote:
> On Mon, 11 Jan 2010, loody wrote:
>
>> I have some question about extended assembly in mips
>> 1. is mips assembly in AT&T syntax?
>>     from the document I google from the web, they emphasize that the
>> GNU C compiler use AT&T syntax, and they list some example about intel
>> instructions.
>
>  I'm not sure if the "AT&T syntax" term has any meaning except for Intel
> architecture processors.

It also affects m68k, IIRC.

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

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

end of thread, other threads:[~2010-01-10 17:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-06  7:13 some question about Extended Asm loody
2010-01-06 12:48 ` Maciej W. Rozycki
2010-01-10 16:09   ` loody
2010-01-10 17:14     ` Maciej W. Rozycki
2010-01-10 17:17       ` Geert Uytterhoeven

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.