?
Solved

How to diab 4.2b powerpc family asm macros work?

Posted on 2007-08-01
2
Medium Priority
?
1,526 Views
Last Modified: 2013-12-13
My Embedded Application runs on Motorola PowerPC MPC555 Microcontroller.  The cross compiler is Diab 4.2b.   Following is a macro for raising and restroing interrupts in MPC555.

asm unsigned int iplm_raise(void)
{
! "r3"

    mfmsr       r3
    mtspr       81,r1
}

asm void iplm_restore(const unsigned int mask)
{
%reg mask ;
! "r12"

    mfmsr       r12
    rlwimi      r12,mask,0,16,16
    mtmsr       r12
}

The calls to these asm macros are as follows:

unsigned_32 mask;

RAISE_IPLM(mask) ;

/* critical section of code */

RESTORE_IPLM(mask) ;

Following are links:

1) Link to MPC555 Manual - pages of interest are 3-20 to 3-23
http://www.freescale.com/files/microcontrollers/doc/user_guide/MPC555UM.pdf?fsrch=1

2) Link to MPC555 Instruction Set - Section 9 is of interest
http://www.freescale.com/files/microcontrollers/doc/ref_manual/RCPURM.pdf?fsrch=1

3)  I could not find a link to Diab 4.2b Target User's Manual for PowerPC Family. However, I have soft copy
of this manual.  How can I attach it?  This manual explains asm macros.

Please explain above two macro in detail, line by line.  Thanks.



0
Comment
Question by:naseeam
2 Comments
 
LVL 1

Author Comment

by:naseeam
ID: 19619001
Diab Target User's Manual for Power PC Family should be at www.windriver.com.  A registration will be required in order to access the document.
0
 
LVL 8

Accepted Solution

by:
Anthony2000 earned 2000 total points
ID: 19680673
asm unsigned int iplm_raise(void)  // assembler macro iplm_raise returning a value of type unsigned int
{
! "r3"                          //   register list is an optional list of scratch regs, enables the compiler to generate more efficient code

    mfmsr       r3          //  contents of the MSR are placed into R3
    mtspr       81,r1      //  I didn't exactly understand what this instruction actually does, I would need more time to study the micro's details
                                  // if R1 contains the return value, then this is what the caller will get for the unsigned int value
}

asm void iplm_restore(const unsigned int mask)
{
%reg mask ;      // describes the parameter mask, specifying "%reg in front of mask means that the parameter is in a non-scratch register.
! "r12"               // optional list of scratch registers, enables the compiler to generate more efficient code.

    mfmsr       r12
    rlwimi      r12,mask,0,16,16
    mtmsr       r12
}

Generally these macros look like they disable/enable interrupts? Is this what you want or do you not understand the actual assembly language instructions?
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question