DATA SEGMENT USE16
NUM DB -19,+28,37,-46,+55,61,-74,+255
COUT1 DB ?,0DH,0AH,'$'
COUT2 DB 0AH,'MAX=',?,0DH,0AH,'$'
COUT3 DB 0AH,'MIN=',?,0DH,0AH,'$'
DATA ENDS
CODE SEGMENT USE16
ASSUME CS:CODE,DS:DATA
BEG: mov AX,DATA
MOV DS,AX
MOV SI,OFFSET NUM
MOV CX,8
MOV BX,0
MOV DL,0
COM: CMP BYTE PTR[SI],0
JGE ZHE;大于等于0跳转
INC DL ;DL记录负数的个数
CMP BYTE PTR[SI],BL;小于0的数存放在BL中
JLE FINDMIN
ZHE: CMP BYTE PTR[SI],BH;大于等于0的数存放在BH中
JGE FINDMAX
ADD DL,30H;输出负数个数的十进制数
MOV AH,9
mov COUT1,DL
MOV DX,OFFSET COUT1
INT 21H
MOV AH,9
MOV DX,OFFSET COUT2
INT 21H
MOV CX,8
COUTMAX: MOV DL,'0'
MOV AH,2
ROL BH,1
ADC DL,0
INT 21H
LOOP COUTMAX
MOV DL,'B'
MOV AH,2
INT 21H
MOV AH,9
MOV DX,OFFSET COUT3
INT 21H
MOV CX,8
COUTMIN: MOV DL,'0'
MOV AH,2
ROL BL,1
ADC DL,0
INT 21H
LOOP COUTMIN
MOV DL,'B'
MOV AH,2
INT 21H
MOV AH,4CH
INT 21H
FINDMIN: MOV BL,BYTE PTR[SI]
INC SI
LOOP COM
FINDMAX:MOV BH,BYTE PTR[SI]
INC SI
LOOP COM
CODE ENDS
END BEG