This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

使用CCS编译,怎样在主程序为C语言中调用汇编子程序



#include <stdio.h>

#if defined(rvmdk) || defined(__ARMCC_VERSION)
__asm void
SysCtlDelay(uint32_t ui32Count)
{
subs r0, #1;
bne SysCtlDelay;
bx lr;
}
#endif
int main(void)
{
printf("Hello World!\n");
//SysCtlDelay();//**************这里怎样处里呢?
return 0;
}

上边的程序在CCS中编译通过的,但是我怎样调用子程序,按照以前的方式编译报错,请各位大哥指导!谢谢!

  • //*****************************************************************************
    //
    // rgb.c - Evaluation board driver for RGB LED.
    //
    // Copyright (c) 2012-2014 Texas Instruments Incorporated.  All rights reserved.
    // Software License Agreement
    // 
    // Texas Instruments (TI) is supplying this software for use solely and
    // exclusively on TI's microcontroller products. The software is owned by
    // TI and/or its suppliers, and is protected under applicable copyright
    // laws. You may not combine this software with "viral" open-source
    // software in order to form a larger program.
    // 
    // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
    // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
    // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
    // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
    // DAMAGES, FOR ANY REASON WHATSOEVER.
    // 
    // This is part of revision 2.1.0.12573 of the EK-TM4C123GXL Firmware Package.
    //
    //*****************************************************************************
    
    #include <stdint.h>
    #include <stdbool.h>
    #include "driverlib/sysctl.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "driverlib/debug.h"
    #include "driverlib/fpu.h"
    #include "driverlib/gpio.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/rom.h"
    #include "driverlib/uart.h"
    #include "utils/uartstdio.h"
    #include <stdbool.h>
    #include <stdint.h>
    #include "inc/hw_ints.h"
    #include "inc/hw_nvic.h"
    #include "inc/hw_sysctl.h"
    #include "inc/hw_types.h"
    #include "inc/hw_flash.h"
    #include "driverlib/cpu.h"
    #include "driverlib/debug.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/sysctl.h"
    
    
    __asm void
    SysCtlcall(uint32_t ui32Count)
    {
        subs    r0, #1;
        bne     SysCtlcall;
        bx      lr;
    }
    
    
    int main(void)
    {
    
        SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |
                           SYSCTL_OSC_MAIN);
    
        SysCtlcall(8000);
    }
    
    

    这个代码在MDK中是可以编译通过的。在CCS中估计还需要定义什么东西吧。你可以试试在sysctl.c"中慢慢修改。在CCS中的汇编还需要符合CCS汇编的规范