是否有插入组装code为C的方法吗? [英] Is there a way to insert assembly code into C?

查看:112
本文介绍了是否有插入组装code为C的方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我记得在与老的Borland DOS的编译器,你可以做这样的事情的日子:

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

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

有没有做这方面的一个半独立于平台的方式?我有必要做一个BIOS调用,因此,如果有办法做到这一点不ASM code,这将是对我来说同样有用。

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.

推荐答案

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

使用 VC ++

__asm {
  mov eax, edx
  add eax, 2
}

这篇关于是否有插入组装code为C的方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