汇编编程介绍 [英] assembley programming introduction

查看:74
本文介绍了汇编编程介绍的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,
我很担心这门课,因为这是我的学期.因此,请告诉我有关入门的基本知识.请告诉我要使用什么软件,以及任何简单的基本说明.




谢谢和问候,
Ravindra Bisht

Dear All,
I''m quite worry about this subject as it''s in my semester. So please tell me basic stuff for getting start in this. Kindly tell me what software to use for this, and any simple basic notes for this.




Thanks and Regards,
Ravindra Bisht

推荐答案

没有简单的基本注释".无论是什么,您都需要学习CPU.还有更多.让我们看看.

您需要学习其体系结构,其模式,其寄存器,其典型用法,一些基本说明,并且还需要确保可以在参考书中找到与您的目的相关的说明,并清楚地了解其说明.您需要清楚地了解CPU如何与嵌入式系统的内存和端口一起工作.您甚至需要至少对各种操作的时间有一个清晰的认识.

在体系结构部分,除了CPU的纯正式体系结构之外,您还需要学习一些基本的数据结构及其上的操作.在大多数系统中,这是 stack ,几乎是所有体系结构中最基本的结构,但也可以是其他结构.如果这是x86/IE32/IE64体系结构,则它们极其复杂并且在各个方面都很难理解.我可以想象,要想在所有模式下进行足够的实际工作来学习所有细节,就需要2-4个学期,如果不是更多的话.如果您的学校仅就此主题提供1个学期的课程,那么您正在学习的只是基础知识或相对简单的知识.



我刚刚看到了您的下一个问题并将其删除-您不应重新发布问题.除了这个问题之外,唯一的细节就是这个问题:CPU是8086.这是一个相对复杂的处理器,但是数量级或大小都比x86简单.实际上,x86具有模拟8086的实模式".它只有一种具有固定内存的内存模式.存储器寻址为16位segment:offset对.这些寄存器分为段寄存器和偏移寄存器,因此该地址可以由一对相关的寄存器指示.这样一来,您只有1M的地址空间;在MS-DOS中,仅可寻址640K的物理内存(预留主要在基于80286的计算机上使用的称为扩展内存"和扩展内存"的特殊结构-这些东西永远无法正常工作.

在这种segment:offset寻址中,自然可以用不同的地址值来寻址相同的物理地址.有效地址只有20位,因此有4096种方法可以寻址物理地址的同一点.

几乎所有内容都在Wikipedia文章"Intel 8086"中进行了解释.

[END EDIT]

最重要的是,您应该开发一些与汇编语言代码一起使用的技巧,而这些技巧与CPU无关.汇编语言有很多不同的风格,每类CPU都使用不同的语言,但是即使对于同一CPU,也可以选择不同的汇编器(这些编译器称为汇编器"(它们可以进行汇编),术语汇编语言"实际上是汇编程序的语言"),具有不同的语法和许多特殊性.汇编语言不是标准化的.与指令和寄存器无关的指令和句法元素是为您的方便而设计的,但它们可能是好东西,也可能是晦涩而令人讨厌的.甚至CPU命令的语法(即使对于同一CPU)也可能不同,寻址对象的方法也不同(总是有很多).

我将秘密武器"用于将CPU指令汇编成有效的仅汇编(或不仅如此)代码:使用C ++或Borland Pascal的内联汇编.这是使用更清晰的语法(可以使用高级语言声明),跳过无聊的琐碎工作并避免真实"汇编语言的古怪语法特质的极好方法.但是,您的课程可能需要真实的"汇编语言.看一看.根据您以前的经验,您可以同时学习和安全学习.

还有什么?哦,我害怕地说,您将需要学习一些与CPU或语言本身无关的语言环境.事情是这样的:汇编程序通常不生成可执行模块,而是生成目标文件,这是模块化开发所需要的.这是编程的一个非常重要的方面,开发人员仅使用高级语言就无法很好地理解它.目标代码不是某些特定地址空间中的代码.它由在不同的相对地址空间中运行的不相关的代码片段组成,这些片段随后将相对彼此进行转换.这是因为可执行模块由一个以上的目标文件(和目标库,您可以大致理解为以某种方式放入一个文件中的目标文件的集合)组成.地址转换是通过名为 linker 的实用程序完成的.因此,另一个麻烦是,即使与CPU体系结构无关,您也应该基本了解这种寻址和地址转换.这是开发周期的纯粹产物.最后,您应该基本了解 loader 这样重要的OS部件的操作.即使大多数用户甚至软件开发人员并不真正知道这种情况的存在,这也是将可执行模块放入RAM的非常重要的部分(数据对象和代码在RAM中的位置每次都可能不同).因此,这是另一种地址转换.仅在那一刻,您的代码才具有运行时应具有的形状;只有这样,真正的" CPU架构才能发挥作用.请注意,对于复杂的CPU体系结构,还有许多其他地址转换将进程的地址空间与物理RAM地址映射,这可能涉及在运行时重新分配内存的物理片段(虚拟内存,其机制有所不同).因此,您应该至少从一般的角度理解所有这些解决方面.

因此,我希望我大致列出了程序集开发人员需要学习的最实际的知识领域.这并不是真正的火箭手术,但这是相当可观的工作.好吧,这是您从学生那里获得的机会,请善加利用. :-)

