⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 thumbcode2.s

📁 基于S3C2410的Thumb指令使用实验用例 非常实用
💻 S
字号:
;#*********************************************************************************************
;# NAME:		Thunbcode2.s																	 *
;# Author: 	Embest																			 *
;# Desc:		Thunmbcode examples																 *
;#           copy words from src to dst														 *
;# History:	shw.He 2005.02.22																 *
;#*********************************************************************************************

;/*------------------------------------------------------------------------------------------*/
;/*	 								constant define						 				    */
;/*------------------------------------------------------------------------------------------*/
;/*------------------------------------------------------------------------------------------*/
;/*	 								code								 				    */
;/*------------------------------------------------------------------------------------------*/
 		area start,code,readwrite
		entry
		code32								   ;/*  Subsequent instructions are ARM */
num equ 20 	  							   ;/*  Set number of words to be copied */
		export START
START
        code32											;/*  Subsequent instructions are ARM header */
		mov		sp, #0x32000000						;/*  set up user_mode stack pointer (r13) */
		adr		r0, Tstart + 1					;/*  Processor starts in ARM state,  */
		bx		r0 								;/*  so small ARM code header used  */
        code16											;/*  Subsequent instructions are Thumb.  */

Tstart
		ldr		r0, =src						;/*  r0 = pointer to source block */
		ldr		r1, =dst						;/*  r1 = pointer to destination block */
		mov		r2, #num						;/*  r2 = number of words to copy */

blockcopy
		lsr		r3,r2, #2						;/*  number of four word multiples */
		beq		copywords						;/*  less than four words to move ? */

		push	{r4-r7}							;/*  save some working registers */
quadcopy
		ldmia	r0!, {r4-r7}					;/*  load 4 words from the source */
		stmia	r1!, {r4-r7}					;/*  and put them at the destination */
		sub		r3, #1							;/*  decrement the counter */
		bne		quadcopy						;/*  ... copy more */

		pop		{r4-r7}							;/*  don't need these now - restore originals */

copywords
		mov		r3, #3							;/*  bottom two bits represent number... */
		and		r2, r3							;/*  ...of odd words left to copy */
		beq		stop							;/*  No words left to copy ? */
wordcopy
		ldmia	r0!, {r3}						;/*  a word from the source */
		stmia	r1!, {r3}						;/*  store a word to the destination */
		sub		r2, #1							;/*  decrement the counter */
		bne		wordcopy						;/*  ... copy more */

stop
		b		stop

;/*------------------------------------------------------------------------------------------*/
;/* make a word pool														 				    */
;/*------------------------------------------------------------------------------------------*/
        align
src
		dcd		1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,1,2,3,4
dst
		dcd		0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

        end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -