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

Could someone explain?

This ex. will not work

char	data	test;

char TestF(void);

char TestF(void)
{
if (test == 0x8A)
	{
	//...
	return(1);
	}
}
//Take a look at the Assambly code
             ; FUNCTION TestF (BEGIN)
                                           ; SOURCE LINE # 5
                                           ; SOURCE LINE # 6
                                           ; SOURCE LINE # 7
                 R     MOV     R7,test
                       MOV     A,R7
                       RLC     A
                       SUBB    A,ACC
                       MOV     R6,A
                       MOV     A,R7
                       XRL     A,#08AH
                       ORL     A,R6
                 R     xJNZ    ?C0002
                                           ; SOURCE LINE # 8
                                           ; SOURCE LINE # 10
                       MOV     R7,#01H
                                           ; SOURCE LINE # 11
                                           ; SOURCE LINE # 12
             ?C0002:
                       RET
But this one works
char	data	test;

char TestF(void);

char TestF(void)
{
if (test == (char)0x8A)
	{
	//...
	return(1);
	}
}
//Take a look at the Assambly code
             ; FUNCTION TestF (BEGIN)
                                           ; SOURCE LINE # 5
                                           ; SOURCE LINE # 6
                                           ; SOURCE LINE # 7
                 R     MOV     A,test
                 R     xJNE    A,#08AH,?C0002
                                           ; SOURCE LINE # 8
                                           ; SOURCE LINE # 10
                       MOV     R7,#01H
                                           ; SOURCE LINE # 11
                                           ; SOURCE LINE # 12
             ?C0002:
                       RET

0