s_rw_ram.s

来自「Embest EudKit-II教学系统配Samsung S3C44B0处理器的」· S 代码 · 共 79 行

S
79
字号
/*********************************************************************************************
* 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 + =
减小字号Ctrl + -
显示快捷键?