⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c.asm

📁 学生成绩管理系统用汇编编写的 包括对成绩的插入
💻 ASM
📖 第 1 页 / 共 2 页
字号:
;为使本程序很顺利运行,在运行本程序之前,请确保您的F盘目录下有符合要求的文件'st.txt',如果没有请新建一个
;学生成绩管理系统(XP环境下完成设计与调试)
;--------------------------------------------------------------------------
data    segment
mess1    db '          student grade management system',0ah,0dh,'$'
mess2    db '   this is main menu',0ah,0dh,'$'
mess3    db '    insert  (i)         please input:',0ah,0dh,'$' 
mess4    db '    modify  (m)         name    :',0ah,0dh,'$'
mess5    db '    delete  (d)         number  :',0ah,0dh,'$'
mess6    db '    query   (q)         english :',0ah,0dh,'$'
mess7    db '    count   (c)         computer:',0ah,0dh,'$'
mess8    db '    print   (p)         chinese :',0ah,0dh,'$'
mess9    db '    exit    (e)',0ah,0dh,'$'
mess10   db '**********************************************************$'
mess11   db 'name             Num   Eng    Com    Chi',0ah,0dh,'$'
mess13   db '    list    (l)',0ah,0dh,'$'
mess14   db '1.english  2.computer 3.chinese.',0ah,0dh,'$' 
mess15   db 'Please collect :','$' 
mess01   db 'The number of 0-60  :','$'
mess02   db 'The number of 60-80 :','$'
mess03   db 'The number of 80-100:','$'
err1     db ' there is not this student$'
err2     db ' file close wrong$'
err3     db 'Input wrong.',0ah,0dh,'$' 
cf       db 13,10,'$'
stutab   db  50 dup(42 dup(20h))
sav      db  42 dup(20h),13,10,'$'
nasav    db  21 dup(20h)
be60     db  0
be80     db  0
be100    db  0
endaddr  dw  ?
swapped  db  0
handle   dw  ?
savdi    dw  ?
names         label         byte
max1           db           16
act1           db            ?
nam            db           16 dup(?)

number       label        byte      
max2           db           3
act2           db           ?
num            db           3  dup(?)

english      label        byte      
max3           db           4
act3           db           ?
eng            db           4  dup(?)

computer     label        byte      
max4           db           4
act4           db           ?
com            db           4  dup(?)

chinese      label        byte      
max5           db           4
act5           db           ?
chi            db           4  dup(?)

RecordCount    db       0
RecordCount1   db       0
fname          db 'f:\st.txt',00h
retemp 	db 	?
counts	       dw 	0
buffer1        db 42  dup(20h)
buffer2        db 1ah
data    ends
;--------------------------------------------------------------------------
;功    能:输出字符串
;入口参数:addrs
;出口参数:
;说  明:
show macro addrs
        lea dx,addrs
        mov ah,9
        int 21h
        endm
;--------------------------------------------------------------------------
;功    能:从键盘输入字符串
;入口参数:
;出口参数:
;说  明:
input   macro  addrs
        lea    dx,addrs
        mov    ah,0ah
        int    21h
        endm
;--------------------------------------------------------------------------
;功    能:置光标位置在0页,a行,36列
;入口参数:
;出口参数:
;说  明:
set_p1 macro  a
        mov ah,2
        mov dh,a
        mov dl,36
        mov bh,0
        int 10h
        endm

;功    能:置光标位置在0页,12行,2列
;入口参数:
;出口参数:
;说  明:
set_p2 macro
       mov ah,2
       mov dh,12
       mov dl,2
       mov bh,0
       int 10h
       endm
;--------------------------------------------------------------------------
;功    能:置光标位置在0页,1行,30列
;入口参数:
;出口参数:
;说  明:
set_p3 macro
       mov ah,2
       mov dh,1
       mov dl,30
       mov bh,0
       int 10h
       endm

;功    能:屏幕初始化
;入口参数:
;出口参数:
;说  明:
clear  macro 
       mov al,0
       mov cl,0
       mov ch,0
       mov dh,24
       mov dl,79
       mov bh,7
       mov ah,6
       int 10h
       endm
;--------------------------------------------------------------------------
;功    能:屏幕初始化
;入口参数:
;出口参数:
;说  明:
clear1 macro
       mov al,0
       mov bh,7
       mov ch,4
       mov cl,36
       mov dh,10
       mov dl,79
       mov ah,6
       int 10h
       endm
;--------------------------------------------------------------------------
;功    能:屏幕初始化
;入口参数:ah=6
;出口参数:
;说  明:在调用这个宏之前,都先调用宏clear1
clear2 macro
       mov al,0
       mov bh,7
       mov ch,12
       mov cl,0
       mov dh,24
       mov dl,79
       int 10h
       endm
;--------------------------------------------------------------------------
;功    能:换行
;入口参数:
;出口参数:
;说  明:
newline macro
        push ax
        push dx
        mov dl,0dh
        mov ah,2
        int 21h
        mov dl,0ah
        mov ah,2
        int 21h
        pop dx
        pop ax
        endm
