求助一道汇编语言的题目

2024-12-15 14:00:52
推荐回答(1个)
回答1:

流程图这没办法给你,具体思路:将10个无符号数按冒泡法从小到大排序,最后的那个数就是最大的了
程序执行结果:
the max:
02334

data segment
mes1 db 'the max:$'
a dw 1,2,100,10,99,120,89,2334,90,1239
data ends

code segment
main proc far
assume cs:code,ds:data
start:
push ds
sub ax,ax
push ax

mov ax,data
mov ds,ax
;以下是起泡排序核心代码
mov cx,10
dec cx

loop1:
mov di,cx
mov bx,0
loop2:
mov ax,a[bx]
cmp a[bx+2],ax
jge cotinue
xchg ax,a[bx+2]
mov a[bx],ax

cotinue:
add bx,2
loop loop2
mov cx,di
loop loop1

mov dx,offset mes1
mov ah,09h
int 21h
call crlf
mov bx,a[18]
call bini ;转换为十进制的子程序
ret
main endp

bini proc near
mov cx,10000d
call bin
mov cx,1000d
call bin
mov cx,100d
call bin
mov cx,10d
call bin
mov cx,1d
call bin
ret
bini endp

bin proc near
mov ax,bx
mov dx,0
div cx
mov bx,dx
mov dl,al
add dl,30h
mov ah,02h
int 21h
ret
bin endp

crlf proc near
mov dl,0ah
mov ah,02h
int 21h
mov dl,0dh
mov ah,02h
int 21
ret
crlf endp
code ends
end start