Comparing strings in assembly using 8051 MCU

Thread Starter

Dritech

Joined Sep 21, 2011
901
Hi all,

I need to compare a string which is saved in Code memory location starting from 200H with another three strings which are also saved in the Code memory location this time staring from 300H.

The three strings will be separated by a comma to indicate different words and a full-stop will be used at the end of the words stream to indicate end of stream.

For now I managed to save the string to be compared and the other three strings as follows:

Code:
ORG 0000H
MOV DPTR,#200H
CLR A
MOVC A,@A+DPTR
MOV R0,A

MOV DPTR,#300H
CLR A
MOVC A,@A+DPTR
MOV R1,A

//compare R0 to R1, compare the rest of the array characters

Here: SJMP HERE


ORG 200H
MYDATA1: DB "abc"
   
    ORG 300H
MYDATA2: DB "ab,abc,abcd."
END
How can I continue comparing till I find a matching string?

Any help would be highly appreciated as I have been searching the web for quite a while but still cannot manage to make it work.
 

WBahn

Joined Mar 31, 2012
30,060
This sounds like homework.

How would you do it in a high-level language, like C, if the data was in two character arrays and you couldn't use any of the standard libraries?

Also, what is the result supposed to be? Just a T/F indicating that the reference string was found in the stream? A count of how many times it was found? Do substring matches count?
 
Top