This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

memcmp function

I'm having a problem with the memcmp library function. Even though the buffers match, it returns a value that is not 0. Here is the code:

if (sx == app_id[0])
{
      sx = memcmp((rx1_buf+y),app_id,8);
      if (sx==0)
      .
      .
      .
Here is the assembled code:
;sx = memcmp((rx1_buf+y),app_id,8);
			; SOURCE LINE # 207
	MOV  	DPTR,#y?041
	MOVX 	A,@DPTR
	ADD  	A,#LOW (rx1_buf)
	MOV  	R1,A
	CLR  	A
	ADDC 	A,#HIGH (rx1_buf)
	MOV  	R0,AR1
	MOV  	R4,A
	MOV  	R5,#01H
	MOV  	R3,#0FFH
	MOV  	R2,#HIGH (app_id)
	MOV  	R1,#LOW (app_id)
	MOV  	R6,#00H
	MOV  	R7,#08H
	LCALL	?C?MEMCMPAMD
	   MOV  	R7,AR1 
; if (sx==0)
The problem is in the statement MOV R7,AR1.
When it returns from the ?c?MEMCMPAMD function , R7 has the correct answer (0). Then it loads R7 with AR1 which is not correct. I know that R7 holds the return value for the function, but I don't understand why it wants to reload R7 with AR1. I don't know what exactly AR1 stands for but I know by stepping through it with my emulator that it is just loading R1 into R7.

Thoughts or suggestions?