All of lore.kernel.org
 help / color / mirror / Atom feed
* MIPS assembly question
@ 2007-09-20 23:14 Winson Yung
  2007-09-20 23:44 ` David Daney
  2007-09-21  9:34 ` Freddy Spierenburg
  0 siblings, 2 replies; 3+ messages in thread
From: Winson Yung @ 2007-09-20 23:14 UTC (permalink / raw)
  To: linux-mips

Hi there, I have some general mips inline assembly question regards to
32 bit atomic operation, here a section of its assembly
implementation:

                "       .set    mips3                                   \n"
                "1:     ll      %0, %2                  # __cmpxchg_u32 \n"
                "       bne     %0, %z3, 2f                             \n"
                "       .set    mips0                                   \n"
                "       move    $1, %z4                                 \n"
                "       .set    mips3                                   \n"
                "       sc      $1, %1                                  \n"
                "       beqzl   $1, 1b                                  \n"

Questions:

1) what does 'z' mean in the line of 'bne %0, %z3, 2f'?
2) Is $1 suppose to be use as an constant 1, I don't understand the
line 'sc  $1, %1'

Will appreciate if someone can point out to me a good tutorial on
explaining these little things.

Thanks!
/Winson.

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

* Re: MIPS assembly question
  2007-09-20 23:14 MIPS assembly question Winson Yung
@ 2007-09-20 23:44 ` David Daney
  2007-09-21  9:34 ` Freddy Spierenburg
  1 sibling, 0 replies; 3+ messages in thread
From: David Daney @ 2007-09-20 23:44 UTC (permalink / raw)
  To: Winson Yung; +Cc: linux-mips

Winson Yung wrote:
> Hi there, I have some general mips inline assembly question regards to
> 32 bit atomic operation, here a section of its assembly
> implementation:
> 
>                 "       .set    mips3                                   \n"
>                 "1:     ll      %0, %2                  # __cmpxchg_u32 \n"
>                 "       bne     %0, %z3, 2f                             \n"
>                 "       .set    mips0                                   \n"
>                 "       move    $1, %z4                                 \n"
>                 "       .set    mips3                                   \n"
>                 "       sc      $1, %1                                  \n"
>                 "       beqzl   $1, 1b                                  \n"
> 
> Questions:
> 
> 1) what does 'z' mean in the line of 'bne %0, %z3, 2f'?

I think this 'z' comes from print_operand() in gcc/config/mips/mips.c in 
  GCC:

    'z'	if the operand is 0, use $0 instead of normal operand.

This is an optimization so that if you are comparing against the value 
of zero, you can use $0 instead of loading up another register with the 
value of zero first.

> 2) Is $1 suppose to be use as an constant 1, I don't understand the
> line 'sc  $1, %1'

$1 is register 1.  AKA $at.

So that line is Store Conditional Word from register 1 into the memory 
location indicated by operand 1.

> 
> Will appreciate if someone can point out to me a good tutorial on
> explaining these little things.
> 

If it is not in the GCC documentation, then you have to look at the GCC 
source code.  I don't know of any better way.

David Daney

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

* Re: MIPS assembly question
  2007-09-20 23:14 MIPS assembly question Winson Yung
  2007-09-20 23:44 ` David Daney
@ 2007-09-21  9:34 ` Freddy Spierenburg
  1 sibling, 0 replies; 3+ messages in thread
From: Freddy Spierenburg @ 2007-09-21  9:34 UTC (permalink / raw)
  To: Winson Yung; +Cc: linux-mips

[-- Attachment #1: Type: text/plain, Size: 551 bytes --]

Hi Winson,

On Thu, Sep 20, 2007 at 04:14:15PM -0700, Winson Yung wrote:
> Will appreciate if someone can point out to me a good tutorial on
> explaining these little things.

Maybe this is too basic, but I liked this tutorial very much:

	http://chortle.ccsu.edu/AssemblyTutorial/TutorialContents.html


-- 
$ cat ~/.signature
Freddy Spierenburg <freddy@dusktilldawn.nl>  http://freddy.snarl.nl/
GnuPG: 0x7941D1E1=C948 5851 26D2 FA5C 39F1  E588 6F17 FD5D 7941 D1E1
$ # Please read http://www.ietf.org/rfc/rfc2015.txt before complain!

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

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

end of thread, other threads:[~2007-09-21  9:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-20 23:14 MIPS assembly question Winson Yung
2007-09-20 23:44 ` David Daney
2007-09-21  9:34 ` Freddy Spierenburg

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.