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.
Hello,
under the link: https://developer.arm.com/documentation/ka003813/latest
I found the file “C2ASM2C.zip”.
The following information: The actual code for the assembly module was generated using the SRC pragma and the following C source file:
}
extern void c_func(void); void a_func (void) { c_func(); }
I don't understand yet.
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.
Hi Juergen,Directives are used to control the compilation process:developer.arm.com/.../DirectivesWhat the error message is telling you, that you have to you the SRC directive when using #pragma ASM:developer.arm.com/.../Source--SRC--FileIf you're using uVision instead of the command line: Right-Click the source file -> Options for file -> Generate Assembler SRC FileRene
Rene Koenig said:Right-Click the source file -> Options for file -> Generate Assembler SRC File
And last I looked, you did need a professional edition of the tools for that to actually be available...
Broeker said:And last I looked, you did need a professional edition of the tools for that to actually be available...
The only available edition these days:
https://developer.arm.com/Tools%20and%20Software/Keil%20PK51#Editions