ntwo

导航

基于x86处理器汇编语言-基本概念

1.1 Welcome to Assembly Language

1. How do assemblers and linkers work together?汇编器和链接器是如何一直工作的?

An assembler convert source-code programs from assembly language into machine language. A linker combines individual files created by an assembler into a single executable program.

汇编器将汇编语言源代码转换为机器语言。链接器将汇编器产生的单独文件合并成一个可执行程序。

2. How will studying assembly language enhance your understanding of operating systems?学习汇编语言是如何加强对操作系统的理解的?

Assembly language is a good tool for learning how application programs communicate with the computer’s opeating system via interrupt handlers, system calls, and common memory areas. Assembly language programming also helps when learning how the operating system loads and executes application programs.

汇编语言是一个很好的工具,可以用来学习应用程序如何通过中断处理程序、系统调用和内存公用区与操作系统交互。在学习操作系统如何装载和执行应用程序时,汇编语言也有帮助。

3. What is meant by a one-to-many relationship when comparing a high-level language to machine language?在比较高级语言和机器语言时,一对多关系是什么意思?

In a one-to-many relationship, a single statement expands into multiple assembly language or machine instructions.

在一对多关系中,一个语句会展开为多条汇编或机器指令。

4. Explain the concept of portability as it applies to programming languages. 解决编程语言中的可移植性。

A language whose source programs can compiled and run on wide variety of computer systems is said to be portable.

一个语言的源代码可以在多种计算机系统上编译和运行,那么这种语言称为可移植的。

5 Is the assembly language for x86 processors the same as as those for computer systems such as the Vax or Motorola 68x00? x86汇编语言与Vax或Motorola 68x00汇编语言是否一样?

No. Each assembly language is based on either a processor family or a specific computer.

不一样。每一种汇编语言都是基于一个系列的处理器或特定机器的。

6. Give an example of an embedded system application. 给出一个嵌入式系统应用程序的例子。

Some examples of embedded systems applications are automobile fuel and ignition system, air-conditioning control systems, security systems, flight control system, hand-held computers, modems, printers, and other intelligent computer peripherals.

例如汽车燃料以及点火系统,空调控制系统,安全系统,飞行控制系统,手持计算机,调制解调器,打印机和其它智能计算机外设。

7. What is a device driver? 什么是设备驱动?

Device drives are programs that translate general operating system commands into specific references to hardware details that only the manufacture knows.

设备驱动是一种将操作系统命令翻译成只有生产商才知道的硬件细节的特定引用的程序。

8. Do you suppose type checking on pointer variables is stronger (stricter) in assembly language or in C and C++? 你认为指针变量检查在汇编语言还是在C和C++中更严格?

C++ does not allow a pointer of one type to be assigned to a pointer of another type. Assembly language has no such restriction regarding pointers.

C++不允许一种类型的指针赋给另一种类型的指针。汇编语言没有这种限制。

9. Name two types of applications that would be better suited to assembly language than a higth-level language. 给出两种相对高级语言更适合使用汇编语言开发的应用程序。

Applications suited to assembly language: hardware device driver and embedded systems and computer games requiring direct hardware access.

硬件设备驱动、嵌入式系统和要求直接硬件访问的计算机游戏。

10. Why would a high-level language not be an ideal tool for writing a program that directly accesses a particular brand of printer? 为什么高级语言不是编写直接访问某一品牌的打印机程序的理想工具。

A high-level language may not provide for direct hardware access. Even if it does, awkward coding techniques must often be used, resulting in possible maintenance problems.

高级语言一般不提供直接硬件访问。即使提供,也需要经常使用一些变通的编码的技术,导致维护问题。

11. Why is assembly language not usually used when writing large applications programs? 为什么通常不使用汇编语言编写大型应用程序?

Assmbly language has minimal formal structure, so structure must be imposed by programmers who have varying levels of experience. This leads to difficulties maintaining existing code.

汇编语言有最少的正式结构,所以这些结构需要由拥有不同经验的程序员实现。这导致代码难以维护。

12 Translate the following C++ expression to assembly language, using the example presented earlier int this chapter as guide: X = (Y * 4) + 3.

mov eax,y
mov ebx,4
imul ebx
add eax,3
mov x,eax
 

1.2 Virtual Machine Concept

1. In your own words, describe the virtual machine concept. 什么是虚拟机?

Computers are constructed in layers, so that each layer represents a translation layer from higher-level instruction set to a lower-level instruction set.

计算机是分层的,所有每一层都将上一层指令集翻译成下一层指令集。

2. Why don’t programmers write application programs in machine language?为什么不使用机器语言写程序?

It is enormously detailed and consists purely of numbers. Hard for humans to understand.

机器语言过于关心细节,而且它只由数字组成。人很难理解。

3. (True/False): When an interpreted program written in language L1 runs, each of its instructions is decoded and executed by a program written in language L0.

True. 真。

4. Explain the technique of translation when dealing with languages at different virtual machine levels. 解释处理不同层次虚拟机语言的转换技术。

An entire L1 program is converted into an L0 program by an L0 program specifically designed for this purpose. Then the resulting L0 program is executed directly on the computer hardware.

