Assembly language: Try to write a program to compare the two strings string1 and string2 contains the same characters, such as the equivalent display "match", if not the same show "No MATCH." __ Assembly language

Source: Internet
Author: User

Try to write a program to compare two strings string1 and string2 contain the characters are equal, such as equal display "match", if not the same show "No MATCH."
May 25, 2017 23:54:01

Data segment

str1 db ' 123456 ', ' $ '
len1 equ $-str1 str2

db ' 123456 ', ' $ '
len2 equ

match db ' $-str2 H! ', ' $ '
nomatch db ' NO match! ', ' $ '
data ends

stack segment stack
 DW 20h dup (?) 
Top label word
stack ends

code segment
    assume Cs:code,ds:data,ss:stack
main proc far 

    mov ax, Data
    mov ds,ax
    mov es,ax This is  important



    mov ax,stack
    mov ss,ax lea sp,top

    mov AH,LEN1
    mov al,len2

    cmp al,ah
    jne no

    mov ch,0
    mov cl,al

    lea si,str1
    Lea DI,STR2
    CLD
    repe cmpsb
    jne no

yes:
    Lea dx,match
    mov ah,09h
    int 21h 
    JMP exit    

No : Lea Dx,nomatch
    mov ah,09h
    int 21h 

exit: 
    mov ah,4ch
    int 21h

main ENDP
 code  Ends End
  Main

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.