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

📄 1.asm

📁 大型汇编程序管理系统
💻 ASM
📖 第 1 页 / 共 3 页
字号:

;学生成绩管理系统 written by Jerry liu
student struc
sname db 6 dup(' ')
sno db 8 dup(' ')
sco db 3 dup(' ')
student ends

stsg segment stack 's'
     dw 32 dup(?)
stsg ends
         
anykey macro
 ;push ax
 mov ah,7
 int 21h
 ;pop ax
 endm
 
anykeyback macro
 anykey
 showmsg back
 endm
 
;回车换行
crlfm      macro
 push ax
 push dx
   mov     ah,9
   lea     dx,crlf
   int     21h
   pop dx
   pop ax
           endm 

exchange macro i,j
;交换studentx中相邻表项的内容:i->前项,j->后项
;注意cmpsb过程中si,di指针的自动变化!
  push cx
  push si
  push di

        mov cx,17;t=[i],即t=前项
        mov si,i
        lea di,stutemp
        rep movsb
        
        mov cx,17;i=j,si->后项,即前项=后项
        mov di,i ;
        rep movsb
        
        mov cx,17;j=t,di->后项,即后项=t
        lea si,stutemp
        rep movsb
        mov swapped,1
        
        pop di
        pop si
        pop cx
 endm
 
space macro
;输出空格符
 push dx
 push ax
 lea dx,gap
    mov ah,9
    int 21h
    pop ax
    pop dx
 endm 

;显示提示信息
showmsg   macro   n
  push ax
  push dx
          mov      ah,9
          lea      dx,msg&n
          int      21h
         pop dx
          pop ax
          endm

movitem macro dst,src
;movitem(int dst,int src)
 push cx
 push di
 push si
 
 cld
 mov cx,17
 lea di,[dst]
 lea si,[src]
 rep movsb
 
 pop si
 pop di
 pop cx
 endm          
 
data segment
studentx student 30 dup(<>)
stutemp    db         17 dup (0),'$';临时保存一条item信息
studisp    db  19 dup(0),'$'
;---------定义名字 学号 分数的输入缓冲区---------------------------------------------------------
    namepar   LABEL      BYTE;输入缓冲区
    maxnlen   db         7
    namelen   db         ?
    namefld   db         7 dup(?)
    numpar    label      byte
    maxmlen   db         9
    numlen    db         ?
    numfld    db         9 dup(?)
    scopar   label  byte
    maxsco    db         4
    scolen    db         ?
    scofld    db         4 dup(?)
;输入文件路径缓冲区    
 pathpar   label      byte
    pathmax   db         40
    pathlen   db         ?
    pathnam   db         40 dup(?)
;修改项目用输入缓冲区   
 ;nname label byte 
    ;maxnnlen   db         7
    ;nnamelen   db         ?
    ;nnamefld   db         7 dup(?)
    ;nnum label byte
    ;nnumpar    label      byte
    ;maxnmlen   db         9
    ;nnumlen    db         ?
    ;nnumfld    db         9 dup(?)
    ;nsco label byte
    ;maxnsco    db         4
    ;nscolen    db         ?
    ;nscofld    db         4 dup(?) 
;modify所用类型标志    
   ;name equ 1
   ;num equ 2
   ;score equ 3
   
 ae90 db 0
 ae80 db 0
 ae70 db 0
 ae60 db 0
 b60 db 0
   
   msg_b60      db         9,9,'Scores<60:$'
   msg_ae60      db         9,9,'Scores>=60:$'
   msg_ae70      db         9,9,'Scores>=70:$'
   msg_ae80      db         9,9,'Scores>=80:$'

	
   msg_ae90      db         9,9,'Scores>=90:$'   
   
   cur_i dw ?
   
crlf       db         13,10,'$'
      
titl db '         Students Database System',0DH,0AH,'                                                      ',0DH,0AH,0DH,0AH
;其中“I”表示插入,“L”表示浏览,“Q”表示查询,“E”表示退出,
;“D”表示删除,“M”表示修改,“c”表示统计各分数段人数,“p”表示打印.
menu1 db '  I:Insert',0DH,0AH       ;menu
menu2 db '  L:Browse',0DH,0AH           
menu3 db '  Q:Query',0DH,0AH
menu4 db '  D:Delete',0DH,0AH
menu5 db '  M:Modify',0DH,0AH
menu7 db '  P:Print',0DH,0AH
menu8 db '  C:Statistics',0DH,0AH
menu9 db '  E:Exit',0DH,0AH,'$'

