assembly - masm 错误 A2075 : jump destination too far : by 30 bytes

标签 assembly x86 masm

我的女士给了我一个作业,我必须制作一个程序,该程序将通过键盘输入并检查嵌套括号的常规顺序。
例如:

input= {[()]}, output = correct format, input = ({[]}) output = incorrect



我的程序:
.model small

.stack 100h

.386

.data

msg1 db "this is a correct format of nested brackets$"
msg2 db "this is no a correct format of nested brakets$"

.code

main proc 
mov ax,@data
mov ds,ax

mov cx,15

push '#'
l1:

mov ah,1
int 21h

cmp al,'['
je pushh1

cmp al,'{'
je pushh2

cmp al,'('
je pushh3

cmp al,']'
je pop1

cmp al,'}'
je pop2

cmp al,')'
je pop3

jmp ser

pushh1:

pop dx
cmp dx,'('

push dx

je wrongorder

movzx dx,al

push dx

jmp ser

pushh2:

pop dx

cmp dx,'['

je wrongorder

cmp dx,'('

je wrongorder

push dx

movzx dx,al

push dx

jmp ser

pushh3:

pop dx

cmp dx,'{'

push dx

je wrongorder

movzx dx,al

push dx

jmp ser

wrongorder:

mov dx,'*'

push dx

jmp ser

pop1:

pop dx

cmp dx,'#'

push dx

je ser

pop dx

cmp dx,'{'

push dx

je ser

pop dx

cmp dx,'('

push dx

je ser

pop dx

jmp ser

pop2:

pop dx

cmp dx,'#'

push dx

je ser

pop dx

cmp dx,'('

push dx

je ser

pop dx

cmp dx,'['

push dx

je ser

pop dx

jmp ser

pop3:

pop dx

cmp dx,'#'

push dx

je ser

pop dx

cmp dx,'{'

push dx

je ser

pop dx

cmp dx,'['

push dx

je ser

pop dx

ser:

cmp al,'q'

je labo

loop l1



labo:

mov ah,2

mov dl,0ah

int 21h

mov dl,0dh

int 21h


mov ah,2h

pop dx

;int 21h

cmp dx,'#'

je labe

cmp dx,'#'

jnz labr



labe:

mov dx, offset msg1

mov ah,9h

int 21h

jmp lab8

labr:

mov dx, offset msg2

mov ah,9h

int 21h


lab8:


mov ah,4ch

int 21h

main endp

end main

但是当我编译这段代码时,masm 向我显示了一个错误:

jmp destination too far by 30 bytes.



请告诉我我该怎么做才能摆脱此消息并运行我的程序。

最佳答案

loop l1导致错误。 LOOP只能执行短跳转(–128 到 +127 字节)。将其替换为

dec cx
jne l1

关于assembly - masm 错误 A2075 : jump destination too far : by 30 bytes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32769277/

相关文章:

c - 如何将全局寄存器变量关联到 %gs(或 %fs)?

gcc - 两个数相加

c++ - 将 MASM 中制作的库调用为 C 或 C++

assembly - TBYTE 可容纳的最大值(value)

c - 这个程序如何知道存储这个字符串的确切位置?

linux - 如何在汇编 NASM 中打印数字?

c - x86 从数据中分辨指令的方法

oop - 如何通过查看程序集来判断程序是否使用动态调度

assembly - (x86) 虚拟机通常如何处理标志?

c++ - masm 指令集资源