As mentioned in my post about the memory view: I want to go down to the bits and bytes. Same applies to programming: I want to get down to the assembly instruction level, the heavy metal world :-).
Although it sounds a little bit weird in the age of object-oriented programming and C++, but sometimes I need to do ‘assembly level only’ programming on a 32bit controller too. CodeWarrior for MCU offers assembly only project creation for all the 8bit microprocessors, but for the 32bit including the ColdFire it assumes that the usual way is to use C and C++? Yes, it offers C and C++ and you can add assembly files. But how to do assembly only?
Luckily it is not hard to transform a normal high level language project into an assembly only one:
- Create a normal high level language project.
- Remove all the files you do not need.
- Add the heavy metal stuff.
- Have fun!
Ok, point 4 above will requires that I have to do really everything in assembly, but hey, that’s what I have asked for, right ;-)?
I’m illustrating the steps for the MCF51JM128. It works the same way for other controller types too.
- Start the new project wizard in CodeWarrior for MCU using the menu File > New > Bareboard project.
- Specify a project name, press Next.
- Select the device you want to use, e.g. MCF51JM128.
- At this time I’m going with the defaults, so I can press Finish.
This will create a project like the one shown below:
All the parts marked in yellow are things used for the high level language environment, in my case for ANSI C: header files with registers and derivative information, startup code to initialize global variables, exceptions table and the file with the main() application starting point.
The next step is to remove all these files, as I want to do everything in assembly. This gives me following structure:
I keep the files for the debugger, I’m not ready for a blind flight (yet). I could remove the empty folders too. But in that case I need to remove the folder names from the compiler/assembler project settings too, as otherwise I will get warnings from the compiler/assembler complaining about folders not found. So I keep them, as I can put useful things into the folders later.
What is missing is the assembly source file where I can to do the heavy metal stuff. For this I select the Sources folder (or any place in the project where I want to create the new file), use the context menu New > Source File. This will prompt a dialog where I can enter the information for my new file:
As Template I can specified <None>, otherwise it will add some high language headers to the file which I could remove later. I use an extension supported by the assembler. Usually this .asm or .s, and I prefer .asm over .s.
Now all what I need is to enter at least a minimal skeleton: declaring the external symbol __startup as application starting point for the linker with the .global directive. .text starts my code section and .end marks the end of my file. Then added some very little code to get things rolled:
No I build my project and hopefully the assembler and linker are happy. Then I download to the target and hopefully I have made my first baby step in that little project.
Of course I will need to add all the other useful stuff: vector table, processor and register initialization, and finally the putting in all my blood, sweat and assembly.
But this is what I aimed for, right?
Happy assembling 🙂