写了个程序 感觉太长了 我想应该有简单一点的 求删减
两个整数相加的程序 谁能帮忙修剪一下 不知不觉写的太长了 感觉能简单一点 DATA SEGMENT
A1 DB 100 DUP(?)
A2 DB 100 DUP(?)
A3 DB 101 DUP(?)
A4 DB 0DH,0AH,'Are you ready?(Y/N)$'
A5 DB 0DH,0AH,'Please enter your first number:$'
A6 DB 0DH,0AH,'Please enter your second number:$'
A7 DB 0DH,0AH,'The answer is:$'
A8 DB 0DH,0AH,'Your enter number is error',0DH,'$'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
BEGIN PROC
L1: MOV DX,OFFSET A4
MOV AH,09H
INT 21H
L2: MOV AH,01H
INT 21H
MOV BL,AL
CMP BL,'Y'
JE L3
CMP BL,'y'
JE L3
CMP BL,'N'
JE L4
CMP BL,'n'
JE L4
JMP L1
L3: CALL NUM1
CALL NUM2
CALL ADD1
CALL PRINT
JMP L1
L4: MOV AH,4CH
INT 21H
BEGIN ENDP
NUM1 PROC
N11: MOV SI,00H
MOV CX,64H
N12: MOV A1[SI],00H
MOV A3[SI],00H
INC SI
LOOP N12
MOV A3[SI],00H
MOV DX,OFFSET A5
MOV AH,09H
INT 21H
MOV SI,00H
N13: MOV AH,01H
INT 21H
MOV BL,AL
CMP BL,30H
JB N14
CMP BL,39H
JA N15
JMP N16
N14: CMP BL,0DH
JE N17
N15: MOV DX,OFFSET A8
MOV AH,09H
INT 21H
JMP N11
N16: SUB BL,30H
MOV A1[SI],BL
INC SI
JMP N13
N17: DEC SI
MOV BP,SI
RET
NUM1 ENDP
NUM2 PROC
N21: MOV SI,00H
MOV CX,64H
N22: MOV A2[SI],00H
INC SI
LOOP N22
MOV DX,OFFSET A6
MOV AH,09H
INT 21H
MOV SI,00H
N23: MOV AH,01H
INT 21H
MOV BL,AL
CMP BL,30H
JB N24
CMP BL,39H
JA N25
JMP N26
N24: CMP BL,0DH
JE N27
N25: MOV DX,OFFSET A8
MOV AH,09H
INT 21H
JMP N21
N26: SUB BL,30H
MOV A2[SI],BL
INC SI
JMP N23
N27: DEC SI
MOV DX,SI
RET
NUM2 ENDP
ADD1 PROC
MOV SI,BP
MOV DI,DX
CMP SI,DI
JA AD1
MOV CX,BP
JMP AD2
AD1: MOV CX,DX
AD2: INC CX
CLC
MOV BP,00H
JMP AD3
AD8: DEC SI
DEC DI
AD3: MOV BL,A1[SI]
MOV AL,A2[DI]
ADC AL,BL
AAA
MOV A3[BP],AL
INC BP
LOOP AD8
LAHF
CMP SI,DI
JB AD5
CMP SI,DI
JE AD7
MOV CX,SI
AD4: SAHF
AD9: DEC SI
MOV AL,A1[SI]
ADC AL,00H
AAA
MOV A3[BP],AL
INC BP
LOOP AD9
LAHF
JMP AD7
AD5: MOV CX,DI
AD6: SAHF
AD11: DEC DI
MOV AL,A2[DI]
ADC AL,00H
AAA
MOV A3[BP],AL
INC BP
LOOP AD11
LAHF
AD7: SAHF
MOV AL,A3[BP]
ADC AL,00H
AAA
MOV A3[BP],AL
RET
ADD1 ENDP
PRINT PROC
MOV DX,OFFSET A7
MOV AH,09H
INT 21H
MOV CX,64H
MOV SI,64H
P1: MOV BL,A3[SI]
CMP BL,00H
JNE P2
DEC SI
LOOP P1
MOV DL,30H
MOV AH,02H
INT 21H
JMP P4
P2: MOV CX,SI
INC CX
P3: MOV AL,A3[SI]
OR AL,30H
MOV AH,02H
MOV DL,AL
INT 21H
DEC SI
LOOP P3
P4: RET
PRINT ENDP
CODE ENDS
END START