masm error A2075: jump destination too far : by 30 bytes
Asked Answered
T

1

5

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.

Tatting answered 24/9, 2015 at 19:20 Comment(2)
Which jump exactly is the assembler complaining about? Since you're targeting the 80386 I would've expected MASM to automatically use near jumps when a short jump isn't possible. There's an OPTION LJMP for MASM to enable jump-lengthening, but it's supposed to be enabled by default.Nissie
Take the habit to add some comments along your opcodes. In six month, you won't remember what it does / how it proceed.Oldfashioned
S
8

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

dec cx
jne l1
Strategy answered 24/9, 2015 at 19:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.