I wrote a C extension file program where my function is declared with C langage with parameters and writen in ASM langage: int MyFunc(int param1, int param2) { #asm ... ... #endasm } From other files, the call is working but I have WARNING in compilation of my assembly file on param1 and param2 because I don't use them directly but I use register R4 to R7. The program is working but I don't understand how can I write the program to don't have any warning.
First you have to set up some kind of fake C file... here I will call it "xxx_prot.c" because you only set up kind of function skeletons. It looks like this: xxx_prot.c: #pragma SRC unsigned char func1( unsigned char parameter ) { unsigned char loc_var_func1; // some local variable loc_var_func1 = 0; return loc_var_func1; } void func2( void ) { } Then you compile this file (the SRC pragma is important). Instead of an object file, you get a file called xxx_prot.src. It is an assembler program and looks looks like this: NAME XXX_PROT ?PR?_func1?XXX_PROT SEGMENT CODE ?XD?_func1?XXX_PROT SEGMENT XDATA OVERLAYABLE ?PR?func2?XXX_PROT SEGMENT CODE PUBLIC func2 PUBLIC _func1 RSEG ?XD?_func1?XXX_PROT ?_func1?BYTE: parameter?040: DS 1 ; #pragma SRC ; ; unsigned char func1( unsigned char parameter ) { RSEG ?PR?_func1?XXX_PROT _func1: USING 0 MOV DPTR,#parameter?040 MOV A,R7 MOVX @DPTR,A ; SOURCE LINE # 3 ; unsigned char loc_var_func1; // some local variable ; ; loc_var_func1 = 0; ; SOURCE LINE # 6 ;---- Variable 'loc_var_func1?041' assigned to Register 'R7' ---- CLR A MOV R7,A ; return loc_var_func1; ; SOURCE LINE # 7 ; } ; SOURCE LINE # 8 ?C0001: RET ; END OF _func1 ; ; void func2( void ) { RSEG ?PR?func2?XXX_PROT func2: ; SOURCE LINE # 10 ; } ; SOURCE LINE # 11 RET ; END OF func2 END As you can see the parameters are commented and the required segments already have the right names and what you need to be imported by other c-files is declared public. You can copy this into your destination assembler file (e.g. xxx.a51) and "fill in" your code. Then you write a header file (e.g. xxx.h), like if you would do that for the xxx_prot.c. That's it. It is not very difficult. I woudl recommend to name the "prototype c file" different from the actual assembler file.