指令的执行过程

1.png

2.png

3.png

4.png

5.png

6.png

7.png

8.png

9.png

10.png

11.png

12.png

13.png

14.png

总结.png
1.CS 段地址+ IP偏移地址 通过地址加法器,生成20位物理地址,通过20位的地址总线并找到内存对应的代码指令(这是一个寻址的过程)
2.寻址成功后,控制总线通过指令传递给数据总线,并告诉数据总线是读写的操作过程
3.数据总线通过 BIOS(Basic Input Output System)基本输入输出系统,到指令缓冲器,指令缓存器这里存取代码指令中的数据如(B8 23 01
4 指令缓冲器存取ok后到执行控制器,再通过CPU的三大控制器传递到各通用的寄存器(ax,bx,cx,dx)
这里还有个重点,当数据到达指令缓存器的时候,IP=IP+所读取指令的长度,已经开始指向下一条指令,(这在反汇编的过程中,很重要,我们读取的是IP的下一条地址,而不是当前的IP地址)
- 指令和数据
- 在内存或者磁盘上,指令和数据没有任何区别,都是二进制信息
- CPU在工作的时候把有的信息看做指令,有的信息看做数据,为同样的信息赋予了不同的意义
例如:内存中的二进制信息1000100111011000,计算机可以把它看作大小89D8H的数据来处理,也可以将其看作指令mov ax bx来执行
1000100111011000 ->89D8H(数据)
1000100111011000 ->mov ax,bx (程序)
- CPU根据什么将内存中的信息看做指令?
- CPU将CS:IP指向的内存单元的内容看做指令
- 如果内存中的某段内容曾被CPU执行过,那么它所在的内存单元必然被CS:IP指向过
jmp指令
- CPU从何处执行指令是由CS、IP中的内容决定的,我们可以通过改变CS、IP的内容来控制CPU执行目标指令
- 8086提供了一个mov指令(传送指令),可以用来修改大部分寄存器的值,比如
mov ax,10、mov bx,20、mov cx,30、mov dx,40
- 但是,mov指令不能用于设置CS、IP的值,8086没有提供这样的功能
- 8086提供了另外的指令来修改CS、IP的值,这些指令统称为转移指令,最简单的是jmp指令

imge.png

imge.png
jmp指令 -- 练习

images.png

image.png

image.png

image.png
代码段

image.png

image.png

image.png
网友评论