输入输出数据是汇编的关于数据运算的基础,写好模板会很方便
DATA SEGMENT
MES2 DB 'Input:',0AH,0DH,'$'MES1 DB 0AH,0DH,'Output:',0AH,0DH,'$'
XXX DB 6,?,6 DUP('$')
C10 DW 10
B10 DB 10
X DW ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MES2
MOV AH,9
INT 21H
INPUT: LEA DX,XXX
MOV AH,0AH
INT 21H
MOV CL,XXX+1
MOV CH,0
LEA BX,XXX+2
MOV AX,0
FIRST: MUL B10
MOV DL,[BX]
SUB DX,30H
ADD AX,DX
INC BX
LOOP FIRST
MOV X,AX
LEA DX,MES1
MOV AH,9
INT 21H
MOV AX,X
MOV CX,0
ONE:
MOV DX,0
DIV C10
PUSH DX
INC CX
CMP AX,0
JE OUTPUT
JMP ONE
OUTPUT: POP DX
ADD DL,30H
MOV AH,2
INT 21H
LOOP OUTPUT
MOV AX,4C00H
INT 21H
CODE ENDS
END START