msgmenu5_1 db 0DH,0AH,'1-----Modify name',0DH,0AH
msgmenu5_2 db '2-----Modify number',0DH,0AH
msgmenu5_3 db '3-----Modify score',0DH,0AH,'$'

msgmenu3_1 db 0DH,0AH,'1-----Search name',0DH,0AH
msgmenu3_2 db '2-----Search number',0DH,0AH
msgmenu3_3 db '3-----Search score',0DH,0AH,'$'

mmenutip db '  choose a number from the menu above',0DH,0AH,'$'  

msgprinttitle db 0DH,0AH,0DH,0AH,' sno    sname          score  ',0DH,0AH,'$'
gap  db '  $'

stu       dw         ?
;curstu    dw         ?
stustored dw         0;已写至内存中的item数
swapped   db         0
sav_cnt   dw         ?
stusaved   dw         0;已存盘的item数
saveflag  db         1;是否已存盘标志
errcde    db         0;文件操作错误标志
endcde    db         0;读文件结束标志
endaddr dw ?

filehandle dw ?
msg_titleln db '           ------------------------------------',13,10,'$'
msgsepln db '--------------------------------',0DH,0AH,'$'
msg02      db         'Please input the new student info.',13,10,'$'
msg03      db         'Name:','$'
msg04      db         'ID:','$'
msg05      db         'Score:','$'
;msg06      db         'Press any key to continue!$'
msg07      db         'Successly Saved!',13,10,'$'
msgdeled db    'Successly Deleted a item!',13,10,'$'
msgmoded db    'Successly Modified a item content!',13,10,'$'
msginsed db    'Successly Inserted item(s)!',13,10,'$'
msgqforins db    'Insert this item?(y/n):',13,10,'$'
msgback      db         'Press any key to back.$'
msgexit  db   'Press any key to exit.$'
msg09      db         'students out of 30.',13,10,'$'
;msg19      db         'The scores have been sorted!',13,10,'$'
msg20      db         'There are more than 30 students.',13,10,'$'
msg21      db         'Save as:',13,10,'$'
msg22      db         'Please input the file you want to operate:',13,10,'$'
msg23      db         'Read successly!',13,10,'$'
msg27      db         'There isn',27h,'t any student.',13,10,'$'
msgnoext db   'There  is no such item!',13,10,'$'
msgnaminfid db   'Please input a name to find:',13,10,'$'
msgnuminfid db   'Please input a number to find:',13,10,'$'
msgscoinfid db    'Please input a score to find:',13,10,'$'
msgstattit db   9,9,'The result of statistics is listed as follow:',13,10,'$'
;msg28      db         '$'
;msg29      db         'Score1  Score2  Score3',13,10,'$'
;msg30      db         '$'
;msg31      db         'Input your order:$'
;msg32      db         '$'

msg_nname db  'Please input a new one:',13,10,'$'
msg_nnum db  'Please input a new num.:','$'
msg_nsco db  'Please input a new score.:','$'
msgqsave      db         'The ducoment have not saved.Do you want to save it now(y/n)?','$'   
msg_delnamin db    'Please input the name you want to delete:',13,10,'$'
msg_modname db    'Please input the name field you want to modify:',13,10,'$'
msg_modnum db    'Please input the number field you want to modify:',13,10,'$'
msg_modsco db    'Please input the score field you want to modify:',13,10,'$'
opnmsg     db         '***Error occured while opening file***',13,10,'$'
wrtmsg     db         '***Error occured while writing file***',13,10,'$' 
readmsg    db         '***Error occured while reading file***',13,10,'$' 
routemsg   db         '***Path name is invalid***',13,10,'$'

data ends
;------------------------------------------------------------------------
code segment
 assume cs:code,ds:data,ss:stsg,es:data
main proc   far
start:
     mov    ax,data
     mov    ds,ax
     mov es,ax

     ;lea    dx,filename  ;open file    
     ;mov    al,2;2=读/写
     ;mov    ah,3dh   
     ;int    21h
     ;mov    filehandle,ax ;save filehandle

     ;call near ptr  readall
     
