欢迎来到Doc100.Net免费学习资源知识分享平台!
您的位置:首页 > 程序异常 >

用编译语言实现结构体的输入和保存

更新时间: 2014-01-05 03:16:46 责任编辑: Author_N1

 

用汇编语言实现结构体的输入和保存

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

上一篇:上一篇
下一篇:下一篇

 

随机推荐程序问答结果

 

 

如对文章有任何疑问请提交到问题反馈,或者您对内容不满意,请您反馈给我们DOC100.NET论坛发贴求解。
DOC100.NET资源网,机器学习分类整理更新日期::2014-01-05 03:16:46
如需转载,请注明文章出处和来源网址:http://www.doc100.net/bugs/t/20336/
本文WWW.DOC100.NET DOC100.NET版权所有。