A student achievement management system prepared by sinks

Source: Internet
Author: User
Tags error handling mul readfile

The student achievement management which compiles with the remit, is more satisfactory to the individual, now for everybody to share the reference, if has any question to want the message to propose

Functions: 1. Create a score document

2. Calculate total and average points

3. Show Results Report

Principle Analysis

The idea is simply that the keyboard inputs the student's relevant data (study number, subject score), then calculates the average and total score of each student, then records them in the linked list, generates the corresponding text, and then reads the corresponding data from the text and displays it.


SOURCE program

The program starts running:

Input data:

Create file successfully

File contents after writing to file

Read the content

Huanhang macro; newline carriage return mov ah,2 mov dl,10 int 21h mov ah,2 mov dl,13 int 21h endm;------------ -----------------------------------------------------------DATAS SEGMENT buff2 db (' $ '), buffer 2 for storing files read from file
。
Englishgrade DW (0); used to record English.
Arrage DW (' $ '), used to record the average score. Sum DW (' $ '); Used to record the total score Studycode DW (' $ '); used to record number Mathgrade DW (0);
    Record math scores.
    Buff DB, DUP (' $ '), buffer 1, for writing to file.
    Buffcode db (0); The following is the corresponding linked list, mainly for the file layout to use.
    
    Buffenglish db (0) Buffmath db DUP (0) Buffarrage db (0) buffsum db DUP (0)
                                    INPUT1 DW 0; Intermediate amount used for various inputs y DW 10; for Div 10 The following is the menu Z1 db "*--------------------------------------------------------*$" Z2 db "* 1.In                 Put the data about students. *$ "Z3 db * 2.create a new file to store the data.                  *$ "Z4 DB" * 3.write the data into the file.                   *$ "Z5 DB" * 4.read the data from the file.        *$ "Z6 DB" * 5.output the data you read from the file.                                           *$ "Z7 db" *--------------------------------------------------------*$ "Z8 db" * 6.exit
    *$ "; The following are various success, error statements. H12 db "The data is successful read!$" H11 db "the data are successful writed!$" H10 db "The file is successful CRE ated!$ "H9 db" Please input your choose:$ "H8 db" code 中文版 Math sum arrage$ "H7 db" error!! Your file can ' t open!$ "h6 db" error!! Can ' t make the new file!! $ "H5 db" Please input the students ' math grade:$ "h4 db" Please input the How many students:$ "H3 db" plea SE input the students ' 中文版 grade:$ "H2 db" your input is error!$ "H1 db" please inputThe students ' codes:$ '; flag bit, because the score is likely to be 3 bit also may be 2 bit, so write file need to determine how many bits to write Aflag DW 0 bflag DW 0
    ; intermediate variable, used to record "array subscript". A DW 0 B DW 0 d DW 0 e DW 0 F DW 0 g DW 0 h DW 0 I DW 0 J DW 0 K DW 0 Shuliang DW 0 K1 db ' abc.txt ', 00h handle DW 0 handle2 DW 0 DATAS ENDS STACKS SEGMENT Stack s D
    W-DUP (0) STACKS ENDS CODES SEGMENT assume Cs:codes,ds:datas,ss:stacks main proc far; Main program.
    Push DS XOR Ax,ax push AX mov ax,datas mov ds,ax n0:huanhang huanhang huanhang Huanhang
    
    Huanhang call menu Huanhang mov ah,09h lea dx,h9 int 21h mov ah,01h int 21h CMP al,36h JG kerror CMP al,30h JB kerror cmp al,31h JE N1 cmp al,32h JE N2 cmp al, 33h JE N3 cmp al,34h JE N4 cmp al,35h JE N5 cmp al,36h JE exit N1:huanhang call Input jmp N0 N2:huanhang mov ah,09h lea dx,h10 int 21h call NewFile jmp N0 Huanhan G N3:huanhang mov ah,09h lea dx,h11 int 21h call WriteFile Huanhang jmp N0 N4:hu  
    Anhang mov ah,09h lea Dx,h12 int 21h call ReadFile huanhang jmp N0 N5:huanhang Call output jmp N0 kerror:call error1 exit:ret main ENDP;--------------------------------------
    ---------------------------------input proc near uses AX bx CX dx si di; Call Inputshuliang mov cx,shuliang bl1:call inputstudycode call Inputenglishgrade call INPUTMATHG Rade Call Inputbuff Huanhang call getsum call Getarrage mov di,h mov buff[di],0dh inc h MO V DI,H mov buff[di],0ah inc h mov di,h loop bL1 bexit:ret input ENDP;-------------- ---------------------------------------------------------INputstudycode proc near uses ax bx CX dx si di; input study number In__1:mov ah,09h Lea dx,h1 int 21h mov cx,4 mov  Si,a mov di,b in_1:mov ah,01h int 21h cmp al,0dh JE P1 cmp al,0ah JE P1 xor Ah,ah; This small piece is to press the number into the corresponding linked list.
 Easy next Operation mov Buffcode[di],al Inc b mov di,b p1:cmp ax,30h; multiplied by 10 input method. JB Aerror CMP ax,39h JG aerror Sub ax,30h mov bx,ax mov ax,input1 mul y mov input1,ax add input1,bx loop i n_1 Huanhang mov dx,input1 mov studycode[si],dx xor BX,BX mov input1,bx jmp aexit Aerro R:call error1 jmp in__1 Aexit:mov di,b; bit of typesetting nice, here pressed into a space mov al, ' mov buffcode[di
 
],al Inc b ret inputstudycode ENDP;----------------------------------------------------------------------- Inputenglishgrade proc near uses ax bx CX dx si di; input English score In__2:mov ah,09h Lea Dx,h3 int 21h m
  OV Si,a   MOV cx,3 mov di,d in_2:mov ah,01h int 21h cmp al,0dh JE aL1 xor Ah,ah; will be the result (mention here, because here is directly a code, the following write will not add 30h), press into the corresponding list mov buffenglish[di],al Inc d mov di,d Inc Aflag; record the number of digits, 2 or 3 Bit p2:cmp ax,0dh JE aL1 cmp ax,30h JB berror CMP ax,39h JG berror Sub ax,30h mov bx,ax mov ax,input 
     1 mul y mov input1,ax add input1,bx loop in_2 Al1:huanhang mov dx,input1 mov englishgrade[si],dx XOR BX,BX mov input1,bx jmp bexit berror:call error2 jmp in__2 bexit:ret Inputengli Shgrade ENDP;-----------------------------------------------------------------------inputmathgrade proc near uses a
     X bx cx dx si di; input math scores, almost as input English scores In__4:mov ah,09h lea Dx,h5 int 21h mov si,a mov cx,3 mov di,e in_4:mov ah,01h int 21h cmp al,0dh JE cL1 xor Ah,ah mov buffmath[di ],al Inc e MOV di,e inC bflag CMP ax,30h JB cerror CMP ax,39h JG cerror Sub ax,30h mov bx,ax mov ax,input1 mul y mov input1,ax ad D INPUT1,BX Loop in_4 Cl1:huanhang mov dx,input1 mov mathgrade[si],dx xor BX,BX mov input 1,BX jmp cexit cerror:call error2 jmp in__4 cexit:ret inputmathgrade ENDP;-------- ---------------------------------------------------------------Inputshuliang proc near uses ax di CX; Enter student number mov a
      h,09h Lea Dx,h4 int 21h mov cx,6 in_3:mov ah,01h; simple multiply 10 input.  int 21h xor Ah,ah cmp ax,0dh JE in_out cmp ax,30h JB in_out CMP ax,39h JG in_out Sub ax,30h mov Bx,ax mov ax,shuliang mul y mov shuliang,ax add shuliang,bx loop in_3 in_out:huanhang ret Inputshuli Ang ENDP;-----------------------------------------------------------------------error1 proc near uses ax bx CX dx si
   DI; Enter error handling.
  Huanhang mov ah,09h Lea DX,H2 int 21h xor CX,CX mov input1,cx huanhang ret error1 ENDP;---------------------------------------------- -------------------------, enter error handling.
