汇编语言jmp 长跳转+debug

我们知道,在汇编语言中的长跳转有两种写法;
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.

首先,长跳转肯定是段间跳转,也就是不在同一个代码段里了,8086cpu寻址的代码段不超过64K,在另一个代码段里面CS的值已经发生了变化,而IP的值被清0,至于他跳转到了哪个代码段
CUP给出了指示是4C8A,如果你想问为什么跳到这里,肯定是你定义的代码段不明确,那么CPU不可能知道具体是哪里,相信你在写-a指令的时候CPU给出的CS也是随机的,这个时候你可以改CPU中手动改CS的值来完全的操纵自己的代码追问

cs是随机的?跳转后的第一条指令是怎么载入的?
如果真是随机的,那是编译器随机生成的还是操作系统在运行时随机载入的?

温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-05-28
做做任务蹭蹭分。
第2个回答  2012-05-27
研究得这么深入?
第3个回答  2012-05-26
CS不是已经指定了么?怎么还要计算?
相似回答