How to diab 4.2b powerpc family asm macros work?

Posted on 2007-08-01
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 */


Following are links:

1) Link to MPC555 Manual - pages of interest are 3-20 to 3-23

2) Link to MPC555 Instruction Set - Section 9 is of interest

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.

Question by:naseeam

    Author Comment

    Diab Target User's Manual for Power PC Family should be at  A registration will be required in order to access the document.
    LVL 8

    Accepted Solution

    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?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    Title # Comments Views Activity
    bigHeights  challenge 13 43
    userCompare  challenge 3 51
    wordappend challenge 8 44
    How does Google get such fast response times? 5 64
    RIA (Rich Internet Application) tools are interactive internet applications which have many of the characteristics of desktop applications. The RIA tools typically deliver output either by the way of a site-specific browser or via browser plug-in. T…
    Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
    The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
    The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now