如何为 MMIX 链接多个汇编程序文件

发布于 2024-10-17 16:50:53 字数 136 浏览 12 评论 0原文

假设,我编写了一个小库,实现了类似“fprint”的功能。教我MMIX(Das MMIX-Buch,德语)的书总是将整个库复制到新程序中,但我不喜欢这种方法。有没有办法将库组装成一个目标文件,将主程序组装成另一个目标文件并将这两个链接在一起?如何做到这一点?

Assume, I wrote a small lib implementing something "fprint"-likely. The book that teaches me MMIX (Das MMIX-Buch, german) always copies the whole lib into the new program, but I dislike this approach. Is there any way to assemble the library into one object file, the main program into another and link these two together? How to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

囚我心虐我身 2024-10-24 16:50:53

检查mmix存储库www.mmix.cs.hm.edu,示例文件夹中有两个示例:Hello World GNU,逐步描述如何获取和使用GNU工具以及编译和链接hello.s(汇编器)或hello .c 与 C 库链接,第二个示例是在 MMIX 上运行 MMIX,它将来自不同 c 文件的 MMIX 的 MMIX 可执行文件链接在一起,并将多个汇编程序文件和 C 库链接在一起以实现 MMIX 的 fat32 文件系统。
马丁

Check the mmix repository www.mmix.cs.hm.edu there are two examples in the examples folder: Hello World GNU, descrobes step by step how to get and use the GNU Tools and compile and link hello.s (assembler) or hello.c linked with the C library and a second example, running MMIX on MMIX which links together the MMIX executable for MMIX from different c files, and linking together several assembler files and a C library to implement a fat32 file system for MMIX.
Martin

墟烟 2024-10-24 16:50:53

根据我从简短的互联网搜索中了解到的信息,mmix 工具使用普通的 gcc 和 binutils 软件包。因此,我希望多个目标文件甚至标准静态库都能“正常工作”。我想知道您遇到了什么具体问题。

gcc -c lib.c -o lib.o
gcc -c main.c -o main.o
gcc lib.o main.o -o program

编辑:显然与 asm 源类似,只需使用 .s 或 .S 扩展名。当然,您也可以使用 gcc 在幕后使用的适当的汇编器和链接器命令。命令行选项 -v 将显示这些。

According to what I have learned from a brief internet search, the mmix tools use the normal gcc and binutils packages. As such, I expect multiple object files and even standard static libraries to "just work". I wonder what exact problem you have run into.

gcc -c lib.c -o lib.o
gcc -c main.c -o main.o
gcc lib.o main.o -o program

EDIT: obviously similar for asm sources, just use .s or .S extension. You can of course use the appropriate assembler and linker commands that gcc uses behind the scenes too. The command line option -v will show those.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文