01.12.2014 Views

RealView Compilation Tools Developer Guide - ARM Information ...

RealView Compilation Tools Developer Guide - ARM Information ...

RealView Compilation Tools Developer Guide - ARM Information ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

混 合 使 用 C、 C++ 和 汇 编 语 言<br />

示 例 5-9 汇 编 语 言 字 符 串 复 制 子 程 序<br />

AREA SCopy, CODE, READONLY<br />

EXPORT strcopy<br />

strcopy<br />

; r0 points to destination string.<br />

; r1 points to source string.<br />

LDRB r2, [r1],#1 ; Load byte and update address.<br />

STRB r2, [r0],#1 ; Store byte and update address.<br />

CMP r2, #0 ; Check for zero terminator.<br />

BNE strcopy ; Keep going if not.<br />

MOV pc,lr<br />

; Return.<br />

END<br />

第 5-21 页 的 示 例 5-8 位 于 Examples_directory\asm 中 , 文 件 名 为 strtest.c 和<br />

scopy.s。 按 以 下 步 骤 从 命 令 行 编 译 该 示 例 :<br />

1. 键 入 armasm -g scopy.s 编 译 汇 编 语 言 源 代 码 。<br />

2. 键 入 armcc -c -g strtest.c 编 译 C 源 代 码 。<br />

3. 键 入 armlink strtest.o scopy.o -o strtest 链 接 目 标 文 件 。<br />

4. 将 ELF/DWARF2 兼 容 调 试 器 与 相 应 调 试 目 标 配 合 使 用 , 运 行 映 象 。<br />

5-22 © 2002、 2003 <strong>ARM</strong> Limited 版 权 所 有 。 保 留 所 有 权 利 。 <strong>ARM</strong> DUI 0203BSC

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!