Is there a way to insert assembly code into C?

前端 未结 4 548
独厮守ぢ
独厮守ぢ 2020-12-07 15:57

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 se

4条回答
  •  鱼传尺愫
    2020-12-07 16:05

    For Microsoft compilers, inline assembly is supported only for x86. For other targets you have to define the whole function in a separate assembly source file, pass it to an assembler and link the resulting object module.

    You're highly unlikely to be able to call into the BIOS under a protected-mode operating system and should use whatever facilities are available on that system. Even if you're in kernel mode it's probably unsafe - the BIOS may not be correctly synchronized with respect to OS state if you do so.

提交回复
热议问题