c - 如何告诉 GCC 为实模式生成 16 位代码

标签 c gcc assembly x86-16 inline-assembly

我正在编写实模式函数,它应该是带有堆栈帧等的正常函数,但它应该使用 %sp 而不是 %esp。有什么办法吗?

最佳答案

GCC 5.2.0(以及可能的更早版本)支持使用 -m16 标志生成 16 位代码。但是,代码几乎肯定会依赖 32 位处理器功能(例如 32 位宽寄存器),因此您应该仔细检查生成的程序集。

来自 man 页面:

The -m16 option is the same as -m32, except for that it outputs the ".code16gcc" assembly directive at the beginning of the assembly output so that the binary can run in 16-bit mode.

关于c - 如何告诉 GCC 为实模式生成 16 位代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19055647/

相关文章:

c - 根据用户输入决定动态分配多少内存

C 问题:另一个 while 循环内的 while(fgets) 循环仅执行一次

c - Windows x64 上的 MySQL C Connector 与 GCC 链接错误

c - 如何让 gcc 将包含函数调用的表达式识别为常量?

c - Shell 排序中的 h 排序

c++ - 构建cpp应用

assembly - 有没有人在 xcore 的基于汇编器的 LED 闪光灯上取得成功?

linux - 了解 ASM 中的输入和输出

string - x86 ASM Linux - 创建循环

sqlite3_exec中的回调函数(C API)