Hello, i'm using die uvision2, cx51 7.2 for a philips mx chip. In my following example code, keil reserves data, which is assigned to registers und so furthermore not used. The problem only comes, when i'm using more params as can all be passed through registers. thanks for help, solving the problem. the .c file:
#include <REG51M.H> typedef unsigned char byteT; typedef unsigned int shortT; void test(shortT param1, shortT param2, shortT param3,shortT param4); shortT sub2(shortT param1, shortT param2 ); void main(void) { test(0x0011, 0x0022, 0x0033, 0x0044); while(1){} } void test(shortT param1, shortT param2, shortT param3,shortT param4) { shortT param5 =sub2(param1, param2)+ param3; param4++; } shortT sub2(shortT param1, shortT param2) { return param1+param2; }
FUNCTION/MODULE BIT_GROUP DATA_GROUP --> CALLED FUNCTION/MODULE START STOP START STOP ==================================================== ?C_C51STARTUP ----- ----- ----- ----- +--> ?PR?MAIN?MAIN MAIN/MAIN ----- ----- ----- ----- +--> ?PR?_TEST?MAIN _TEST/MAIN ----- ----- 0008H 0011H +--> ?PR?_SUB2?MAIN _SUB2/MAIN ----- ----- ----- -----
RSEG ?DT?_test?MAIN ?_test?BYTE: param1?140: DS 2 param2?141: DS 2 param3?142: DS 2 param4?143: DS 2 ORG 8 param5?144: DS 2 ; #include <REG51M.H> ; ; typedef unsigned char byteT; ; typedef unsigned int shortT; ; ; void test(shortT param1, shortT param2, shortT param3,shortT param4); ; shortT sub2(shortT param1, shortT param2 ); ; ; void main(void) RSEG ?PR?main?MAIN main: USING 0 ; SOURCE LINE # 9 ; { ; SOURCE LINE # 10 ; test(0x0011, 0x0022, 0x0033, 0x0044); ; SOURCE LINE # 11 MOV ?_test?BYTE+06H,#00H MOV ?_test?BYTE+07H,#044H MOV R3,#033H MOV R2,#00H MOV R5,#022H MOV R4,#00H MOV R7,#011H MOV R6,#00H LCALL _test ?C0001: ; while(1){} ; SOURCE LINE # 12 SJMP ?C0001 ; END OF main ; } ; ; void test(shortT param1, shortT param2, shortT param3,shortT param4) RSEG ?PR?_test?MAIN _test: USING 0 ; SOURCE LINE # 15 MOV param3?142,R2 MOV param3?142+01H,R3 ;---- Variable 'param2?141' assigned to Register 'R4/R5' ---- ;---- Variable 'param1?140' assigned to Register 'R6/R7' ---- ; { ; SOURCE LINE # 16 ; shortT param5 =sub2(param1, param2)+ param3; ; SOURCE LINE # 17 LCALL _sub2 MOV A,param3?142+01H ADD A,R7 MOV param5?144+01H,A MOV A,param3?142 ADDC A,R6 MOV param5?144,A ; param4++; ; SOURCE LINE # 18 INC param4?143+01H MOV A,param4?143+01H JNZ ?C0006 INC param4?143 ?C0006: ; } ; SOURCE LINE # 19 RET ; END OF _test ; ; shortT sub2(shortT param1, shortT param2) RSEG ?PR?_sub2?MAIN _sub2: USING 0 ; SOURCE LINE # 21 ;---- Variable 'param2?246' assigned to Register 'R4/R5' ---- ;---- Variable 'param1?245' assigned to Register 'R6/R7' ---- ; { ; SOURCE LINE # 22 ; return param1+param2; ; SOURCE LINE # 23 MOV A,R7 ADD A,R5 MOV R7,A MOV A,R6 ADDC A,R4 MOV R6,A ; } ; SOURCE LINE # 24 ?C0005: RET ; END OF _sub2