我们知道,在汇编语言中的长跳转有两种写法;
1,段间直接转移:JMP label_far
2,段间存储器间接转移 JMP var_dw;JMP DWORD PTR [SI];等
在第一种情况中,代码段寄存器CS=label_far所在代码段的段地址,而指令指针ip=label_far所指向
的指令的地址。
在第二种情况,IP低8位=var_dw,ip高8位=var_dw+1;cs低8位=VAR_dw+2,cs高8位=VAR_dw+3。
以上是在编写汇编语言中断间转移指令的写法。
本人的问题是:
以上的说明是针对汇编器对源程序汇编时的处理方法,当实际的CPU处理实际的长跳转指令时,
到底是如何实现的?(指的是8086CPU或X86CPU的16位实模式)。
本人用debug.exe反汇编了系统中的MEM.exe。在其中发现了一条长跳转指令,如图。
在cpu执行了长跳转指令后,CS到底是如何计算出来的?(IP的计算方法已经知道了。)
是不是和EXE的文件头有关?
是不是CS=DS+10H总成立?
请详细说明在反汇编断间转移指令时,8086CPU对CS的计算方法。
本人在INTEL手册中查到了这些,但好像说的是在写汇编语言的cs的处理过程。
Far Jumps in Real-Address or Virtual-8086 Mode.
When executing a far jump in real-address or virtual-8086 mode, the processor jumps to the code segment
and offset specified with the target operand.
Here the target operand specifies an absolute far address either directly with a pointer (ptr16:16 or
ptr16:32) or indirectly with a memory location (m16:16 or m16:32).
With the pointer method, the segment and address of the called procedure is encoded in the instruction,
using a 4-byte (16-bit operand size) or 6-byte (32-bit operand size) far address immediate.
With the indi-rect method, the target operand specifies a memory location that contains a 4-byte (16-bit
operand size) or 6-byte (32-bit operand size) far address.
The far address is loaded directly into the CS and EIP registers. If the operand-size attribute is 16, the
upper two bytes of the EIP register are cleared.
cs是随机的?跳转后的第一条指令是怎么载入的?
如果真是随机的,那是编译器随机生成的还是操作系统在运行时随机载入的?