COUNT EQU 1
ALL_INPUT MACRO STRING,NUM,FUNCTION
MOV DX,OFFSET STRING
MOV AH,9H
INT 21H
MOV DI,OFFSET INFO.&NUM
MOV AX,SIZE INFO.&NUM
CALL FUNCTION
ENDM
SCORE STRUC
NO DW ?
NAMES DB 8 DUP(?)
CSCORE DB 0
MSCORE DB 0
ESCORE DB 0
SCORE ENDS
DSEG SEGMENT
INFO SCORE <12,'wang',12,23,21>
S_NO DB 0DH,0AH,"student no : ",'$'
S_NAME DB 0DH,0AH,"student name : ",'$'
S_CSCORE DB 0DH,0AH,"Chiness score : ",'$'
S_MSCORE DB 0DH,0AH,"Math score : ",'$'
S_ESCORE DB 0DH,0AH,"English score : ",'$'
FILE_NAME DB 'DATA.DAT',0
OPEN_ERR DB 0DH,0AH,"OPEN FILE ERROR !",'$'
BUFFER DB 10 DUP(?)
DSEG ENDS
SSEG SEGMENT PARA STACK
DB 256 DUP(?)
SSEG ENDS
CSEG SEGMENT
ASSUME DS:DSEG,CS:CSEG,SS:SSEG,ES:DSEG
START : MOV AX,DSEG
MOV DS,AX
MOV ES,AX
MOV DX,OFFSET FILE_NAME
MOV AL,02H
MOV AH,3DH
INT 21H
JC _ERROR
MOV BX,AX
MOV CX,COUNT
_INPUT : NOP
ALL_INPUT S_NO,NO,ASSIC_INPUT
ALL_INPUT S_NAME,NAMES,ASSIC_INPUT
ALL_INPUT S_CSCORE,CSCORE,NUMBER_INPUT
ALL_INPUT S_MSCORE,MSCORE,NUMBER_INPUT
ALL_INPUT S_ESCORE,ESCORE,NUMBER_INPUT
MOV DX,OFFSET INFO
CALL SAVA
LOOP _INPUT
JMP ENDPROC
_ERROR : MOV DX,OFFSET OPEN_ERR
MOV AH,9H
INT 21H
JMP ENDPROC
SAVA PROC
PUSH CX
MOV CX,SIZE INFO
MOV AH,40H
INT 21H
POP CX
RET
SAVA ENDP
ASSIC_INPUT PROC ;ADDRESS IN DI,INPUT NUM IN AX
PUSH AX
PUSH CX
PUSH SI
MOV SI,OFFSET BUFFER
MOV CX,AX
INPUT_STR: MOV AH,1H
INT 21H
CMP AL,0DH
JZ TRANST_STR
MOV [SI],AL
INC SI
JMP INPUT_STR
TRANST_STR: MOV SI,OFFSET BUFFER
REP MOVSB
POP SI
POP CX
POP AX
RET
ASSIC_INPUT ENDP
NUMBER_INPUT PROC ;ADDRESS IN DI,INPUT NUM IN AX
PUSH AX
PUSH CX
PUSH SI
MOV SI,OFFSET BUFFER
MOV CX,AX
INPUT_NUM: MOV AH,1H
INT 21H
CMP AL,0DH
JZ TRANST_NUM
SUB AL,30
ADD [SI],AL
JNC NCARRED
CARRED: INC SI ;IF CARRED
XOR AL,AL
INC AL
MOV [SI],AL
NCARRED: JMP INPUT_NUM
TRANST_NUM: MOV SI,OFFSET BUFFER
REP MOVSB
POP SI
POP CX
POP AX
RET
NUMBER_INPUT ENDP
ENDPROC : MOV AH,3EH
INT 21H
MOV AH,4CH
INT 21H
CSEG ENDS
END START