We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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)
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)