* __asm__
@ 2001-05-23 6:54 Blesson Paul
2001-05-23 7:38 ` __asm__ David Howells
0 siblings, 1 reply; 7+ messages in thread
From: Blesson Paul @ 2001-05-23 6:54 UTC (permalink / raw)
To: linux-kernel
Hi
I am comfronting with a macro __asm__ . What is the meaning of
this. I cannot find the definition of this. I need the meaning of this line
__asm__("and 1 %%esp.%0; ":"=r" (current) : "0" (~8191UL));
This is defined inside the get_current() in current.h
Thanks in advance
by
Blesson
____________________________________________________________________
Get free email and a permanent address at http://www.netaddress.com/?N=1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: __asm__
2001-05-23 6:54 __asm__ Blesson Paul
@ 2001-05-23 7:38 ` David Howells
0 siblings, 0 replies; 7+ messages in thread
From: David Howells @ 2001-05-23 7:38 UTC (permalink / raw)
To: Blesson Paul; +Cc: linux-kernel
> __asm__("and 1 %%esp.%0; ":"=r" (current) : "0" (~8191UL));
This doesn't look right... Where did you get this from.
Taking the one in include/asm-i386/current.h as an example:
| __asm__(
This signifies a piece of inline assembly that the compiler must insert into
it's output code. The __asm__ is the same as asm, but can't be disabled by
command line flags.
| "andl %%esp,%0
"%%" is a macro that expands to a "%".
"%0" is a macro that expands to the first input/output specification.
So in this case, it takes the stack pointer (register %esp) and ANDs it
into a register that contains 0xFFFFE000, leaving the result in that register.
Basically, the a task's task_struct and a task's kernel stack occupy an 8KB
block that is 8KB aligned, with the task_struct at the beginning and the stack
growing from the end downwards. So you can find the task_struct by clearing
the bottom 13 bits of the stack pointer value.
| ; "
The semicolon can be used to separate assembly statements, as can the newline
character escape sequence ("\n").
| :"=r" (current)
This specifies an output constraint (all of which occur after the first colon,
but before the second). The '=' also specifies that this is an output. The 'r'
indicates that a general purpose register should be allocated such that the
instruction can place the output value into it. The bit inside the brackets -
'current' - is the intended destination of the output value (normally a local
variable) once the C part is returned to.
| : "0" (~8191UL));
This specifies an input constraint (all of which occur after the second colon,
but before the third). The '0' references another constraint (in this case,
the first output constraint), saying that the same register or memory location
should be used for both. The '~8191UL' inside the brackets is a constant that
should be loaded into the register allocated for the output value before using
the instructions inside the asm block.
See also the gcc info pages, Topic "C Extensions", subtopic "Extended Asm".
David
^ permalink raw reply [flat|nested] 7+ messages in thread
* __asm__
@ 2005-03-28 4:44 Ankit Jain
2005-03-30 5:29 ` __asm__ Daniel Souza
0 siblings, 1 reply; 7+ messages in thread
From: Ankit Jain @ 2005-03-28 4:44 UTC (permalink / raw)
To: linux-assembly
can anybody tell me when we write like this while
writing asm construct then what does underscore mean?
__asm__("construct")
does it have any connection wit volatile?
thanks
ankit
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* __asm__
@ 2005-03-29 6:48 Ankit Jain
2005-03-29 7:40 ` __asm__ Steve Graegert
2005-04-02 13:18 ` __asm__ Glynn Clements
0 siblings, 2 replies; 7+ messages in thread
From: Ankit Jain @ 2005-03-29 6:48 UTC (permalink / raw)
To: linux prg
can anybody tell me when we write like this while
writing asm construct then what does underscore mean?
__asm__("construct")
does it have any connection wit volatile?
thanks
ankit
__________________________________
Do you Yahoo!?
Make Yahoo! your home page
http://www.yahoo.com/r/hs
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: __asm__
2005-03-29 6:48 __asm__ Ankit Jain
@ 2005-03-29 7:40 ` Steve Graegert
2005-04-02 13:18 ` __asm__ Glynn Clements
1 sibling, 0 replies; 7+ messages in thread
From: Steve Graegert @ 2005-03-29 7:40 UTC (permalink / raw)
To: Ankit Jain; +Cc: linux prg
On Mon, 28 Mar 2005 22:48:28 -0800 (PST), Ankit Jain
<ankitjain1580@yahoo.com> wrote:
> can anybody tell me when we write like this while
> writing asm construct then what does underscore mean?
>
> __asm__("construct")
Underscores in those contexts usually represent a lanugage extension
and are used to make clear that this contruct may not be part of the
language standard, although a lot of other C compiler may implement
it. GNU C knows about a lot of other extensions like
__attribute__((always_inline)) that is used for function inlining.
> does it have any connection wit volatile?
Yes, it has. It prevents the compiler from modifying the inline asm
code, like reordering of statements and the like. This makes sure,
your code is handled by the compiler as is, so you will be using
__volatile__ most of the time.
Kind Regards
\Steve
--
Steve Graegert <graegerts@gmail.com> // Anyone who considers arithmetical
Software Consultant {C/C++ && .NET} // methods of producing random digits
Mobile: +49 (176) 21 24 88 69 // is, of course, in a state of sin.
Voice: +49 (9131) 71 26 40 9 // -- JOHN VON NEUMANN (1951)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: __asm__
2005-03-28 4:44 __asm__ Ankit Jain
@ 2005-03-30 5:29 ` Daniel Souza
0 siblings, 0 replies; 7+ messages in thread
From: Daniel Souza @ 2005-03-30 5:29 UTC (permalink / raw)
To: Ankit Jain; +Cc: linux-assembly
Yes, it means that the compiler will consider the asm instructions as
literal, and they will not be changed by compiler (either
instructions, optimization or bytecodes orders)
--
# (perl -e "while (1) { print "\x90"; }") | dd of=/dev/evil
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: __asm__
2005-03-29 6:48 __asm__ Ankit Jain
2005-03-29 7:40 ` __asm__ Steve Graegert
@ 2005-04-02 13:18 ` Glynn Clements
1 sibling, 0 replies; 7+ messages in thread
From: Glynn Clements @ 2005-04-02 13:18 UTC (permalink / raw)
To: Ankit Jain; +Cc: linux prg
Ankit Jain wrote:
> can anybody tell me when we write like this while
> writing asm construct then what does underscore mean?
>
> __asm__("construct")
Underscores are treated just like letters in macro and symbol names.
By convention, the implementation (compiler, core libraries) puts
underscores at the beginning of any "private" names, so that they
don't conflict with any names which you might use in your code (you
wouldn't normally choose names beginning with underscores in your own
code).
According to the ANSI C99 specification:
7.1.3 Reserved identifiers
[#1] Each header declares or defines all identifiers listed
in its associated subclause, and optionally declares or
defines identifiers listed in its associated future library
directions subclause and identifiers which are always
reserved either for any use or for use as file scope
identifiers.
-- All identifiers that begin with an underscore and
either an uppercase letter or another underscore are
always reserved for any use.
-- All identifiers that begin with an underscore are
always reserved for use as identifiers with file scope
in both the ordinary and tag name spaces.
--
Glynn Clements <glynn@gclements.plus.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2005-04-02 13:18 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-29 6:48 __asm__ Ankit Jain
2005-03-29 7:40 ` __asm__ Steve Graegert
2005-04-02 13:18 ` __asm__ Glynn Clements
-- strict thread matches above, loose matches on Subject: below --
2005-03-28 4:44 __asm__ Ankit Jain
2005-03-30 5:29 ` __asm__ Daniel Souza
2001-05-23 6:54 __asm__ Blesson Paul
2001-05-23 7:38 ` __asm__ David Howells
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.