Search code examples
cinline-assemblyassembly

Is there a way to insert assembly code into C?


I remember back in the day with the old borland DOS compiler you could do something like this:

asm {
 mov ax,ex
 etc etc...
}

Is there a semi-platform independent way to do this now? I have a need to make a BIOS call, so if there was a way to do this without asm code, that would be equally useful to me.


Solution

  • Using GCC

    __asm__("movl %edx, %eax\n\t"
            "addl $2, %eax\n\t");
    

    Using VC++

    __asm {
      mov eax, edx
      add eax, 2
    }