嵌入式系统架构软体设计.ppt
《嵌入式系统架构软体设计.ppt》由会员分享,可在线阅读,更多相关《嵌入式系统架构软体设计.ppt(179页珍藏版)》请在三一办公上搜索。
1、嵌入式系统架构软体设计,嵌入式系统架构软体设计-using ARMDay#3,#4,#5 Modules Outline,课程介绍,Day#3Simple RISC Assembly Language ARM Assembly LanguageARM Development Suite 使用练习Day#4Arm Instruction setImportant ASM Programming SkillsARM/THUMB/C InterworkingDay#5ARM Exception HandlerBuild ARM ROM ImageUse NET-Start!ucLinux BSP,嵌
2、入式系统产品设计流程概观,ARM system-on-chip Architecture,2nd ed.ARM architecture reference manual,2nd ed.ARM Development Suite-Getting StartedARM Development Suite-Developer GuideARM Development Suite-Assembler Guidehttp:/www.uclinux.org/2002嵌入式系统开发经验Building powerful platform with Windows CESoftware Engineerin
3、g,A practitioners Approach 3rd ed.Professional Symbian Programming,嵌入式系统架构软体设计-using ARMModule#3-1:Simple RISC Assembly Concept,RISC精简指令集vs.CISC复杂指令集,Hardware instruction decode logicPipeline executionSingle execution,Large microcode ROMs to decode instructionAllow little pipelineMany cycles to comp
4、leter a single instruction,A smaller die sizeA shorter development timeA higher performance Poor code density,MUO 一个简单的处理器,MUO指令集与资料路径,指令规则,指令执行范例,ADD 0 x16AACC:=ACC+mem0 x16A,运算范例,C function:Main()C=A+B;,MUO 机器指令LDA 0 x100ADD 0 x104STO 0 x108,练习:MUO微处理器的运算,0 x100 LDA 0 x1000 x002 SUB 0 x1040 x004 S
5、TO 0 x1000 x006 JNE 0 x0000 x008 STP,请描述此段程式的动作,暂存器值的变化、与资料流。请用C语言来写出这段程式码。,嵌入式系统架构软体设计-using ARMModule#3-2:ARM Assembly Language,ARM7TDMI资料流,e.g.r3:=r4+(r4,2)ADD r3,r4,r4,LSL#2 A bus B bus,ARM 的暂存器,30 general-purpose,32 bits registers1 Program Counter(PC)1 Current Program Status Register(CPSR)5 Sav
6、ed Program Status Registers(SPSR),User mode FIQ mode irq mode SVC mode abort mode undefined mode,Program Status Register,CPSR:Currrent Program Status RegiterSPSR:Saved Program Status Register,Condition code flags-N:Negative rsult from ALU-Z:Zero result from ALU-C:ALU operation Carried out-V:ALU oper
7、ation overflowed,Inerrupt Disable bits-I:disable the IRQ-F:Disable the FIQ,T bit-Architechture xT only-T=0:ARM state-T=1:Thumb state,Q:Stickly Overflow flag-Architecture 5TE only-QADD,QSUB,J:Processor in Jazelle stateArchitecture 5TEJ only,Mode bitsSpecify the processor mode10000 User10001 FIQ10010
8、IRQ10011 SVC10111 Abort11011 Undef11111 System,31 30 29 28 27 24 7 6 5 4 0N Z C V Q J undefined I F T mode,Program counter R15,ARM state:All ARM instructions are four bytes long(one 32-bit word)and are always aligned on a word boundary.The PC value is stored in bits 31:2 with bits 1:0 undefined.In T
9、humb state:All instructions are 16 bits wide,and halfword alignedThe PC value is stored in bits31:1 with bits 0 undefined.In Jazelle state:All instructions are 8 bits wide.The processor performs a word access to read 4 instructions at once.,Link Register R14,Register 14 is the Link Register(LR).This
10、 register holds the address of the next instruction after a Branch and Link(BL)instruction,which is the instruction used to make a subroutine call.At all other times,R14 can be used as a general-purpose register,Other Register R0-R13,The remaining 15 registers have no special hardware purpose.Their
11、uses are defined purely by software.By convention,ARM assembly language use R13 as Stack Pointer.C and C+compilers always use R14 as the Stack Pointer(SP),Structure of ARM Assembly Language Module,AREA Sectionname,attr,attrStart of New code or data section.CODE:contain machine instructions.READONLY:
12、section should not be written to.Other attr:DATA,NOINIT,READWRITE,Declares an entry point to a program.Labels.Declares the end of the source file.,Calling Subroutines Uses BL,BL destination destination is the label on the first instruction of the subroutine.BL does:place the return address in the li
13、nk register(R14)sets PC to the address of the subroutine.In the subroutinewe can use“MOV pc,lr”to return.By convention,R0-R3 are used to pass parameters.,Calling Subroutines Example,;name this block of code;mark first instruction;to execute,;Set up parameters;Call subroutine,;angel_SWI reason_report
14、 Exception;ADP_Stopped_ApplicationExit;ARM semihosting SWI,;Subroutine code;Return from subroutine.;Mark end of file,Constant Data Types,Numbers Numeric constants are accepted in three forms:Decimal,for example,123Hexadecimal,for example,0 x7Bn_XXX where:n is as base between 2 and 9 xxx is a number
15、in that base.Boolean TRUE and FALSE must be written as TRUE and FALSE.Characters constants consist of opening and closing single quotes X,enclosing either a single character or an escaped character,using the standard C escape characters.Strings consist of opening and closing double quotes“XXXX”.If d
16、ouble quotes or dollar signs are used within a string as literal text characters,they must be represented by a pair of the appropriate character.For example,you must use$if you require a single$in the string.The standard C escape sequences can be used within string constants.,Almost all ARM instruct
17、ions can be conditionally executed.e.g.ADDS r0,r1,r2ADDEQ r0,r1,r2Execute if the N,Z,C and V flags in the CPSR satisfy a condition specified in the instruction,otherwise,NOP.,Conditional ARM Instructions,Almost every ARM instruction can be executed conditionally on the state of the ALU state flags i
18、n the CPSR.Add an S suffix to an ARM data processing instruction to make it update the ALU state flags in the CPSRE.g.ADDS r0,r1,r2;r0=r1+r2 and update ALU status in CPSR.In ARM state,you can:update the ALU status flags in the PSR on the result of a data operationexecute several other data operation
19、 without updating the flagsexecute following instructions or not,according to the state of the flags updated in the first operation.In Thumb state most data operations always update the flagsand conditional execution can only be achieved using the conditional branch instruction(B).Do not use the S s
20、uffix with CMP,CMN,TST,or TEQ.These comparison instructions always update the flag,Conditional Execution,ALU Status Register in CPSR,N Set when the result of the operation was Negative.Z Set when the result of the operation was Zero.C when the result of the operation was Carry.A carry occurs if the
21、result of an addition is greater than or equal to 232If the result of a instruction is positive,or as the result of an inline barrel shifter operation in a move or logical instruction.V Set when the operation caused oVerflow.Overflow occurs if the result of an add,subtract,or compare is greater than
22、 or equal to 231,or less than 231.Q ARM architecture v5Eonly.Sticky flag.Used to detect saturation in special saturating arithmetic instructions(e.g.QAD,ASUB,QDADD,and QDSUB),Or overflow in certain multiply instructions(SMLAxy and SMLAWy),Conditional Code Suffixes,Conditional Code Examples,ADD r0,r1
23、,r2;r0=r1+r2,dont update flagsADDS r0,r1,r2;r0=r1+r2,and update flagsADDCSS r0,r1,r2;if C flag set then r0=r1+r2,and update flagsCMP r0,r1;update flags based on r0-r1.Example code sequence:MOV R0,#0LOOP ADD R0,R0,#1CMP R0,#10BNE LOOPSUB R1,R1,R0,Write Efficient and small size Code by Conditional Ins
24、truction,Exercise,Write program by ARM assembly,&evaluate the execution cost in clock.A Branch needs 3 cycles,others cost 1,注:只需使用CMP,SUB,B这三个指令,加上条件式,就可以完成,While(r1!=r2)do if(r1r2)r1=r1-r2;elser2=r2-r1;,嵌入式系统架构软体设计-using ARM Module#3-3:ARM Development Suite使用练习,ARM ADS 1.2,Others:C&C+LibrariesARM f
25、irmware suiteAM application libraryRealMonitor:for real time debug monitor,Implementation Integration,Pre-configured Project Stationary Files,DebugThis build target is configured to built output binaries that are fully debuggable,at the expense of optimization.ReleaseThis build target is debuggable
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 嵌入式 系统 架构 软体 设计

链接地址:https://www.31ppt.com/p-6415004.html