1、實現1+2+3------+100
AREA test02,CODE,READONLY
start
MOV R0,#0
MOV R1,#1
MOV R2,#1
LOOP
ADD R2,R2,R0
ADD R1,R1,#1
CMP R1,#101
BEQ label
ADD R2,R2,R1
B LOOP
label
NOP
NOP
NOP
END
2、匯編LED測試
/************************************
*注意修改段名為testLED(兩處修改)
*在MDK中,要添加簇文件RuninRAM.sct
*在MDK中,要添加初始化文件Ext_RAM.ini
**************************************/
AREA testLED,CODE,READWRITE
ENTRY
rGPBCON EQU 0x56000010
rGPBDAT EQU 0x56000014
rGPBUP EQU 0x56000018
start
ldr r0, =rGPBCON
ldr r1, [r0]
bic r1,r1,#(0xff<<10)
orr r1,r1,#0x01
orr r1,r1,#(0x55<<10)
str r1,[r0]
ldr r0, =rGPBUP
mov r1, #0xff
str r1,[r0]
LED_LOOP
ldr r0, =rGPBDAT
mov r1, #0xE0
str r1, [r0]
mov r2, #0x120000
delay1
sub r2, r2, #1
cmp r2, #0
bne delay1
ldr r0, =rGPBDAT
mov r1, #0x00
str r0, [r0]
mov r2, #0x120000
delay2
sub r2, r2, #1
cmp r2,#0
bne delay2
b LED_LOOP
end
3、C語言LED測試
/*******************************************************
*在MDK中需要修改段名(RESET)
*在MDK中S3C2440A.S初始化文件已存在
*在MDK中需要添加簇文件RuninRAM.sct
******************************************************/
#define rGPBCON (*(volatile unsigned *)0x56000010)
#define rGPBDAT (*(volatile unsigned *)0x56000014)
#define rGPBUP (*(volatile unsigned *)0x56000018)
void msdelay(int time)
{
volatile unsigned int i,j;
for(i=0;i<2000;i++)
for(j=0;j<time;j++);
}
void GPIO_init()
{
rGPBCON &= ~((3<<10)|(3<<12)|(3<<14)|(3<<16));
rGPBCON |= (1<<10)|(1<<12)|(1<<14)|(1<<16);
//rGPBCON = 0x15400;//0001 0101 0100 0000 0000
rGPBUP = 0xff;
}
void ledtestC()
{
volatile unsigned int i;
while(1)
{
for(i=0;i<4;i++)
{
rGPBDAT = 0x000;
rGPBDAT |=(1<<(5+i));
msdelay(500);
rGPBDAT &=~(1<<(5+i));
msdelay(500);
}
}
}
int main(int argc, char **argv)
{
GPIO_init();
ledtestC();
return 0;
}