Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/19/00 17:14
Read: times


 
#2772 - RE: strcmp
Do you mean in 'C' or assembler?

In C:-

#include "string.h"

int strcmp (char *src, char *dst ) {

register int ret = 0 ;

while( ! (ret = *src - *dst) && *dst)
++src, ++dst;

if ( ret < 0 )
return (-1) ;
else if ( ret > 0 )
return (1) ;
}

The problem with a general solution is that most 8052s have a single DPTR. So if you are working in assembler it's best to optimise for the required memory model and pointer size. 8 bit pointer dereferences (@r0 & @r1) produce much less code than 16 bit (@DPTR).

If you let me know where BOTH source and destination strings are (XDATA, IDATA, DATA, CODE) and I can post what the compiler kicks out.

List of 3 messages in thread
TopicAuthorDate
strcmp            01/01/70 00:00      
RE: strcmp            01/01/70 00:00      
RE: strcmp            01/01/70 00:00      

Back to Subject List