|
|||||||||||
Technical Support On-Line Manuals Cx51 User's Guide ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Using the SRC DirectiveThe Cx51 Compiler can create assembly source files that you assemble with the A51 Assembler. These SRC files can help you determine the argument passing conventions between C and assembly. To create an assembly source file, you must use the SRC directive with the Cx51 Compiler. For example: #pragma SRC #pragma SMALL unsigned int asmfunc1 ( unsigned int arg) { return (1 + arg); } For this example, the compiler generates the following SRC file. ; ASM1.SRC generated from: ASM1.C NAME ASM1 ?PR?_asmfunc1?ASM1 SEGMENT CODE PUBLIC _asmfunc1 ; #pragma SRC ; #pragma SMALL ; ; unsigned int asmfunc1 ( RSEG ?PR?_asmfunc1?ASM1 USING 0 _asmfunc1: ;---- Variable 'arg?00' assigned to Register 'R6/R7' ---- ; SOURCE LINE # 4 ; SOURCE LINE # 6 ; return (1 + arg); ; SOURCE LINE # 7 MOV A,R7 ADD A,#01H MOV R7,A CLR A ADDC A,R6 MOV R6,A ; } ; SOURCE LINE # 8 ?C0001: RET ; END OF _asmfunc1 END In this example, note that the function name, asmfunc1, is prefixed with an underscore character signifying that arguments are passed in registers. The arg parameter is passed using R6 and R7. The following example shows the assembly source generated for the same function with register parameter passing disabled by the NOREGPARMS directive. ; ASM2.SRC generated from: ASM2.C NAME ASM2 ?PR?asmfunc1?ASM2 SEGMENT CODE ?DT?asmfunc1?ASM2 SEGMENT DATA PUBLIC ?asmfunc1?BYTE PUBLIC asmfunc1 RSEG ?DT?asmfunc1?ASM2 ?asmfunc1?BYTE: arg?00: DS 2 ; #pragma SRC ; #pragma SMALL ; #pragma NOREGPARMS ; ; unsigned int asmfunc1 ( RSEG ?PR?asmfunc1?ASM2 USING 0 asmfunc1: ; SOURCE LINE # 5 ; SOURCE LINE # 7 ; return (1 + arg); ; SOURCE LINE # 8 MOV A,arg?00+01H ADD A,#01H MOV R7,A CLR A ADDC A,arg?00 MOV R6,A ; } ; SOURCE LINE # 9 ?C0001: RET ; END OF asmfunc1 END Note in this example that the function name, asmfunc1, is not prefixed with an underscore character and that the arg parameter is passed in the ?asmfunc1?BYTE segment. | ||||||||||
|
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.