HCS12 Disassembler doesn't show constant variable

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

HCS12 Disassembler doesn't show constant variable

2,865 Views
ssinfod
Contributor IV
Hi, I am currently working with a 9S12DP512 MCU.
 
I have the following code in 'C' and I want to see how the assembler is generating the assembly code for the constant variables. (array, struct, etc...)
 
Code:
#include <hidef.h>      /* common defines and macros */#include <mc9s12dp512.h>     /* derivative information */#pragma LINK_INFO DERIVATIVE "mc9s12dp512"const char array[] = {32,32,32,32,32,32,32,32,32,32,32,33,33,33,33,33,33,33,34,34,34,34,35,35,35,35,36,36,36,37,37,37,38,38,39,39,40,40,41,41,42,42,43,44,44,45,46,47,48,49,50,51,52,53,54,56,57,59,60,62,64,66,68,70,73,76,79,82,85,89,94};int val = 0;void mp_dummy(int in_param){    val = array[in_param];}void main(void) {  /* put your own code here */  EnableInterrupts;  mp_dummy(1);    for(;;) {} /* wait forever */}

 
When I use the disassembler, I don't see any "DC.x" declaration for the const array ? Where is it ? Is there an option to display the generated assembly code for the constant ?
 
Code:
ANSI-C/cC++ Compiler for HC12 V-5.0.24 Build 4047, Feb 17 2004    1:  #include <hidef.h>      /* common defines and macros */    2:  #include <mc9s12dp512.h>     /* derivative information */    3:      4:      5:  #pragma LINK_INFO DERIVATIVE "mc9s12dp512"    6:      7:  const char array[] = {32,32,32,32,32,32,32,32,32,32,32,33,33,33,33,33,33,33,34,34,34,34,35,35,35,35,36,36,36,37,37,37,38,38,39,39,40,40,41,41,42,42,43,44,44,45,46,47,48,49,50,51,52,53,54,56,57,59,60,62,64,66,68,70,73,76,79,82,85,89,94};    8:      9:  int val = 0;   10:     11:  void mp_dummy(int in_param)   12:  {Function: mp_dummySource  : C:\Example\Sources\main.cOptions : -D_HCS12 -D__NO_FLOAT__ -Env"GENPATH=C:\Example;C:\Example\bin;C:\Example\prm;C:\Example\cmd;C:\Example\Sources;C:\CodeWarrior CW12_V3.1\lib\HC12c\lib;C:\CodeWarrior CW12_V3.1\lib\HC12c\src;C:\CodeWarrior CW12_V3.1\lib\HC12c\include" -Env"LIBPATH=C:\CodeWarrior CW12_V3.1\lib\HC12c\include" -Env"OBJPATH=C:\Example\bin" -Env"TEXTPATH=C:\Example\bin" -Lasm="C:\Example\Example-Disassemble_Data\Simulator\ObjectCode\main.c.lst" -Mb -ObjN="C:\Example\Example-Disassemble_Data\Simulator\ObjectCode\main.c.o" -WmsgSd1106  0000 3b           PSHD     13:      val = array[in_param];  0001 e681         LDAB  1,SP  0003 ce0000       LDX   #array  0006 a6e5         LDAA  B,X  0008 b705         SEX   A,X  000a 7e0000       STX   val   14:  }  000d 3a           PULD    000e 0a           RTC      15:     16:  void main(void)    17:  {Function: mainSource  : C:\Example\Sources\main.cOptions : -D_HCS12 -D__NO_FLOAT__ -Env"GENPATH=C:\Documents and Settings\phd\Local Settings\Application Data\Example-Disassemble;C:\Example\bin;C:\Example\prm;C:\Example\cmd;C:\Example\Sources;C:\CodeWarrior CW12_V3.1\lib\HC12c\lib;C:\CodeWarrior CW12_V3.1\lib\HC12c\src;C:\CodeWarrior CW12_V3.1\lib\HC12c\include" -Env"LIBPATH=C:\CodeWarrior CW12_V3.1\lib\HC12c\include" -Env"OBJPATH=C:\Example\bin" -Env"TEXTPATH=C:\Example\bin" -Lasm="C:\Example\Example-Disassemble_Data\Simulator\ObjectCode\main.c.lst" -Mb -ObjN="C:\Example\Example-Disassemble_Data\Simulator\ObjectCode\main.c.o" -WmsgSd1106   18:    /* put your own code here */   19:    EnableInterrupts;  0000 10ef         CLI      20:    mp_dummy(1);  0002 c601         LDAB  #1  0004 87           CLRA    0005 4a000000     CALL  mp_dummy,PAGE(mp_dummy)   21:       22:    for(;;) {} /* wait forever */  0009 20fe         BRA   *+0 ;abs = 0009   23:  }   24: 

 
As you see, there is no ASM code for the "const char array[]" variable. The same thing happen for more complex data type.
 
Any idea ?
 
Thanks
 
 
 
 
 
 
Labels (1)
0 Kudos
Reply
2 Replies

1,148 Views
CompilerGuru
NXP Employee
NXP Employee
The compiler is not generating assembly code at all, it directly issues object files.

The default disassembly file as shown in the OP is the compiler generated listing file, its only purpose is to be read by humans,
it does today only show the code and not constants as you noted.

You can check the constants in the debugger, or you can disassemble the object files.
To disassemble object files, enable the corresponding check box in the compiler preferences
(something like "use the decoder to generate the disassembly listing").
In addition you probably have to enable dumping of the ELF sections in the Importer for HC12 settings too,
as by default the decoder also only shows the disassembled code and does not display the plain section content.
(That's some option in the importer, don't know what it is by heart,I'm usually using "-e -ed -d" but that dumps too much,
that also issues the debug information internals)

Daniel
0 Kudos
Reply

1,148 Views
ssinfod
Contributor IV
I was able to see the rodata (constant) in the file generated by the "decoder".
 
Thanks for the answer.
 
 
 
0 Kudos
Reply