asm inline function

Programming, for all ages and all languages.
Post Reply
asdfgh
Member
Member
Posts: 42
Joined: Fri Apr 18, 2008 9:14 pm

asm inline function

Post by asdfgh »

wat is the asm inline function in c for poping value from stack and storing it in a variable
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

Have you googled it? Have you read the manual?

------------------------

Code: Select all

asm volatile("pop %0" : "=r" (my_value))
DeletedAccount
Member
Member
Posts: 566
Joined: Tue Jun 20, 2006 9:17 am

Post by DeletedAccount »

I however hate gcc inline assembly , write a separate .asm or .s and link it ...
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

SandeepMathew wrote:I however hate gcc inline assembly , write a separate .asm or .s and link it ...
You might, however, not everyone agrees with you.

I sure don't, 99.9% of the time. ;)
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Post by piranha »

Inline assembly can be annoying, but it makes the code better (in my opinion) because I don't have to load 2 files to look at one function.

I like it better than normal assembly.

-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
svdmeer
Member
Member
Posts: 87
Joined: Tue May 06, 2008 9:32 am
Location: The Netherlands

Post by svdmeer »

For just one or two instructions, inline assembly is imho better.
A seperate file is "too much" for such tiny things.
Korona
Member
Member
Posts: 1000
Joined: Thu May 17, 2007 1:27 pm
Contact:

Post by Korona »

Inline assembly integrates better into the c code. There are no unnecessary register spills and there is no function prologue / epilogue overhead if the inline assembly instructions can be inlined.
Post Reply