以下代码在数据段定义了10个无符号型整数(8 bits)
代码如下:
data segment
dat db 3,4,2,3,4,6,7,8,9,19
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov cx,10-1
mov si,offset dat
lp1:jcxz exit
jmp sort
loop lp1
jmp exit
sort:
push cx
push si
cmplp:mov al,[si]
cmp al,byte ptr[si+1]
jae next
mov bl,[si+1]
mov [si],bl
mov [si+1],al
next:
inc si
loop cmplp
pop si
pop cx
dec cx
jmp lp1
exit:hlt
code ends
end start