;--------------------------------------------------------------------------
;主函数
code    segment
     assume  cs:code,ds:data,es:data
main proc far
      push      ds
      sub       ax,ax
      push      ax
      mov       ax,data
      mov       ds,ax
      mov       es,ax
      cld
      mov ah,0
      mov al,3
      int 10h
      clear
      lea  di,stutab
      show mess1
      show mess2
      show mess13
      show mess3
      show mess4
      show mess5
      show mess6
      show mess7
      show mess8
      show mess9
      newline
      show mess10
      call read

w:    set_p3
      clear1
      xor ax,ax
      mov ah,1
      int 21h
      cmp al,'i'
      jnz n1            
      call insert
      jmp  w
n1:   cmp al,'m'
      jnz  n2
      call modify
      jmp  w
n2:   cmp al,'d'
      jnz  n3
      call delete
      jmp  w
n3:   cmp al,'q'
      jnz  n4
      push di
      call query
      pop  di
      jmp  w
n4:   cmp  al,'c'
      jnz  n5
      clear1
      clear2 
      call cot
      call cprint
      jmp  w
n5:   cmp  al,'p'
      jnz  n6
      push di
      call print
      pop  di
      jmp  w
n6:   cmp  al,'l'
      jnz  n7
      call read
      call list
      jmp  w
n7:   cmp  al,'e'
      jz   exitf
      jmp  w
exitf:
       clear
       call write
       mov ax,4c00h
       int 21h
main   endp
;--------------------------------------------------------------------------
;功    能:插入一项新的记录
;入口参数:
;出口参数:
;说  明:
insert proc near
       push ax
       push bx
       push cx
       push dx
       xor  ax,ax
       set_p1 4
       input   names 
       set_p1 5
       input   number
       set_p1 6
       input   english
       set_p1 7
       input   computer
       set_p1 8
       input   chinese
       call    store
       push    di
       call    sort
       pop     di
       pop dx
       pop cx
       pop bx
       pop ax
       ret
insert endp
;--------------------------------------------------------------------------
;功    能:存储记录
;入口参数:RecordCount1
;出口参数:RecordCount1(=RecordCount1+1)
;说  明:
store  proc near
       lea       di,stutab
       mov       al,42
       mul       RecordCount1
       add       di,ax
       mov       bl,RecordCount1
       mov       RecordCount,bl
       inc       RecordCount
       inc       RecordCount1  
       cld
       mov       ch,0
       lea       si,nam
       mov       cl,names+1
       mov       bx,di
       rep       movsb
       add       bx,19
       mov       di,bx
       lea       si,num
       mov       cl,number+1
       cmp       cx,2
       jz        s1
       inc       di
s1:    rep       movsb
       add       bx,6
       mov       di,bx
       lea       si,eng
       mov       cl,english+1
       cmp       cx,3
       jz        s2
       inc       di
       cmp       cx,2
       jz        s2
       inc       di
s2:    rep       movsb
       add       bx,7
       mov       di,bx
       lea       si,com
       mov       cl,computer+1
       cmp       cx,3
       jz        s3
       inc       di
       cmp       cx,2
       jz        s3
       inc       di
s3:    rep       movsb
       add       bx,7
       mov       di,bx
       lea       si,chi
       mov       cl,chinese+1
       cmp       cx,3
       jz        s4
       inc       di
       cmp       cx,2
       jz        s4
       inc       di
       cmp       cx,1
       jz        s4
       inc       di
s4:    rep       movsb
       ret  
store  endp
;--------------------------------------------------------------------------
;功    能:复制字符串
;入口参数:(bx)(=stutab对应的项)
;出口参数:swapped(=1),sav与stutab对应的项互换
;说  明:供记录修改函数modify调用
change    proc      near
         mov      cx,42
         lea      di,sav
         mov      si,bx
         rep      movsb

         mov      cx,42
         mov      di,bx
         rep      movsb

         mov      cx,42
         lea      si,sav
         rep      movsb
         mov      swapped,1 
         ret
change   endp
;--------------------------------------------------------------------------
;功    能:对已有记录进行排序
;入口参数:
;出口参数:
;说  明:
sort      proc         near
        cmp       RecordCount,2
        jb        s40
        sub       di,84
        mov       endaddr,di        

s10:
        mov       swapped,0
        lea       si,stutab
s20:
        mov       cx,42
        mov       di,si
        add       di,42
        mov       ax,di
        mov       bx,si
        repe      cmpsb
        jbe       s30
        call      change
s30:
        mov       si,ax
        cmp       si,endaddr
        jbe       s20
        cmp       swapped,0
        jnz       s10
s40:    ret
sort    endp
;--------------------------------------------------------------------------
;功    能:修改指定记录项
;入口参数:
;出口参数:
;说  明:
modify proc near
       call     query

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -