Data segment
buf db 3,4,2,5
Data ends
Code segment
Assume cs:code,ds:data
Start:
Mov ax,data
Mov ds,ax
Mov cx,4
dec cx
Mov bx,0
Mov al,buf[bx]
add bx,1
Mov ah,buf[bx]
Loop1:
cmp cx,bx
jna exit
Loop2:
add bx,1
Cmp al,buf[bx]
jna Loop3
Xchg al,buf[bx]
jmp loop1
Loop3:
cmp ah,buf[bx]
Xchg ah,buf[bx]
jmp loop1
exit:
int 20h
Code ends
End start
(我自己写的第一个汇编程序)