Logo 
Search:

Assembly Language Articles

Submit Article
Home » Articles » Assembly Language » Homework HelpRSS Feeds

Program to accept a name from the user and check whether the name is present in the defined table, If not present then insert the name in the table

Posted By: Nicole Hughes     Category: Assembly Language     Views: 4021

Write an assembly program to accept a name from the user and check whether the name is present in the defined table, If not present then insert the name in the table.

Code for Program to accept a name from the user and check whether the name is present in the defined table, If not present then insert the name in the table in Assembly Language

.model small
.data
        tabnames db 'Apple '
                 db 'Orange'
                 db 'Peach '
                 db 'Chikoo'
                 db 6 dup(' '),'$'

        Accept LABEL BYTE
        MaxLen db 7
        ActLen db ?
        Input  db 7 dup(' ')

        Flag db 0
        CR EQU 13
        LF EQU 10
        Line db CR,LF,'$'
        Eq1  db 'Name Is Present','$'

.code
        Main PROC NEAR
        mov ax,@data
        mov ds,ax
        mov es,ax

        CALL AcceptString

        mov BX,0
        L1:
                mov cx,6

                LEA SI,tabnames[BX]
                LEA DI,Input
                REPE CMPSB
                je Equal
                add BX,CX
                INC BX
                cmp BX,19
                jle L1
                jmp addName

           Equal:
                mov ax,0900h
                LEA DX,Eq1
                int 21h
                jmp ext

         addName:
                mov cx,6
                mov bx,25
                LEA SI,Input
                LEA DI,tabnames[BX]
                REP MOVSB

                mov ax,0900h
                LEA DX,tabnames
                int 21h

        ext:
        mov ax,4C00h
        int 21h

   Main EndP

AcceptString PROC NEAR
        mov ax,0A00h
        LEA DX,Accept
        int 21h

        mov cx,6
        
        mov bh,00
        mov bl,ActLen

        cmp ActLen,6
        jge Ok
        sub cl,ActLen
        L2:
                mov Input[BX],20h
                Inc BX
                Loop L2
        Ok:
         mov Input[BX],'$'

        mov ax,0900h
        LEA DX,Line
        int 21h
        ret
AcceptString EndP

end
  
Share: 



Nicole Hughes
Nicole Hughes author of Program to accept a name from the user and check whether the name is present in the defined table, If not present then insert the name in the table is from London, United Kingdom.
 
View All Articles

Related Articles and Code:


 

Other Interesting Articles in Assembly Language:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!