关于masm不能直接call imm的问题!

简介:

    很多人困惑为啥masm不能直接写call 立即数地址的汇编指令,如果你那样

写铁定报错的。但是查看intel指令手册这种指令编码方式是合法正确的。那么

只有推测是masm对此作了限制。

    解决的办法有很多,做一个间接调用 call [eax],或者call far xxx,或者直接

写byte码。

    其他的办法是在gcc内联汇编里写(VC的内联貌似还是不行):

__asm__ __volatile__("call 0x400000");

    但是这种写法会导致目标地址发生变化,要修正地址,即先算出修正增值:

addx,然后调用:

__asm__ __volatile__("call 0x400000+addx");

    最后完美的做法是用nasm,里面可以直接写:

    call 0x400000


相关文章
|
5月前
|
网络协议 C++
解决MASM32代码汇编出错: error A2181: initializer must be a string or single item
解决MASM32代码汇编出错: error A2181: initializer must be a string or single item
|
9月前
|
程序员
深入理解汇编:平栈、CALL和RET指令详解
深入理解汇编:平栈、CALL和RET指令详解
172 1
|
内存技术 芯片
MDK st-link下载STM32程序出现Internal command error和Error:Flash download failed. Target DLL
MDK st-link下载STM32程序出现Internal command error和Error:Flash download failed. Target DLL   是因为目标板的芯片处于休眠的状态,在尝试连接目标板时候也会出现报错Internal command ...
3767 0
|
iOS开发
iOS linker command failed with exit code 1 (use -v to see invocation)解决方法
iOS linker command failed with exit code 1 (use -v to see invocation)解决方法
2430 0
|
图形学 Android开发
Unity3d:Exception: JNI: Init'd AndroidJavaClass with null ptr!
Unity3d 错误:Exception: JNI: Init'd AndroidJavaClass with null ptr! 解决:需要运行在安卓真机上。
2170 0
|
前端开发 rax Linux
nasm示例一:调用syscall打印Hello World
NASM是基于英特尔 x86 架构的汇编与反汇编工具 syscall是x86_64架构中专门做系统调用的指令
4959 0