0

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

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
4

1 回答 1

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=zOWSUbWxGcWDyAH7AEwAjCAgved=

我看到代码中有一个叫做near jump...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.

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

于 2013-05-15T02:07:59.160 回答