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

📄 s_rw_ram.s

📁 memory_test Memory Read/Write Access Test Memory read base Address : 0xc010000 Memory write bas
💻 S
字号:
/*********************************************************************************************
* File:	c_ram_test.s
* Author:	embest R.X.Huang
* Desc:	Memory Read/Write (ASM code) Test
* History:	
*********************************************************************************************/
    
/*------------------------------------------------------------------------------------------*/
/*                                     global label                                         */
/*------------------------------------------------------------------------------------------*/                                                                                                                                                           
	.global s_ram_test

/*------------------------------------------------------------------------------------------*/
/*                                     constant definition                                     */
/*------------------------------------------------------------------------------------------*/
	.equ	RW_NUM,		100
	.equ	RW_BASE,	0x0c010000
	.equ	RW_TARGET,	0x0c020000
    
/*********************************************************************************************
* name:		s_ram_test
* func:		access memory by word, hard word, byte
* para:		none
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
s_ram_test:
	stmdb	sp!, {r2-r4, lr}      /* push r0-r11, ip, lr */
	bl      init_ram
	@ read from RW_BASE and write them into RW_TARGET
	ldr     r2,=RW_BASE
	ldr     r3,[r2]                    /* Read by Word */
	ldr     r2,=RW_TARGET
	str     r3,[r2]                    /* Write by Word */

	bl      init_ram
	@ read from RW_BASE and write them into RW_TARGET
	ldr     r2,=RW_BASE 	
	ldrh    r3,[r2],#2                 /* Read by half Word */
	ldrh    r4,[r2]                    /* Read next half Word */
	ldr     r2,=RW_TARGET
	strh    r3,[r2],#2                 /* Write by half Word */
	strh    r4,[r2]                    /* Write next half Word */
	
	@ read from RW_BASE     
	ldr     r2,=RW_BASE                       
	ldrb    r3,[r2]	                   /* Read by Byte */
	@ write 0xDDBB2211 into RW_TARGET
	ldr     r2,=RW_TARGET
	ldrb    r3,=0xDD
	strb    r3,[r2],#1                 /* Write by Byte */
	ldrb    r3,=0xBB	
	strb    r3,[r2],#1	
	ldrb    r3,=0x22	
	strb    r3,[r2],#1 
	ldrb    r3,=0x11	
	strb    r3,[r2]
	
	ldmia	sp!, {r2-r4, lr}           /* pop r0-r11, ip, lr */
	mov	    pc,lr                      /* return */
    
/*********************************************************************************************
* name:		init_ram
* func:		write constant into memory
* para:		none
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
init_ram:
	ldr     r2,=RW_BASE
	ldr     r3,=0x55AA55AA	
	str     r3,[r2]                    /* write 0x55AA55AA into RW_BASE */
	ldr     r2,=RW_TARGET
	ldr     r3,=0x0	
	str     r3,[r2]                    /* write 0x0 into RW_TARGET */
    mov	    pc,lr                      /* return */

⌨️ 快捷键说明

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