Extended inline assembly with GCC in CodeWarrior

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Extended inline assembly with GCC in CodeWarrior

Extended inline assembly with GCC in CodeWarrior

Hello community!

 

Nowadays assembly language is being eradicated for embedded systems, and other alternatives such as C/C++ are widely used.

 

However we know sometimes it becomes necessary to get to "the bones" of our MCU, even from a C project, and play directly with its registers and status flags. Some use cases are:

 

- Startup code

- Bootloaders

- Time critical routines

- Benchmarking

 

It is common to include assembly code using the "asm()" style. But what if I want to use my C variables in the assembly code? or if I want to call an assembly subroutine from a C project? The GCC toolchain integrated with CodeWarrior brings this flexibility.

 

In the attached pdf document you can find an overview and explanation of this extended assembly feature. Also attached a pair of example projects tested with CW v10.6 using KL25Z128 and K60DN512.

 

Thanks to Abigail Inzunza Lopez for helping with this.

 

I hope you like it !

Labels (1)
Attachments
%3CLINGO-SUB%20id%3D%22lingo-sub-1118871%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EExtended%20inline%20assembly%20with%20GCC%20in%20CodeWarrior%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1118871%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%20community!%3C%2FP%3E%3CP%20style%3D%22min-height%3A%208pt%3B%20padding%3A%200px%3B%22%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENowadays%20assembly%20language%20is%20being%20eradicated%20for%20embedded%20systems%2C%20and%20other%20alternatives%20such%20as%20C%2FC%2B%2B%20are%20widely%20used.%3C%2FP%3E%3CP%20style%3D%22min-height%3A%208pt%3B%20padding%3A%200px%3B%22%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHowever%20we%20know%20sometimes%20it%20becomes%20necessary%20to%20get%20to%20%22%3CEM%3Ethe%20bones%3C%2FEM%3E%22%20of%20our%20MCU%2C%20even%20from%20a%20%3CSTRONG%3EC%3C%2FSTRONG%3E%20project%2C%20and%20play%20directly%20with%20its%20registers%20and%20status%20flags.%20Some%20use%20cases%20are%3A%3C%2FP%3E%3CP%20style%3D%22min-height%3A%208pt%3B%20padding%3A%200px%3B%22%3E%26nbsp%3B%3C%2FP%3E%3CP%3E-%20Startup%20code%3C%2FP%3E%3CP%3E-%20Bootloaders%3C%2FP%3E%3CP%3E-%20Time%20critical%20routines%3C%2FP%3E%3CP%3E-%20Benchmarking%3C%2FP%3E%3CP%20style%3D%22min-height%3A%208pt%3B%20padding%3A%200px%3B%22%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20is%20common%20to%20include%20assembly%20code%20using%20the%20%22%3CSTRONG%3Easm()%3C%2FSTRONG%3E%22%20style.%20But%20what%20if%20I%20want%20to%20use%20my%20C%20variables%20in%20the%20assembly%20code%3F%20or%20if%20I%20want%20to%20call%20an%20assembly%20subroutine%20from%20a%20C%20project%3F%20The%20GCC%20toolchain%20integrated%20with%20CodeWarrior%20brings%20this%20flexibility.%3C%2FP%3E%3CP%20style%3D%22min-height%3A%208pt%3B%20padding%3A%200px%3B%22%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20the%20attached%20pdf%20document%20you%20can%20find%20an%20overview%20and%20explanation%20of%20this%20extended%20assembly%20feature.%20Also%20attached%20a%20pair%20of%20example%20projects%20tested%20with%20CW%20v10.6%20using%20KL25Z128%20and%20K60DN512.%3C%2FP%3E%3CP%20style%3D%22min-height%3A%208pt%3B%20padding%3A%200px%3B%22%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20aria-label%3D%22Info%22%20class%3D%22emoticon-inline%20emoticon_info%22%20style%3D%22height%3A16px%3Bwidth%3A16px%3B%22%3E%3C%2FSPAN%3E%20Thanks%20to%20%3CA%20_jive_internal%3D%22true%22%20data-containerid%3D%22-1%22%20data-containertype%3D%22-1%22%20data-objectid%3D%22228324%22%20data-objecttype%3D%223%22%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Fpeople%2Fabigailinzunza%22%20target%3D%22_blank%22%3EAbigail%20Inzunza%20Lopez%3C%2FA%3E%20for%20helping%20with%20this.%3C%2FP%3E%3CP%20style%3D%22min-height%3A%208pt%3B%20padding%3A%200px%3B%22%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20hope%20you%20like%20it%20%3CSPAN%20aria-label%3D%22Happy%22%20class%3D%22emoticon_happy%20emoticon-inline%22%20style%3D%22height%3A16px%3Bwidth%3A16px%3B%22%3E%3C%2FSPAN%3E!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1118871%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3EGeneral%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
No ratings
Version history
Last update:
‎09-30-2014 11:29 AM
Updated by: