What does %P1 mean in gcc inline assembly?

张云 zyunone at 163.com
Fri Mar 4 22:37:21 EST 2016


> On Mar 4, 2016, at 11:59 PM, Dave Tian <dave.jing.tian at 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 at 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 at 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 


More information about the Kernelnewbies mailing list