一.實驗目的:
理解匯編的編程結構,有助於學習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;
}
//------------------------------------------------------------