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

Compiling error for calling assembly function from C

Dear C8051 Gurus and Experts.

New to the C8051 so just bought the C8051F120DK (Development Board) to learn. My question is can the C51 compiler V7.05 which comes with the development kit, handles well when you mixed C with assembly code? Here, mixing C with assembly code means that my Main function is written in C and it called a subroutine (in a seperate file) which is written in assembly.

Here is how I tried to do it (2-step process).

step 1: Wrote a skeleton code for the subroutine in C and compiled it with the main function using directive #pragma src to obtain the assembly code.
in the main program:

#pragma src
.
.
<include FIR.h>
.
.
external short FIR(short *databuf_ptr,short *hbuf_ptr,int Taps);
.
.
main(void)
.
FIRout = FIR(&databuf[0],&hbuf[0],Taps1]);
.
end

in the subroutine (FIR.h file)

short FIR(short*databuf_ptr,short *hbuf_ptr, int Taps)
{
short firout;

return firout;
}

I compiled the main function with the subroutine to generate the assembly code.

Step 2. Went into the assembly code generated in step 1 and cutout the assembly code section for the FIR subroutine and pasted on a blank sheet in the notepad. Saved the the sheet with the assembly code (for the FIR subroutine only.) as FIR.asm

Then went back to the Main routine and replaced the #include <FIR.h> with include <FIR.asm> and removed the #pragma src. Ran the compiler again and got an error from the compiler. The compiler points to the first line of the assembly code in the subroutine FIR.asm and said that 'missing ";" before "?"'. Have followed advices on this thread and in the knowledge base but it has not help. Your help and advice is much appreciated.

Thanks,

Parents Reply Children
No data