08.11.2014 Views

RealView Compilation Tools アセンブラガイド - ARM Information Center

RealView Compilation Tools アセンブラガイド - ARM Information Center

RealView Compilation Tools アセンブラガイド - ARM Information Center

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.

<strong>ARM</strong> アセン ブ リ 言 語 の 記 述<br />

ANDS r2, r2, #7<br />

例 2-9 は、 LDM 命 令 と STM 命 令 を 使 用 し て コ ピーする よ う に 書 き 直 し たブ ロ ッ<br />

クコピーモジュールを 示 しています。<br />

例 2-9 LDM および STM によるブロッ クコピー<br />

AREA Block, CODE, READONLY ; name this block of code<br />

num EQU 20 ; set number of words to be copied<br />

ENTRY<br />

; mark the first instruction called<br />

start<br />

LDR r0, =src ; r0 = pointer to source block<br />

LDR r1, =dst ; r1 = pointer to destination block<br />

MOV r2, #num ; r2 = number of words to copy<br />

MOV sp, #0x400 ; Set up stack pointer (sp)<br />

blockcopy<br />

MOVS r3,r2, LSR #3 ; Number of eight word multiples<br />

BEQ copywords ; Less than eight words to move?<br />

PUSH {r4-r11} ; Save some working registers<br />

octcopy<br />

LDM r0!, {r4-r11} ; Load 8 words from the source<br />

STM r1!, {r4-r11} ; and put them at the destination<br />

SUBS r3, r3, #1 ; Decrement the counter<br />

BNE octcopy ; ... copy more<br />

POP {r4-r11} ; Don't need these now - restore<br />

; originals<br />

copywords<br />

ANDS r2, r2, #7 ; Number of odd words to copy<br />

BEQ stop ; No words left to copy?<br />

wordcopy<br />

LDR r3, [r0], #4 ; Load a word from the source and<br />

STR r3, [r1], #4 ; store it to the destination<br />

SUBS r2, r2, #1 ; Decrement the counter<br />

BNE wordcopy ; ... copy more<br />

stop<br />

MOV r0, #0x18 ; angel_SWIreason_ReportException<br />

LDR r1, =0x20026 ; ADP_Stopped_ApplicationExit<br />

SVC #0x123456 ; <strong>ARM</strong> semihosting (formerly SWI)<br />

AREA BlockData, DATA, READWRITE<br />

src DCD 1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,1,2,3,4<br />

dst DCD 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0<br />

END<br />

<strong>ARM</strong> DUI 0204IJ Copyright © 2002-2008 <strong>ARM</strong> Limited. All rights reserved. 2-49<br />

Non-Confidential

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

Saved successfully!

Ooh no, something went wrong!