برنامه نویسی
 

 

DSEG    SEGMENT 'DATA'
        filename    db  'a:\mha.txt',00h       ;1    file1
        filename2   db  'b:\mha764.txt',00h        ;      file2
        msg1        db  'file crat',"$"    ;1
        error1      db  'file not creat',"$";1
        handle      dw  ?                   ;1
        msgh1       db  'file close',"$"    ;h1
        errorh1     db  'file not close',"$";h1
        ;
        msgh2       db  'file open',"$"                 ;h2
        errorh2     db  'file not open',"$"             ;h2
        getmsg      db  ' please enter name:',"$"   ;2
        str         label   byte                        ;h2-2
        max         db  255                             ;h2-2
        len         db  ?                               ;h2-2
        st_name     db  35dup(20h),"$"                  ;h2-2
        msg2        db  'file write                ',"$";2
        error2      db  'file not write',"$"            ;2
        wbyte       dw  ?
        ;
        msg3        db  'file read                ',"$";3
        error3      db  'file not read',"$"            ;3
        error4      db  'file not rename',"$"          ;4
        error5      db  'file not delet',"$"           ;4
      
       
        menu        db  ' CraeteFile=1   WriteFile=2   ReadFile=3   RenameFile=4   DeletFile=5  Exit=Esc',"$"         
        line1   DB 'DANESHGAH AZAD ESLAMI VAHED E LARESTAN',"$"
        line2   DB 'PROJEH ASSEMBLY',"$"
        line3   DB 'OSTAD E RAHNAMA :   JENAB AGHAY SOORY',"$"
        line5   DB 'barname navis:',"$"
        line6   DB 'zahra khodashenas    id:850748450',"$"
        line7   DB 'zahra soljo         id:850748453',"$"
        line8   DB 'neda kakaey         id:850748426',"$"
        line9   DB 'please enter number :',"$"
        varrow      db  ?
    
      
DSEG    ENDS

SSEG    SEGMENT STACK   'STACK'
        db   256  DUP(0)
SSEG    ENDS

CSEG    SEGMENT 'CODE'
START   PROC    FAR
      ; set segment registers:
      MOV AX, DSEG
      MOV DS, AX
      MOV ES, AX
     
      call  cds                               ;clear display and move menu
      LEA DX,menu;address massage
   MOV AH,9H;number function
   INT 21H;number interrupt
 
 
      mov ah,02h                              ;mov cursor 
      mov bh,0
      mov dh,1
      mov dl,2
      int 10h

      mov ah,09h                              ;clear display and setting color text
      mov al,0c4h
      mov bh,0
      mov bl,0fh
      mov cx,76
      int 10h
     
          
      mov   varrow,2                          ;Set Cursor Position
      call  c
      mov ah,6h
      mov al,23
      mov ch,2
      mov cl,0
      mov dh,24
      mov dl,78
      mov bh,14
      int 10h
      call    info_ds
     
      add     varrow,2
   call    c
      mov ah,6h
      mov al,16
      mov ch,9
      mov cl,0
      mov dh,24
      mov dl,78
      mov bh,12
      int 10h
 
      LEA  DX,line9
   MOV  AH,9H
   INT  21H
   
  
lop:  add     varrow,1
   call    c
 
   mov   ah,01h
      int   21h  
     
      cmp   al,31h
      jne   step2
      call  creat_file          ;1
      mov   handle,ax
      call  close_file
      jmp   lop
     
step2:cmp   al,32h
      jne   step3
      call  open_file           ;2
      mov   handle,ax
      LEA DX,getmsg      
   MOV AH,9H
   INT 21H
   call  get_name                    
   cmp   len,00
   jz    fin    
      mov   bx,handle
      call  write_file
      mov   wbyte,ax
   call  close_file
   jmp   lop 
  
step3:cmp   al,33h
      jne   step4 
      call  open_file           ;3
      mov   handle,ax
      call  read_file
      ;call  close_file
     
      mov   cx,0                ;1 length of string
      mov   cl,len              ;2 length of string 
      mov   si,OFFSET st_name  ; DS:SI - address of string                 
      xor   bh,bh           ; video page - 0
      mov   ah,0Eh           ; function 0Eh - write character 
      NextChar: 
      lodsb                     ; AL = next character in string
      int   10h           ; call BIOS service 
      loop  NextChar
      call  close_file
      jmp   lop
     
step4:
      cmp   al,34h
      jne   step5
      call  rename_file   ;4 
      call  close_file
      jmp   lop
     
step5:cmp   al,35h
      jne   step6
    
      call  delet_file          ;5
      jmp   lop
