STACK1 SEGMENT STACK
DW 256 DUP(?)
STACK1 ENDS
DDATA SEGMENT
NUMB DB 12H,88H,82H,89H,33H,90H,01H,10H,0BDH,01H
MES1 DB 'The number of negative is:$'
DDATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DDATA
START: MOV AX,DDATA
MOV DS,AX
MOV DI,OFFSET NUMB
XOR BH,BH
MOV CX,10D
A1: MOV AL,[DI]
TEST AL,80H
JE A2
INC BL
A2: INC DI
LOOP A1
MOV DX,OFFSET MES1 ;show mes
MOV AH,09H
INT 21H
MOV AL,BL ;show the number of negative
AND AL,0F0H ;get the highest 4 bits
SHR AL,4
CMP AL,0AH
JB C2
ADD AL,07H
C2: ADD AL,30H
MOV DL,AL ;show character
MOV AH,02H
INT 21H
MOV AL,BL
AND AL,0FH ;get the lowest 4 bits
CMP AL,0AH
JB C3
ADD AL,07H
C3: ADD AL,30H
MOV DL,AL ;show character
MOV AH,02H
INT 21H
MOV AX,4C00H ;go back to dos
INT 21H
CODE ENDS
END START
汇编语言 统计负数个数(二)
最新推荐文章于 2022-11-10 16:38:59 发布