[HOLTEK MCU] HOLTEK IDE3000 汇编调用C的DEMO

[复制链接]
3370|3
 楼主| winhi 发表于 2009-8-5 14:43 | 显示全部楼层 |阅读模式
有时候采用汇编程序作为主程序,但是又有些比较麻烦的算法用汇编不容易写.
可以利用汇编调用C的功能,把复杂的算法用C来实现了.

要求汇编与C子程序都添加到同一个工程中,并且汇编程序排在源文件的最上面.

入口变量:MULTIPLY0,MULTIPLY1
出口数据低8位在A中,高8位在RH中


汇编主程序:
;asm call c DEMO
;
#include ht49r50a-1.inc

;-------
extern RH:byte
extern _MULTIPLY:near
extern MULTIPLY0:byte    ;name must same as subs!
extern MULTIPLY1:byte
;-------
data .section 'data'
dat1 db 1
dat2 db 1
edatl db 1
edath db 1

;-------
code .section at 0 'code'
org 0000h
jmp begin
begin:
nop
mov a,3
mov MULTIPLY0,a
mov a,90
mov MULTIPLY1,a
call  _MULTIPLY
mov edatl,a
mov a,RH
mov edath,a
nop
nop
nop
jmp begin
end

---------------------------------------------------

C的子程序

/* C subs for asmcallc.asm  */
/*  winhi                 */
/*  2004.2--2004.06.16    */

unsigned int MULTIPLY(unsigned int cs1, unsigned int cs2)
{
  return (cs1*cs2);
}
谈的元 发表于 2009-8-5 20:47 | 显示全部楼层
这个要顶
點點學步 发表于 2009-8-6 10:45 | 显示全部楼层
:call:
繼續!
 楼主| winhi 发表于 2009-8-7 13:43 | 显示全部楼层
这个要顶
谈的元 发表于 2009-8-5 20:47


:handshake
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:困难时记得转换思路!

5

主题

71

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部