我必须从键盘上读取10个数字,然后找到最小和最大。它适用于0-200之间的值,但是如果我输入“ 232,102,1,2,3,4,5,6,7,8”,则代码只说232是最低的而102是最大的。
我
.model small
.stack 200h
.data
max db 0
min db 0
numar db 0
mesaj_min db 13,10, 'Minimul este: $'
mesaj_max db 13,10, 'Maximul este: $'
.code
programStart:
mov ax,@data
mov ds,ax
xor cx,cx
xor bx,bx
mov dl, 10
mov cx, 10
start:
readNumber:
xor ax,ax
mov ah, 01h
int 21h
cmp al, 13
je incarca_stiva
mov bl, al
sub bl, 30h
mov al, numar
mul dl
add al, bl
mov numar, al
jmp readNumber
incarca_stiva:
xor ax,ax
mov al,numar
push ax
mov numar,0
loop start
val_initiala:
xor ax,ax
pop ax
mov min,al
mov max,al
mov cx,9
comparatie:
pop ax
cmp min,al
jge minim
cmp max,al
jle maxim
jmp repetare
minim:
mov min,al
jmp repetare
maxim:
mov max,al
jmp repetare
repetare:
loop comparatie
xor cx, cx
xor bx,bx
Descompunere_max:
xor ax, ax
mov al, max
mov dl, 10
div dl
mov max, al
mov bl, al
add ah, 30h
mov al, ah
mov ah, 0
push ax
inc cx
mov al, bl
cmp al, 0
je AfisareMesaj
jmp Descompunere_max
AfisareMesaj:
mov ah,09H
mov dx, offset mesaj_max
int 21H
AfisareMax:
pop ax
mov ah, 02h
mov dl, al
int 21h
loop AfisareMax
xor cx, cx
xor bx,bx
Descompunere_min:
xor ax, ax
mov al, min
mov dl, 10
div dl
mov min, al
mov bl, al
add ah, 30h
mov al, ah
mov ah, 0
push ax
inc cx
mov al, bl
cmp al, 0
je AfisareMesajMin
jmp Descompunere_min
AfisareMesajMin:
mov ah,09H
mov dx, offset mesaj_min
int 21H
AfisareMin:
pop ax
mov ah, 02h
mov dl, al
int 21h
loop AfisareMin
SfarsitProgram:
mov ah, 4ch
int 21h
end programStart
结果应为: “最大雅思:232” “最低要求:1”
有人可以向我解释一下问题是什么吗?