跳转目标太远:3字节 [英] jump destination too far : by 3 byte(s)

查看:74
本文介绍了跳转目标太远:3字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的循环有问题,其中包含的代码很长,并且给了我错误jump destination too far : by 3 byte(s).当ı移除时:

I m having a problem with my loop, the code contained in it is long and it gives me error jump destination too far : by 3 byte(s). When ı remove:

mov edx,offset str1 
call writestring

这部分位于主PROC下方,它没有给出错误.但我需要此字符串的用户输入一个负数来发送消息.怎么会?

this part below the main PROC, it doesnt give an error. But ı need this string user enters a negative number to give a message. How can ı?

INCLUDE Irvine32.inc

.data

    money      dword    200,100,50,20,10,5,1
    str1       byte     "Enter the amounts for each value of money : ",0
    str2       byte     "The sum of your moneys are:",0
    total      dword    0
    buffer     dword    1000 dup(0),0    
    str3       byte     "Do not enter neg number ",0

.code
main PROC
    mov edx,offset str1 
    call writestring
    call crlf
    mov ecx,lengthof money
    mov esi,0
    mov edi,0

start1:
    jmp continue
    don:
    push ecx


    mov edx,ecx
    mov edx,0

    mov edx,7
    sub edx,ecx
    mov ecx,edx
    mov edi,0
    mov esi,0
        start2:

            mov eax,money[esi]
            call writedec
            mov ebx,eax
            mov al,'x'
            call writechar
            mov eax,buffer[edi]
            call writedec
            call crlf
            add esi,4 
            add edi,4

        loop start2

    pop ecx
    continue:

    ;**************************************************
    mov edx,0
    mov eax,money[esi]
    call writedec
    mov ebx,eax
    mov al,'x'
    call writechar
    call readint
    ;***************************************************

    sub eax,0
    js don
    mov buffer[edi],eax
    ;*************************
    mul ebx
    add total,eax       ;we add each the multiplication to total.
    add esi,4           ;increases the index by 4.(because of dword type)
    add edi,4


loop start1

    mov edx,offset str2
    call writestring
    mov eax, total
    call writedec

    exit
main ENDP
END main

推荐答案

loop的范围有限.从下一条指令开始算起,它只能在指令流中向前跳转127个字节或向后跳转128个字节.

loop has limited range. It can only jump up to 127 bytes ahead or 128 back in the instruction stream measured from the start of the following instruction.

要解决此问题,您可以执行以下操作.

To get around that, you can do something like the following.

代替

label1:

<lots of code>

loop label1 

如果标签触手可及,您可以执行以下操作:

if the label is out of reach you can do something like this:

label1:

<lots of code>

loop tmp1
jmp tmp2
tmp1:
  jmp label1
tmp2:

否则将基于没有范围限制的条件跳转使用其他构造.

or else use a different construct based on conditional jumps that don't have the range limitation.

这篇关于跳转目标太远:3字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