可以在8086汇编中操纵指令指针吗? [英] Is it possible to manipulate the instruction pointer in 8086 assembly?

查看:100
本文介绍了可以在8086汇编中操纵指令指针吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道我是否可以在8086汇编中操纵(读取并更改其值).

I want to know if I can manipulate (read and change the value of) the instruction pointer (IP) in 8086 assembly.

例如,

说IP当前正在存储0200h.我想读取此值并将其更改为其他值,例如4020h.我该怎么办?

Say IP is currently storing 0200h. I would like to read this value and change it to something else, say 4020h. How could I do that?

推荐答案

如果要将指令指针设置为已知值(例如十六进制值4020h),则可以直接跳转到该地址:

If you wanted to set the instruction pointer to a known value, say hex value 4020h, you could jump directly to that address:

jmp 4020h

或者,如果某个内存位置myVariable保留了要存储在IP中的值,则可以进行间接跳转:

Or if some memory location, myVariable, held the value you wanted to store in IP you could do an indirect jump:

jmp [myVariable]

jmp(间接或直接)的结果会修改指令指针.

The result of a jmp (indirect or direct) modifies the instruction pointer.

读取指令指针是有问题的.通过使用一组类似以下代码的代码,可以在Linux上定位独立的代码:

Reading the instruction pointer is problematic. Position independent code on Linux used to work by using a set of code something like:

 call getIP

使用

 :getIP
 mov bx, [sp] ; Read the return address into BX.
 ret

有关其他读取IP的方法,请参见堆栈溢出:读取IP .

For other methods of reading IP, see Stack Overflow: reading IP.

这篇关于可以在8086汇编中操纵指令指针吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