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

Error in assembled output? return value loaded after RET

After compiling, a section from my src file looks something like this:

;
; U08  ReadOtpU08( const OTPAddr addr )

        RSEG  ?PR?_ReadOtpU08?OTPCOMMIT
_ReadOtpU08:
        USING   0
                        ; SOURCE LINE # 157
        MOV     addr?549,R6
        MOV     addr?549+01H,R7
; {   // Must be within OTP Range {{{
                        ; SOURCE LINE # 158
;     ASSERT( addr < OTP_SIZE );
; //P0 = 0xAA;
;     TRACE((" - %bx - ", otpCodeRead.codeSpace[addr] ));
                        ; SOURCE LINE # 161
        MOV     R3,#0FFH
        MOV     R2,#HIGH (?SC_30)
        MOV     R1,#LOW (?SC_30)
        LCALL   L?0045
        MOV     ?_printf?BYTE+03H,A
        LCALL   _printf
;     return otpCodeRead.codeSpace[addr];
                        ; SOURCE LINE # 162
        CLR     A
        ADD     A,addr?549+01H
        MOV     DPL,A
        MOV     A,#080H
        ADDC    A,addr?549
        MOV     DPH,A
        CLR     A
        MOVC    A,@A+DPTR
        MOV     R7,A
;     // }}}
; }
                        ; SOURCE LINE # 164
?C0017:
        RET
; END OF _ReadOtpU08

;

but the assembled output produces:

....
C:0x8A99    E4       CLR      A
C:0x8A9A    2569     ADD      A,0x69
C:0x8A9C    F582     MOV      DPL(0x82),A
C:0x8A9E    7480     MOV      A,#P0(0x80)
C:0x8AA0    3568     ADDC     A,0x68
C:0x8AA2    F583     MOV      DPH(0x83),A
C:0x8AA4    E4       CLR      A
C:0x8AA5    93       MOVC     A,@A+DPTR
C:0x8AA6    22       RET
C:0x8AA7    FF       MOV      R7,A

which clearly shows the result being moved to R7 after the return ??!!

Can anybody shed light on this: Apologies if I'm overlooking the obvious...

0