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.
I do my main program in c. I want to call in this c program a fonction (procedure) in assembler. How can I do this ? with a #include <xxxx.a51> ? how can I do a mix program with c and assembler procedure?
thanks for your answer.
the easy way
write a 'skeleton' function in C compile it using SRC use the generated assembler as a base for your code
Erik
thanks you for your answer,
but when I modify the option of my main program (with a double click on SRC and assembler), I have 2 warnings:
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL SYMBOL: ?C_START MODULE: STARTUP.obj (?C_STARTUP)
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL SYMBOL: ?C_START MODULE: STARTUP.obj (?C_STARTUP) ADDRESS: 0834H
and this warning came without any assembler code in my programm
what can I do for this?
thanks.
this warning came without any assembler code
Well, then, better add some assembler code to your program. I'd suggest the file STARTUP.A51 in the lib directory.
This file is the equivalent of the C runtime system, which in the case of C51 is pretty minimal. The provided code mostly initializes RAM to zero and jumps to main. ?C_STARTUP is the entry point to this code. (?C_START is effectively main()).
If you use global initializers, you'll also want INIT.A51, which copies the initializer from code memory to the RAM space at init time.
"I'd suggest the file STARTUP.A51 in the lib directory. This file is the equivalent of the C runtime system"
No, that's not true!
STARTUP.A51 is the user-customisable part of the 'C' startup - it then calls the rest of the startup which, in turn, calls main().
"and this warning came without any assembler code in my programm."
The trouble is, you have convered your entire project to assembler. This means that the Linker doesn't know that it should be a 'C' project, and doesn't automatically include the necessary 'C' runtime support.
If you search for those messages in the knowledge base, you will find more detailed descriptions.
"what can I do for this?"
Don't convert the entire project to assembler!
Have just one file that contains the "skeleton" for just one function, and apply the SRC directive to that file only.
the one that works for me when doing 'funny stuff' mixing C and assembler
void assembler_main(void) void main(void) {
assembler_main(): }
with that you can - when you FULLY know what you are doing - have C calling assembler and assewmbler calling C
sir erak
you give good idea for simple code
i do assssemblery code in startup go call c from that
main is not need you know it is only convention
you want i give you sample????
main is not need you know it is only convention it IS, unless you code assembler from scratch. The 'assembler' generated by the SRC still depend on all the C 'amenities' that startup and the next 'automatic', the name of which I can not think of right now, create.
sir erac
it IS, unless you code assembler from scratch
you is wrong you be know!!!!
startup has line
LJMP ?C_START
this is be line to calll main
remove ?C_START you no need main
you caall can then
LJMP any_asm_or_c_function_you_be_wanting
i know you see i try and workk well
you now want me send yo sample code to see?????
i not want money from friend erac for code!!!!
Modifying the startup code to jump to an application completely written in assembler does not make sense.
If I am then why does what I have work and yours not?
DO IT
what is your problem trying a simple thing that will take you 5 minutes instead of discussing this for hours?
"Modifying the startup code to jump to an application completely written in assembler does not make sense."
why you not think so?????
if appplication is all assemblere you must break in modules
i told it is good structuure you know more modules
begin module is startup
but i not say all assembllerer!!!!!
you call assembleerc in start and c in any order i say
plz think consept is good!!!???!!!
sorry
i sit in corner wear my hat and think good
I am sorry, I have made the mistake of responding to what you asked him