指令系统 教学课件.ppt
《指令系统 教学课件.ppt》由会员分享,可在线阅读,更多相关《指令系统 教学课件.ppt(76页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、Instruction Set & Assembly Language Programming,Jianjian SONGSoftware Institute, Nanjing University,Content,Computer Architecture TaxonomyARM Architecture IntroductionARM Instruction SetARM Assembly Language Programming,1. Computer Architecture Taxonomy,What is architecture?,Architecture & Organizat
2、ion 1,Architecture is those attributes visible to the programmerInstruction set, number of bits used for data representation, I/O mechanisms, addressing techniques.e.g. Is there a multiply instruction?Organization is how features are implementedControl signals, interfaces, memory technology.e.g. Is
3、there a hardware multiply unit or is it done by repeated addition?,Architecture & Organization 2,All Intel x86 family share the same basic architectureThe IBM System/370 family share the same basic architectureThis gives code compatibilityAt least backwardsOrganization differs between different vers
4、ions,von Neumann architecture,Memory holds data, instructions.Central processing unit (CPU) fetches instructions from memory.Separate CPU and memory distinguishes programmable computer.CPU registers help out: program counter (PC), instruction register (IR), general-purpose registers, etc.,CPU + memo
5、ry,memory,CPU,PC,address,data,IR,ADD r5,r1,r3,200,200,ADD r5,r1,r3,Harvard architecture,CPU,PC,data memory,program memory,address,data,address,data,von Neumann vs. Harvard,Harvard cant use self-modifying code.Harvard allows two simultaneous memory fetches.Most DSPs use Harvard architecture for strea
6、ming data:greater memory bandwidth;more predictable bandwidth.,RISC vs. CISC,Complex instruction set computer (CISC):many addressing modes;many operations.Reduced instruction set computer (RISC):load/store;pipelinable instructions.,Load-store Architecture,指令集仅能处理(如ADD、SUB等)寄存器中(或指令中直接指定)的值,而且总是将处理结果
7、放回寄存器中。针对存储器的唯一操作是将存储器的值装入寄存器(load指令),或将寄存器的值存到存储器(store指令)。相比较,典型的CISC处理器允许将存储器中的值加(ADD)到寄存器,有时还允许将寄存器的值加(ADD)到存储器中。,Instruction set characteristics,Fixed vs. variable length.Addressing modes.Number of operands.Types of operands.,Programming model,Programming model: registers visible to the program
8、mer.Some registers are not visible (e.g. IR).,Multiple implementations,Successful architectures have several implementations:varying clock speeds;different bus widths;different cache sizes;etc.,2. ARM Architecture Introduction,ARM (Advanced RISC Machines)ARM公司是一家设计公司,是IP 供应商,靠转让设计许可证由合作伙伴生产各具特色的芯片。W
9、hat is IP?Intellectual Property,ARM的特点,ARM具有RISC体系的一般特点:大量寄存器绝大多数操作都在寄存器中进行,通过Load/Store的在内存和寄存器间传递数据。寻址方式简单采用固定长度的指令格式此外,小体积、低功耗、低成本、高性能16位/32位双指令集全球众多合作伙伴,ARM体系结构的版本和扩充,六个版本ARMv1 ARMv6ARM体系结构的扩充Thumb (T variant): 16位指令集,用以改善指令密度;DSP (E variant): 用于DSP应用的算术运算指令集;Jazeller (J variant): 允许直接执行Java字节码,
10、什么是指令密度?执行同等操作序列的前提下,单位内存空间所容纳的机器指令数。,ARM体系结构版本的命名格式,命名字符串:ARMvx (x: 指令集版本号,16)表示变种的字符 (如 T, E, J )用字符x表示排除某种写功能。,ARM处理器系列,ARM7系列ARM9系列ARM9E系列ARM10系列SecureCore系列Intel StrongARMIntel XScale,3. ARM Instruction Set,ARM assembly languageARM programming modelARM memory organizationARM data operationsARM
11、flow of control,Assembly language,Why assembly language?One-to-one with instructions (more or less).Basic features:One instruction per line.Labels provide names for addresses (usually in first column).Instructions often start in later columns.Columns run to end of line.,ARM assembly language example
12、,label1ADR r4,cLDR r0,r4 ; a commentADR r4,dLDR r1,r4SUB r0,r0,r1 ; comment,ARM指令的一般编码格式,opcode: 指令操作符编码cond: 指令执行条件编码S: 指令的操作是否影响CPSR的值Rn: 包含第一个操作数的寄存器编码Rd: 目标寄存器编码Shifter_operand: 第二个操作数,ARM指令的基本寻址方式,寄存器寻址例:ADD R0 , R1 , R2 ; (R1)+(R2)R0立即数寻址例:ADD R3 , R3 , #2 ; (R3)+2R3寄存器间接寻址例:LDR R0 , R3 ; (R3)
13、R0寄存器变址例:LDR R0 , R1, #4 ; (R1)+4)R0相对寻址例:B rel ; (PC)+relPC,Pseudo-ops,Some assembler directives dont correspond directly to instructions:Define current address.Reserve storage.Constants.,ARM programming model,r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14,r15 (PC),CPSR,31,0,Endianness,Relations
14、hip between bit and byte/word ordering defines endianness:,byte 3,byte 2,byte 1,byte 0,byte 0,byte 1,byte 2,byte 3,bit 31,bit 0,bit 0,bit 31,little-endian,big-endian,ARM data types,Word is 32 bits long.Word can be divided into four 8-bit bytes.ARM addresses can be 32 bits long.Address refers to byte
15、.Address 4 starts at byte 4.Can be configured at power-up as either little- or big-endian mode.,ARM status bits,Every arithmetic, logical, or shifting operation sets CPSR bits:N (negative), Z (zero), C (carry), V (overflow).Examples: -1 + 1 = 0: NZCV = 0110.231-1+1 = -231: NZCV = 0101.,Instructions
16、Overview,Data instructionsMove InstructionsLoad/Store instructionsComparison instructionsBranch instructions,ARM data instructions,Basic format:ADD r0,r1,r2Computes r1+r2, stores in r0.Immediate operand:ADD r0,r1,#2Computes r1+2, stores in r0.,ARM data instructions,ADD, ADC : add (w. carry)SUB, SBC
17、: subtract (w. carry)RSB, RSC : reverse subtract (w. carry)MUL, MLA : multiply (and accumulate),AND, ORR, EORBIC : bit clearLSL, LSR : logical shift left/rightASL, ASR : arithmetic shift left/rightROR : rotate rightRRX : rotate right extended with C,Data operation varieties,Logical shift:fills with
18、zeroes.Arithmetic shift:fills with ones.RRX performs 33-bit rotate, including C bit from CPSR above sign bit.,ARM move instructions,MOV, MVN : move (negated)MOV r0, r1 ; sets r0 to r1,ARM load/store instructions,LDR, LDRH, LDRB : load (half-word, byte)STR, STRH, STRB : store (half-word, byte)Address
19、ing modes:register indirect : LDR r0,r1with second register : LDR r0,r1,-r2with constant : LDR r0,r1,#4,ARM comparison instructions,CMP : compareCMN : negated compareTST : bit-wise testTEQ : bit-wise negated testThese instructions set only the NZCV bits of CPSR.,ARM branch instructions,B: BranchBL:
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 指令系统 教学 课件
限制150内