step6:cmp   al,1bh
      jne   p
      jmp   fin      
      p:jmp lop
                      
             
      
       
fin:      
      

      MOV AX, 4C00h ; exit to operating system.
      INT 21h   
   START   ENDP
;*******************************************************
;proc creat file                                            1
;*******************************************************   
creat_file  proc
        lea dx,filename
        mov ah,3ch
        mov cx,00;file mamoli
        int 21h
        jc  error01
        ret
        error01:
        ;call    c
        LEA  DX,error1;address massage
     MOV  AH,9H;number function
     INT  21H;number interrupt
     jmp     fin

creat_file  endp
;*******************************************************
;proc move cursor                                           Set Cursor Position
;*******************************************************
c   proc
    mov ah,02h
    mov dh,varrow
    mov dl,20
    mov bh,0
    int 10h

ret
c   endp

;*******************************************************
;proc clear display
;*******************************************************
cds   proc
    mov ah,6h
    mov al,25
    mov ch,0
    mov cl,0
    mov dh,2
    mov dl,78
    mov bh,10
    int 10h

ret
cds   endp

;*******************************************************
;proc close file                                            h1
;*******************************************************  
close_file  proc
    mov bx,handle
    mov ah,3eh
    int 21h
    jc  error0h1
    ret
    error0h1:
    ;call    c
    LEA  DX,errorh1;address massage
 MOV  AH,9H;number function
 INT  21H;number interrupt
 jmp     fin

ret
close_file   endp
;*******************************************************
;proc open file                                              h2
;*******************************************************  
open_file  proc
    lea dx,filename
    mov ah,3dh
    mov al,02h
    int 21h
    ret
    error0h2:
    ;call    c
    LEA  DX,errorh2;address massage
 MOV  AH,9H;number function
 INT  21H;number interrupt
 jmp     fin
ret
open_file   endp  
;*******************************************************
;proc get name                                               h2-2
;*******************************************************  
get_name    proc

        mov ah,0ah
        lea dx,str
        int 21h

ret
get_name    endp
;*********************************************************
;proc   write to file                                        2
;*********************************************************  
write_file  proc
        mov ah,40h
        lea dx,st_name
        mov cx,35
        int 21h
        jc  error02
        ret
        error02:
       
        ;call    cds
        ;call    c
        LEA  DX,error2;address massage
     MOV  AH,9H;number function
     INT  21H;number interrupt
     jmp     fin

write_file  endp
;*********************************************************
;proc read file                                              3
;*********************************************************  
read_file  proc
    lea dx,st_name
    mov bx,handle
    mov cx,wbyte
    mov ah,3fh
    int 21h
    jc  error03
     ret
    error03:
   
    ;call    c
    LEA  DX,error3;address massage
 MOV  AH,9H;number function
 INT  21H;number interrupt
 jmp     fin
    
ret
read_file   endp  
;****************************************************
;proc rename to  file                                        4
;****************************************************
rename_file proc
     
      mov   ah,56h;number function
      lea   dx,filename;address file
      lea   di,filename2
      int   21h;number interrupt
      jc    error04
      ret
      error04:
      LEA  DX,error4;address massage
   MOV  AH,9H;number function
   INT  21H;number interrupt
   jmp     fin
    
rename_file endp
;****************************************************************************
;proc delet   file
;****************************************************************************
delet_file  proc
      
      mov   ah,41h;number function
      lea   dx,filename;address file
      int   21h;number interrupt
      jc    error05
      ret
      error05:
      LEA  DX,error5;address massage
   MOV  AH,9H;number function
   INT  21H;number interrupt
   jmp     fin
delet_file  endp
;*****************************************************
;;information
;*****************************************************
info_ds        proc
             
            LEA  DX,line1
   MOV  AH,9H
   INT  21H
   add     varrow,1
   call    c
   LEA  DX,line3
   MOV  AH,9H
   INT  21H
   add     varrow,1
   call    c
   LEA  DX,line5
   MOV  AH,9H
   INT  21H
   add     varrow,1
   call    c
   LEA  DX,line6
   MOV  AH,9H
   INT  21H
   add     varrow,1
   call    c
   LEA  DX,line7
   MOV  AH,9H
   INT  21H
   add     varrow,1
   call    c
   LEA  DX,line8
   MOV  AH,9H
   INT  21H
   
   
   ret
info_ds        endp  


;****************************************************************************
;****************************************************************************


 

 

CSEG    ENDS
END    START    ; set entry point.

+ نوشته شده در  جمعه بیست و دوم آذر ۱۳۸۷ساعت 19:27  توسط ابراری |