Skip to main content
gamedev.net
🔒 Locked

inline assembly?

Started by Venerable Vampire Jun 8, 2004 at 5:46 PM 1 replies 450+ views
Original Post
Venerable Vampire
Venerable Vampire
I''m terribly confused. I''ve heard about something called "inline assembly". I have no idea what this is. How does it relate to normal assembly? What exactly can you do with it? What is up with the "__asm" keyword in my c compiler? Also, I thought assembly was rather machine specific, while c syntax is not (not talking about API, just the syntax). Can someone explain assembly and c for me or point to a tutorial? -------------------------------------------------------- Life would be so much easier if we could just get the source code.
--------------------------------------------------------Life would be so much easier if we could just get the source code.
dcosborn
dcosborn
Inline assembly is a compiler-specific extension that allows you to insert assembly code in the middle of regular C code. Yes, its machine specific, so you need to know your target platform beforehand. The __asm keyword tells the compiler that all the code within its scope is assembly. So you can usually write either:

__asm mov eax, 0
__asm cmp ebx, eax

or

__asm
{
mov eax, 0
cmp ebx, eax
}

Note that the prefixed underscores denote compiler-specific keywords. How the assembly code integrates with the C code depends on your compiler. Also note that GCC handles x86 assembly in AT&T syntax, which is unusual and you can google for it.

[edited by - dcosborn on June 8, 2004 7:12:44 PM]
Charles B
Charles B
Note : inline asm is much more interesting (but also more complex to handle) under gcc.
"Coding math tricks in asm is more fun than Java"

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.