How to compare two strings assembly

后端 未结 2 490
无人及你
无人及你 2021-01-24 07:16

Could anyone tell me how to compare two strings in assembly language, I`ve written the followign, but it does not seem to work.

assume cs:code, ds:data

data seg         


        
2条回答
  •  春和景丽
    2021-01-24 07:43

    I had the same problem when I was writing asm in school, years ago. The problem I encountered was that I wanted to compare the word "exit" with a user entry. If they typed "exit", the application quit. If they typed anything else, then a message appeared telling them there was an erroneous entry.

    The way I solved the issue was to compare the strings character-by-character, until the characters no longer matched, or vice-versa.

    This also might be of some use. Here are some code examples relating to string comparison in assembly language: http://www.daniweb.com/software-development/assembly/threads/58667/assembly-language-comparing-strings

    You might also want to look at this article relating to regular expressions (regex) in assembly language: Regular Expressions and Assembly

提交回复
热议问题