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

📄 insert.asm

📁 用汇编语言实现的一个简单的学生档案的管理系统
💻 ASM
字号:
   
   public insert
   data0 SEGMENT 

        CRLF DB 13,10,'$'
        ERRCDE DB 0 
       
        name1 db 10 dup(?)
        num      db 6 dup(?)
        sex      db ?
        birth    db 8 dup(?)
        place    db 3 dup(?)
        score1   db 5 dup(?)
        score2   db 5 dup(?)
        score3   db 5 dup(?)
        total    db 5 dup(?)

        msnum        db 0ah,0dh,"    Num      :$"    
        msname       db 0ah,0dh,"    Name     :$"
        mssex        db 0ah,0dh,"    Sex      :$"
        msbirth      db 0ah,0dh,"    Birth    :$"
        msplace      db 0ah,0dh,"    Place    :$"
        msscore1     db 0ah,0dh,"    English  :$"
        msscore2     db 0ah,0dh,"    Chinese  :$"
        msscore3     db 0ah,0dh,"    Maths    :$"
        mstotal      db 0ah,0dh,"    Total    :$"
      
       erfop db 0ah,0dh,'* * * open error ! * * *$'
       erfwt db 0ah,0dh,'* * * write error ! * * *$'
       erfct db 0ah,0dh,'* * * creat error ! * * *$'
       continue db 0ah,0dh,'       Press space to continue... $'
       confirm  db 0ah,0dh,'        OK?..(y/n) $'
       msg db  0ah,0dh,'  Do you want to input another record...?(y/n)$'
       mswrong db 0ah,0dh,'   Input score is wrong!',0ah,0dh
               db  '   Please press Enter input again...$'
       reclen equ 49
       recordf   label byte
       maxlen    db reclen 
       actlen    db ?
       recordfld db reclen dup(?)

      fcb label byte
      fcbdriv db 0
      fcbname db 'students'
      fcbext  db 'txt'
      fcbblk  dw 0
      fcbrcsz dw 0
              dd ?
              dw ?
              dt ?
      fcbsqrc db 0
              dd ?
       s db ?,?,?,'.',?,13,10,'$'
       cff db 0
      data0 ends
    
         ;;;display chars begin at addrs.
      showms macro addrs
             push dx
             lea dx,addrs
             mov ah,09h
             int 21h
              pop dx
             endm
       
          stoos macro target,source,count
               lea di,target
               lea si,source
               mov cx,count
               cld
               rep movsb
               endm 
       
        getin macro addrs,count1
              local lop,zeroit,input_end,exi,lop1
              mov bx,0
            lop:
              mov ah,1
              int 21h
              cmp al,0dh
              jz input_end
              cmp al,0ah
              jz input_end
              mov &addrs&[bx],al
              inc bx
              cmp bx,count1
              jl lop
       input_end: cmp bx,count1
                  je exi
                   mov ch,0
                  mov cx,count1
                  sub cx,bx
              lop1:
                  mov &addrs&[bx],' '
                  inc bx
                  loop lop1
               exi:
              endm

         clr macro
         push ax
         push bx
         push cx
         push dx
       mov ax,0600h
       mov cx,0
       mov dx,184fh
       mov bh,9Eh
       int 10h
         pop dx
         pop cx
         pop bx
         pop ax
        endm

        ;;she zhi shu biao
         setcur macro row,col
           push ax
           push bx
           push cx
           push dx
         mov ch,5
         mov cl,7
         mov ah,1
         int 10h
         mov dh,row
         mov dl,col
         mov bh,0
         mov ah,2
         int 10h
         pop dx
         pop cx
         pop bx
         pop ax
         endm
     calt macro n,cff,target
            local exx,ae1,ag1
               push ax
               sub score1[n],30h
              mov al,score1[n]
              sub score2[n],30h
              add al,score2[n]
              sub score3[n],30h
              add al,score3[n]
              add al,cff
              add score1[n],30h
              add score2[n],30h
              add score3[n],30h
              cmp al,20
              jae ae1
               cmp al,10
               jae ag1
               add al,30h
               mov target,al
               mov cff,0
               jmp exx
             ae1:sub al,20
                add al,30h
                mov target,al
                 mov cff,2
                 jmp exx
             ag1:sub al,10
               add al,30h
                mov target,al
                 mov cff,1
              exx:
                 pop ax
               endm




        code0 segment 
         assume cs:code0,ds:data0,es:data0
       insert proc far
             
             push ds
             push es
             mov ax,data0
             mov ds,ax
             mov es,ax
             clr
             setcur 0,0
             call openf
             cmp errcde,0
             jz contin
             ret
         contin:
             call inputf
             call closef
             pop es
             pop ds
             ret
           insert endp

      openf proc near
             mov ah,0fh
             lea dx,fcb
             int 21h
             cmp al,0
             jz found
             showms erfop
             mov ah,16h 
             lea dx,fcb
             int 21h
             or al,al
             jz found
             showms erfct
             mov errcde,01
             ret
          found:
             mov fcbrcsz,reclen
             lea dx,recordfld
             mov ah,1ah
             int 21h
             ret
             openf endp
           
       inputf proc near
          agin:   
              showms msnum
              getin num,6
              showms msname
              getin name1,10
              showms mssex
              getin sex,1
              showms msbirth
              getin birth,8
              showms msplace
              getin place,3
              showms msscore1
              getin score1,5
              showms msscore2
              getin score2,5
              showms msscore3
              getin score3,5
              showms mstotal
              getin total,5
              showms crlf
              calt 4,cff,s+4 
              calt 2,cff,s+2
              calt 1,cff,s+1
              calt 0,cff,s
               push di
               push si
               push cx
               lea di,s
               lea si,total
               mov cx,5
               rep cmpsb
               jne errr1
               pop cx
               pop si
               pop di
               jmp ru
             errr1:
             pop cx
             pop si
             pop di
                showms mswrong
            chon:mov ah,0
                int 16h
                cmp ah,1ch
                je  agin11
                cmp ah,01h
                je eeee
                jmp chon
           eeee:ret
          agin11:
               jmp agin

            ru:showms crlf
              showms confirm
           ain:
              mov ah,1
              int 21h
              cmp al,'n'
              je gi
               jmp n1
           gi:jmp agin
            n1:cmp al,'y'
              je st1
               jmp ain
           st1:
               cld
               lea di,recordfld
               mov al,20h
               mov cx,49
               rep stosb
           serch_end:
               mov ah,14h
               lea dx,fcb
               int 21h
               cmp al,01
               je wrif
               cmp al,0
               je serch_end

             wrif:
               stoos recordfld,num,6
               stoos recordfld+6,name1,10
               stoos recordfld+16,sex,1
               stoos recordfld+17,birth,8
               stoos recordfld+25,place,3
               stoos recordfld+28,score1,5
               stoos recordfld+33,score2,5
               stoos recordfld+38,score3,5
               stoos recordfld+43,total,5
               mov recordfld+48,1ah
               call writef
               showms msg

            aa12:mov ah,1
               int 21h
               cmp al,'y'
               je  an11
               jmp n22
            an11:jmp agin
            n22:cmp al,'n'
               je iend1
                jmp  aa12
               iend1:
                 ret
         inputf endp

         writef proc near
             mov ah,15h
             lea dx,fcb
             int 21h
             cmp al,0
             jz valid
             showms erfwt
             mov actlen,0
         valid: 
             ret
         writef endp
        
         closef proc near
          mov ah,10h
          lea dx,fcb
          int 21h
          ret
         closef endp

       code0 ends
       end  

⌨️ 快捷键说明

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