CrossWorks AVR 1.4 - mixed code C/assembler

Comments

2 comments

  • Avatar
    Robert Wood

    Yes, it works similarly. Here's how I did it:

    Create a .asm file like this:

            .code
            .even
            .opt
            .export _LSBSwap

            .export _AllIntsOn
            .export _AllIntsOff

    _LSBSwap PROC

     

    ; Code goes here, any labels have a colon after them.              
          endproc

     

    Put that in your project and in your C file:

     

    extern unsigned char LSBSwap(unsigned char);

     

    And to use it in the code:

     

    FramesUnits = LSBSwap(FrameIn[0]);    // LSBSwap puts bits in correct order

     

    IIRC one byte gets passed into r23 a word into r23/r22 etc. I might be wrong about that. Might want to play with it and see how it works.

     

    Don't fotget to push and pull any registers you use! :~)

     

    Cheers,

     

    Rob

     

     

     

     

     

     

     

    0
    Comment actions Permalink
  • Avatar
    Robert Wood

    Sorry, ignore        

    .export _AllIntsOn
    .export _AllIntsOff

    That was for a second and third routine.

     

    0
    Comment actions Permalink

Please sign in to leave a comment.