.data
array dw 2, 9, 6, 5, 8, 3, 7, 4, 1
n equ ($ - array)/2
.code
start: mov ax, @data
mov ds, ax
mov dx, offset array
mov cx, n
sort:
push cx
mov si, dx
mov di, offset array + 2
dec si
dec si
dec di
dec di
s:inc si
inc si
inc di
inc di
mov bx, [si]
cmp bx, [di]
jl s
xchg bx, [di]
mov [si], bx
loop s
pop cx
loop sort
mov dx, array
call arrout
mov ax, 4c00h
int 21h
arrout proc near ;参数为dx
push ax
push bx
push cx
push dx
mov si, dx
mov cx, n
disp:
mov bx, [si]
call output
inc si
inc si
loop disp
pop dx
pop cx
pop bx
pop ax
ret
arrout endp
output proc near ;参数为bx
push ax
push bx
push cx
push dx
mov ax, bx
mov bx, 10
mov cx, 0
insert:
cwd
div bx
push dx
inc cx
cmp ax, 0
jne insert
opt:pop dx
add dx, 30h
mov ah, 02h
int 21h
loop opt
pop dx
pop cx
pop bx
pop ax
ret
output endp
end start
不知道 为什么 这句loop 0015不仅没有执行,反而把很多寄存器都修改了,求大神解答,上面是我写的代码