Good day,
I would like to use an existing function with assembly code in a C program.
Unfortunately I don't know the exact syntax for this.
Of course, I also searched for it on the Internet (I probably didn't use the right search terms):
I found: “You have to read the documentation”.
I did that too and found:
1. at: https://developer.arm.com/documentation/101655/0961/Cx51-User-s-Guide/Compiling-Programs/Directives/Reference/ENDASM-Compiler-Directive?lang=en
The example:
extern void test(); void main (void) { test(); #pragma asm JMP$; endless loop #pragma endasm }
but it's not understandable to me.
If I in my C program
#pragma asm JMP$; endless loop #pragma endasm
insert,
I get the following error message:
lcd_at89C51_2.c(113): error C272: 'asm/endasm' requires src-control to be active
lcd_at89C51_2.c(115): error C272: 'asm/endasm' requires src-control to be active
Of course I have completed this point (it is the default)
None. µVision 1. Right click on the file in the Project Window — Files tab 2. Choose Options for... to open Options — Properties page 3. Enable Generate Assembler SRC file 4. Enable Assemble SRC file.
I understand the example shown to be the assembler code of an external file (extern void test ();) ?
If so, what should this file look like and with what ending (file.?)
2. at: https://developer.arm.com/documentation/dui0375/g/Compiler-specific-Features/--asm
This post doesn't help me either.
It seems to be possible that you can insert assembly code into a C program and compile it, but it would be nice for me if I could do this in a working example.
Kind Regards
Juergen B.
One thing isn't quite clear from your description of what you're trying to do: do you want assembly code in a C program, or inside a C source file?The former is a whole lot easier than the latter, because it can usually be achieved even without explicit compiler support: just write a dummy implementation of that function in C, compile it to assembler source, copy that and then fill in the ultra-special things you think you can only do in assembler.
The latter is usually referred to as "in-line assembly", and is entirely compiler-specific. You really will have to read essentially all the applicable documentation to do it without risking the stability of the surrounding C code.