Can any one tell me how to mix C and Assembly in kiel in a single file?
Thanks in advance
All the manuals are available online: http://www.keil.com/support/man/
I can't find the RealView manuals online.
I'm trying to add some assembly code to a RealView ARM (AT91SAM7S) project and am not getting very far. I found the "Interfacing C and Assembly" advanced programming topic, but am not sure it's applicable, since it's under a CARM (rather than a RealView) heading. I tried copying the example code from that topic and putting it into my RealView project, but I get errors out the kazoo starting on the first line. I searched for "interfacing" in the RealView Assembler Guide, but it's not there. I also tried putting #pragma SRC at the top of a small C file to see if that would help, but in RealView, it doesn't look like that pragma is supported, and I haven't been able found a pragma that looks like it replaces the SRC pragma yet (bummer!).
Can anyone point me to (1) where the RealView manuals are online, and (2) to a sample RealView compatible (bare bones, small, simple) assembly file that I can use as a template to help get started (maybe for something as simple as a function that just toggles the state of an I/O pin), and (3) an app note (or something) that shows how to interface C and assembly with the RealView tools?
EDITORIAL COMMENT: I sure wish I would've received hard copy manuals from KEIL when I upgraded to RealView. Nothing like kicking back in a comfortable recliner with my feet propped up for some serious reading. Reading PDF files on a PC is no fun for me. Can't put bookmarks in them, can't dog-ear pages, can't highlight text or add annotations, can't stuff prinout's in them... I could go on and on. Printing out a 464 page PDF file is not an option for me.
Okay... here's something that seems to work. Simply put this code into a .S file and add it to your project.
AREA |.text|, CODE, READONLY ARM PIOA_SODR EQU 0xFFFFF430 ; set output data register PIOA_CODR EQU 0xFFFFF434 ; clr output data register IOPIN_PA8 EQU 0x1<<8 ; I/O pin PA8 (1 << 8) ALIGN myfunc FUNCTION EXPORT myfunc MOV R1,#IOPIN_PA8 LDR R0,=PIOA_SODR STR R1,[R0,#0] LDR R0,=PIOA_CODR STR R1,[R0,#0] BX LR ENDFUNC END
Then add the below line to the C file you want to call 'myfunc' from,
extern void myfunc(void);
and then just call
myfunc();
from your C file. Works for me. Of course, there might be more to it, but this seems to have been enough for me to create a function in a RealView compatible ASM file that just toggles an I/O pin that I can then call from a C file in a RealView project. Dave :-)
Hello Dave,
Glad to see that you are still around. Gotta say, though, that you really need to get out more and have some fun ;-)
ARM? Now I know why I haven't heard from you in ages. What happened? Did you change jobs, or just architectures?
Take care.
Regards,
Mark Fabiny Infineon Technologies