祝你好运,
—SA
P.S.:我没有提供任何参考,因为这会使本小篇文章的体积增加一倍.我已经远远超出了通常的答案范围.只需使用我提到的术语并逐一阅读即可.获取文献的最好方法也许是在Wikipedia中搜索每个术语,仔细阅读文章并遵循每个文章中提供的链接.
There are no "simple basic notes". You need to learn the CPU, whatever it is. And a lot more. Let''s see.

You need to learn its architecture, its modes, its registers, its typical use, some basic instructions, and you also need to make sure you can find instructions relevant to your purpose in a reference book and clearly understand their description. You need clearly understand how a CPU works with memory and ports of the system it is embedded. You even need to get a clear idea of timing of different kinds of operations, at least approximately.

On architecture part, in addition to pure formal architecture of the CPU, you need to learn some basic data structures and operations on them. In most system, this is the stack, most fundamental structure in nearly all architectures, but it can be something else. If this is x86/IE32/IE64 architectures, they are extremely complex and hard to understand in all aspect. I would imagine learning all of it at the detail level sufficient for practical work in all modes can take 2-4 semesters, if not more. If your school delivers only 1 semester on this topic, you are learning just bare basics or something relatively simple.



I just saw your next question and removed it — you should not re-post questions. The only detail in addition to this question was this one: the CPU is 8086. Well, this is a relatively complex processor, but the order or magnitude simpler than x86. Actually, x86 has a "real mode" which simulates 8086. It has only one memory mode with fixed memory. The memory is addressed as 16-bit segment:offset pair. The registers are classified into segment and offset ones, so the address can be indicated by a pair of related registers. That gives you only 1M of address space; in MS-DOS, only 640K of physical memory is addressed (setting aside special structures called "expanded memory" and "extended memory" used mostly on 80286-based machines — this stuff never worked properly.

In such segment:offset addressing, it''s natural that the same physical address can be addressed by different address values. The effective address is only 20-bit, so there are 4096 ways to address the same point of the physical address.

Nearly everything is explained in the Wikipedia article "Intel 8086".

[END EDIT]

On top of it, you should develop some skills working with the code of Assembly language in part not related to the CPU. There are many different flavors of Assembly languages, different language for each class of CPUs, but even for the same CPU, you can choose different Assemblers (the compilers are called "Assemblers" (they assemble things), and the term "Assembly language" actually mean "the language of the Assembler"), with different syntax and a lot of peculiarities. Assembly languages are not standardized. The instruction and syntactic elements not related to the instructions and registers are devised for your convenience, but they can be good or cryptic and annoying. Even the syntax for CPU commands (even for the same CPU) could be different, as well as the syntax for different ways of addressing objects (there are always quite a few).

I used my "secret weapon" in assembling of the CPU instruction into a working Assembly-only (or not only) code: using in-line assembly of C++ or Borland Pascal. This was an excellent way to use more clear syntax with the possibility of use of the high-level language declarations, skip boring trivial parts of work and avoid freaky syntax peculiarity of "real" Assembly language. However, your course may require "real" Assembly language. Take a look. Depending on your previous experience, you can learn both and safe some time.

What else? Oh, I''m afraid to say, you will need to learn some language environment not related to CPU or the language itself. Here is the thing: the Assembler usually produce not the executable module, but an object file, something needed for modular development. This is a very non-trivial aspect of programming which is not well understood by developers using only high-level language. The object code is not a code in some certain address space. It is composed of unrelated fragments of code operating in different relative address spaces, which will be translated relative to each other later. This is because the executable module is composed of more then one object files (and object libraries, which you can roughly understand as a collection of object files somehow put in one file). This address translation is done by the utility called linker. So, another complication is that you should basically understand this kind of addressing and address translation even though it has nothing to do with CPU architecture. This is a pure artifact of the development cycle. And finally, you should basically understand the operation of such an important OS part as loader. Even though most users and even software developers do not really know that such thing exist, this is a very important part which places the executable module in the RAM (and the location of your data objects and code in RAM can be different each time). So, this is yet another address translation. Only at that moment of time, your code gets the shape which is should have during run time; and only then the "real" CPU architecture comes into play. Note that for complex CPU architectures, there are many other address transforms mapping address space of your process with the physical RAM addresses, which may involve relocation of the physical fragment of memory during run time (virtual memory, which has some different mechanism). So, you should understand all those addressing aspects, at least in general terms.

So, I hope I roughly listed most practical fields of knowledge an Assembly developer needs to learn. It''s not really the rocket surgery, but this is quite considerable amount of work. Well, this is the opportunity you get from being a student, use it well. :-)

Good luck,
—SA
P.S.: I did not provide any references, because this would double the volume of this little article. I''m already well beyond the usual volume of the answer. Just use the terms I mentioned and read on each. Perhaps the best way to get the literature is to search each of the term in Wikipedia, read the article with attention and follow the links provided in each article.


这篇关于汇编编程介绍的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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