Hard Code assembler in C

Discussion in 'Embedded Systems and Microcontrollers' started by jcia, Jan 25, 2010.

  1. jcia

    Thread Starter New Member

    Dec 9, 2008
    4
    0
    Hi All,

    I am trying to put a series a branch instructions in a certain part of the flash memory, I already made the needed changes to put values on that part of memory, the problem is, I need to put a branch instruction to another address but right now the way I do it is declare a constant long int value with and assign the HEX value of the ASM, let say I want to put asm("mov.w &0xF3DA, PC") so give the value 0xF3DA4210 which translates into BR &0xF3DA, but it seems weird that I have to hard code the value instead of writing the inline asm. The problem is, I need that branch instruction to be there before the program runs and I don't know how to put define the ASM instruction to reside on that location. The way I do it with the constant is like this:

    #pragma DATA_SECTION(_B_INT45,".B_INT_45")
    const unsigned long int _B_INT45 = 0xF3DA4210;

    .B_INT_45 is a section in the linker file which is the part of memory to which I want to save the constant value. What I thought I could do was something like this:

    #pragma CODE_SECTION(<what to put here>,".B_INT_45")
    asm(" mov.w &0xF3DA,PC");

    But that pragma is to define function, not a single instruction. I hope I made myself more or less clear on what I need. Is hardcoding the value my only chance?, I also thought of just creating an assemble file with ORG and the branch instruction, but my Compiler/Linker (TI CCS) doesn't allow that, just inline assembly.

    Any help would be appreciated.
     
  2. rjenkins

    AAC Fanatic!

    Nov 6, 2005
    1,015
    69
    What device are you working with and what compiler are you using?

    Every compiler uses different techniques to things like this.
     
  3. jcia

    Thread Starter New Member

    Dec 9, 2008
    4
    0
    Hi,
    I am using the CC430 based on the MSP430 microcontroller and my compiler is Texas Instruments Code Composer Studio, which doens't let me mix 1 file in assembler with my project in C.

    Thanks.
     
  4. rjenkins

    AAC Fanatic!

    Nov 6, 2005
    1,015
    69
    As far as I can see, the only location that MPU needs values at fixed rom locations is for the interrupt & reset vectors, and they are are just the 16 bit target addresses not complete instructions.

    More info of what you are trying to achieve could help?
     
Loading...