在64位系统(Ubuntu)上编译32位汇编 [英] Compiling 32 bit assembly on 64bit system (Ubuntu)

查看:194
本文介绍了在64位系统(Ubuntu)上编译32位汇编的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过从头开始编程" .本书仅涵盖32位指令.有没有办法在64位Ubuntu系统上运行示例代码?我听不懂GNU汇编器手册页上的内容,但我听说-m32标志应该这样做.但这不是公认的选项.

I'm trying to learn about assembly with the book "Programming from the ground up". The book covers only 32 bit instructions. Is there a way to run the example codes on 64 bit Ubuntu system? I can't understand the stuff on the man page of the GNU assembler but I heard the -m32 flag should do it. But it's not a recognized option.

如何使书中的示例易于使用?

How do I get the examples on the book to work with ease?

推荐答案

当汇编器和链接器为x86_64版本时,用于生成i386(32位)输出的选项为

When your assembler and linker are x86_64 versions, the options to produce i386 (32-bit) output are

as --32
ld -m elf_i386

您不必仅仅因为正在使用汇编代码而使用asld.可以使用gcc,在这种情况下,您将使用-m32.

You don't have to use as and ld just because you're working with assembly code. gcc can be used, and in that case you would use -m32.

gcc -m32 -nostdlib myprog.s -o myprog

这篇关于在64位系统(Ubuntu)上编译32位汇编的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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