1、编写汇编程序:
#include <xc.inc>
GLOBAL _add声明全局可用的函数add
SIGNAT _add,4217 告诉编译器调用方式
PSECT mytext,local,class=CODE,delta=2
our routine to add to ints and return the result
_add:
W is loaded by the calling function
BANKSEL (PORTB) select the bank of this object
ADDWF BANKMASK(PORTB),w add parameter to port
the result is already in the required location (W)so we can just return immediately
RETURN
2、编写c语言程序
//声明调用外部的汇编程序
extern unsigned char add(unsigned char a)
void main(void) {
volatile unsigned char result
result = add(5) // 开始调用上面声明的汇编函数
}
_asm mov ax,0_asm{
mov ax,0
mov bx,0
}
两种写法都行,VC++6.0编译通过
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)