汇编语言笔记 下载本文

内容发布更新时间 : 2024/6/29 11:10:21星期一 下面是文章的全部内容请认真阅读。

汇编笔记

计算机的定义:

A computer is a device that accepts input processes data,stores data and produces output all according to a series of stored instructions.

Computer input is whatever is typed,submitted or transmitted to a computer system. In the context computing data refers to symbols that represent facts,objects and ideas.computers manipulate data in many ways and this manipulation is called processing.

Memory is a area of computer that temporarily holds data waiting to be processed,stored or output. 微处理器如何获取指令

Where does the microprocessor get it’s instructions ? The simple answer is that a microprocessor executes(执行) instructions provided by a computer program . However,a microprocessor can’t follow just any instructions . A program that contains an instruction to “self destruct(自毁)” won’t have much effect because a microprocessor can perform only a limited list of instructions “self destruct”isn’t one of them .

The list of instructions that a microprocessor can perform is called it’s instruction set. These instructions are hard-wired(硬线连接) into the processor’s circuitry(电路、电路系统) and include basic arithmetic(算法) and logic operations. Fetching data and clearing registers.

A computer can perform very complex tasks,but it does so by performing a combination of simple tasks from it’s instruction set .

How does a microprocessor work? Inside the chip/carrier , a microprocessor is a very complex integrated circuit , containing as many as 300 million miniaturized

electronic components . The miniaturized circuitry in a microprocessor is grouped into important functional areas ,such as the ALU and the control unit.

The ALU(arithmetic logic unit) performs arithmetic operations , such as addition and subtraction . It also performs logic operations,such as comparing two numbers to see if they are the same . The ALU uses registers to hold data that is being processed , just as you use a mixing bowl to hold the ingredients for a batch of brownies . The microprocessor’s control unit fetches each instruction , just as you get each ingredient out of a cupboard or the refrigerator .

第一章

1.1.1计算机算计的定义

计算机室一种能偶按照事先存储的程序,自动、快速、准确地进行大量数值计算和各种信息处理的现代化智能电子设备

依冯。偌依曼机制,计算机由五大部件组成,即运算器,控制器、存储器、输入设备、输出设备。

1.1.2计算机的特征 1)运算速度快 2)计算精度高 3)记忆功能强

4)具有逻辑判断能力 1.2计算机系统组成

计算机系统由硬件和软件两大部分组成 1.2.1计算机硬件

计算机硬件由控制器、运算器、存储器、输入设备和输出设备组成。 存储器分为内存储器和外存储器。 1) 运算器

注意ALU(Arithmetic Logic Unit) 2) 存储器(主存储器) 3) 控制器 4) 输入设备 5) 输出设备

1.4.1 8086的寄存器

8086是Intel公司推出的第一个16位的微处理器,它由两个具有紧密联系的部件,执行部件EU(Executive Unit)和总线接口部件BIU(Bus Interface Unit)构成,其内部逻辑结构如下图。8086的外部具有20根地址总线,可直接寻址的存储器空间达2^20=1MB.

8086中程序科访问的寄存器共有14个,按功能可分为通用寄存器组,段寄存器组和专用寄存器组。

1)通用寄存器组。 8个,分为两组

一组是数据寄存器(4个): AX(Accumulator):累加寄存器,常用于运算,在乘除指令中指定用来存放操作数(运算结果);另外,所有的I/O指令都使用这一寄存器与外界设备传送数据。 MUL BL -------------> AX = BL * AL

BX(Base):基址寄存器,常用于地址索引。 CX(Count):计数寄存器,常用于计数.。 DX(Dat):数据存储器,常用于数据传递。

特点:这4个16位寄存器可分为高8位:AH、BH、CH、DH以及低8位:AL、BL、CL、DL。 Mov AX,BX ○√ Mov AL,AH○√

另一组是指针寄存器和变址寄存器,包括:

SP(Stack Pointer):堆栈指针寄存器,与SS配合使用,可指向目前的堆栈位置。 BP(Base Pointer):基址指针寄存器,可用作SS的一个相对基址位置。 SI(Source Index):源变址寄存器,可用来存放相对于DS段之源变址指针。 (Si、Di对首地址的存储)

DI(Destination Index):目的变址寄存器,主要用来存放相对于ES段之目前的变址之址指针。 这4个16位寄存器只能按16位进行存取操作,主要用来形成操作数的地址,用于在堆栈操作和变址运算中计算操作数的有效地址 2)段寄存器(Segment Register)

4个16位段寄存器,专门用来保存段地址:

CS(Code Segment):代码段寄存器,存放当前正在运行的程序。

DS(Data Segment):数据段寄存器,数据段存放当前运行程序所有的数据,。 SS(Stack Segment):堆栈段寄存器,堆栈段定义了堆栈的所在区域。 ES(Extra Segment):附加段寄存器。

由于段寄存器都是16位的,所有只能在可寻址空间小于64KB的情况下被设成任意大小。 3)专用寄存器组

包括指令指针IP(Instruction Pointer) 和标志寄存器FR(Flag Register) IP:16位专用寄存器,它指向当前需要取出的指令字节。如下

IP=PC{pc+1->pc pc +n->pc}

注意,IP指向的是指令地址的段内地址偏移量,又称偏移地址(Offset Address)或有效地址EA(Effective Address)。

FR:=PSW。FR有16位,其中有意义的有9位-----6位状态位,3位是控制位。具体含义如下。(16=9+7(没有意义),9=6个状态位+3个控制位)

OF,溢出标志位。反映有符号数加减运算所得结果是否溢出。溢出,OF=1,否则OF=0. DF,方向标志,该位用来决定在串操作指令执行时有关之争寄存器指向高地址或低地址的方向。