《嵌入式系统设计.pdf》由会员分享,可在线阅读,更多相关《嵌入式系统设计.pdf(120页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、北京大学软件与微电子学院北京大学软件与微电子学院2006.22006.2嵌入式系统设计嵌入式系统设计嵌入式系统设计嵌入式系统设计第三章第三章第三章第三章 ARM ARM 汇编语言汇编语言汇编语言汇编语言北京大学软件与微电子学院北京大学软件与微电子学院2006.22006.2汇编语言汇编语言汇编语言汇编语言?ADS1.2ADS1.2?AssemblerAssembler?ARM Assembly LanguageARM Assembly Language?ARM Instruction SetARM Instruction Set?Thumb Instruction SetThumb Instr
2、uction Set?ExamplesExamples?SummarySummary北京大学软件与微电子学院北京大学软件与微电子学院2006.22006.2汇编语言汇编语言汇编语言汇编语言-ADS(1)ADS(1)1.What is ADS1.What is ADS?ARM Developer SuiteARM Developer Suite?Can be used to develop,build,and debug C,Can be used to develop,build,and debug C,C+,or ARM assembly language programs.C+,or AR
3、M assembly language programs.?RVDS RVDS(RealViewRealView Developer SuiteDeveloper Suite)2.Components of ADS2.Components of ADS?CommandCommand-line development toolsline development tools?GUI development toolsGUI development tools?UtilitiesUtilities?Supporting software.Supporting software.北京大学软件与微电子学
4、院北京大学软件与微电子学院2006.22006.2汇编语言汇编语言汇编语言汇编语言-ADS(2)ADS(2)3.Command3.Command-line development toolsline development tools?armccarmccThe ARM C compiler.It compiles ANSI source into The ARM C compiler.It compiles ANSI source into 3232-bit ARM code.bit ARM code.?armcpparmcppThis is the ARM C+compiler.It co
5、mpiles ISO C+This is the ARM C+compiler.It compiles ISO C+or EC+source into 32or EC+source into 32-bit ARM code.bit ARM code.?tcctccThe Thumb C compiler.It compiles ANSI source into The Thumb C compiler.It compiles ANSI source into 1616-bit Thumb code.bit Thumb code.?tcpptcppThis is the Thumb C+comp
6、iler.It compiles ISO This is the Thumb C+compiler.It compiles ISO C+or EC+source into 16C+or EC+source into 16-bit Thumb code.bit Thumb code.北京大学软件与微电子学院北京大学软件与微电子学院2006.22006.2汇编语言汇编语言汇编语言汇编语言-ADS(3)ADS(3)3.Command3.Command-line development tools line development tools(cont.)(cont.)?armasmarmasmThe
7、 ARM and Thumb assembler.The ARM and Thumb assembler.For both ARM and Thumb assembly language source.For both ARM and Thumb assembly language source.?armlinkarmlinkThe ARM linker.The ARM linker.It Combines object files and libraries to produce an It Combines object files and libraries to produce an
8、ELF executable images.ELF executable images.?armsdarmsdThe ARM and Thumb symbolic debugger.This The ARM and Thumb symbolic debugger.This enables source level debugging of programs.enables source level debugging of programs.为什么为什么ARM和和Thumb编译工具不同,而汇编工具可以是同一个?编译工具不同,而汇编工具可以是同一个?北京大学软件与微电子学院北京大学软件与微电子学
9、院2006.22006.2汇编语言汇编语言汇编语言汇编语言-ADS(4)ADS(4)4.GUI development tools4.GUI development tools?AXDAXDThe ARM Debugger for Windows and UNIX.The ARM Debugger for Windows and UNIX.?IDEIDEThe project management tool for Windows.The project management tool for Windows.5.Supporting software.5.Supporting softwar
10、e.?ARMulatorARMulator,The ARM core simulator.,The ARM core simulator.?This provides instructionThis provides instruction-accurate simulation of accurate simulation of ARM processorsARM processors?Enables ARM and Thumb executable programs to Enables ARM and Thumb executable programs to be run on nonb
11、e run on non-native hardwarenative hardware北京大学软件与微电子学院北京大学软件与微电子学院2006.22006.2汇编语言汇编语言汇编语言汇编语言-ADS(5)ADS(5)6.Utilities 6.Utilities?fromELFfromELFThe ARM image conversion utility.The ARM image conversion utility.?armprofarmprofThe ARM profiler displays an execution profile of a simple The ARM profil
12、er displays an execution profile of a simple program from a profile data file generated by an ARM program from a profile data file generated by an ARM debugger.debugger.?armararmarThe ARM librarian enables sets of ELF format object files to The ARM librarian enables sets of ELF format object files t
13、o be collected together and maintained in librariesbe collected together and maintained in libraries?Flash downloaderFlash downloaderUtility for downloading binary images to Flash memory on Utility for downloading binary images to Flash memory on an ARM Integrator board or an ARM Development boardan
14、 ARM Integrator board or an ARM Development board.北京大学软件与微电子学院北京大学软件与微电子学院2006.22006.2汇编语言汇编语言汇编语言汇编语言-ADS(9)ADS(9)8.AXD 8.AXD?What is AXDWhat is AXD?ARM ARM eXtendedeXtended DebuggerDebugger?Debug targetDebug target?Simulator on the same computerSimulator on the same computer?Hardware on a printed
15、circuit boardHardware on a printed circuit board?debugger issuesdebugger issues?Load software into memory on the targetLoad software into memory on the target?Start and stop execution of that softwareStart and stop execution of that software?Display the contents of memory,registers,and Display the c
16、ontents of memory,registers,and variablesvariables?Enable you to change stored values.Enable you to change stored values.北京大学软件与微电子学院北京大学软件与微电子学院2006.22006.2汇编语言汇编语言汇编语言汇编语言-ADS(10)ADS(10)8.AXD(cont.)8.AXD(cont.)?What is AXD(cont.)What is AXD(cont.)?Debug agentDebug agent?FunctionsFunctions?Setting
17、breakpointsSetting breakpoints?Reading from memoryReading from memory?Writing to memoryWriting to memory北京大学软件与微电子学院北京大学软件与微电子学院2006.22006.2汇编语言汇编语言汇编语言汇编语言-ADS(11)ADS(11)8.AXD(cont.)8.AXD(cont.)?What is AXD(cont.)What is AXD(cont.)?Debug agentDebug agent?ExamplesExamples?ARMulatorARMulatorProvides
18、an environment for the development of Provides an environment for the development of ARMARM-targeted software on the supported host targeted software on the supported host systemssystemsEnables benchmarking of ARMEnables benchmarking of ARM-targeted software.targeted software.?AngelAngelDevelopment
19、and debugging of applications Development and debugging of applications running on ARMrunning on ARM-based hardwarebased hardware?MultiMulti-ICEICEProvide the interface between a debugger and Provide the interface between a debugger and an ARM corean ARM core北京大学软件与微电子学院北京大学软件与微电子学院2006.22006.2汇编语言汇
20、编语言汇编语言汇编语言?ADS1.2ADS1.2?AssemblerAssembler?ARM Assembly LanguageARM Assembly Language?ARM Instruction SetARM Instruction Set?Thumb Instruction SetThumb Instruction Set?ExamplesExamples?SummarySummary北京大学软件与微电子学院北京大学软件与微电子学院2006.22006.2汇编语言汇编语言汇编语言汇编语言-Assembler(1)Assembler(1)1.Format of source line
21、s1.Format of source lines?lines in an ARM assembly language module lines in an ARM assembly language module is:is:symbol instruction|directive|pseudosymbol instruction|directive|pseudo-instruction;instruction;commencommen?ExamplesExampleslable1lable1ADD r1ADD r1,r2 ;r2 ;”+”北京大学软件与微电子学院北京大学软件与微电子学院20
22、06.22006.2汇编语言汇编语言汇编语言汇编语言-Assembler(2)Assembler(2)2.Predefined register and coprocessor names2.Predefined register and coprocessor names?PredeclaredPredeclared register namesregister names?r0r0-r15 and R0r15 and R0-R15R15?a1a1-a4(argument,result,or scratch registers,a4(argument,result,or scratch re
23、gisters,synonyms for r0 to r3)synonyms for r0 to r3)?v1v1-v8(variable registers,r4 to r11)v8(variable registers,r4 to r11)?sbsb and SB(static base,r9)and SB(static base,r9)?slsl and SL(stack limit,r10)and SL(stack limit,r10)?fpfp and FP(frame pointer,r11)and FP(frame pointer,r11)?ipip and IP(intraan
24、d IP(intra-procedureprocedure-call scratch register,call scratch register,r12)r12)?sp and SP(stack pointer,r13)sp and SP(stack pointer,r13)?lr lr and LR(link register,r14)and LR(link register,r14)?pc and PC(program counter,r15).pc and PC(program counter,r15).北京大学软件与微电子学院北京大学软件与微电子学院2006.22006.2汇编语言汇
25、编语言汇编语言汇编语言-Assembler(3)Assembler(3)2.Predefined register and coprocessor 2.Predefined register and coprocessor names(cont.)names(cont.)?PredeclaredPredeclared program status register namesprogram status register names?cpsrcpsr and CPSR(current program status register)and CPSR(current program status
26、 register)?spsrspsr and SPSR(saved program status register).and SPSR(saved program status register).?PredeclaredPredeclared floatingfloating-point register namespoint register names?f0f0-f7 and F0f7 and F0-F7(FPA registers)F7(FPA registers)?s0s0-s31 and S0s31 and S0-S31(VFP singleS31(VFP single-prec
27、ision registers)precision registers)?d0d0-d15 and D0d15 and D0-D15(VFP doubleD15(VFP double-precision precision registers).registers).?PredeclaredPredeclared coprocessor namescoprocessor names?p0p0-p15(coprocessors 0p15(coprocessors 0-15)15)?c0c0-c15(coprocessor registers 0c15(coprocessor registers
28、0-15).15).北京大学软件与微电子学院北京大学软件与微电子学院2006.22006.2汇编语言汇编语言汇编语言汇编语言-Assembler(4)Assembler(4)3.Built3.Built-in variablesin variables?ListList?PC or.PC or.Address of current instructionAddress of current instruction.?VAR or VAR or Current value of the storage area location Current value of the storage area
29、 location counter.counter.?TRUETRUELogical constant true.Logical constant true.?FALSEFALSELogical constant false.Logical constant false.?OPTOPTValue of the currentlyValue of the currently-set listing option.set listing option.?CONFIGCONFIG?32 if the assembler is assembling ARM code32 if the assemble
30、r is assembling ARM code?16 if it is assembling Thumb code.16 if it is assembling Thumb code.?ENDIANENDIAN?big if the assembler is in bigbig if the assembler is in big-endian modeendian mode?little if it is in littlelittle if it is in little-endian mode.endian mode.北京大学软件与微电子学院北京大学软件与微电子学院2006.22006
31、.2汇编语言汇编语言汇编语言汇编语言-Assembler(5)Assembler(5)4.Symbols4.Symbols?Symbol naming rulesSymbol naming rules?you can use you can use uppercase lettersuppercase letters,lowercase letterslowercase letters,numeric charactersnumeric characters,or the,or the underscore characterunderscore characterin symbol name
32、s.in symbol names.?Do not use Do not use numeric characters for the first numeric characters for the first character of symbol namescharacter of symbol names,except in,except in local labelslocal labels(see Local labels).(see Local labels).?Symbol names are Symbol names are casecase-sensitivesensiti
33、ve.?All characters in the symbol name areAll characters in the symbol name are significantsignificant.?Symbol names must be Symbol names must be unique within their scopeunique within their scope.北京大学软件与微电子学院北京大学软件与微电子学院2006.22006.2汇编语言汇编语言汇编语言汇编语言-Assembler(6)Assembler(6)4.Symbols(cont.)4.Symbols(c
34、ont.)?Symbol naming rules(cont.)Symbol naming rules(cont.)?Symbols must not use Symbols must not use builtbuilt-in variablein variable names or names or predefined symbolpredefined symbol names names?Symbols must not use the same name as Symbols must not use the same name as instruction mnemonicsins
35、truction mnemonics oror directivesdirectives.If you use.If you use the same name as an instruction mnemonic or the same name as an instruction mnemonic or directive,directive,use double bars to delimit the symbol use double bars to delimit the symbol namename.For example:For example:|ASSERT|ASSERT|?
36、If you need to use a If you need to use a wider range of characterswider range of characters in in symbols,use symbols,use single barssingle bars to delimit the symbol to delimit the symbol name.name.For example:For example:|.text|.text|?The bars are not part of the symbol.You cannot The bars are no
37、t part of the symbol.You cannot use bars,semicolons,or use bars,semicolons,or newlinesnewlines within the bars.within the bars.北京大学软件与微电子学院北京大学软件与微电子学院2006.22006.2汇编语言汇编语言汇编语言汇编语言-Assembler(7)Assembler(7)4.Symbols(cont.)4.Symbols(cont.)?VariablesVariables?three types three types?Numeric,Logical,Stri
38、ng.Numeric,Logical,String.?The type of a variable cannot be The type of a variable cannot be changed.changed.?The range of possible values of a The range of possible values of a numeric variable is the same as the numeric variable is the same as the range of possible values of a numeric range of pos
39、sible values of a numeric constant or numeric expression.constant or numeric expression.北京大学软件与微电子学院北京大学软件与微电子学院2006.22006.2汇编语言汇编语言汇编语言汇编语言-Assembler(8)Assembler(8)4.Symbols(cont.)4.Symbols(cont.)?VariablesVariables?The possible values of a logical variable The possible values of a logical variable
40、 are TRUE or FALSEare TRUE or FALSE?The range of possible values of a string The range of possible values of a string variable is the same as the range of variable is the same as the range of values of a string expression values of a string expression?Use the GBLA,GBLL,GBLS,LCLA,LCLL,Use the GBLA,GB
41、LL,GBLS,LCLA,LCLL,and LCLS directives to declare symbols and LCLS directives to declare symbols representing variables,and assign representing variables,and assign values to them using the SETA,SETL,values to them using the SETA,SETL,and SETS directives.and SETS directives.北京大学软件与微电子学院北京大学软件与微电子学院20
42、06.22006.2汇编语言汇编语言汇编语言汇编语言-Assembler(9)Assembler(9)4.Symbols(cont.)4.Symbols(cont.)?Numeric constantsNumeric constants?Numeric constants are 32Numeric constants are 32-bit integers.bit integers.?unsigned numbers in the range 0 to 2unsigned numbers in the range 0 to 23232 1 1?signed numbers in the ra
43、nge signed numbers in the range-2 23131to to 2 23131-1.1.?Use the EQU directive to define Use the EQU directive to define constants.You constants.You cannot changecannot change the value the value of a numeric constant after you define it.of a numeric constant after you define it.北京大学软件与微电子学院北京大学软件与
44、微电子学院2006.22006.2汇编语言汇编语言汇编语言汇编语言-Assembler(10)Assembler(10)4.Symbols(cont.)4.Symbols(cont.)?Assembly time substitution of variablesAssembly time substitution of variables?Use the variable with a$prefix in the Use the variable with a$prefix in the places where the value is to be places where the val
45、ue is to be substituted for the variable.substituted for the variable.?Numeric and logical variables can also Numeric and logical variables can also be substituted.The current value of the be substituted.The current value of the variable is converted to a hexadecimal variable is converted to a hexad
46、ecimal string(or T or F for logical variables)string(or T or F for logical variables)before substitution.before substitution.北京大学软件与微电子学院北京大学软件与微电子学院2006.22006.2汇编语言汇编语言汇编语言汇编语言-Assembler(11)Assembler(11)4.Symbols(cont.)4.Symbols(cont.)?Assembly time substitution of Assembly time substitution of var
47、iables(cont.)variables(cont.)?Use a dot to mark the end of the variable name Use a dot to mark the end of the variable name if the following character would be permissible if the following character would be permissible in a symbol name in a symbol name?If you need a$that you do not want to be If yo
48、u need a$that you do not want to be substituted,use$.This is converted to a single substituted,use$.This is converted to a single$.$.?You can include a variable with a$prefix in a You can include a variable with a$prefix in a string.Substitution occurs in the same way as string.Substitution occurs i
49、n the same way as anywhere else.anywhere else.?Substitution does not occur within vertical bars,Substitution does not occur within vertical bars,except that vertical bars within double quotes do except that vertical bars within double quotes do not affect substitution.not affect substitution.北京大学软件与
50、微电子学院北京大学软件与微电子学院2006.22006.2汇编语言汇编语言汇编语言汇编语言-Assembler(12)Assembler(12)4.Symbols(cont.)4.Symbols(cont.)?Assembly time substitution of variables(cont.)Assembly time substitution of variables(cont.)?ExamplesExamples;straightforward substitution;straightforward substitutionGBLS add4ffGBLS add4ffadd4ff