data1 segment
array db 05h,03h,01h,04h,02h
count db 05h
data1 ends
code1 segment
assume cs:code1,ds:data1
start:
mov ax,data1
mov ds,ax
sub ax,ax
mov dl,count
mov di,dx
dec di
back1:
dec dx
mov cx,dx
mov si,offset array
back:
mov al,[si]
cmp al,[si+1]
jle forw
xchg al,[si+1]
mov [si],al
forw:
inc si
loop back
dec di
jnz back1
mov ah,4ch
int 21h
code1 ends
end start
end
; DATA1 RESULT1 DATA2 RESULT2
; 05 01 23 ?
; 03 02 08 ?
; 01 03 18 ?
; 04 04 09 ?
; 02 05 11 ?
back to itmp lab