I'm looking for a simpler code that isn't resource hungry that can compare two strings stored in different locations in the extended memory of a classic 8052 (namely the AT89S52 microcontroller) to make sure the characters match exactly.
The error flag can be a bit value, but the only thing that concerns me is that I need scanning to begin at any two 16-bit memory locations of my choice and that the same number of consecutive bytes in each location need to be scanned.
I was considering applying boolean logic to DPH or the DPL variables (example ANL and ORL) but at the same time will I be able to make that programmer friendly? I don't want to make the memory addressing confusing later on. Also, I'm looking for code that can replace this that can provide better performance (meaning fewer instructions required to execute a string comparison code).
Any ideas are welcome.
;Load # bytes to check in R7 mov R7,#BYTESTOCHECK ;R6 = our error status. Assume no error here mov R6,#0h ;Load first memory pointer address to R2:R3 mov R2,#HIGHBYTE1 mov R3,#LOWBYTE1 ;Load second memory pointer address to R4:R5 mov R4,#HIGHBYTE2 mov R5,#LOWBYTE2 checknextbyte: mov DPL,R2 mov DPH,R3 ;DPTR here = R2:R3 movx A,@DPTR ;Store value at DPTR in B mov B,A inc DPTR mov R3,DPH mov R2,DPL mov DPL,R4 mov DPH,R5 ;DPTR here = R4:R5 movx A,@DPTR ;Store value at DPTR in A inc DPTR mov R5,DPH mov R4,DPL CJNE A,B,notsame ;Both addresses aren't same so string isn't same ;make R7=1 to exit loop faster mov R7,#1h ;Make R6=1 to show we have error mov R6,#1h notsame: djnz R7,checknextbyte