DATAS SEGMENT
buf db 89,91,-5,77,56,55,90,88,65,75
db 59,75,02,5,4,68,25,-85,-95,4
db 48,50,42,93,-82,-80,59,-52,85,-96
db 89,91,-5,77,56,55,90,88,65,75
db 59,75,02,5,4,68,25,-85,-95,4
db 48,50,42,93,-82,-80,59,-52,85,-96
len_buf dw $-buf
num_r dw 0
num_l dw 0
doing db 0
DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
;initial the mems
xor bx,bx ; count the num of buf in print
xor dx,dx ; dl and ah for display
xor ax,ax ; ah for display
xor cx,cx ; cl for shr and shl ; ch for 10
;display enter
mov dl,0ah
mov ah,02h
int 21h
jmp sort
;begin to sort
sort:
mov dx,[len_buf]
sub dx,01h
;the first layer loop
mov bx,00h
add cx,01h
cmp cx,dx
jna lp
ja redo
;the second layer loop
lp:
mov al,[buf][bx]
mov ah,[buf][bx+1]
cmp al,ah
ja exchange
jna next
;exchange the num
exchange:
mov al,[buf][bx+1]