# برنامه نویسی سطح پایین > برنامه نویسی اسمبلی خانواده x86 > آموزش: سورس برنامه دفترچه تلفن به زبان اسمبلی

## hamzeh1989

.model small

.data

   msginput1 db "Enter String1 : ","$"
   msginput2 db 10,10,13,"Enter String2 : ","$"   
   msginvert db 10,13,"Invert String : ","$"
   msginputx db 10,10,13,"Enter Number  : ","$"   
   msginsert db 10,10,13,"Inserted str  : ","$"
   msgconvert db 10,13,"Convert 2 big: ","$"   
   msgdelete db 10,10,13,"Deleted char  : ","$"

   string1 label byte
     max1 db 20
     len1 db ?
     str1 db 20 dup ('$')

   string2 label byte
     max2 db 20
     len2 db ?
     str2 db 20 dup ('$')

   x db 0

.code
   main proc far
     mov ax,@data
     mov ds,ax

     ;input string1
     mov ah,09h
     lea dx,msginput1
     int 21h
     mov ah,0ah
     lea dx,string1
     int 21h

     ;input string2
     mov ah,09h
     lea dx,msginput2
     int 21h
     mov ah,0ah
     lea dx,string2
     int 21h

;==================================== Invert str2 ============================;

     mov ah,09h
     lea dx,msginvert
     int 21h

     mov cx,0
     mov cl,len2

     lea bx,str2
     add bl,len2 
     dec bx

     invert:

        mov ah,02h
        mov dl,[bx]
        int 21h         
        dec bx

     loop invert


     ;input x
     mov ah,09h
     lea dx,msginputx
     int 21h  
     mov ah,01h
     int 21h
     aaa
     mov x,al


;===========================Insert str2 in str1 after str1[x]=================;

     ;shift character in str1 

     ;1- loop conter = str len1 - x
     mov cx,0
     mov cl,len1
     sub cl,x
     jcxz no_shift ; if x == end of str1 dont need to shift

     ;2- point bx to str1[x]
     lea bx,str1
     add bl,x

     ;3- point si to str1[x]+str len2 
     lea dx,str1
     add dl,x
     add dl,len2
     mov si,dx

     ;4- shift char

     shift:
        mov dl,[bx]
        mov [si],dl
        inc si
        inc bx
     loop shift   

     no_shift:

     ;mov str2 to str1
     lea si,str2
     lea bx,str1
     add bl,x
     mov cx,0
     add cl,len2     
     add len1,cl ; len1 must change by programer   

     insert:
        mov dl,[si]
        mov [bx],dl
        inc si
        inc bx
     loop insert



     mov ah,09h
     lea dx,msginsert
     int 21h

     lea dx,str1
     int 21h

;===========================Convert str1 to big char ======================;

     mov cx,0
     mov cl,len1

     lea bx,str1

     convert:
         mov dl,[bx]
         cmp dl,'a'
         jl  next
         cmp dl,'z'
         jg  next
         sub dl,32
         mov [bx],dl

         next:
         inc bx
     loop convert

     mov ah,09h
     lea dx,msgconvert
     int 21h

     lea dx,str1    
     int 21h

;============================ Delete char from str1 =======================;

     mov ah,09h
     lea dx,msginputx
     int 21h

     mov ah,01h
     int 21h
     aaa
     mov x,al

     mov cx,0
     mov cl,x
     inc cx   ; for clear position of last char

     dec x    ; because array begin of "0"
     lea bx,str1
     add bl,x

     delete:
         mov dl,[bx+1]
         mov [bx],dl
         inc bx
     loop delete
     dec len1

     mov ah,09h
     lea dx,msgdelete
     int 21h

     mov ah,09h
     lea dx,str1
     int 21h

     mov ax,4c00h
     int 21h

   main endp
end main

----------


## Ship Storm

.این الآن کامل هست ؟
فکر نمیکنم این کل پروژه باشه ها

----------


## morycom

این اصلا برنامه دفترچه تلفن نیست که :قهقهه:

----------

