Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
491 views
in Technique[技术] by (71.8m points)

x86 - To learn assembly - should I start with 32 bit or 64 bit?

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:

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??


Edit:

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 :)

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

  • 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.

    (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.)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

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.

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.

You can download all of the Intel 64 and IA-32 Architectures Software Developer's Manuals to get started.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...