一.实验目的:
理解汇编的编程结构,有助于学习ARM汇编,为后续学习CPU的启动机制来了个入门级
二.实验环境:
TX2440平台
三.实验工具:
ADS1.2 + AXD + JLINK调试
四.实验步骤:
1.在ads 上建立新工程,增加两个源文件.
int.s 源码:
;------------------------------------------------------------
;我的LED程序,EastonWoo procedure
area init,code,readonly
import main
start
ldr sp,=4096
bl main
end
;------------------------------------------------------------
main.c 源码:
//------------------------------------------------------------
//我的LED 实验程序,EastonWoo procedure
#define rGPFCON (*((volatile unsigned *)0x56000050))
#define rGPFDATA (*((volatile unsigned *)0x56000054))
#define LED1_ON rGPFDATA &=(~(1<<0))
#define LED2_ON rGPFDATA &=(~(1<<1))
#define LED3_ON rGPFDATA &=(~(1<<2))
#define LED4_ON rGPFDATA &=(~(1<<3))
#define LED1_OFF rGPFDATA |=(1<<0)
#define LED2_OFF rGPFDATA |=(1<<1)
#define LED3_OFF rGPFDATA |=(1<<2)
#define LED4_OFF rGPFDATA |=(1<<3)
void delay(int i)
{
while(i--);
}
int main()
{
rGPFCON = (rGPFCON & 0xFFFFFF00) | 0x55; //input:输入模式(检测);output:输出模式(输0,输1);高阻状态(常用于AD转换)
while(1)
{
LED1_ON;
delay(100000);
LED2_ON;
delay(100000);
LED3_ON;
delay(100000);
LED4_ON;
delay(100000);
LED1_OFF;
delay(100000);
LED2_OFF;
delay(100000);
LED3_OFF;
delay(100000);
LED4_OFF;
delay(100000);
}
return 0;
}
//------------------------------------------------------------