64位Linux,汇编语言,问题?

时间:2022-09-11 22:30:18

I'm currently in the process of learning assembly language. I'm using Gas on Linux Mint (32-bit). Using this book: Programming from the Ground Up.

我目前正在学习汇编语言。我在Linux Mint(32位)上使用Gas。使用本书:从头开始编程。

The machine I'm using has an AMD Turion 64 bit processor, but I'm limited to 2 GB of RAM. I'm thinking of upgrading my Linux installation to the 64-bit version of Linux Mint, but I'm worried that because the book is targeted at 32-bit x86 architecture that the code examples won't work.

我使用的机器有一个AMD Turion 64位处理器,但我限制在2 GB的RAM。我正在考虑将我的Linux安装升级到64位版本的Linux Mint,但我担心因为本书针对的是32位x86架构,所以代码示例不起作用。

So two questions:

所以有两个问题:

  1. Is there likely to be any problems with the code samples?
  2. 代码示例可能有任何问题吗?

  3. Has anyone here noticed any benefits in general in using 64-bit Linux over 32-bit (I've seen some threads on Stack Overflow about this but they are mostly related to Windows Vista vs. Windows XP.)
  4. 有没有人注意到使用64位Linux超过32位的一般好处(我在Stack Overflow上看到了一些关于此问题的线程,但它们主要与Windows Vista和Windows XP相关。)

3 个解决方案

#1


4  

Your code examples should all still work. 64-bit processors and operating systems can still run 32-bit code in a sort of "compatability mode". Your assembly examples are no different. You may have to provide an extra line of assembly or two (such as .BITS 32) but that's all.

您的代码示例应该仍然有效。 64位处理器和操作系统仍然可以在某种“兼容模式”下运行32位代码。您的装配示例也不例外。您可能需要提供额外的一两个装配线(例如.BITS 32),但这就是全部。

In general, using a 64-bit OS will be faster than using a 32-bit OS. x86_64 has more registers than i386. Since you're working on assembly, you already know what registers are used for... Having more of them means less stuff has to be moved on and off the stack (and other temporary memory) thus your program spends less time managing data and more time working on that data.

通常,使用64位操作系统将比使用32位操作系统更快。 x86_64的寄存器多于i386。由于你正在进行汇编,你已经知道了什么寄存器用于...拥有更多的寄存器意味着更少的东西必须移入和移出堆栈(和其他临时存储器),因此你的程序花费更少的时间管理数据和更多时间处理这些数据。

Edit: To compile 32-bit code on 64-bit linux using gas, you just use the commandline argument "--32", as noted in the GAS manual

编辑:要使用gas在64位linux上编译32位代码,只需使用命令行参数“--32”,如GAS手册中所述

#2


1  

Even if you run Linux 64bit, it is possible to compile and run 32bit binaries on it. I don't know how good Mint's support for that is, I assume you should check.

即使您运行Linux 64bit,也可以在其上编译和运行32位二进制文​​件。我不知道Mint对此的支持有多好,我想你应该检查一下。

64bit assembler however is not fully compatible to 32bit, for example you have different (more) registers. There are some specific instructions not available on either platform.

但是,64位汇编程序与32位不完全兼容,例如,您有不同的(更多)寄存器。两个平台都没有一些特定说明。

I would say the move to 64bit is not a big deal. You can still write 32bit assembly and then perhaps try to get it also running as 64bit (shouldn't be too hard), as a source of even more programming/learning fun.

我想说转向64位并不是什么大问题。您仍然可以编写32位汇编,然后尝试将其运行为64位(不应该太难),作为更多编程/学习乐趣的来源。

#3


1  

Usually 32-bits is plenty so only use 64-bits or more if you really NEED IT. Best to decide prior to programming if you want to do it as a 32-bit app or a 64-bit app and then stick to it as mixed mode debugging ca get tricky fast.

通常32位是足够的,所以如果你真的需要它只使用64位或更多。如果你想在32位应用程序或64位应用程序中进行编程,那么最好在编程之前做出决定,然后坚持使用它作为混合模式调试快速变得棘手。

#1


4  

Your code examples should all still work. 64-bit processors and operating systems can still run 32-bit code in a sort of "compatability mode". Your assembly examples are no different. You may have to provide an extra line of assembly or two (such as .BITS 32) but that's all.

您的代码示例应该仍然有效。 64位处理器和操作系统仍然可以在某种“兼容模式”下运行32位代码。您的装配示例也不例外。您可能需要提供额外的一两个装配线(例如.BITS 32),但这就是全部。

In general, using a 64-bit OS will be faster than using a 32-bit OS. x86_64 has more registers than i386. Since you're working on assembly, you already know what registers are used for... Having more of them means less stuff has to be moved on and off the stack (and other temporary memory) thus your program spends less time managing data and more time working on that data.

通常,使用64位操作系统将比使用32位操作系统更快。 x86_64的寄存器多于i386。由于你正在进行汇编,你已经知道了什么寄存器用于...拥有更多的寄存器意味着更少的东西必须移入和移出堆栈(和其他临时存储器),因此你的程序花费更少的时间管理数据和更多时间处理这些数据。

Edit: To compile 32-bit code on 64-bit linux using gas, you just use the commandline argument "--32", as noted in the GAS manual

编辑:要使用gas在64位linux上编译32位代码,只需使用命令行参数“--32”,如GAS手册中所述

#2


1  

Even if you run Linux 64bit, it is possible to compile and run 32bit binaries on it. I don't know how good Mint's support for that is, I assume you should check.

即使您运行Linux 64bit,也可以在其上编译和运行32位二进制文​​件。我不知道Mint对此的支持有多好,我想你应该检查一下。

64bit assembler however is not fully compatible to 32bit, for example you have different (more) registers. There are some specific instructions not available on either platform.

但是,64位汇编程序与32位不完全兼容,例如,您有不同的(更多)寄存器。两个平台都没有一些特定说明。

I would say the move to 64bit is not a big deal. You can still write 32bit assembly and then perhaps try to get it also running as 64bit (shouldn't be too hard), as a source of even more programming/learning fun.

我想说转向64位并不是什么大问题。您仍然可以编写32位汇编,然后尝试将其运行为64位(不应该太难),作为更多编程/学习乐趣的来源。

#3


1  

Usually 32-bits is plenty so only use 64-bits or more if you really NEED IT. Best to decide prior to programming if you want to do it as a 32-bit app or a 64-bit app and then stick to it as mixed mode debugging ca get tricky fast.

通常32位是足够的,所以如果你真的需要它只使用64位或更多。如果你想在32位应用程序或64位应用程序中进行编程,那么最好在编程之前做出决定,然后坚持使用它作为混合模式调试快速变得棘手。