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

📄 main.asm

📁 cypress 的PSOC DESIGNER 4.4如何在C语言中调用汇编程序.
💻 ASM
字号:
;-----------------------------------------------------------------------------
; Interop - Calling C Functions from Assembler
;
; This project will deminstrate how to call a C Function from Assembler.
;
; We will create a small math library and call the functions from our
; main loop. 
;-----------------------------------------------------------------------------

export _main
export _OperandTwo

AREA bss(ram)

//We will use two names for the same memory location.
_OperandOne::					//Create some memory location we can use globally
OperandOne::	blk	2			//The :: exports the ram location
								//The _ Is used for C functions. This must be here
								//for the C functions to recognize it.
_OperandTwo:							
OperandTwo::	blk	2			//use the export function above to make it global

_OperandThree::
OperandThree::	blk	4

_Result::
Result::		blk	4

area text(ROM,REL)

_main:

MainLoop:
	//We need to assign the values to the variables we are going to use in the C function
	mov		[OperandOne],	0x05
	mov		[OperandOne+1],	0x56
	mov		[OperandTwo],	0x07
	mov		[OperandTwo+1],	0x96
	//Now we will call the C function. We use the _ to call the function
	call	_Addition
	//When we return we have 0x0CEC in location Result and Result+1
	
	mov		[OperandOne],		0x01	//Lets multiply 300
	mov		[OperandOne+1],		0x2c
	mov		[OperandThree+1],	0x07    //by 470,000
	mov		[OperandThree+2],	0x2b
	mov		[OperandThree+3],	0xf0
	
	call	_Multiplication
	
	//Result will contain 0x8677D40 - 141,000,000
	
	jmp	MainLoop

    ret

⌨️ 快捷键说明

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