题目描述
3、有BUF数组,从文件IN.TXT输入89,91 (自己添加60个数据,可以按补码输入),请找出>0和<0 的个数并分正数,负数显示,要求显示数据5个一行,并用原码屏幕显示和输出到文件OUT.TXT
参考程序
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
BUF DB 99,-98,97,-96,95,-94,93,92,91,90
DB -89,-88,87,86,-85,-84,-83,-82,81,-80
DB -79,78,77,-76,-75,74,73,72,71,-70
DB 69,68,67,66,-65,64,-63,62,61,61
DB 59,58,57,56,55,-54,-53,52,-51,50
DB 49,-48,47,46,-45,44,-43,-42,41,40
OPN DB 'THE NUMBER OF POSITIVE NUMBER:$'
POSNNUM DB ?
OP DB 'POSITIVE NUMBER:$'
POSNUM DB 60 DUP(?)
OMN DB 'THE NUMBER OF MINUS:$'
MINUSNUM DB ?
OM DB 'MINUS:$'
MINUS DB 60 DUP(?)
CLF DB 0AH,0DH,'$'
DATA ENDS
CODE SEGMENT
START:MOV AX,DATA
MOV DS,AX
MOV BX,OFFSET BUF
MOV DI,OFFSET MINUS
MOV SI,OFFSET POSNUM
MOV CX,60
MOV AX,0
S1:MOV DL,[BX]
CMP DL,0
JE NEXT
CMP DL,128
JA MN
JB PN
JMP NEXT
PN:ADD AH,1
MOV [SI],DL
INC SI
JMP NEXT
MN:ADD AL,1
MOV [DI],DL
INC DI
NEXT:INC BX
LOOP S1
MOV BX,OFFSET MINUSNUM
MOV [BX],AL
MOV BX,OFFSET POSNNUM
MOV [BX],AH
CALL SHOWPOSNUM
LEA DX,CLF
MOV AH,09H
INT 21H
CALL SHOWMINUS
MOV AX,4C00H
INT 21H
SHOWPOSNUM:
PUSHF
PUSH AX
PUSH DX
LEA DX,OPN
MOV AH,09H
INT 21H
MOV BX,OFFSET POSNNUM
MOV DL,[BX]
MOV DH,0
CALL DISP_D_1
MOV CX,DX
LEA DX,CLF
MOV AH,09H
INT 21H
LEA DX,OP
MOV AH,09H
INT 21H
MOV BX,OFFSET POSNUM
MOV SI,0
S2:CMP SI,5
JE HUANHANG
JMP N1
HUANHANG:LEA DX,CLF
MOV AH,09H
INT 21H
MOV SI,0
N1:MOV DL,[BX]
CALL DISP_D_1
MOV DL,' '
MOV AH,02H
INT 21H
INC BX
INC SI
LOOP S2
POP DX
POP AX
POPF
RET
SHOWMINUS:
PUSHF
PUSH AX
PUSH DX
LEA DX,OMN
MOV AH,09H
INT 21H
MOV BX,OFFSET MINUSNUM
MOV DL,[BX]
MOV DH,0
CALL DISP_D_1
MOV CX,DX
LEA DX,CLF
MOV AH,09H
INT 21H
LEA DX,OM
MOV AH,09H
INT 21H
MOV BX,OFFSET MINUS
MOV SI,0
S3:CMP SI,5
JE HUANHANG2
JMP N2
HUANHANG2:LEA DX,CLF
MOV AH,09H
INT 21H
MOV SI,0
N2:MOV DL,'-'
MOV AH,02H
INT 21H
MOV AL,[BX]
NEG AL
MOV DL,AL
CALL DISP_D_1
MOV DL,' '
MOV AH,02H
INT 21H
INC BX
INC SI
LOOP S3
POP DX
POP AX
POPF
RET
DISP_D_1:
PUSHF
PUSH AX
PUSH DX
MOV AL,DL
MOV AH,0
MOV DL,10
DIV DL
MOV DL,AL
CALL DISP_HD_1
MOV DL,AH
CALL DISP_HD_1
POP DX
POP AX
POPF
RET
DISP_HD_1:
PUSHF
CMP DL,9
JA L1_1
CALL DISP_1_DEC
JMP L1_2
L1_1:
CALL DISP_1_HEX
L1_2:
POPF
RET
DISP_1_DEC:
PUSH AX
PUSH DX
PUSHF
ADD DL,30H
MOV AH,02H
INT 21H
POPF
POP DX
POP AX
RET
DISP_1_HEX:
PUSH AX
PUSH DX
PUSHF
ADD DL,37H
MOV AH,02H
INT 21H
POPF
POP DX
POP AX
RET
CODE ENDS
END START