寻找 16 位 x86 编译器 [英] Looking for 16-bit x86 compiler

查看:23
本文介绍了寻找 16 位 x86 编译器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从事一个嵌入式系统项目,并且遇到了编译器以编程方式嵌入到 Paradigm C++ IDE 中的问题.我希望能够自动构建.

I am working on an embedded systems project and have run into an issue of the compiler being programatically embedded in the Paradigm C++ IDE. I would like to be able to automate building.

处理器是 AMD186ES.我没有使用操作系统 - 只是裸机的东西.我需要从 C++ 生成实模式 16 位 8086 机器代码.

The processor is the AMD186ES. I am not working with the OS - just baremetal stuff. I need to generate real-mode 16-bit 8086 machine code from C++.

我的谷歌搜索表明 G++ 可以构建这样的代码.

My googling indicates that G++ can build such code.

我的问题是:

可以配置g++来构建这个机器码吗?

Can g++ be configured to build this machine code?

是否有其他 C++ 编译器也可以做到这一点?

Are there other C++ compilers that can do it as well?

推荐答案

我目前正在使用 gnu as(binutils 的一部分和用于 gcc 的汇编器),并且我已经成功汇编了 16 位汇编代码带有以下内容:

I am currently using gnu as (part of binutils and the assembler used for gcc) and I have successfully been assembling 16bit assembly code with the following:

as <file>
ld --oformat binary -Ttext 0x0 -e start <file>

我的程序集文件以:

.code16
.globl start
.text
start:

因为它的普通二进制省略了行,

since its plain binary omitting the lines,

.globl start
start:

只会产生警告,即使平面二进制文件不需要入口点.

will simply yield an warning, even though flat binaries need no entry point.

我通过艰苦的方式学到的东西;

something I learned the hard way;

-Ttext 0x0

很关键,否则 .text 段会被推到 16 位寻址范围之外(不要问我为什么)

is critical, otherwise the .text segment is pushed outside of 16bit addressing range (don't ask me why)

我个人还在学习汇编,所以这只是我的方式,不一定是最好的方式.

I am personally still learning assembly, so this is just my way, not necessarily the best way.

如果你正在编写启动代码,你应该改变

If you are writing boot code, you should change

-Ttext 0x0

-Ttext 0x7c00

这将使您的内存地址偏移 0x7c00,因为引导代码通常由 BIOS 加载到 0x7c00.

this will offset your memory addresses by 0x7c00 since boot code is usually loaded at 0x7c00 by the BIOS.

这篇关于寻找 16 位 x86 编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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