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

Return instruction of CALLA

Hi All

I'm looking for an issue in a code written in C and I think it might be due to the compiler. For this SW I'm using c166 V3.05a (an old legacy code).

The compiler calls one function with CALLA instruction but the return instruction is RETS (I think should be RET).
I think that this cause a spurious value into the stack that in some case create error in the other part of the code.

The code that cause this is like
BYTE* funct();
BYTE * p_a;
BYTE funct_val();

*(p_a = funct()) = funct_val();

The compiler call funct() with a CALLA instruction (and the function return with RETS)

if i change it with

p_a = funct()
*(p_a) = funct_val();

funct() is called with CALLS (and the function return with RETS)

Parents
  • Some more detailed information

    NOT WORKING

    {
    static BYTE a = 0;
    static BYTE * p_a = 0;
    p_a = &a;
    *(p_a = funct(a)) = (a );
    }

    1664 E6F45800 R MOV R4,#a
    1668 F6F42600 R MOV p_a,R4 ; SOURCE LINE # 1628
    166C C2F85800 R MOVBZ R8,a
    1670 CA000000 R CALLA cc_UC,funct
    1674 F6F42600 R MOV p_a,R4
    1678 A4045800 R MOVB [R4],a

    ; FUNCTION funct (BEGIN RMASK = @0x4010) ; SOURCE LINE # 35
    ;---- Variable 'b' assigned to Register 'R8' ---- ; SOURCE LINE # 36 ; SOURCE LINE # 39
    0000 E6F45900 R MOV R4,#a ; SOURCE LINE # 40
    0004 DB00 RETS ; FUNCTION funct (END RMASK = @0x4010)

Reply
  • Some more detailed information

    NOT WORKING

    {
    static BYTE a = 0;
    static BYTE * p_a = 0;
    p_a = &a;
    *(p_a = funct(a)) = (a );
    }

    1664 E6F45800 R MOV R4,#a
    1668 F6F42600 R MOV p_a,R4 ; SOURCE LINE # 1628
    166C C2F85800 R MOVBZ R8,a
    1670 CA000000 R CALLA cc_UC,funct
    1674 F6F42600 R MOV p_a,R4
    1678 A4045800 R MOVB [R4],a

    ; FUNCTION funct (BEGIN RMASK = @0x4010) ; SOURCE LINE # 35
    ;---- Variable 'b' assigned to Register 'R8' ---- ; SOURCE LINE # 36 ; SOURCE LINE # 39
    0000 E6F45900 R MOV R4,#a ; SOURCE LINE # 40
    0004 DB00 RETS ; FUNCTION funct (END RMASK = @0x4010)

Children
  • WORKING

    {
    static BYTE a = 0;
    static BYTE * p_a = 0;
    p_a = &a;
    p_a = funct(a);
    *(p_a) = (a );
    }

    1664 E6F45800 R MOV R4,#a
    1668 F6F42600 R MOV p_a,R4 ; SOURCE LINE # 1629
    166C C2F85800 R MOVBZ R8,a
    1670 DA000000 R CALLS SEG (funct),funct
    1674 F6F42600 R MOV p_a,R4 ; SOURCE LINE # 1630
    1678 F2F42600 R MOV R4,p_a
    167C A4045800 R MOVB [R4],a

    ; FUNCTION funct (BEGIN RMASK = @0x4010) ; SOURCE LINE # 35
    ;---- Variable 'b' assigned to Register 'R8' ---- ; SOURCE LINE # 36 ; SOURCE LINE # 39
    0000 E6F45900 R MOV R4,#a ; SOURCE LINE # 40
    0004 DB00 RETS ; FUNCTION funct (END RMASK = @0x4010)