It would have been a little different, and it would have been the same, but to avoid a large-scale change in the code, it was saved.  
   ERROR2 proc near uses ax bx CX dx si di huanhang mov ah,09h lea dx,h2 int 21h xor CX,CX mov input1,cx Huanhang ret Error2 ENDP;-----------------------------------------------------------------------getsum proc NE AR uses ax bx cx dx si di; Sub program for Total score mov si,a XOR CX,CX mov di,h mov ax,englishgrade[si] mov bx,mathgrad
   E[SI] Add AX,BX mov sum[si],ax L8: Here, with the exception of the 10 method, the total score is pressed into the buffer xor dx,dx Div y push DX INC CX CMP ax, 0 je L9 jmp L8 l9:pop dx add dl,30h mov buff[di],dl inc h mov di,h Loop L 9 mov di,h mov al, ' mov buff[di],al inc h ret getsum ENDP;--------------------------------- --------------------------------------getarrage proc near uses AX BXCX dx Si di; averaging score, and the basic consistency of the total score mov si,a XOR CX,CX mov di,h xor DX,DX mov ax,sum[si] mov bx,2 div BX mov arrage[si],ax add a,2 l10:xor dx,dx Div y Push DX inc cx 0 JE L11 jmp L1
    0 L11:pop DX Add dl,30h mov buff[di],dl inc h MOV di,h Loop L11 mov di,h mov al, ' MOV buff[di],al Inc h ret getarrage ENDP;--------------------------------------------------------------
