This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

mixing C and Assembly


Hello,I'm using the soft-core Cortex-M0,and keil uvision 5,
I have initialized the registers used for my ADDER : 0x59000000--->059FFFFFF
and run simulation using vivado simulator
when i tried that with assembly the simulaion worked correctly,but if i tried to add c code with the assembly it doesn't work:
this the code:
-----------------------------------------------------------------------------------------


; Vector Table Mapped to Address 0 at Reset

                                                PRESERVE8
                                THUMB

                                        AREA    RESET, DATA, READONLY
                                        EXPORT  __Vectors
__Vectors                       DCD             0x0000FFFC
                                        DCD             Reset_Handler
                                        DCD             0
                                        DCD             0
                                        DCD             0
                                        DCD             0
                                        DCD             0
                                        DCD             0
                                        DCD             0
                                        DCD             0
                                        DCD             0
                                        DCD     0
                                        DCD             0
                                        DCD             0
                                        DCD     0
                                        DCD             0

                                        ; External Interrupts

                                        DCD             0
                                        DCD             0
                                        DCD             0
                                        DCD             0
                                        DCD             0
                                        DCD             0
                                        DCD             0
                                        DCD             0
                                        DCD             0
                                        DCD             0
                                        DCD             0
                                        DCD             0
                                        DCD             0
                                        DCD             0
                                        DCD             0
                                        DCD             0

                AREA |.text|, CODE, READONLY
;Reset Handler
Reset_Handler   PROC
                GLOBAL Reset_Handler
                ENTRY
                                IMPORT  __main
                LDR     R0, =__main
                BX      R0
                ENDP

                            EXPORT func
func            FUNCTION
                 ENDFUNC


                                ALIGN           4
                        END



-------------------------------------------------------------------------------------
and the code C :

#include <stdlib.h>
#include <stdio.h>
#include <rt_misc.h>
#define AAA     (*((volatile unsigned long *)(0x59000000UL)))
extern void func_x()
{
        unsigned int volatile * const port1 = (unsigned int *) AAA;
         int a = 0x11111111;
  *port1 = a;
                }

int main(void) {
        func_x();
return 0;
}