统计DA_WORD数据区中正数、0、负数的个数,数据定义如下:
DA_WORD DW -1,3,5,0,-5,-7,4,0,-8……
COUNT EQU $-DA_WORD
NUM DB 0 ;存放正数的个数
DB 0 ;存放0的个数
DB 0 ;存放负数的个数
DATAS SEGMENT
ORG 1000H
DA_WORD DW 0FFFFH,3,5,0,0FFFBH,0FFF9H,4,0,0FFF8H
DOUNT EQU $-DA_WORD
ORG 1020H
NUM DB 0 ;存放正数的个数
ZE DB 0 ;存放0的个数
PLUS DB 0
DATAS ENDS
STACKS SEGMENT
DW 100 DUP(0)
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
MOV AX,DOUNT
MOV CL,1
SHR AX,CL
MOV CX,AX
MOV SI,OFFSET DA_WORD
AG:MOV AX,[SI]
CMP AX,0
JNZ NOZ
INC [ZE]
JMP NEXT
NOZ:TEST AX,8000H
JNZ ISPLUS
INC [NUM]
JMP NEXT
ISPLUS:
INC [PLUS]
NEXT:
ADD SI,2
LOOP AG
INT 3
MOV AH,4CH
INT 21H
CODES ENDS
END START