kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* What does %P1 mean in gcc inline assembly?
@ 2016-03-04 12:36 张云
  2016-03-04 15:59 ` Dave Tian
  0 siblings, 1 reply; 5+ messages in thread
From: 张云 @ 2016-03-04 12:36 UTC (permalink / raw)
  To: kernelnewbies

Hi

In /arch/x86/boot/main.c  (http://lxr.free-electrons.com/source/arch/x86/boot/main.c) ,

In the function init_heap,
asm("leal %P1(%%esp),%0"
122 <http://lxr.free-electrons.com/source/arch/x86/boot/source/arch/x86/boot/main.c#L122>                     : "=r" (stack_end) : "i" (-STACK_SIZE <http://lxr.free-electrons.com/source/arch/x86/boot/ident?i=STACK_SIZE>));
 What does the ?%P1? mean in the inline assembly above ?

Thanks !
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160304/4f217015/attachment.html 

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

* What does %P1 mean in gcc inline assembly?
  2016-03-04 12:36 What does %P1 mean in gcc inline assembly? 张云
@ 2016-03-04 15:59 ` Dave Tian
  2016-03-05  3:37   ` 张云
  0 siblings, 1 reply; 5+ messages in thread
From: Dave Tian @ 2016-03-04 15:59 UTC (permalink / raw)
  To: kernelnewbies

This ?P? is used to make gcc happy and work.
Without ?P?, this inline would be interpreted as:
leal $-512(%esp), %eax
With ?P?, this inline is the thing we really want:
leal -512(%esp), %eax

Eventually, my gcc 4.9.2 does not compile with ?P? is missing. I am not sure if this is still the case for newer gcc (5/6). But you get the point.

-daveti


> On Mar 4, 2016, at 7:36 AM, ?? <zyunone@163.com> wrote:
> 
> Hi
> 
> In /arch/x86/boot/main.c  (http://lxr.free-electrons.com/source/arch/x86/boot/main.c <http://lxr.free-electrons.com/source/arch/x86/boot/main.c>) ,
> 
> In the function init_heap,
> asm("leal %P1(%%esp),%0"
> 122 <http://lxr.free-electrons.com/source/arch/x86/boot/source/arch/x86/boot/main.c#L122>                     : "=r" (stack_end) : "i" (-STACK_SIZE <http://lxr.free-electrons.com/source/arch/x86/boot/ident?i=STACK_SIZE>));
>  What does the ?%P1? mean in the inline assembly above ?
> 
> Thanks !
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160304/f4d2f5de/attachment-0001.html 

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

* What does %P1 mean in gcc inline assembly?
  2016-03-04 15:59 ` Dave Tian
@ 2016-03-05  3:37   ` 张云
  2016-03-07  2:51     ` Adam Lee
  0 siblings, 1 reply; 5+ messages in thread
From: 张云 @ 2016-03-05  3:37 UTC (permalink / raw)
  To: kernelnewbies


> On Mar 4, 2016, at 11:59 PM, Dave Tian <dave.jing.tian@gmail.com> wrote:
> 
> This ?P? is used to make gcc happy and work.
> Without ?P?, this inline would be interpreted as:
> leal $-512(%esp), %eax
> With ?P?, this inline is the thing we really want:
> leal -512(%esp), %eax
> 
> Eventually, my gcc 4.9.2 does not compile with ?P? is missing. I am not sure if this is still the case for newer gcc (5/6). But you get the point.
> 
> -daveti
> 

Thank you for your detailed answer !

By the way? If someone have the problems alike, I suggest them to write some inline assembly and check the compiler?s assembly output.

