有没有办法跳转到MASM中的过程的特定部分

时间:2016-05-20 16:52:51

标签: assembly x86 masm

我想从另一个程序跳转到主程序的特定部分。基本上我有一个主要过程的介绍部分,其余部分我想循环,但从另一个程序。这可能吗?

main PROC
    call    otherProc
    section:
        ;Do something else
main ENDP


other PROC
    jmp    main.section ; Jump to section inside main...is this possible?
other ENDP

1 个答案:

答案 0 :(得分:3)

根据此链接,使用双冒号使标签无范围

http://coding.derkeiler.com/Archive/Assembler/alt.lang.asm/2006-11/msg00909.html

我刚刚做了一个例子,它按预期工作

.686P
.MODEL FLAT
.STACK 4096

EXTERN      _printf     :PROC

.DATA
msg     BYTE    "testing", 0dh, 0ah, 0

.CODE

_main   PROC

    push    ebp
    mov     ebp, esp

    call    _other
lbl1::
    add     esp, 4
    push    OFFSET msg
    call    _printf
    add     esp, 4

    xor     eax, eax
    pop     ebp
    ret

_main   ENDP

_other  PROC

    jmp     lbl1
    ret

_other  ENDP

END

在VS 2015命令提示符下编译:

ml jumps.asm /link legacy_stdio_definitions.lib msvcrt.lib