c - 如何使用 Turbo C 2.01 编写内联汇编?

标签 c assembly inline-assembly turbo-c

我想在使用 Turbo C 2.01 编译的 DOS 程序中编写一些内联汇编。当我写作时

asm {
   nop
}

编译器声称函数中不允许内联汇编...。请参阅:Inline assembly error Turbo C 2.01

有什么想法吗?

最佳答案

参见 Turbo C user manual第 430 页:

Inline assembly not allowed

Your source file contains inline assembly language statements and you are compiling it from within the Integrated Environment. You must use the TCC command to compile this source file.

我相信您还需要将 -B 选项传递给 TCC(第 455 页)。

或者,您可以使用 __emit__(第 103 页)将相对简单的代码输入为机器代码而不是汇编助记符。

在 IDE 中不允许内联汇编似乎是一个奇怪的限制。您可能会考虑“升级”到我认为允许的 Turbo C++ 3.0。我想 TC++ 会在出现 .c 文件时编译 C 代码,或者可以将 IDE 设置为显式编译 C。有一个 manual也是为了那个。

关于c - 如何使用 Turbo C 2.01 编写内联汇编?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47580731/

相关文章:

c - 了解一些汇编代码

c++ - 在 Visual Studio Debug模式下编译的可执行文件 : jmp to function body instead of direct address in call

windows - 如何在 win32 控制台上解析 "printf"而不是 "_printf"的符号?

在 gcc 内联 x86_64 程序集中约束 r10 寄存器

C 错误 : "initializer element is not constant" with &, 适用于 +

c - 查找数组的大小和单词洗牌

c - 执行 x87 FPATAN 操作的扩展 GCC 内联汇编中的 clobber 列表的说明

c - 在 bcm2836 上使用 GPIO

c - C 中带有控制字符的格式化输出?

在同一 C 程序中从一个函数调用其他函数