I wrote a program in (a86 )to sort the whole array into ascending order and its run ok but how can I make it more effcient(reducing unnecessary work) this is my code;
Code segment
Jmp main
Add1 dw 9,3,2,7,1,4,2,5,8,1
Main: mov si,0
call order
mov si,0
call order
mov si,0
call order
mov si,0
call order
mov si,0
call order
mov si,0
call order
mov si,0
call order
mov si,0
call order
ret
order: call orderab
call orderab
call orderab
call orderab
call orderab
call orderab
call orderab
call orderab
call orderab
orderab: mov ax,add1[si]
cmp ax,add1[si+2]
jli finish
mov bx,add1[si+2]
mov add1[si],bx
mov add1[si+2],ax
finish: inc si
inc si
ret
Start Free Trial