电工学习网

 找回密码
 立即注册

C程序调用汇编程序

2015-4-4 07:09| 编辑:电工学习网| 查看: 4123| 评论: 0

    文件strtest.c
    1 #include <stdio.h>
    2 extern void strcopy(char *d, const char *s);
    3 int main()
    4 { const char *srcstr = "First string - source";
    5 char dststr[] = "Second string - destination";
    6 /* dststr is an array since we're going to change it */
    7
    8 printf("Before copying:\n");
    9 printf(" '%s'\n '%s'\n",srcstr,dststr);
    10 strcopy(dststr,srcstr);
    11 printf("After copying:\n");
    12 printf(" '%s'\n '%s'\n",srcstr,dststr);
    13 return 0;
    14 }
    文件scopy.s
    1 AREA SCopy, CODE, READONLY
    2 EXPORT strcopy
    3 strcopy
    4 ; r0 points to destination string
    5 ; r1 points to source string
    6 LDRB r2, [r1],#1 ; load byte and update address
    7 STRB r2, [r0],#1 ; store byte and update address;
    8 CMP r2, #0 ; check for zero terminator
    9 BNE strcopy ; keep going if not
    10 MOV pc,lr ; Return
    11 END

看过《C程序调用汇编程序》的人还看了以下文章:

发表评论

最新评论

  • 嵌入式开发到底是做什么的?
  • FPGA芯片结构
  • FPGA工作原理
  • 嵌入式学习方法与心得
  • 嵌入式软件工程师必须要掌握哪些知识
  • 嵌入式系统开发的可靠性设计

电工学习网 ( )

GMT+8, 2021-12-6 20:44

Powered by © 2011-2021 www.diangon.com 版权所有 免责声明 不良信息举报

技术驱动未来! 电工学习网—专业电工基础知识电工技术学习网站。

栏目导航: 工控家园 | 三菱plc | 西门子plc | 欧姆龙plc | plc视频教程

返回顶部