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

📄 main.lis

📁 cypress 的PSOC DESIGNER 4.4如何在C语言中调用汇编程序.
💻 LIS
字号:
 0000           ;-----------------------------------------------------------------------------
 0000           ; Interop - Calling C Functions from Assembler
 0000           ;
 0000           ; This project will deminstrate how to call a C Function from Assembler.
 0000           ;
 0000           ; We will create a small math library and call the functions from our
 0000           ; main loop. 
 0000           ;-----------------------------------------------------------------------------
 0000           
                export _main
                export _OperandTwo
                
                AREA bss(ram)
                
                //We will use two names for the same memory location.
 0000           _OperandOne::					//Create some memory location we can use globally
 0000           OperandOne::    blk     2                       //The :: exports the ram location
 0002                                                                           //The _ Is used for C functions. This must be here
 0002                                                                           //for the C functions to recognize it.
 0002           _OperandTwo:							
 0002           OperandTwo::    blk     2                       //use the export function above to make it global
 0004           
 0004           _OperandThree::
 0004           OperandThree::  blk     4
 0008           
 0008           _Result::
 0008           Result::                blk     4
 000C           
                area text(ROM,REL)
                
 0000           _main:
 0000           
 0000           MainLoop:
 0000           	//We need to assign the values to the variables we are going to use in the C function
 0000 550005            mov             [OperandOne],   0x05
 0003 550156            mov             [OperandOne+1], 0x56
 0006 550207            mov             [OperandTwo],   0x07
 0009 550396            mov             [OperandTwo+1], 0x96
 000C                   //Now we will call the C function. We use the _ to call the function
 000C 9000              call    _Addition
 000E                   //When we return we have 0x0CEC in location Result and Result+1
 000E                   
 000E 550001            mov             [OperandOne],           0x01    //Lets multiply 300
 0011 55012C            mov             [OperandOne+1],         0x2c
 0014 550507            mov             [OperandThree+1],       0x07    //by 470,000
 0017 55062B            mov             [OperandThree+2],       0x2b
 001A 5507F0            mov             [OperandThree+3],       0xf0
 001D                   
 001D 9000              call    _Multiplication
 001F                   
 001F                   //Result will contain 0x8677D40 - 141,000,000
 001F                   
 001F 8FE0              jmp     MainLoop
 0021           
 0021 7F            ret

⌨️ 快捷键说明

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