---------, create a new document, which should have been created on the C-drive, but under WIN7 (or under the virtual machine), resulting in the creation, and finally can only be created in the root directory of MASM. NewFile proc near uses ax bx CX dx si di mov ah,3ch mov cx,00 lea dx,k1 int 21h JC Eerror mov Hand Le,ax jmp e5 eerror:mov ah,09h Lea Dx,h6 int 21h e5:ret newfile ENDP;-------------------
----------------------------------------------------, write a document, here made a very serious mistake, that is, finally forgot to turn off the file, resulting in the contents of the following document can not be read, bitter for a whole afternoon to find. WriteFile proc near uses ax bx CX dx si di mov ah,40h mov bx,handle moV cx,h Lea Dx,buff int 21h JC Derror jmp e6 derror:mov ah,09h Lea Dx,h6 int 2 1h e6:mov Ah,3eh int 21h ret WriteFile ENDP;----------------------------------------------------------------
-------, the integration of data, the various types of data according to the "school number English scores of mathematics scores average score" in the order of typesetting, one student.
    Inputbuff proc near uses ax bx CX dx si di mov si,h mov cx,5 s1:mov di,i mov Al,buffcode[di] MOV Buff[si],al Inc I inc h MOV si,h mov di,i Loop S1 Inc Aflag; Here's the logo for the previous article, because you need to add
    Space, so it's going to be +1. MOV cx,aflag mov di,d mov al, ' mov buffenglish[di],al inc d S2:mov di,j mov si,h mov
    AL,BUFFENGLISH[DI] mov Buff[si],al Inc h Inc J MOV si,h mov di,j Loop S2 Inc bflag MOV cx,bflag mov di,e mov al, ' mov buffmath[di],al inc e S3:mov di,k mov si,h mov al , Buffmath[di] mov Buff[si],al Inc h Inc k MOV si,h MOV Di,k Loop S3 xor Ax,ax mov aflag,ax mov bflag,ax ret inputbuff ENDP;------------------------
-----------------------------------------------; Read the file. ReadFile proc near uses ax bx CX dx si di mov ah,3dh mov al,00 lea dx,k1 int 21h JC Gerror mov h 
    Andle2,ax J1:mov AH,3FH mov bx,handle2 mov cx,512 lea dx,buff2 int 21h JC Gerror CMP ax,0 Je e13 jmp e13 gerror:call error5 e13:ret readfile ENDP;----------------------------------------- --------------------------------ERROR5 proc near uses ax bx CX dx si di; read the wrong Sub-program mov ah,09h Lea Dx,h7 int 21 h ret error5 ENDP;-------------------------------------------------------------------------output proc near use
    s ax bx cx dx si di; output read to content mov ah,09h lea dx,h8 int 21h Huanhang xor si,si O1:mov ah,02h
MOV Dl,buff2[si] CMP dl, ' $ ' JE e14 int 21h inc si jmp O1 E14:    RET output ENDP;-------------------------------------------------------------------------menu proc near uses ax
    BX CX dx si di; menu bar. MOV ah,09h lea dx,z1 int 21h Huanhang mov ah,09h lea dx,z2 int 21h Huanhang mov ah,09h Lea dx,z3 int 21h Huanhang mov ah,09h lea dx,z4 int 21h Huanhang mov
    ah,09h Lea Dx,z5 int 21h Huanhang mov ah,09h lea dx,z6 int 21h Huanhang mov ah,09h Lea Dx,z8 int 21h Huanhang mov ah,09h lea dx,z7 int 21h ret menu ENDP CODES ENDS END Main


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.