"dbug" macro problems

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

"dbug" macro problems

7,550 Views
nanoGeek
Contributor I
I am trying to port dbug to a 5407 board and have run into a snag regarding macros.
 
The following snippet is representative of the macros included in my dbug source:
 
/**********************************************************************/
/*  Macro for computing address of on-chip peripheral registers       */
/**********************************************************************/
 
#define Mcf5407_addr(IMMP,OFFSET)   ((void *)&((uint8 *)IMMP)[OFFSET])
/**********************************************************************/
/*  Macros for accessing the on-chip I/O resources                    */
/**********************************************************************/
 
#define Mcf5407_iord(IMMP,OFFSET,SIZE)      \
   *(volatile uint ## SIZE *)(Mcf5407_addr(IMMP,OFFSET))
#define Mcf5407_iowr(IMMP,OFFSET,SIZE,DATA)  \
   *(volatile uint ## SIZE *)(Mcf5407_addr(IMMP,OFFSET)) = (DATA)
//
//
//
#define MCF5407_CS_CSAR0        (0x0080)
#define MCF5407_WR_CS_CSAR0(IMMP,DATA)  \
   Mcf5407_iowr(IMMP,MCF5407_CS_CSAR0,16,DATA)
However, when I compile and examine the object code, I notice that the addressed offsets are 2x too big (the compiler is using (d16,Ax) addressing where Ax = the MBAR address in this case).  For example, the MCF5407_CS_CSAR0 offset compiles as 0x0100 instead of 0x0080.  I'm new to C macros and I'm stumped as to what is wrong.
 
Note that these macros are as-is from the dbug source that I aquired.
 
Thanks,
 
Joe
 
Labels (1)
0 Kudos
7 Replies

1,249 Views
CompilerGuru
NXP Employee
NXP Employee
For macro topics, it always a good idea to check the preprocessor output.
Appart from this, can you provide a compilable code snippet, the compiler version, any special setup (options, prefs) the output you see and a description of what should be different.

I did actually compile your macros with one setup, but the outcome was fine, as far as I can tell.

Daniel
0 Kudos

1,249 Views
nanoGeek
Contributor I

this is the pre-processor output:

*(volatile uint32 *)(((void *)&((uint8 *)imm)[(0x0090)])) = (0x00070001) ;

and this is the resulting object code:

0x000000CE  0x206F0004               movea.l  4(a7),a0
0x000000D2  0x203C00070001           move.l   #458753,d0            ; '....'
0x000000D8  0x21400120               move.l   d0,288(a0)

Note that the offset of 0x120 in the last move.l is the same as (0x90 << 1).

0 Kudos

1,250 Views
CrasyCat
Specialist III

Hello

Which version of CodeWarrior are you using?

I am using CodeWarrior for Coldfire V6.2 and disassembling following source code

typedef unsigned long uint32;
typedef unsigned char uint8;

char imm[80];

int main()
{
 *(volatile uint32 *)(((void *)&((uint8 *)imm)[(0x0090)])) = (0x00070001) ;

gives following code:

0x00000000                    _main:
;                             main:
0x00000000  0x4E560000               link     a6,#0
;
;   17:  *(volatile uint32 *)(((void *)&((uint8 *)imm)[(0x0090)])) = (0x00070001) ;
;   18: 
;   19: 
;   20: 
;
0x00000004  0x41F900000000           lea      _imm,a0
0x0000000A  0x203C00070001           move.l   #458753,d0            ; '....'
0x00000010  0x21400090               move.l   d0,144(a0)
;
Which looks correct.

CrasyCat

0 Kudos

1,250 Views
nanoGeek
Contributor I
I've attached the installed items file (in pdf) showing what I have for CW.
0 Kudos

1,250 Views
CrasyCat
Specialist III

Hello

It looks like you are using a beta version of the Coldfire tools.
The official CodeWarrior for Coldfire V6.0 had build number 10. You are using build number 8.

Official release of CodeWarrior for Coldfire V6.0 Build 10 is also generating following code:

0x00000004  0x41F900000000           lea      _imm,a0
0x0000000A  0x203C00070001           move.l   #458753,d0            ; '....'
0x00000010  0x21400090               move.l   d0,144(a0)
;

So I would kindly ask you to install an official version of the tool.

CrasyCat

0 Kudos

1,250 Views
nanoGeek
Contributor I

Daniel,

the macros I've shown do compile, but the offsets weren't correct (as far as I could tell).  What were your results?

Where does one find the preprocessor output?  I am running CW 6.0.  I can provide my project file if that would be of any help.

Thanks,

Joe

 

0 Kudos

1,250 Views
CrasyCat
Specialist III
Hello
 
 If you are building from the IDE:
     - Click with the right mouse button on the file name within the project window
     - In the drop down menu select Preprocess. A new edit window showing the
       preprocessor output will be opened.
 
 If you are building from Batch
    - Add option -E  to see preprocessor output.
 
CrasyCat
0 Kudos