一个L1程序由一个专门设计为转换程序的L0程序转换成L0程序。转换后的程序由计算机硬件直接执行。

5. At which level does assembly language appear in the virtual machine example shown in this section? 在这一节中演示的虚拟机示例中,汇编语言是第几级。

At Level 3。第三级。

2010-12-11 15 58 33

6. What software permits compiled Java programs to run on almost any computer? 什么软件使得Java程序运行在几乎任何计算机上?

Java virtual machine (JVM)。Java虚拟机。

7. Name the four virtual machine levels named in this section, from lowest to hightest. 从低到高说出本节中虚拟机的四个级别。

Digital logic, instruction set architecture, assembly language, high-level language。数字逻辑、指令集架构、汇编语言、高级语言。

8. Machine language is used at which level of the virtual machine show in Figure 1-1? 机器语言在虚拟机的哪个级别?

Instruction set architecture. 指令集架构。

9. Statements at the assembly language level of a virtual machine are translated into statements at which other level?  汇编语言语句翻译成哪一级语句?

Instruction set architecture. 指令集架构。

1.3 Data Representation

1. Explain the term Least Significant Bit (LSB).

The bit on the left。最左边的比特,最低位。

2. Explain the term Most Significant Bit (LSB).

The bit on the right。最右边的比特,最高位。

3. What is the decimal representation of each of the following unsigned binary integers?
a. 11111000          248
b. 11001010          202
c. 11110000          240

4. What is the decimal representation of each of the following unsigned binary ingegers?
a. 00110101          53
b. 10010110         150
c. 11001100          204

5. What is the sum of each pair of binary integers?
a. 00001111 + 00000010               00010001
b. 11010101 + 01101011              101000000
c. 00001111 + 00001111               00011110

6. What is the sum of each pair of binary integers?
a. 10101111 + 11011011               110001010
b. 10010111 + 11111111               110010110
c. 01110101 + 10101100                10010001

7. How many bytes are contained in each of the following data types?
a. word                      2
b. doubleword            4
c. quadword               8

8. How many bits are contained in each of the following data types?
a. word                     16
b. doubleword            32
c. quadword               64

9. What is the minimum number of binary bits needed to represent each of the following unsigned decimal integers?
a. 65                        7
b. 256                      9
c. 32768                   16

10. What is the minimum number of binary bits needed to represent each of the following unsigned decimal integers?
a. 4095                    12
b. 65534                   16
c. 2134657                22

11. What is the hexadecimal representation of each of the following binary numbers?
a. 1100 1111 0101 0111         CF57
b. 0101 1100 1010 1101         5CAD
c. 1001 0011 1110 1011         93EB

12. What is the hexadecimal representation of each of the following binary numbers?
a. 0011 0101 1101 1010         35DA
b. 1100 1110 1010 0011         CEA3
c. 1111 1110 1101 1011         FEDB

13. What is the binary representation of the following hexadecimal numbers?
a. E5B6AED7     
b. B697C7A1
c. 234B6D92

14. What is the binary representation of the following hexadecimal numbers?
a. 0126F9D4
b. 6ACDFA95
c. F69BDC2A

15. What is the unsigned decimal representation of each hexadecimal integer?
a. 3A           58
b. 1BF         447    
c. 4096       16534
16. What is the unsigned decimal representation of each hexadecimal integer?
a. 62           98
b. 1C9         457
c. 6A5B       27227

17. What is the 16-bit hexadecimal representation of each signed decimal integer?
a. –26         FFE6
b. –452       FE3C
18. What is the 16-bit hexadecimal representation of each signed decimal integer?
a. –32         FFE0
b. –62         FFC2
19. The following 16-bit hexadecimal numbers represent signed integers. Convert to decimal.

a. 7CAB      31915
b. C123      -16093

20. The following 16-bit hexadecimal numbers represent signed integers. Convert to decimal.
a. 7F9B       32667
b. 8230       -32208
21. What is the decimal representation of the following signed binary numbers?
a. 10110101            -75
b. 00101010            42
c. 11110000            -16

22. What is the decimal representation of the following signed binary numbers?
a. 10000000          -128
b. 11001100          -52
c. 10110111           -73
23. What is the 8-bit binary (two’s-complement) representation of each of the following signed decimal integers?
a. –5                11111011
b. –36              11011100
c. –16               11110000
24. What is the 8-bit binary (two’s-complement) representation of each of the following signed decimal integers?
a. –72              10111000
b. –98              10011110
c. –26               11100110
25. What are the hexadecimal and decimal representations of the ASCII character capital X?

58h and 88d

26. What are the hexadecimal and decimal representations of the ASCII character capital M?

4Dh and 77d

27. Why was Unicode invented?

To handle international character sets that require more than 256 codes.

为了处理多于256个编码的国际字符集。

28. What is the largest value you can represent using a 256-bit unsigned integer?

2256 - 1

29. What is the largest positive value you can represent using a 256-bit signed integer?

2255 - 1

posted on 2010-12-14 19:44  9527  阅读(1287)  评论(0编辑  收藏  举报