Logo 
Search:

Assembly Language Articles

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

Program to check for string

Posted By: Luana Fischer     Category: Assembly Language     Views: 3491

Write a program to check for string.

Code for Program to check for string in Assembly Language

prnstr macro msg
    mov ah, 09h
    lea dx, msg
    int 21h
    endm
readstr macro st
    mov ah, 0ah
    lea dx, st
    int 21h
    endm

data segment
    buf1 db "Enter first string : $"
    first db 11
          db 0
          db 11 dup(' ')
    buf2 db 0ah, "Enter second string : $"
    second db 11
           db 0
           db 11 dup(' ')
    buf3 db 0ah, "The strings are not of equal length...$"
    buf4 db 0ah, "The strings are same...$"
    buf5 db 0ah, "The strings are not same...$"
data ends

code segment
    assume cs:code, ds:data
start :
    mov ax, data
    mov ds, ax
    mov es, ax

    prnstr buf1
    readstr first

    prnstr buf2
    readstr second

    mov si, offset first + 1
    mov ax, 0000h
    mov al, byte ptr [si]
    mov si, offset second + 1
    cmp al, byte ptr [si]
    jz continue

    prnstr buf3
    jmp stop
continue :
    mov cx, ax
    lea si, first+2
    lea di, second+2
        cld
        repe cmpsb
        jnz cont
        prnstr buf4
        jmp stop
cont :
        prnstr buf5
stop :
        mov ax, 4c00h
        int 21h
code ends
        end start
  
Share: 


Didn't find what you were looking for? Find more on Program to check for string Or get search suggestion and latest updates.

Luana Fischer
Luana Fischer author of Program to check for string is from Frankfurt, Germany.
 
View All Articles

Related Articles and Code:


 
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!