汇编语言简介

来源:互联网 发布:数据库技术研究方向 编辑:程序博客网 时间:2024/04/30 00:06

汇编语言(Assembly)
  显然,汇编是第一个计算机语言。汇编语言实际上是你计算机处理器实际运行的指令的命令形式表示法。这意味着你将与处理器的底层打交道,比如寄存器和堆栈。如果你要找的是类英语且有相关的自我说明的语言,这不是你想要的。
  By default, assembly was the first computer language. Assembly language is actually a command-based representation of the actual instructions that your computer's processor runs. That means you will be dealing with the low-level details of your processor, like registers and stacks. If you're looking for a language that's English-like and is relatively self-documenting, this isn't it!

  确切的说,任何你能在其他语言里做到的事情,汇编都能做,只是不那么简单 — 这是当然,就像说你既可以开车到某个地方,也可以走路去,只是难易之分。话虽不错,但是新技术让东西变得更易于使用。
  By definition, anything you can do in any other language, you can do in assembly, only not as easily --of course, that's like saying that anywhere you can go in a car, you can go on foot, only not as easily. While the statement might be true, the later technologies made things much easier to use.

  总的来说,汇编语言不会在游戏中单独应用。游戏使用汇编主要是使用它那些能提高性能的零零碎碎的部分。比如说,毁灭战士整体使用C来编写,有几段绘图程序使用汇编。这些程序每秒钟要调用数千次,因此,尽可能的简洁将有助于提高游戏的性能。而从C里调用汇编写的函数是相当简单的,因此同时使用两种语言不成问题。
  In general, assembly language is not used on its own for games. Games that use assembly language use it in bits and pieces where it can improve performance. For example, DOOM is written entirely in C with a couple of drawing routines hand-coded in assembly. They are the routines that are called a few thousand times a second, so making the routine as tight as possible really helped the performance of the game. It's fairly easy to write a function in assembly that is call-able from C, so using both languages wasn't a problem.

  特别注意:语言的名字叫“汇编”。把汇编语言翻译成真实的机器码的工具叫“汇编程序”。把这门语言叫做“汇编程序”这种用词不当相当普遍,因此,请从这门语言的正确称呼作为起点出发。
  Special Note: The name of the language is "assembly". The name of the tool that converts assembly language into true machine code is called an "assembler". It's a common misnomer to call the language "assembler", so start out on the right foot by calling the language by its proper name.

  优点:最小、最快的语言。汇编高手能编写出比任何其他语言能实现的快得多的程序。你将是利用处理器最新功能的第一人,因为你能直接使用它们。
  Advantages: Is, by definition, the smallest and fastest language. A talented assembly programmer can write programs that are faster than anything that can be done in other languages. You'll be the first person to be able to take advantage of the processor's latest new features, because you can use them directly.

  缺点:难学、语法晦涩、坚持效率,造成大量额外代码 — 不适于心脏虚弱者。
  Disadvantages: Difficult to learn, cryptic syntax, tough to do efficiently, and it takes much more code to get something done --not for the faint of heart!

  移植性:接近零。因为这门语言是为一种单独的处理器设计的,根本没移植性可言。如果使用了某个特殊处理器的扩展功能,你的代码甚至无法移植到其他同类型的处理器上(比如,AMD的3DNow指令是无法移植到其它奔腾系列的处理器上的)。
  Portability: Zilch. Since the language is designed for a single processor, it is not portable by definition. If you use extensions specific to a particular brand of processor, your code isn't even portable to other processors of the same type (for example, AMD 3DNOW instructions are not portable to other Pentium-class processors).

  使用汇编编写的游戏:我不知道有什么商业游戏是完全用汇编开发的。不过有些游戏使用汇编完成多数对时间要求苛刻的部分。
  Games Written in Assembly: I don't know of any commercial games that are written entirely in assembly. Some games, however, have the most time-critical portions done in assembly.

  资料:如果你正在找一门汇编语言的文档,你主要要找芯片的文档。网络上如Intel、AMD、Motorola等有一些关于它们的处理器的资料。对于书籍而言,《Assembly Language: Step-By-Step》是很值得学习的。
  Resources: When you're looking for documentation for an assembly language, you're basically looking for the documentation for the chip. There is some online information at [Intel], [AMD][Motorola] for their processors. As for books, [Assembly Language: Step-By-Step] is well-reviewed.


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/yalai/archive/2005/08/04/445383.aspx

原创粉丝点击