HC12: Generating Assembly Code from C++

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

HC12: Generating Assembly Code from C++

6,299 Views
LM
Contributor I
Hi, I'm working on a C++ program in CodeWarrior and I need it to generate the assembly code like in a .asm file.
 
Any help would be greatly appreciated! :smileyhappy:

Message Edited by CrasyCat on 2007-04-13 11:03 AM

Labels (1)
Tags (1)
0 Kudos
9 Replies

960 Views
CrasyCat
Specialist III

Hello

Which processor are you targeting (HC08, EPPC, ColdFire, ....)?

CrazyCat

0 Kudos

960 Views
Glacier
Contributor I
Any one knows how to generate assembly code from C? I am targeting M5235 processor. I am using the command-line complier tool mwccmcf.exe. I canno any option that leads to generate an assembly code.
 
Any idea would be greatly appreciated.
 
Thanks
Glacier
0 Kudos

960 Views
CrasyCat
Specialist III
Hello
 
CodeWarrior for Coldfire Compiler generates directly object code for the ColdFire CPU.
It does not generate an intermediate assembly source file that you could build using the macro assembler tool.
 
If you want to check the assembly code generated by the compiler, you can ask it to disassemble the source file.
If you are building from the IDE you have to follow these steps:
   - Open the project in the IDE
   - Right click on the source file name you want to disassemble and select "disassemble"
      in the drop down menu
   - A new window is opened showing the disassembly listing for the source file.
   - Select File -> Save As to save content of the window to a file.
Using the Panel "ELF Disassembler" from the target setting dialog, you can configure what you want to see in that listing file.
 
If you are building from batch (make file , batch file, ...) you can use the option -S for that.
This will generate a file with extension .s containing the disassembly listing.
 
 I hope this helps.
CrasyCat
0 Kudos

960 Views
Glacier
Contributor I
Thanks.
 
I got some problem and hope you could help me out.
 
In main.c, I have
#include "a.h"                   //a.h is located in .\a_inc 
#include "b.h"                   //b.h is located in .\b_inc
#include "c.h"                   //c.h is located in .\c_inc
 
In make file, I have
 
OBJDIR = ".\obj"
 
SOURCE = ".\src\main.c"
 
DEP_C = ".\a_inc\a.h" \
               ".\b_inc\b.h" \ 
               ".\c_inc\c.h"
 
Proc = "MCF5235"
 
CC=mwccmcf.exe
CFLAGS=-c -proc $(Proc) -g -bool on -inline smart -wchar_t on -opt speed -opt level=0   \
  -cwd include -Ia_inc -Ib_inc -Ic_inc \
  -DDEBUG=1 -model farCode,farData -abi compact -sdata 0 -intsize 4 -a6 -nopic -nopid -list -o >CMP.ERR
"$(OBJDIR)\main.o" : $(SOURCE) $(DEP_C)
       $(CC) $(CFLAGS) $@ $**
       move *.o $(OBJDIR)
 
I got some error message saying that the include files can not be found.
Any help would be highly appreciated.
 
Thanks in advance
Glacier 
0 Kudos

960 Views
CrasyCat
Specialist III

Hello

As far as I remember when you are building from batch you need to define 3 environment variables:
MWCIncludes, MWLibraries, MWLibraryFiles.

MWCIncludes: Define paths where compiler will look for include files (that is the one you are probably missing)

MWLibraries: Defines the paths where the linker will look for object library (in case you do not specify the library full path in the linker command line).

MWLibraryFiles: Defines the name of the library files to link to the application (in case you do not specify all library files on the linker command file).

Can you try that?

CrasyCat

 
0 Kudos

960 Views
LM
Contributor I

We're using a HCS12.

Thanks!

0 Kudos

960 Views
CrasyCat
Specialist III

Hello

The HC12 compiler does directly generate object code for the HC12 CPU. It does not generate an intermediate assembly source file.

The closest you can get to an assembly source file would be to use the options -Lasm & -Lasmc to configure the output of the disassembly listing file.

Using -Lasmc=acpesv will write only decoded instruction and function header in the listing file. Then you can adjust the listing file to get assembly source file.

I hope that helps  

CrasyCat

0 Kudos

960 Views
LM
Contributor I

Do you know by any chance how exactly to download the code to the board.

Thanks!

0 Kudos

960 Views
CrasyCat
Specialist III
Well depends on which Host Target Interface (HTI) you have available.
Usually customers are using Multilink cable from P&E (www.pemicro.com) or InDart Cable for Softec (http://www.softecmicro.com).
 
Then just use the appropriate connection to be able to download code.
 
CrasyCat
0 Kudos