DATAS SEGMENT;此处输入数据段代码 MARRAY DW 1,2,3,4,5,-6,-7,-8,-9,-10,-11,12,13,14,-15,-16,-17,18,'$' PARRAY DW 10 DUP(?) NARRAY DW 10 DUP(?) Z DB 10 DATAS ENDS STACKS SEGMENT ;此处输入堆栈段代码 DW 100 DUP(?) STACKS ENDS CODES SEGMENT ASSUME CS:CODES,DS:DATAS,SS:STACKS START: MOV AX,DATAS MOV DS,AX ;此处输入代码段代码 MOV DI,0 ;统计正数个数 MOV SI,0 ;统计负数个数 LEA BX,MARRAY MOV DX,[BX] MOV AX,0 MOV CX,0 BIJIAO: CMP DX,0 JG PARRAY1 ;大于跳转 JL NARRAY1 ;小于跳转 PARRAY1: MOV AX,[BX] MOV PARRAY[BX],AX INC DI ADD BX,2 MOV DX,[BX] CMP DX,24H ;与结束符$比较,看是否结束 JNZ BIJIAO ;不相等跳转到比较处 JZ SHUCHU ;相等时跳到输出位置 NARRAY1: MOV AX,[BX] MOV NARRAY[BX],AX INC SI ADD BX,2 MOV DX,[BX] CMP DX,24H ;与结束符$比较,看是否结束 JNZ BIJIAO ;不相等跳转到比较处 JZ SHUCHU ;相等时跳到输出位置 SHUCHU :MOV AX,0 ;输出正数的个数 MOV AX,DI DIV Z PUSH AX CMP AL,0 JZ AA ADD AL,30H MOV DL,AL MOV AH,02H INT 21H AA:POP AX MOV AL,0 ADD AH,30H MOV DL,AH MOV AH,02H INT 21H MOV AX,0 ;输出空格 ADD AL,20H MOV DL,AL MOV AH,02H INT 21H MOV AX,0 ;输出负数的个数 MOV AX,SI DIV Z PUSH AX CMP AL,0 JZ BB ADD AL,30H MOV DL,AL MOV AH,02H INT 21H BB:POP AX MOV AL,0 ADD AH,30H MOV DL,AH MOV AH,02H INT 21H MOV AH,4CH INT 21H CODES ENDS END START