⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 functions.asm

📁 ADI公司SHARC与BlackFin通过SPI协议相互通信的源代码
💻 ASM
字号:
/****************************************************************************
 Include Section
*****************************************************************************/

#include "global.h"
#include "SPI.h"

/*****************************************************************************
 Symbolic constants / definitions
******************************************************************************/

#define delay 0x0000F000

/*****************************************************************************
 Prototypes
******************************************************************************/

.GLOBAL __delay;
.GLOBAL __copy;
.GLOBAL __compare;

/*****************************************************************************
 Functions
******************************************************************************/

.SECTION L1_code;

/****************************************************************************
 Function:              __delay
 Description:           simple __delay function
 Input Parameters:      none
 Return Parameters:     none
 Registers Used:        R0,P5,LOOPREG
 Global Registers Used: none
 C-Callable :           no
*****************************************************************************/

__delay:

    link 0;
    [--SP] = P5;
    [--SP] = R0;
    PUSH_LOOP_REGx(0);

    call __get_cclk_hz;
    IMM32(R0,delay);
    P5 = R0;
    nop;nop;nop;nop;

    lsetup(delay.lp,delay.lp) LC0 = P5;
    delay.lp: nop;

    POP_LOOP_REGx(0);
    R0 = [SP++];
    P5 = [SP++];
    unlink;

    rts;
__delay.END:


/****************************************************************************
 Function:              __copy
 Description:           copy rx_buf to tx_buf
 Input Parameters:      P5 = loop counter value
                        I0 = source
                        I1 = destination
 Return Parameters:     none
 Registers Used:        R7:6,P5,DAGREG1:0,LOOPREG0
 Global Registers Used: none
 C-Callable :           no
*****************************************************************************/

__copy:

    link 0;
    [--SP] = (R7:6,P5:5);
    PUSH_DAG_REGx(0);
    PUSH_DAG_REGx(1);
    PUSH_LOOP_REGx(0);

    L0=0;L1=0;

    /* 32-bit ALU/MAC instruction || 16-bit instruction || 16-bit instruction */
                               R6 = [I0++]; /* 16-bit instruction (load immediate) */
    lsetup(copy.lp,copy.lp) LC0 = P5;
    copy.lp:   [I1++] = R6 ||  R6 = [I0++]; /* MNOP || 16-bit instruction (load immediate) || 16-bit instruction (load immediate) */
               [I1] = R6; /* (store immediate) */


    POP_LOOP_REGx(0);
    POP_DAG_REGx(1);
    POP_DAG_REGx(0);
    (R7:6,P5:5) = [SP++];
    unlink;

    rts;
__copy.END:


/****************************************************************************
 Function:              __compare
 Description:           compare rx_buf to tx_buf
 Input Parameters:      P5 = loop counter value
                        I0 = source
                        I1 = destination
 Return Parameters:     none
 Registers Used:        R7:0,P5,DAGREG1:0,ASTAT,LOOPREG
 Global Registers Used: none
 C-Callable :           no
*****************************************************************************/

__compare:

    link 0;
    [--SP] = ASTAT;
    [--SP] = (R7:0,P5:5);
    PUSH_DAG_REGx(0);
    PUSH_DAG_REGx(1);
    PUSH_LOOP_REGx(0);


    L0=0;L1=0;R1=0;R3=0;A0=0;A1=0;

    /* 22 cycles | VDSP++ Simulator: 26 */
    /* 32-bit ALU/MAC instruction || 16-bit instruction || 16-bit instruction */
    /* SAA (Quad 8-Bit Subtract-Absolute-ACCumulate) || 16-bit instruction (load immediate) || 16-bit instruction (load immediate) */
                                            R0 = [I0++] || R2 = [I1++];
    lsetup (compare.lp,compare.lp) LC0 = P5;
    compare.lp:     SAA (R1:0, R3:2)    ||  R0 = [I0++] || R2 = [I1++];
                    SAA (R1:0, R3:2);

    R0 = A0;
    CC = R0 == 0;
    if !CC jump compare.error;
    R1 = A1;
    CC = R1 == 0;
    if !CC jump compare.error;

    compare.ok:
    jump compare.done;

    compare.error:
    call __led_all_turn_on;
    EMUEXCPT;
    jump compare.error;


    compare.done:
    POP_LOOP_REGx(0);
    POP_DAG_REGx(1);
    POP_DAG_REGx(0);
    (R7:0,P5:5) = [SP++];
    ASTAT = [SP++];
    unlink;

    rts;
__compare.END:


/*****************************************************************************
 EOF
******************************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -