C中如何使用.asm文件

C中如何使用.asm文件,第1张

asm文件是宏汇编文件,在c中调用方法如下:

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编译通过


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/8054388.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-13
下一篇 2023-04-13

发表评论

登录后才能评论

评论列表(0条)

保存