data segment
arr dw 2678h,2222h,3789h,0aaah,1111h,1234h,3234h,7568h,0a12h,8798h
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
lea si,arr
mov cx,09h
mov ax,[si] ; loading 1st element of array in ax
up:
cmp ax,[si+2]
jnc down ; if ax is larger element in array
mov ax,[si+2] ;swapping to store large element in array
down:
inc si
inc si
dec cx
jnz up
int 03h
code ends
end start
arr dw 2678h,2222h,3789h,0aaah,1111h,1234h,3234h,7568h,0a12h,8798h
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
lea si,arr
mov cx,09h
mov ax,[si] ; loading 1st element of array in ax
up:
cmp ax,[si+2]
jnc down ; if ax is larger element in array
mov ax,[si+2] ;swapping to store large element in array
down:
inc si
inc si
dec cx
jnz up
int 03h
code ends
end start
No comments:
Post a Comment