4. 7. 1 实验目的
阅读S3C2410 启动代码,观察处理器启动过程;
学会使用 MDK 集成开发环境辅助窗口来分析判断调试过程和结果;
学会在 MDK 集成开发环境中编写、编译与调试汇编和C 语言相互调用的程序。
4. 7. 6 实验参考程序
1.randtest.c 参考源代码:
/*********************************************************************************************
* File: randtest.c
* Author: Wuhan R&D Center, embest
* Desc: Random number generator demo program
* Calls assembler function 'randomnumber' defined in random.s
* History:
*********************************************************************************************/
/*------------------------------------------------------------------------------------------*/
/* extern function */
/*------------------------------------------------------------------------------------------*/
extern unsigned int randomnumber( void );
unsigned int unRandom[10];
/*********************************************************************************************
* name: main
* func: c code entry
* para: none
* ret: none
* modify:
* comment:
*********************************************************************************************/
int __main()
{
unsigned int i,nTemp;
for( i = 0; i < 10; i++ )
{
nTemp = randomnumber();
unRandom[i] = nTemp;
}
while(1);
}
2.random.s 参考源代码:
;#************************************************************************************************************
;# File: random.s *
;# Author: Wuhan R&D Center, embest *
;# Desc: Random number generator *
;# This uses a 33-bit feedback shift register to generate a pseudo-randomly *
;# ordered sequence of numbers which repeats in a cycle of length 2^33 - 1 *
;# NOTE: randomseed should not be set to 0, otherwise a zero will be generated *
;# continuously (not particularly random!). *
;# This is a good application of direct ARM assembler, because the 33-bit *
;# shift register can be implemented using RRX (which uses reg + carry). *
;# An ANSI C version would be less efficient as the compiler would not use RRX. *
;# AREA |Random$$code|, CODE, READONLY *
;# History: *
;#*************************************************************************************************************
;/*------------------------------------------------------------------------------------------*/
;/* global symbol define */
;/*------------------------------------------------------------------------------------------*/
global randomnumber
global seed
;/*------------------------------------------------------------------------------------------*/
;/* code */
;/*------------------------------------------------------------------------------------------*/
AREA BLOCK, code , readonly
EXPORT randomnumber
randomnumber
;# on exit:
;# a1 = low 32-bits of pseudo-random number
;# a2 = high bit (if you want to know it)
ldr ip, seedpointer
基于S3C2410 嵌入式 MDK 开发实验与实践――EduKit 系列丛书
Email:support@edukit.com.cn Tel:0755-25631365
ldmia ip, {a1, a2}
tst a2, a2, lsr #1 ;/* to bit into carry */
movs a3, a1, rrx ;/* 33-bit rotate right */
adc a2, a2, a2 ;/* carry into LSB of a2 */
eor a3, a3, a1, lsl #12 ;/* (involved!) */
eor a1, a3, a3, lsr #20 ;/* (similarly involved!) */
stmia ip, {a1, a2}
BX lr
seedpointer
DCD seed
seed
DCD 0x55555555
DCD 0x55555555
END
上一篇:ARM平台上实现Linux PPP拨号
下一篇:Flash与S3C44B0X连接时地址线为什么要偏移一位
推荐阅读最新更新时间:2024-03-16 15:03
设计资源 培训 开发板 精华推荐
- “超级周期”告一段落 韩国半导体产业将进入停滞期?
- 又见7nm,AMD下一代GPU核心“Navi 12”遭曝光
- 苹果新专利曝光头戴式耳机:可自动调整左右声道
- 淡季不淡,晶圆代工厂投片满载,带动半导体材料走势强劲
- 想中手机大奖,微博CEO详解中奖规则:你得活跃起来
- 未来机器人获数亿元融资,2021年业绩同比增长300%
- KEMET推出适用于恶劣环境的最小EMI X2薄膜电容器解决方案
- NVIDIA首席执行官黄仁勋将在GTC主题演讲中发布全新AI技术产品
- Teledyne 将在Vision 2021展览会中展示全面的工业和科学成像技术
- 贸泽与Texas Instruments和Phoenix Contact联手推出单对以太网技术页