We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, i got this this error while trying to add some assembly code to my C. How do i activate the src-control? Any help is appreciated. Thank you! error C272: 'asm/endasm' requires src-control to be active
1) the error message says it all 2) it is a far better method to put the asm code in an a51 module and call the routine from c Erik
"How do i activate the src-control?" Just read the description of ASM and ENDASM in the Manual; it clearly tells you what to do - you just have to read the whole of the page...
Thank you, guess should have read the manual throughly before posting, sorry. But after that i got a warning saying. *** WARNING L7: MODULE NAME NOT UNIQUE MODULE: INIT.obj (?C_INIT) is this because i included init.a51 in my project? any advice? thanks
"any advice?" Follow Erik's advice - do not use inline assembler! Create a separate assembler module (or modules) and call it from 'C'. Unless you have a specific reason for needing inline assembler - if so, what is it?
Thanks for the help, but i'm sorry to say i'm a little new to this. Is there a thread i can read or particle section in the manual i can refer to regarding creating and linking a a51 module to my c code? Thanks again.
I think the section titled, "Interfacing C to Assembler" might have just a tiny bit to do with it... Hint: the easiest way is to just create a "skeleton" function in 'C', then get the compiler to convert that to assembler by using the SRC directive. You then throw away the original 'C' file, and fill-in your required code in the assembler file generated by the compiler.
Thanks i'll check on that. The hint that you gave are quite hard to understand. Is there any example code, that i can refer to? Thanks anyway.
The hint that you gave are quite hard to understand. Is there any example code, that i can refer to Easy, you male it yourself. Say that you want a delay routine which, as we all know, must be in asm to stay precise. 1) make the routine in C in a separate module 2) compile it 3) throw that C file away 4) use the .lst file generated as your template Erik
Thanks! so, i'm suppose to write any C code, as skeleton? as long as it generate a LST file? then i type in my code in the LST file. Then what? how do i call this LST file from my original C file? I hope i'm making myself clear.
I would consider that recipe unduly hard on the newbie. It's a good deal easier to get started with a C module that you compile to assembly directly, then copy the resulting file *.SRC to *.A51, and start working on that. Once you've got off the ground, remove the *.c and *.src files.
"Thanks! so, i'm suppose to write any C code, as skeleton? as long as it generate a LST file?" No - When Erik said "LST" he should've said "SRC" As it tells you in the Manual, when you compile a 'C' source file, file.c, using the SRC directive, the compiler output is an Assembler source file, file.src. You can then pass this Assembler source to the assembler, and it will assemble it to an object file, file.obj. So what you do is: 1) make the skeleton routine in C in a separate file 2) compile it using the SRC directive 3) throw that C file away 4) use the .SRC file generated as your template (rename it to .A51 if you like) You do this because you can be certain that the Compiler will generate a correct skeleton for a function to be called from 'C' And this is only for the purpose of generating an Assembler function to be called from 'C' - you don't do any of this for 'C' functions to be called from 'C'!
"It's a good deal easier to get started with a C module that you compile to assembly directly, then copy the resulting file *.SRC ..." Yes - I think Erik's just confusing his LST with his SRC?
actually not really "confusing" the two, more like forgetting that difference in the simplification. When I do it, I actually use a "cut" from the .lst pasted into the .a51 (I like the "comments"). This serves me very well, but for a newbie, of course, using .src is the better of the two. Erik
"Thanks! so, i'm suppose to write any C code, as skeleton?" No: not any 'C' code - this is purely for the case where you want to generate a skeleton for a 'C'-callable assembler function.
hmm.. sorry i'm getting confious. ok, here's my main objective. i wrote a delay in asm(desired asm). so in my original 'c' code, i would like to call this delay, when necessary. so, from what i understand : - 1) Firstly, i create a 'skeleton' C code for my desired asm. but what do u exactly mean by that? what should i type in the 'skeleton' C code? 2) let's say i finish step1, i'm suppose to edit the .src code generated. (replace the asm code inside with my desired asm) and save it as .a51 3)delete the .c file and .src 4) next step? again, i'm really appreciated with the help of everyone. Thanks