| 有时候采用汇编程序作为主程序,但是又有些比较麻烦的算法用汇编不容易写. 可以利用汇编调用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);
 }
 |