mainmenu:
  mov    AX,0600H  ;ah=6,al=0,clear screen
     mov    CX,0000H;左上角:0,0
     mov    DX,174FH;右下角:18,4f
     mov    BH,07
     int    10H  
               
     mov    AH,02     ;set cursor
     mov    BH,0
     mov    DX,1400H
     int    10H

     lea    DX,titl  ;display menu  
     mov    AH,9
     int    21H
     showmsg _titleln
     lea    DX,mmenutip
     mov    AH,9
     int    21H

case:                 ;switch(ch=getch())  wait for selection from menu
  mov     ah,0
     int     16h
     ;mov    AH,1       
     ;int    21H
     
     cmp    ah,17h;'i'
     je     addone
     cmp ah,26h;'l'
     je  browse
     cmp    ah,19h;'p'
     je     display
     cmp    ah,10h;'q'
     je     query
     cmp    ah,20h;'d'
     je     del_interm
     cmp    ah,2eh;'c'
     je     statis
     cmp    ah,32h;'m'
     je    change
     cmp ah,12h;'e'
     je  exit
     ;jmp     beep

display:
 call display_in
 anykeyback
 jmp  mainmenu

query:
 call query_in
  anykeyback
     jmp    mainmenu
browse:
 call browse_in
     anykeyback
     jmp    mainmenu
addone:
 call insert_in
     anykeyback
     jmp    mainmenu
 
exit:               
    call quit
      
statis:
  call stat_in
     anykeyback
     jmp    mainmenu
del_interm:
 jmp delete        
change: 
 call mod_in 
 anykeyback
 jmp    mainmenu
delete:
 call del_in
 anykeyback
    jmp    mainmenu 
 


beep:                ;beep for error
     mov    AH,14
     mov    AL,7
     mov    BH,0
     int    10H
     jmp    mainmenu      
 
main endp
;------------------------------------------------------------------------
browse_in proc near
 call near ptr        clear
 call near ptr        cursor
 call near ptr  readall 
call name_sort
 call near ptr  print
 ret
browse_in endp
;------------------------------------------------------------------------
del_in proc near
 call clear
    call cursor
 call delete_in
 ret
del_in endp 
;------------------------------------------------------------------------
query_in proc near
 call clear
 call cursor
 call bg_search
 ret
query_in endp
;------------------------------------------------------------------------
stat_in proc near
  call clear
     call cursor
     call near ptr  stat
     ret
stat_in endp
;------------------------------------------------------------------------
insert_in proc near
  call clear
     call cursor
  call near ptr  input
  call name_sort
     ;call near ptr  insert
     ret
insert_in endp
;------------------------------------------------------------------------
display_in proc near 
 call clear
 call cursor
 call near ptr  print
 ret
display_in endp
;------------------------------------------------------------------------
mod_in proc near
 call clear
    call cursor
    call print
 call bg_modify
 call name_sort
 ret
mod_in endp
;------------------------------------------------------------------------
delete_in proc near
;void delete_in()
 push ax
 push dx
 
 call print
 crlfm
 mov ah,9
 lea dx,msg_delnamin
 int 21h
 
 call near ptr  inputname
    call near ptr  del
    
    cmp ax,-1
    je qdel
    showmsg deled
qdel:
    pop dx
    pop ax
    ret
delete_in endp    
;------------------------------------------------------------------------
bg_search proc near
  showmsg menu3_1
  mov ah,1
  int 21h;getch()
  crlfm
  cmp al,'1'
  je q1
  cmp al,'2'
  je q2
  showmsg scoinfid
  lea bx,studentx+14
  mov dx,3
  jmp bgsear
q1:
  showmsg naminfid
     call near ptr  inputname
     ;push bx
     lea bx,studentx
     mov dx,1
     jmp bgsear
q2:
  showmsg numinfid
     call near ptr  inputnum
     lea bx,studentx+6
     mov dx,2
bgsear:     
     push bx;address
     push dx;type
     call near ptr  search;search(studentx,1);
     ;push ax
     ;pop bx
     cmp ax,-1
     je qins
     ;push ax
     showmsg printtitle
     showmsg sepln
     push si
     ;pop ax
     mov si,ax
     call near ptr  printline
     pop si
     jmp qque
qins:
 ;pop ax
 showmsg qforins
 mov ah,01
 int 21h
 crlfm
 cmp al,'y'

⌨️ 快捷键说明

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