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

📄 search.asm

📁 835140masm 实现的简单的学生档案管理
💻 ASM
字号:
public search
  Psize equ 8
  Rsize  equ 49
     
    data2 segment 
      myfcb label byte
      fcbdriv db 0
      fcbname db 'students'
      fcbext  db 'txt'
      fcbblk dw 0
      fcbrcsz dw 0
              dd ?
              dw ?
              dt ?
      fcbwqrc db 0
              dd ?
      dtapar label byte
      maxl db 49
      act db ?
      dta db 49 dup(?)
  crlf db 13,10,'$'    
  num db 6 dup(?)
  names db 10 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(?)

  pcounter db ?
  err_fopen db 0ah,0dh,"   File open error! $"
  err_fcreat db 0ah,0dh,"   File creat error!$"
  err_fread1 db 0ah,0dh,"   File read error in sequence manner! $"
  err_fread2 db 0ah,0dh,"   File read error in random manner !$"
  err_fclose db 0ah,0dh,"   File close error !$"
  msnum db 13,10,'  1.num',13,10,'$'
  msname db '  2.name',13,10,'$'
  mskey db '  key item :$'
  msnumva db 13,10,'  Input num value :$'
  msnameva db 13,10,'  Input name value :$'
  numsto db 6 dup(?)
  namesto db 10 dup(?)
  inflag db ?
  continue db 0ah,0dh,"     Press space to continue...$"
  no_target db 13,10,'Sorry! Search wrong! Please confirm and again! (y/n)? $'
  serch_another db 13,10,'Search another one ?(y/n): $'
  data2 ends

  show macro addrs
  ;display a line started at addrs.
  push dx
  lea dx,addrs
  mov ah,09h
  int 21h 
  pop dx
  endm

  show_item macro addrs,count1,count2
  local iloop,spacelp
  mov bx,0
  iloop:
     mov dl,&addrs&[bx]
     mov ah,2
     int 21h
     inc  bx
     cmp bx,count1
     jl iloop
     mov cx,count2
  spacelp:
  mov dl," "
  mov  ah,2
  int 21h
  loop spacelp
  endm  

   
    code2 segment
    assume cs:code2,ds:data2,es:data2
    search proc far
    
       push  ds
       PUSH ES
       mov  ax,data2
       mov es,ax
       mov ds,ax
          
      call _search
      call closef
      pop es
      pop ds
       ret
        search endp
   

  show_rec proc near
    push ax
    push bx
    push cx
    push dx
    show_item num,6,2
    show_item names,10,2 
    show_item sex,1,2
    show_item birth,8,3
    show_item place,3,2
    show_item score1,5,2
    show_item score2,5,2
    show_item score3,5,2
    show_item total,5,2

    pop dx
    pop cx
    pop bx
    pop ax
    ret
  show_rec endp


  openf proc near
    mov  ah,0fh
    lea dx,myfcb
    int 21h
    or al,al
    jz found
    show err_fopen

  found: mov fcbrcsz,49
         mov ah,1ah
         lea dx,dta
         int 21h

    ret
  openf endp

  closef proc near
    mov ah,10h
    lea dx,myfcb
    int 21h
    ret
    closef endp


    _search proc near

  s_begin:
         mov fcbblk+1,0
         call openf     
         or al,al
         je se_be 
         jmp _exit_
    se_be:
       show msnum
       show msname
       show mskey
      mov bx,0
    _ag:mov ah,1
       int 21h
       mov inflag,al
       cmp al,'1'
       je _na
       cmp al,'2'
       jne _ag
       show msnameva
 ag_in:mov ah,1
       int 21h
       cmp al,0ah
       je in_end_
       cmp al,0dh
       je in_end_
       mov namesto[bx],al
       inc bx
       cmp bx,10
       jl ag_in
     in_end_:
        push cx
        mov cx,10
        sub cx,bx
        mov ch,0
     lp_:mov namesto[bx],' '
         inc bx
          loop lp_
        pop cx
       jmp  in_end
 _na:  show msnumva

   _na_:mov ah,1
       int 21h
       mov numsto[bx],al
       inc bx
       cmp bx,6
       jl _na_;
 in_end: 
      se_re:
         cmp inflag,'1'
         jne _namese
     se_one:
       lea dx,myfcb
       mov ah,14h
       int 21h            
       cmp al,01
       jne m3
       jmp f_end      
    m3:
       cmp al,0
       je  m4
       ;cmp al,03
       ;je f_end
    m4:
       mov bx,0
    movin:
    mov al,dta[bx]
    mov num[bx],al
    inc bx
    cmp bx,RSize
    jl movin

    mov cx,6
    lea di,num
    lea si,numsto
    cld
    rep cmpsb
    jne se_one
    show crlf
    call show_rec
    call closef
    jmp se_anone

 f_end:show no_target
       jmp jj
  se_anone:
     show serch_another
   jj:mov ah,1
     int 21h
     cmp al,'y'
     je s_begi
     jmp _n_
   s_begi:jmp s_begin
   _n_:
     cmp al,'n'
     jne jj
     jmp _exit_
   
      _namese:
     se_one_:
       lea dx,myfcb
       mov ah,14h
       int 21h            
       cmp al,01
       jne m3_
       jmp f_end_      
    m3_:
       cmp al,0
       je  m4_
       cmp al,03
       je f_end_
    m4_:
       mov bx,0
    movin_:
    mov al,dta[bx]
    mov num[bx],al
    inc bx
    cmp bx,RSize
    jl movin_

    mov cx,10
    lea di,num+6
    lea si,namesto
    cld
    rep cmpsb
    jne se_one_
    show crlf
    call show_rec
    call closef
    jmp se_anone_
 f_end_:show no_target
       jmp jj_
  se_anone_:
     show serch_another
   jj_:mov ah,1
     int 21h
     cmp al,'y'
     je s_be
      jmp __n
  s_be:jmp s_begin
  __n:cmp al,'n'
     jne jj_
     jmp _exit_
       
   _exit_:
     ret
   _search endp

    code2 ends
    end 





   



⌨️ 快捷键说明

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