在jmp / far jmp附近组装到助记实模式

时间:2013-05-15 01:12:59

标签: assembly nasm x86-16

我正在编写程序集,我的代码适用于近似跳转(如下所示,指令执行):

org 0x500
jmp main

%include "smallFile.inc"

main:
    ;start instructions, these instructions get executed

但是,当我包含多个文件,较大的文件(以下)时,它不会跳转,指令不会被执行。我试图在“主要”助记符之前添加地址,我的理解可能会消失。

如何使以下情况有效?

org 0x500
jmp main

%include "smallFile1.inc"    ;couple bytes assembled and linked in
%include "smallFile2.inc"    ;couple bytes assembled and linked in
%include "smallFile3.inc"    ;couple bytes assembled and linked in
%include "LargeFile.inc"     ;couple hundred bytes assembled and linked in
%include "LargeFile2.inc"    ;couple hundred bytes assembled and linked in

main:
    ;start instructions, these are never reached

1 个答案:

答案 0 :(得分:1)

所以我正在做更多的挖掘,我偶然发现了以下资源:

http://books.google.com/books?id=veMTOpapeZkC&pg=PT327&lpg=PT327&dq=how+to+far+jump+to+label+assembly&source=bl&ots=_jHSgrwdfG&sig=C63QURL0FlVhDv_FFrDm1oevBfs&hl=en&sa=X&ei=zOWSUbWxGcWDyAH77ICoCA&ved=0CDwQ6AEwAjgK

我看到的是代码中有一个近乎跳跃的东西...... jmp near。我不知道在过去的几个小时里我是如何错过的。当我将其输入我的代码时,它解决了我的问题......

短跳是+ - 127个相对字节。一段内近跳跃高达2GB。 跳远或跳远;我想我可能一直试图错误地使用跳远。

以下修复了我的代码;

org 0x500
jmp near main

%include "smallFile1.inc"    ;couple bytes assembled and linked in
%include "smallFile2.inc"    ;couple bytes assembled and linked in
%include "smallFile3.inc"    ;couple bytes assembled and linked in
%include "LargeFile.inc"     ;couple hundred bytes assembled and linked in
%include "LargeFile2.inc"    ;couple hundred bytes assembled and linked in

main:
    ;start instructions, these instructions are now reached.

感谢所有看过这个问题的人试图解决我的问题。希望有一天这会帮助某人。