> 
>> On Mar 4, 2016, at 7:36 AM, ?? <zyunone at 163.com <mailto:zyunone@163.com>> wrote:
>> 
>> Hi
>> 
>> In /arch/x86/boot/main.c  (http://lxr.free-electrons.com/source/arch/x86/boot/main.c <http://lxr.free-electrons.com/source/arch/x86/boot/main.c>) ,
>> 
>> In the function init_heap,
>> asm("leal %P1(%%esp),%0"
>> 122 <http://lxr.free-electrons.com/source/arch/x86/boot/source/arch/x86/boot/main.c#L122>                     : "=r" (stack_end) : "i" (-STACK_SIZE <http://lxr.free-electrons.com/source/arch/x86/boot/ident?i=STACK_SIZE>));
>>  What does the ?%P1? mean in the inline assembly above ?
>> 
>> Thanks !
>> _______________________________________________
>> Kernelnewbies mailing list
>> Kernelnewbies at kernelnewbies.org <mailto:Kernelnewbies@kernelnewbies.org>
>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
> 
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160305/441516d4/attachment.html 

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

* What does %P1 mean in gcc inline assembly?
  2016-03-05  3:37   ` 张云
@ 2016-03-07  2:51     ` Adam Lee
  2016-03-07  3:22       ` 回复:Re: " 张云
  0 siblings, 1 reply; 5+ messages in thread
From: Adam Lee @ 2016-03-07  2:51 UTC (permalink / raw)
  To: kernelnewbies

On Sat, Mar 05, 2016 at 11:37:21AM +0800, ?? wrote:
> 
>     On Mar 4, 2016, at 11:59 PM, Dave Tian <dave.jing.tian@gmail.com> wrote:
> 
>     This ?P? is used to make gcc happy and work.
>     Without ?P?, this inline would be interpreted as:
>     leal $-512(%esp), %eax
>     With ?P?, this inline is the thing we really want:
>     leal -512(%esp), %eax
> 
>     Eventually, my gcc 4.9.2 does not compile with ?P? is missing. I am not
>     sure if this is still the case for newer gcc (5/6). But you get the point.
> 
>     -daveti
> 
> Thank you for your detailed answer !
> 
> By the way? If someone have the problems alike, I suggest them to write some
> inline assembly and check the compiler?s assembly output.

Didn't get different outputs here, do you have updates?

-- 
Adam Lee
http://adam8157.info

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

* 回复:Re: What does %P1 mean in gcc inline assembly?
  2016-03-07  2:51     ` Adam Lee
@ 2016-03-07  3:22       ` 张云
  0 siblings, 0 replies; 5+ messages in thread
From: 张云 @ 2016-03-07  3:22 UTC (permalink / raw)
  To: kernelnewbies

Maybe your compiler version is different from us. Mine is 4.9.2?debian?as same as daveti's.


?? ??????
?2016?03?07? 10:51?Adam Lee ??:
On Sat, Mar 05, 2016 at 11:37:21AM +0800, ?? wrote:
>
>     On Mar 4, 2016, at 11:59 PM, Dave Tian <dave.jing.tian@gmail.com> wrote:
>
>     This ?P? is used to make gcc happy and work.
>     Without ?P?, this inline would be interpreted as:
>     leal $-512(%esp), %eax
>     With ?P?, this inline is the thing we really want:
>     leal -512(%esp), %eax
>
>     Eventually, my gcc 4.9.2 does not compile with ?P? is missing. I am not
>     sure if this is still the case for newer gcc (5/6). But you get the point.
>
>     -daveti
>
> Thank you for your detailed answer !
>
> By the way? If someone have the problems alike, I suggest them to write some
> inline assembly and check the compiler?s assembly output.

Didn't get different outputs here, do you have updates?

--
Adam Lee
http://adam8157.info

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160307/49cbade4/attachment.html 

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

end of thread, other threads:[~2016-03-07  3:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-04 12:36 What does %P1 mean in gcc inline assembly? 张云
2016-03-04 15:59 ` Dave Tian
2016-03-05  3:37   ` 张云
2016-03-07  2:51     ` Adam Lee
2016-03-07  3:22       ` 回复:Re: " 张云

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).