Click here to Skip to main content
15,891,423 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Everyone!

i am Trying to Sort The Array In Descending Order In Assembly Language But i Got Still Two Error
1:**Error** Array123.asm(12) Relative jump out of range by 007Fh bytes


2:**Error** Array123.asm(119) Relative jump out of range by 0080h bytes


Both Error About the Loop Statement Please Help Me If Any One Solve This Query.

ASM
.model small
.stack 100h
.data
Array db 1,2,3,4,5,6,7,8,9
.code
Main Proc
mov ax,@data
mov ds,ax
;Make Different Session
mov cx,10
Again:
jcxz Comp
mov bl,Array
cmp bl,Array+1
jl One

One:
mov bl,Array
mov cl,Array+1
XCHG bl,cl
mov Array,bl
mov Array+1,cl

mov bl,Array+1
cmp bl,Array+2
jl Two

Two:
mov bl,Array+1
mov cl,Array+2
XCHG bl,cl
mov Array+1,bl
mov Array+2,cl

;Threee
mov bl,Array+2
cmp bl,Array+3
jl Three

Three:
mov bl,Array+2
mov cl,Array+3
XCHG bl,cl
mov Array+2,bl
mov Array+3,cl

;Fourr
mov bl,Array+3
cmp bl,Array+4
jl Four

Four:
mov bl,Array+3
mov cl,Array+4
XCHG bl,cl
mov Array+3,bl
mov Array+4,cl

;Five
mov bl,Array+4
cmp bl,Array+5
jl Five

FIve:
mov bl,Array+4
mov cl,Array+5
XCHG bl,cl
mov Array+4,bl
mov Array+5,cl

;Six
mov bl,Array+5
cmp bl,Array+6
jl Six

Six:
mov bl,Array+5
mov cl,Array+6
XCHG bl,cl
mov Array+5,bl
mov Array+6,cl

;Seven
mov bl,Array+6
cmp bl,Array+7
jl Seven

Seven:
mov bl,Array+6
mov cl,Array+7
XCHG bl,cl
mov Array+6,bl
mov Array+7,cl

;Eight
mov bl,Array+7
cmp bl,Array+8
jl Eight

Eight:
mov bl,Array+7
mov cl,Array+8
XCHG bl,cl
mov Array+7,bl
mov Array+8,cl

;Ninth
mov bl,Array+8
cmp bl,Array+9
jl Ninth

Ninth:
mov bl,Array+8
mov cl,Array+9
XCHG bl,cl
mov Array+8,bl
mov Array+9,cl

Loop Again
;Display Session
Comp:
mov dl,Array
add dl,48
mov ah,02
int 21h

mov dl,Array+1
add dl,48
mov ah,02
int 21h

mov dl,Array+2
add dl,48
mov ah,02
int 21h

mov dl,Array+3
add dl,48
mov ah,02
int 21h
mov dl,Array+4
add dl,48
mov ah,02
int 21h

mov dl,Array+5
add dl,48
mov ah,02
int 21h
mov dl,Array+6
add dl,48
mov ah,02
int 21h

mov dl,Array+7
add dl,48
mov ah,02
int 21h

mov dl,Array+8
add dl,48
mov ah,02
int 21h

mov dl,Array+9
add dl,48
mov ah,02
int 21h

mov ah,4ch
int 21h

Main Endp
End Main
Posted
Updated 6-Nov-19 5:32am
Comments
Tomas Takac 10-Dec-14 14:43pm    
I would say you are jumping too far. The label given must be short (between -128 and +127 bytes from the instruction following the jump).

1 solution

You have two options:
1. Make all your code use far pointers (it means compiler will use word/dword for address computation)
Main Proc FAR

2. Make only the loop use far pointers
jcxz FAR Comp
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900