【任务】编一个子程序,在16个字节型数据中找出最小值,存放于y处
assume cs:code,ds:data
data segment
x db 5, 6, 7, 8, 16, 4, 7, 12, 1, 9, 45, 23, 13, 20, 15, 11
y db ?
data ends
code segment
……
code ends
end start
【参考解答】
assume cs:code,ds:data
data segment
x db 5, 6, 7, 8, 16, 4, 7, 12, 1, 9, 45, 23, 13, 20, 15, 11
y db ?
data ends
code segment
start:mov ax,data
mov ds,ax
mov cx, 16
mov bl, 255
lea si, x
search:
mov al,[si]
cmp al,bl
jae next
mov bl,al
next: inc si
loop search
over: mov y,bl
mov ax,4c00h
int 21h
code ends
end start