要学习汇编-我应该从32位还是64位开始? [英] To learn assembly - should I start with 32 bit or 64 bit?

查看:268
本文介绍了要学习汇编-我应该从32位还是64位开始?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的很想学习汇编.我非常擅长c/c ++,但想更好地了解底层的情况.

I'm really wanting to learn assembly. I'm pretty good at c/c++, but want a better understanding of what's going on at a lower level.

我意识到以前已经询问过与组装相关的问题,但我只是在寻找适合我的情况的方向:

I realize that assembly related questions have been asked before, but I'm just looking for some direction that's particular to my situation:

我正在运行Windows 7,并对如何开始使用汇编感到困惑.因为运行Windows 7,我是否必须以x64开头?有人说先从32位开始"-我该怎么做?我的操作系统与我为'32'或'64'位编写程序集的能力有关.实际上,"n位"汇编的含义是什么,其中n是数字?

I'm running windows 7, and am confused about how I should start working with assembly. Do I have to start with x64 because I'm running windows 7? Some people have said 'start with 32 bit first' - how do I go about doing this? What does my operating system have to do with my ability to write assembly for '32' or '64' bit. In fact, what does 'n bit' assembly mean, where n is a number??

这里有一些链接帮助我开始组装.其他刚入门的人可能会发现它们对您有帮助.在继续组装过程时,我将不断更新此列表:)

Here are some links that have helped me get started with assembly; others who are just getting started may find them helpful. I'll keep updating this list as I continue on my assembly journey :)

注意:在学习的过程中,我决定专注于使用masm32进行编程.因此,下面的大多数资源都将重点放在此.

Note: As I've been learning, I've decided to focus on programming with masm32. Therefore most of the below resources focus on that.

  • x86 tag wiki (beginner guides, reference manuals, ABI documentation, and more.)
  • www.masm32.com
  • X86 Assembly WikiBook
  • X86 Dissassembly WikiBook (great for understanding some conventions, and the basics of how higher level code translates into assembly)
  • WinAsm IDE (plays nicely with masm32)
  • Intro: Assembly for Windows (all code examples are for masm32)
  • List of Interrupts
  • Assembly Tutorial (great for helping to understand core concepts)
  • x86 Assembly Guide
  • Agner Fog's Software optimization resources, including some good stuff about calling conventions on different platforms (Windows vs. Linux/OS X), as well as a lot of examples of how to do specific things efficiently. Not great for total beginners, but great for intermediate to advanced readers.

(他还针对Intel和AMD CPU的每条指令提供了详细的性能信息,非常适合进行认真的性能微优化.一些初学者可能想看看其中的一些内容,以开始思考CPU的工作方式以及为什么会这样做用一种方法代替另一种方法.)

(He also has detailed performance info for each instruction for Intel and AMD CPUs, excellent for serious performance micro-optimization. Some beginners might want to look at some of that to get started thinking about how CPUs work, and why you might do something one way instead of another.)

推荐答案

当人们引用32-bit64-bit程序集时,他们正在谈论要使用的指令集-他们有时也称为Ia32x64在Intel的情况下,我想您是在问这个问题.在64位的情况下,还有很多事情要做,所以从32位开始可能很好.您只需要确保使用32位汇编器将程序汇编为32位二进制文​​件即可. Windows仍然会知道如何运行它.

When people refer to 32-bit and 64-bit assembly, they're talking about which instruction set you'll use - they're also sometimes called Ia32 and x64 in the Intel case, which I presume you're asking about. There is a lot more going on in the 64-bit case, so starting with 32-bit is probably good; you just need to make sure you're assembling your program with a 32-bit assembler into a 32-bit binary. Windows will still know how to run it.

我真正建议您开始使用汇编语言的是带有更简单指令集的内容.开始学习 MIPS组装-main()的C包装器,然后将其与通过编写汇编代码获得的目标文件进行编译和链接.

What I really recommend for getting started with assembly would be something with a simpler instruction set to get a handle on. Go learn MIPS assembly - the spim simulator is great and easy to use. If you really want to dive straight into the Intel assembly world, write yourself a little C program that calls your assembly routines for you; doing all the setup and teardown for a 'real program' is a big mess, and you won't even be able to get started there. So just write a C wrapper with main() in it, and compile and link that with the object files you get from writing your assembly code.

请不要养成在C代码中编写内联汇编的习惯-这是代码可移植性的噩梦,没有理由.

Please don't get in the habit of writing inline assembly in your C code - it's a code portability nightmare, and there's no reason for it.

您可以下载所有英特尔64和IA-32体系结构软件开发人员手册开始.

这篇关于要学习汇编-我应该从32位还是64位开始?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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