|
2Àå¿¡¼´Â ÁÖ·Î ½Ç½ÀÀ» À§ÁÖ·Î ÁøÇà Çϵµ·Ï ÇÏ°Ú½À´Ï´Ù. ½ÇÁ¦ °³¹ßº¸µå¸¦ È°¿ëÇصµ µÇ°ÚÀ¸³ª ¾î¼Àºí¸®¾î ½Ç½ÀÀº ARM Simulator ¸¦ È°¿ëÇؼ ÁøÇàÇÏ´Â °ÍÀÌ È¿À² ÀûÀ̱⠶§¹®¿¡ IAR ÄÄÆÄÀÏ·¯¿¡¼ Simulator »ó¿¡¼ ÁøÇàÀ» Çϵµ·Ï ÇÏ°Ú½À´Ï´Ù.
2. ¾î¼Àºí¸®¾î ½Ç½À
2.1 ARM Simulator ȯ°æ ¼³Á¤
IAR ARM¿ë ÄÄÆÄÀÏ·¯´Â °¡°ÝÀÌ ±×·¸°Ô ½ÎÁö´Â ¾Ê½À´Ï´Ù. ´ÙÇàÈ÷µµ www.iar.com ¿¡¼ ½Ã°£Á¦ÇÑ(30ÀÏ), »çÀÌÁîÁ¦ÇÑ(32Kbyte) ¹öÁ¯À» ´Ù¿î ¹Þ¾Æ¼ »ç¿ëÇØ º¼ ¼ö ÀÖ½À´Ï´Ù.
2.1.1 IAR Evaluation ¹öÁ¯ ´Ù¿î·Îµå
- ´Ù¿î·Îµå »çÀÌÆ® ¹æ¹®
http://supp.iar.com/Download/SW/?item=EWARM-EVAL
ÆÐÅ°Áö »çÀÌÁî°¡ ¾à 830MBÁ¤µµ ÀÔ´Ï´Ù. ´Ù¿î ¹Þ¾Æ¼ ¼³Ä¡ ÇϽñ⠹ٶø´Ï´Ù.
´ÙÀ½Àº Evaluation ¹öÁ¯À» ´Ù¿î·Îµå ¹Þ±â À§ÇÑ ÀýÂ÷µ¥·Î ȸéÀ» ĸÃÄÇØ ³õÀº °ÍÀÔ´Ï´Ù. ÂüÁ¶ÇϽñ⠹ٶø´Ï´Ù.
¹Ýµå½Ã "Code size limited" ¸¦ ¼±Åà ÇϽñ⠹ٶø´Ï´Ù. ±×·¸Áö ¾ÊÀ¸¸é 30ÀÏ ÀÌÈÄ¿¡ ´õÀÌ»ó IAR ÄÄÆÄÀÏ·¯¸¦ »ç¿ëÇÒ ¼ö ¾ø°Ô µË´Ï´Ù.
(2) IAR Evaluation ¹öÁ¯ ¼³Ä¡
¼³Ä¡°¡ ¿Ï·áµÇ¸é ¸¶Áö¸·¿¡ License ¸¦ ÀÔ·ÂÇϴ ȸéÀÌ ³ª¿É´Ï´Ù. ¿©±â¿¡¼ "Register with IAR System to get an evaluation license" ¸¦ ¼±Åà ÇϽñ⠹ٶø´Ï´Ù.
ÇöÀç ¼³Ä¡µÈ Á¦Ç°Áß¿¡ ¶óÀ̼¾½º°¡ ¾ø´Â Á¦Ç°ÀÇ ¸®½ºÆ®°¡ ³ª¿É´Ï´Ù. ¼±ÅÃÀ» ÇÏ°í "´ÙÀ½" À¸·Î ÁøÇà ÇÕ´Ï´Ù.
IAR Evaluation ¹öÁ¯À» ´Ù¿î¹Þ±â À§Çؼ ÀÔ·ÂÇß´ø Email ÁÖ¼Ò·Î Registeration Confirm ¸ÞÀÏÀÌ ¿ÍÀÖÀ» °ÍÀÔ´Ï´Ù.
Confirm ¸ÞÀÏ¿¡ žx´Â Confirm ¸µÅ©¸¦ Ŭ¸¯Çϸé "Rgistration Complete" ¿Í ÇÔ²² Evaluation License ¹øÈ£¸¦ ¾Ë¼ö°¡ ÀÖ½À´Ï´Ù. ±× ¹øÈ£¸¦ À§ÀÇ È¸éÀÇ ºó Ä¿¡ ÀÔ·ÂÇÏ°í ³ª¼
"Regiser" ¹öÆ°À» ´©¸£¸é Àá½ÃÈÄ¿¡ ³×Æ®¿öÅ©¸¦ ÅëÇؼ Evaluation ¶óÀ̼¾½º ¹øÈ£¸¦ ¹Þ°Ô µË´Ï´Ù. °æ¿ì¿¡ µû¶ó¼ Fail À̶ó´Â ¸Þ¼¼Áö°¡ ³ª¿Ã¼öµµ ÀÖ½À´Ï´Ù. ±×¶§´Â "Register" ¹öÆ°À» ´Ù½ÃÇѹø Ŭ¸¯Çؼ Àç ½ÃµµÇØ º¸½Ã±â ¹Ù¶ø´Ï´Ù.
¸ðµç ¼³Ä¡°¡ ¿Ï·áµÈ ȸé ÀÔ´Ï´Ù.
2.1.2
ARM Simulator ÇÁ·ÎÁ§Æ® »ý¼º
¾Æ·¡ ȸ鵥·Î µû¶ó¼ ARM Simulator ±â¹ÝÀÇ ½Ç½À ÇÁ·ÎÁ§Æ®¸¦ »ý¼ºÇØ º¸½Ã±â ¹Ù¶ø´Ï´Ù.
(1) Create New Project
(2) Empty project »ý¼º
(3) ÇÁ·ÎÁ§Æ® ÆÄÀÏÀ̸§ ÀÔ·Â
- "arm_simulator"
(4) ±×·ì»ý¼º
- "base", "testcode" ±×·ì »ý¼º
(5) ¼Ò½º ÆÄÀÏÃß°¡
- "base" ±×·ì :
2440init_ewarm.s Ãß°¡
- "testcode" ±×·ì : main.c, SegInit.c Ãß°¡
(6) ÇÁ·ÎÁ§Æ® ¿É¼Ç ¼³Á¤
(6.1) Target Device ¼³Á¤ : Samsung S3C2440A ·Î ¼³Á¤ ÇÕ´Ï´Ù.
(7) Processor Mode ¼³Á¤ : "ARM" ¸ðµå·Î ¼³Á¤ ÇÕ´Ï´Ù.
(8) Scattor Loading ÆÄÀÏ ¼³Á¤ : ÇÁ·ÎÁ§Æ® µð·ºÅ丮¿¡ "arm_simulator.icf" ÆÄÀÏÀ» ¼±Åà ÇÕ´Ï´Ù.
(9) Program Start Entry ¼³Á¤ : "__program_start" ¶ó°í ÀÔ·Â ÇÕ´Ï´Ù.
(10) µð¹ö±ë Á¤º¸¸¦ Æ÷ÇÔÇϵµ·Ï ¼³Á¤ ÇÕ´Ï´Ù.
(11) Map ÆÄÀÏÀ» »ý¼º Çϵµ·Ï ÇÕ´Ï´Ù.
(12) Debugger Á¤º¸ ¼³Á¤ : Dirver - Simulator, Run to main Àº ¹Ýµå½Ã ¼³Á¤ ÇØÁ¦ ÇÕ´Ï´Ù.
2.2 Data Processing Instructions
2Àå¿¡¼´Â ARM Simulator¸¦ È°¿ëÇÑ ¾î¼Àºí¸®¾î ½Ç½ÀÀ» Çغ¸µµ·Ï ÇÏ°Ú½À´Ï´Ù. ÀÌ ³»¿ëµéÀº ARM Architecture Instruction ÀÇ ÀÌ·Ð ºÎºÐÀ» ¼³¸íÇÒ¶§ Çѹø¾¿ ³ª¿Ô´ø ³»¿ëÀÔ´Ï´Ù. ¿©±â¼´Â ÀÌ·ÐÀ¸·Î °øºÎÇß´ø ³»¿ëµéÀ» ½ÇÁ¦·Î ARM Simulator¿¡¼ Äڵ带 ÀÛ¼ºÇÑ ÈÄ ÄÄÆÄÀÏÇÏ°í ½ÇÇàÇؼ °á°ú°ªÀ» Á÷Á¢ È®ÀÎÇØ º¸´Âµ¥ Àǹ̰¡ ÀÖ½À´Ï´Ù.
R0 = 0x00
R1 = 0x22
R2 = 0x02
R3 = 0x00
R4 = 0x00 |
|
·¹Áö½ºÅÍ °ªÀÌ À§¿Í °°À»¶§ ¾Æ·¡ ¿¹Á¦µéÀ» Â÷·Ê´ë·Î ¼öÇàÇØ º¸¼¼¿ä.
(1) AND R0, R0, #0xFF
2440init_ewarm.s ÆÄÀÏ¿¡ ´ÙÀ½°ú °°ÀÌ ÀÔ·ÂÀ» ÇÕ´Ï´Ù.
SECTION IMAGE_STARTUP:CODE (2)
PUBLIC __program_start
CODE32
__program_start
b ResetHandler
b HandlerUndef ;handler for Undefined mode
b HandlerSWI ;handler for SWI interrupt
b HandlerPabort ;handler for PAbort
b HandlerDabort ;handler for DAbort
b . ;reserved
b HandlerIRQ ;handler for IRQ interrupt
b HandlerFIQ ;handler for FIQ interrupt
ResetHandler
MOV R0, #0x00
MOV R1, #0x22
MOV R2, #0x02
MOV R3, #0x00
MOV R4, #0x00
AND R0, R0, #0xFF
ADD R0, R0, #1
ADD R0, R0, R1
LSL R1, R0, #2
SUB R3, R2, R1, LSR R2
HandlerFIQ
b .
HandlerIRQ
b .
HandlerUndef
b .
HandlerSWI
b .
HandlerDabort
b .
HandlerPabort
b .
END
|
- ½ÇÇà °á°ú
(2) ADD R0, R0, #1 ; R0 = R0 + 1 = 0x1
- ½ÇÇà°á°ú
(3) ADD R0, R0, R1 ; R0 = R0 + R1 = 0x01 + 0x22 = 0x23
- ½ÇÇà°á°ú
(4) LSL R1, R0, #2 ; 0x23(100011) LSL #2 = 0x8C(10001100) -> Âü°í·Î ¿ÞÂÊÀ¸·Î 2¹ø ½¬ÇÁÆ® Çϸé *4 ¸¦ ÇÑ°Í°ú °°½À´Ï´Ù.
- ½ÇÇà°á°ú
(5) SUB R3, R2, R1, LSR R2
- ½ÇÇà°á°ú
R3ÀÇ °ªÀÌ 0xFFFFFFDF ·Î º¹ÀâÇÑ °ªÀÌ ³ª¿Ô½À´Ï´Ù. ¿Ö ÀÌ·± °á°ú°¡ ³ª¿ÔÀ»±î¿ä ?
¿ì¼± R1À» ¿À¸¥ÂÊÀ¸·Î 2¹ø ½¬ÇÁÆ® ½ÃÅ°¸é 0x23ÀÌ µÇ°í R2(0x02) ¿¡¼ R1(0x23) À» »©¸é °á°ú°ªÀÌ -0x21°¡ µÇ°í ÀÌ °ªÀ» 2ÀÇ º¸¼ö·Î Ç¥½ÃÇϸé
0xFFFFFFDF °¡ µË´Ï´Ù.
0x21 = 00000000000000000000000000100001
-0x21 = 11111111111111111111111111011111
--> 0x21ÀÇ 2ÀÇ º¸¼ö
Âü°í·Î 2ÀÇ º¸¼ö¸¦ ÃëÇÏ´Â ¹æ¹ýÀº ¿ø·¡ÀÇ 2Áø¼ö¿¡¼ 0->1, 1->0 À¸·Î ¹Ù²ÛÈÄ¿¡ 1À» ´õÇÏ¸é µÇ°ÚÁö¿ä.
2.3 Multiply Instructions
R0 = 0x01
R1 = 0x02
R2 = 0x03
R3 = 0x04 |
|
·¹Áö½ºÅÍ °ªÀÌ À§¿Í °°À»¶§ ¾Æ·¡ ¿¹Á¦µéÀ» Â÷·Ê´ë·Î ¼öÇàÇØ º¸¼¼¿ä.
(1) MUL R2, R0, R1 ; R2 = R0*R1 = 0x02
2440init_ewarm.s ÆÄÀÏ¿¡ ´ÙÀ½°ú °°ÀÌ ÀÔ·ÂÀ» ÇÕ´Ï´Ù.
ResetHandler
MOV R0, 0x01
MOV R1, 0x02
MOV R2, 0x03
MOV R3, 0x04
MUL R2, R0, R1
MULS R2, R0, R1
MLA R3, R2, R1, R0 |
- ½ÇÇà°á°ú
(2) MULS R2, R0, R1 ; R2 = R0*R1 = 0x02
MUL ¸í·É°ú °°Àº ¸í·ÉÀÔ´Ï´Ù. ÇÏÁö¸¸ MULµÚ¿¡ "S" °¡ ºÙÀ¸¸é ¸í·É¾î 󸮰¡ ³¡³ ÀÌÈÄ¿¡ CPSRÀÇ Flag Field °¡ ¿¬»ê °á°ú¿¡ µû¶ó¼ ¾÷µ¥ÀÌÆ®°¡ µË´Ï´Ù.
- ½ÇÇà°á°ú
(3) MLA R3, R2, R1, R0 ; R3 = R2*R1 + R0
Âü È¿À²ÀûÀ̳׿ä. ¸í·É¾î Çϳª·Î °öÇϱ⠿¬»ê°ú ´õÇϱ⠿¬»êÀ» °°ÀÌ ÇÒ ¼ö ÀÖ½À´Ï´Ù.
- ½ÇÇà°á°ú
2.4 Load/Store Instructions
2.4.1 Pre-index
R0 = 0x31000000
R1 = 0x00
R2 = 0x00 |
|
|
(1) LDR R1, [R0] ; R1 <-- M[R0]
2440init_ewarm.s ÆÄÀÏ¿¡ ´ÙÀ½°ú °°ÀÌ ÀÔ·ÂÀ» ÇÕ´Ï´Ù.
ResetHandler
MOV R0, #0x31000000
MOV R1, #0x0
MOV R2, #0x0
LDR R3, =0x01234567
STR R3, [R0]
LDR R3, =0x89abcdef
STR R3, [R0, #4]
LDR R1, [R0]
STR R1, [R0, #4]
STR R1, [R0, #4]! |
- ½ÇÇà°á°ú
(2) STR R1, [R0, #4] ; R1 <-- M[R0+4]
(3) STR R1, [R0, #4]! ; R1 <-- M[R0+4], then R0 <-- R0+4
- ½ÇÇà°á°ú
2.4.2 Post-index
R0 = 0x31000000
R1 = 0x00
R2 = 0x04 |
|
|
(1) LDR R1, [R0], R2 ; R1 <-- M[R0], then R0 <-- R0+R2
ResetHandler
MOV R0, #0x31000000
MOV R1, #0x0
MOV R2, #0x4
LDR R3, =0x01234567
STR R3, [R0]
LDR R3, =0x89abcdef
STR R3, [R0, #4]
LDR R1, [R0], R2
STR R1, [R0], #4 |
- ½ÇÇà°á°ú
(2) STR R1, [R0], #4 ; R1 <-- M[R0], then R0 <-- R0+4
- ½ÇÇà°á°ú
2.5 Load/Store Multiple Instructions
R0 = 0x000A
R4 = 0x000B
R5 = 0x000C
R13 = 0xFFF0 |
|
|
(1) STMIA R13!, {R0,R4-R5}
ResetHandler
MOV R0, #0x000A
MOV R4, #0X000B
MOV R5, #0x000C
LDR R13, =0xFFF0
STMIA R13!, {R0,R4-R5} |
- ½ÇÇà°á°ú
(2) STMIB R13!, {R0,R4-R5}
ResetHandler
MOV R0, #0x000A
MOV R4, #0X000B
MOV R5, #0x000C
LDR R13, =0xFFF0
STMIB R13!, {R0,R4-R5} |
- ½ÇÇà°á°ú
(3) STMDA R13!, {R0,R4-R5}
ResetHandler
MOV R0, #0x000A
MOV R4, #0X000B
MOV R5, #0x000C
LDR R13, =0xFFF0
STMDA R13!, {R0,R4-R5} |
- ½ÇÇà°á°ú
(4) STMDB R13!, {R0,R4-R5}
ResetHandler
MOV R0, #0x000A
MOV R4, #0X000B
MOV R5, #0x000C
LDR R13, =0xFFF0
STMDB R13!, {R0,R4-R5} |
- ½ÇÇà°á°ú
2.6 Branch Instructions
ResetHandler
subsequent
MOV R0, #1
MOV R1, #2
BL func1
ADD R2, R0, R1
func1
MOV R0, #3
MOV R1, #4
BL func2
ADD R2, R0, R1
MOV PC, LR
func2
MOV R0, #5
MOV R1, #6
ADD R2, R0, R1
MOV PC, LR |
À§ÀÇ ¿¹Á¦¸¦ ½ÇÇàÇϸé R2 ·¹Áö½ºÅÍ¿¡ "3" ÀÌ ÀúÀåÀÌ µÇÁö ¾Ê½À´Ï´Ù.
R2 ·¹Áö½ºÅÍ¿¡ "3" ÀÌ ÀúÀåÀÌ µÉ ¼ö ÀÖµµ·Ï ¿¹Á¦¸¦ ¼öÁ¤ÇØ º¸½Ã±â ¹Ù¶ø´Ï´Ù. ¼öÁ¤ÇÑ ¿¹Á¦ ÄÚµå´Â ¾Æ·¡¿Í °°½À´Ï´Ù.
¼ºê ÇÔ¼ö¸¦ È£Ãâ ÇÒ °æ¿ì¿¡´Â ¼ºê ÇÔ¼ö¿¡¼ »ç¿ëÇÏ´Â ·¹Áö½ºÅÍ¿Í LR ·¹Áö½ºÅ͸¦ ¹Ýµå½Ã ÀúÀåÇÑ ÀÌÈÄ¿¡ »ç¿ëÇØ¾ß ÇÑ´Ù´Â °ÍÀ» ¾Ë ¼ö ÀÖ½À´Ï´Ù.
ÀÌ°ÍÀ» ´Ù¸£°Ô ¸»Çϸé Context switch ¶ó°í À̾߱â ÇÒ ¼ö ÀÖ½À´Ï´Ù.
2.7 Status Register Access Instructions
ResetHandler
MRS R0, CPSR
BIC R0, R0, #0x80 ; 7¹ø ºñÆ®¸¦ clear Çϸé ÀÎÅÍ·´Æ®°¡ È°¼ºÈ µË´Ï´Ù.
MSR CPSR, R0 |
- ½ÇÇà °á°ú
2.8 Conditional Execution
Áö±Ý±îÁö ¹è¿î ¸ðµç ¾î¼Àºí¸®¾îµéÀ» È°¿ëÇؼ ÃÖÁ¾ÀûÀ¸·Î ¸î°¡Áö ¿¹Á¦¸¦ Ç®¾î º¸µµ·Ï ÇÏ°Ú½À´Ï´Ù. ¿¹Á¦¸¦ ±¸ÇöÇϴµ¥¿¡´Â ¿©·¯°¡Áö ¹æ¹ýµéÀÌ ¸¹ÀÌ ÀÖ°ÚÁö¸¸ °¡Àå ÃÖÀûÈµÈ ¾î¼Àºí¸® ¸í·É¾î¸¦ »ç¿ëÇϽñ⠹ٶø´Ï´Ù.
(1) 1 ~ 10À» ´õÇÏ´Â ÃÖÀûÈµÈ ¾î¼Àºí¸®¾î·Î ÀÛ¼ºÇØ º¸¼¼¿ä.
ResetHandler
MOV R5, #10
MOV R6, #0
loop_sum
ADD R6, R6, R5
SUBS R5, R5, #1
BNE loop_sum ; Not Equal(Z=1) |
·çÇÁ¸¦ »ç¿ëÇÒ °æ¿ì¿¡´Â °Å²Ù·Î µµ´Â°ÍÀÌ È¿À²Àû ÀÔ´Ï´Ù.
(2) 2°³ º¯¼ö»çÀÌÀÇ Àý´ë°ªÀ» ±¸Çϼ¼¿ä.
- [-2 and 3] »çÀÌÀÇ Àý´ë°ª
ResetHandler
MOV R0, #-2
MOV R1, #3
SUBS R0, R0, R1
RSBMI R0, R0, #0 |
"SUBS R0, R0, R1" ¸í·ÉÀ» ½ÇÇà ÇßÀ»¶§ÀÇ ±×¸² ÀÔ´Ï´Ù. R0, CPSRÀÇ "N" Flag ¸¦ Àß »ìÆì º¸½Ã±â ¹Ù¶ø´Ï´Ù. Âü°í·Î RSBMI ¸í·É¾î´Â CPSRÀÇ "N" Flag °¡ Set µÇ¾î ÀÖÀ»¶§ –y¼ÀÀ» Çϴµ¥ SUB ¸í·É°ú´Â ¿¬»êÀÇ ¹æÇâÀÌ ¹Ý´ë·Î ¼öÇàÀÌ µÇ´Â ¸í·É¾î ÀÔ´Ï´Ù. ±×·¯´Ï±î À̹ø ¿¹Á¦¿¡¼´Â "#0" ¿¡¼ "R0" ¸¦ »©´Â °ÍÀÔ´Ï´Ù.
- [3 and 1] »çÀÌÀÇ Àý´ë°ª
ResetHandler
MOV R0, #3
MOV R1, #1
SUBS R0, R0, R1
RSBMI R0, R0, #0 |
"SUBS R0, R0, R1" ¸í·ÉÀ» ½ÇÇà ÇßÀ»¶§ÀÇ ±×¸² ÀÔ´Ï´Ù. R0, CPSRÀÇ "N" Flag ¸¦ Àß »ìÆì º¸½Ã±â ¹Ù¶ø´Ï´Ù.
|