Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

masm error A2075: jump destination too far : by 30 bytes

Tags:

x86

assembly

masm

My ma'am give me an assignment in which i have to make a program which will take input through keyboard and check the conventional order of the nested brackets. for example:

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

My program:

.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

but when i compile this code the masm shows me an error:

jmp destination too far by 30 bytes.

Please tell me what should i do to get rid of this message and run my program.

like image 889
Abdussalam Mazhar Avatar asked Sep 24 '15 19:09

Abdussalam Mazhar


1 Answers

loop l1 causes the error. LOOP can only perform short jumps (–128 to +127 bytes). Replace it by

dec cx
jne l1
like image 180
rkhb Avatar answered Oct 11 '22 11:10

rkhb