【问题标题】:Assembly near jmp/far jmp to mnemonic real mode汇编近 jmp/远 jmp 到助记实模式
【发布时间】:2013-05-09 10:41:26
【问题描述】:

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

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

【问题讨论】:

    标签: assembly nasm x86-16


    【解决方案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

    我看到代码中有一个叫做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-01-26
    • 1970-01-01
    • 1970-01-01
    • 2013-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-17
    • 2016-11-01
    相关资源
    最近更新 更多