求助!求助!求助!
修改下面的代码,增加以下两个功能
求助!求助!求助!
增加以下两个功能1.能对任意数进行处理而不是仅限两位数。
2.将固定的数组改为动态的数组进行处理,提高通用性。
DATA SEGMENT
ARRAY_M DB 2,-5,34,28,10,-9,-56,20,-25,-23,-46,-8,-14,-10,81,82,-97,30,-47,-3
ARRAY_P DB 20 DUP(?)
ARRAY_N DB 20 DUP(?)
PLUS DB ?
NEGATV DB ?
MSG0 DB 'ARRAY_M:2,-5,34,28,10,-9,-56,20,-25,-23,-46,-8,-14,-10,81,82,-97,30,-47,-3',0DH,0AH,'$'
MSG1 DB 'ARRAY_P:','$'
MSG2 DB 'ARRAY_N:','$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
MAIN PROC FAR
START:
MOV AX,DATA
MOV DS,AX
LEA SI,ARRAY_M
LEA DI,ARRAY_P
LEA BX,ARRAY_N
MOV CX,20
LOP1: MOV AX,0
MOV AL,[SI]
TEST AL,80H
JZ LOP2
MOV [BX],AL
INC NEGATV
INC BX
JMP AGAIN0
LOP2: MOV [DI],AL
INC PLUS
INC DI
AGAIN0: INC SI
LOOP LOP1
MOV CL,PLUS
CMP CL,0
JE LP1
MOV AH,9
MOV DX,OFFSET MSG0
INT 21H
MOV BX,OFFSET ARRAY_P
MOV AH,9
MOV DX,OFFSET MSG1
INT 21H
AGAIN1: MOV DL,10
MOV AL,[BX]
MOV AH,0
DIV DL
CMP AL,0
JE TO1
MOV DH,AH
ADD AL,30H
MOV DL,AL
MOV AH,2
INT 21H
ADD DH,30H
MOV DL,DH
MOV AH,2
INT 21H
MOV DL,','
MOV AH,2
INT 21H
JMP TO2
TO1: ADD AH,30H
MOV DL,AH
MOV AH,2
INT 21H
MOV DL,','
MOV AH,2
INT 21H
TO2: INC BX
DEC CL
JNE AGAIN1
CALL ENTER
LP1: MOV CL,NEGATV
CMP CL,0
JE LP2
MOV BX,OFFSET ARRAY_N
MOV AH,9
MOV DX,OFFSET MSG2
INT 21H
AGAIN2: MOV DL,'-'
MOV AH,2
INT 21H
MOV DL,10
MOV AL,[BX]
MOV AH,0FFH
NOT AX
ADD AX,1
DIV DL
CMP AL,0
JE TO3
MOV DH,AH
ADD AL,30H
MOV DL,AL
MOV AH,2
INT 21H
ADD DH,30H
MOV DL,DH
MOV AH,2
INT 21H
MOV DL,','
MOV AH,2
INT 21H
JMP TO4
TO3: ADD AH,30H
MOV DL,AH
MOV AH,2
INT 21H
MOV DL,','
MOV AH,2
INT 21H
TO4: INC BX
DEC CL
JNE AGAIN2
LP2: MOV AH,4CH
INT 21H
ENTER PROC NEAR
MOV DL,13
MOV AH,2
INT 21H
MOV DL,10
MOV AH,2
INT 21H
RET
ENTER ENDP
MAIN ENDP
CODE ENDS
END START