无法获得到达PROC末尾的来源

问题描述 投票:0回答:1

我正在尝试调用一个函数,该函数将输出一个字符串,该字符串确定您使用整数的速度。问题是,无论eax寄存器中有什么内容,它都无法正确执行ELSE IF循环并结束PROC。

INCLUDE Irvine32.inc            ;Use Irvine32 library.

.data
    ;Declare variables here.

    speed BYTE ?, 0
    wTooFast BYTE "Woah! You are going way too fast! Slow down!", 0                     
    tooFast BYTE "You are going faster than the speed limit. Slow down.", 0                     
    speedLimit BYTE "You are maintaining an appopriate speed limit. Keep up being a safe driver!", 0                        
    tooSlow BYTE "You are going slower than the flow of traffic. Speed up.", 0                      
    wTooSlow BYTE "Is the engine even on? Speed up!", 0                     



.code
main PROC
    ;Write your code here.  

    target:
        call Randomize
        mov eax, 101
        call RandomRange
        .IF (eax <= 40)
        jmp target
        .ENDIF
    call WriteInt

    call SpeedVal
    mov edx, 0
    mov speed, al
    mov edx, OFFSET speed
    call WriteString
    call Crlf





    exit                        ;Exit program.
main ENDP

    SpeedVal PROC

        .IF (eax >= 85)
        mov al, wTooFast
        .ELSEIF (eax > 75) && (eax < 85)
        mov al, tooFast
        .ELSEIF (eax > 64) && (eax < 76)
        mov al, speedLimit
        .ELSEIF (eax > 54) && (eax < 65)
        mov al, tooSlow
        .ELSE
        mov al, wTooSlow
        .ENDIF


    SpeedVal ENDP



END main

它应该根据随机变量是.data节中声明的字符串之一输出。

assembly x86 masm
1个回答
1
投票

好像您忘记了ret,因此执行落在了PROC的底部。调试器仅向您显示“源不可用”,因为我猜您正在使用源视图而不是反汇编视图。

[PROC / ENDP不会为您插入ret指令。

© www.soinside.com 2019 - 2024. All rights reserved.