Emulation. Michael Jantz
|
|
- Robert Blaze Hamilton
- 5 years ago
- Views:
Transcription
1 Emulation Michael Jantz
2 Acknowledgements Slides adapted from Chapter 2 in Virtual Machines: Versatile Platforms for Systems and Processes by James E. Smith and Ravi Nair Credit to Prasad A. Kulkarni some slides were borrowed from his course on Virtual Machines at the University of Kansas 2
3 Outline Emulation Interpretation Basic, indirect threaded, and direct threaded Binary translation Code discovery, code location Other issues Control transfer optimizations Instruction set issues 3
4 Emulation vs. Simulation Emulation: process of implementing the interface / functionality of a (sub)system on a different system Applies specifically to an instruction set Different emulation techniques Interpretation (instruction-at-a-time) Binary translation (block-at-a-time) Simulation Method for modeling a system s operation Goal is to study process not to imitate function 4
5 Definitions Guest Environment supported by underlying platform Host Underlying platform used to provide an environment for the guest Guest Host supported by 5
6 Definitions Source ISA or binary Original instruction set or binary The ISA to be emulated Target ISA or binary ISA of the host processor Underlying ISA Source / target refer to ISAs Guest / host refer to platforms Source Target emulated by 6
7 Instruction Set Emulation Binaries in source instruction set can be executed on machine implementing target instruction set Required for many VM implementations Example: IA-32 EL 7
8 Interpretation vs. Translation Interpretation Simple, easy to implement Low performance Binary translation Complex implementation Higher initial cost, better performance Techniques in between these extremes Predecoding Selective compilation 8
9 Interpreter State Must maintain state of machine implementing the source ISA Registers Memory Code Data Stack Code Data Stack Program Counter Condition Codes Reg 0 Reg 1. Reg n-1 Interpreter Code 9
10 Decode-And-Dispatch Interpreter Decode-and-dispatch loop One instruction at a time Decode the current instruction Dispatch to corresponding interpreter routine while (!halt &&!interrupt) { inst = code[pc]; opcode = extract(inst,31,6); switch(opcode) { case LoadWordAndZero: LoadWordAndZero(inst); case ALU: ALU(inst); case Branch: Branch(inst);...} } 10
11 Decode-And-Dispatch Interpreter LoadWordAndZero(inst){ RT = extract(inst,25,5); RA = extract(inst,20,5); displacement = extract(inst,15,16); if (RA == 0) source = 0; else source = regs[ra]; address = source + displacement; regs[rt] = (data[address]<< 32)>> 32; PC = PC + 4; } 11
12 Decode-And-Dispatch Interpreter ALU(inst){ RT = extract(inst,25,5); RA = extract(inst,20,5); RB = extract(inst, 15,5); source1 = regs[ra]; source2 = regs[rb]; extended_opcode = extract(inst,10,10); switch(extended_opcode) { case Add: Add(inst); case AddCarrying: AddCarrying(inst); case AddExtended: AddExtended(inst);...} PC = PC + 4; } 12
13 Decode-And-Dispatch Efficiency Decode-and-dispatch loop Several branch instructions Indirect branch on switch statement Interpreting an add instruction Requires approximately 20 target instructions Several expensive loads/stores to memory Hand-coded assembly can improve performance Example: HotSpot JVM 13
14 Indirect Threaded Interpretation High number of branches in decode-anddispatch loop reduces performance At least 5 branches per instruction Threaded interpretation Append dispatch code with each interpretation routine Removes 3 branches Threads interpretation routines together 14
15 Indirect Threaded Interpretation LoadWordAndZero: RT = extract(inst,25,5); RA = extract(inst,20,5); displacement = extract(inst,15,16); if (RA == 0) source = 0; else source = regs(ra); address = source + displacement; regs(rt) = (data(address)<< 32) >> 32; PC = PC +4; If (halt interrupt) goto exit; inst = code[pc]; opcode = extract(inst,31,6) extended_opcode = extract(inst,10,10); routine = dispatch[opcode,extended_opcode]; goto *routine; 15
16 Indirect Threaded Interpretation Add: RT = extract(inst,25,5); RA = extract(inst,20,5); RB = extract(inst,15,5); source1 = regs(ra); source2 = regs[rb]; sum = source1 + source2 ; regs[rt] = sum; PC = PC + 4; If (halt interrupt) goto exit; inst = code[pc]; opcode = extract(inst,31,6); extended_opcode = extract(inst,10,10); routine = dispatch[opcode,extended_opcode]; goto *routine; 16
17 Indirect Threaded Interpretation Dispatch occurs indirectly through a table Interpretation routines can be modified and relocated independently Advantages Interpretation routines still portable Improves efficiency over decode-and-dispatch Disadvantages Increases interpreter code size 17
18 Indirect Threaded Interpretation source code interpreter routines source code interpreter routines "data" accesses dispatch loop Decode-dispatch Threaded 18
19 Predecoding Parse each instruction into a pre-defined data structure to facilitate interpretation Separate opcodes, operands, etc. Reduces shifts / masks for decoding More useful when source ISA is CISC lwz r1, 8(r2) add r3, r3,r1 stw r3, 0(r4) 19
20 Predecoding struct instruction { unsigned long op; unsigned char dest, src1, src2; } code [CODE_SIZE]; LoadWordandZero: RT = code[tpc].dest; RA = code[tpc].src1; displacement = code[tpc].src2; if (RA == 0) source = 0; else source = regs[ra]; address = source + displacement; regs[rt] = (data[address]<< 32) >> 32; SPC = SPC + 4; TPC = TPC + 1; If (halt interrupt) goto exit; opcode = code[tpc].op routine = dispatch[opcode]; goto *routine; 20
21 Direct Threaded Interpretation Replace table lookup with direct access to address of interpreter routine Requires predecoding Reduces portability 21
22 Direct Threaded Interpretation LoadWordandZero: RT = code[tpc].dest; RA = code[tpc].src1; displacement = code[tpc].src2; if (RA == 0) source = 0; else source = regs[ra]; address = source + displacement; regs[rt] = (data[address]<< 32) >> 32; SPC = SPC + 4; TPC = TPC + 1; If (halt interrupt) goto exit; routine = code[tpc].op; goto *routine; 22
23 Direct Threaded Interpretation source code intermediate code interpreter routines predecoder 23
24 Binary Translation Convert source binary to target binary before execution Logical conclusion of predecoding Removes parsing and jumps altogether Allows optimizations on native code Achieves better performance than interpretation Generated code no longer portable 24
25 Binary Translation source code binary translated target code binary translator 25
26 Binary Translation x86 Source Binary addl movl add %edx,4(%eax) 4(%eax),%edx %eax,4 Translate to PowerPC Target r1 points to x86 register context block r2 points to x86 memory image r3 contains x86 ISA PC value 26
27 Binary Translation lwz r4,0(r1) ;load %eax from register block addi r5,r4,4 ;add 4 to %eax lwzx r5,r2,r5 ;load operand from memory lwz r4,12(r1) ;load %edx from register block add r5,r4,r5 ;perform add stw r5,12(r1) ;put result into %edx addi r3,r3,3 ;update PC (3 bytes) lwz r4,0(r1) ;load %eax from register block addi r5,r4,4 ;add 4 to %eax lwz r4,12(r1) ;load %edx from register block stwx r4,r2,r5 ;store %edx value into memory addi r3,r3,3 ;update PC (3 bytes) lwz r4,0(r1) ;load %eax from register block addi r4,r4,4 ;add immediate stw r4,0(r1) ;place result back into %eax addi r3,r3,3 ;update PC (3 bytes) 27
28 Register Mapping Map source registers to target registers Reduces memory loads / stores If target registers < source registers Map some to memory Map on per-block basis 28
29 Register Mapping r1 points to x86 register context block r2 points to x86 memory image r3 contains x86 ISA PC value r4 holds x86 register %eax r7 holds x86 register %edx etc. addi r16,r4,4 ;add 4 to %eax lwzx r17,r2,r16 ;load operand from memory add r7,r17,r7 ;perform add of %edx addi r16,r4,4 ;add 4 to %eax stwx r7,r2,r16 ;store %edx value into memory addi r4,r4,4 ;increment %eax addi r3,r3,9 ;update PC (9 bytes) 29
30 Code Discovery Problem May be difficult to statically predecode or translate the entire source program Code Discovery Problem: how to find the beginning of all source instructions? Consider the x86 code: mov %ch,0?? 31 c0 8b b b bd movl %esi, 0x (%ebp)?? 30
31 Code Discovery Problem Contributors to the code discovery problem Variable length CISC instructions Indirect jumps Data interspersed with code Padding instructions to align branch targets jump indirect to??? reg. source ISA instructions inst. 1 inst. 2 inst. 3 data jump inst. 5 inst. 6 uncond. brnch pad inst. 8 data in instruction stream 31 pad for instruction alignment
32 Code Location Problem How to map source PC to target PC for indirect jumps? Indirect jump addresses in the target code still refer to addresses in the source x86 source code movl %eax, 4(%esp) ;load jump address from memory jmp %eax ;jump indirect through %eax PowerPC target code addi r16,r11,4 ;compute x86 address lwzx r4,r2,r16 ;get x86 jump address ; from x86 memory image mtctr r4 ;move to count register bctr ;jump indirect through ctr 32
33 Simplified Solutions Solutions are simpler for special cases Fixed-length instruction sets (RISC ISAs) ISAs designed to be emulated (Java) No jumps / branches to arbitrary locations No data / padding interspersed with instructions All code can then be discovered 33
34 Incremental Code Translation General solutions translate the code dynamically and incrementally Interpret, then translate Interpretation performs code discovery Emulation Manager (EM) Translated code placed in the code cache Employ a map table for SPC to TPC mapping 34
35 Incremental Code Translation source binary SPC to TPC Lookup Table miss Interpreter translator Emulation Manager hit Translation Memory 35
36 Dynamic Basic Blocks Basic unit of incremental code translation Determined by runtime control flow Start at instruction following branch or jump Follow the sequential instruction stream End with the next branch or jump 36
37 Dynamic Basic Blocks add... load... store... loop: load... add... store brcond skip load... sub... skip: add... store brcond loop add... load... store... jump indirect Static Basic Blocks block 1 block 2 block 3 block 4 block 5 add... load... store... loop: load... add... store brcond skip load... sub... skip: add... store brcond loop loop: load... add... store skip: brcond skip add... store brcond loop Dynamic Basic Blocks block 1 block 2 block 3 block
38 Flow of Control Load source binary into memory, and EM begins interpreting source instructions Dynamically translate blocks of source code Place translated code into code cache SPC-to-TPC mapping placed into the map table Translation for one block is finished when a branch or jump is encountered 38
39 Dynamic Translation Flowchart 39
40 Tracking the Source PC EM needs up-to-date SPC from interpreter or translated code How to transfer? Map SPC to a register Place SPC in a stub after B&L instruction EM uses link register to find the SPC Emulation Manager Hash Table Code Block Branch and Link to EM Next Source PC Code Block 40
41 Translation Chaining Similar to threading in interpreters Link blocks together into chains Replace branch to EM w/ branch to next block Address of successor is determined using the map table If successor block is not yet translated Insert stub code to branch back to the EM EM can replace the stub code later 41
42 Translation Chaining Without Chaining With Chaining translation block translation block VMM translation block VMM translation block translation block translation block translation block 42
43 Creating a Link get next SPC 2 Lookup Successor 3 Set up chain 1 Jump TPC 4 Predecessor B&L JAL EM TM Next SPC Successor 43
44 Translation Chaining 44
45 Indirect Jump Prediction Chaining cannot be used for blocks ending with an indirect jump In many cases, jump target seldom changes Use profiling to determine jump targets Inline frequently used source PC / target PC values that are the targets of the jump Most frequent source PCs are checked first if Rx == addr_1 goto target_1 else if Rx == addr_2 goto target_2 else if Rx == addr_3 goto target_3 else hash_lookup(rx) ; do it the slow way 45
46 Incremental Translation Issues Tracking the source PC See earlier slide Self-modifying code Already translated code may become invalid Self-referencing code Referenced data should correspond to source code not translated target Precise traps Provide source state at traps and executions 46
47 Instruction Set Issues Register architectures Condition codes Data formats and arithmetic Byte Order 47
48 Register Architectures Target registers are used for: Holding general-purpose regs of the source ISA Holding special-purpose regs of the source ISA Pointing to register context block / memory image Holding intermediate values used by emulator # target regs < # source regs Must prioritize use of target registers Assign registers on a block-by-block basis 48
49 Condition Codes Condition codes are not used uniformly IA-32 CC are set implicitly SPARC and PowerPC set CC explicitly MIPS does not use CC Cases for CC emulation Neither source or target ISA use CC Source ISA does not use CC, target does Source ISA has explicit CC, no CC on target Source ISA has implicit CC, no CC on target 49
50 IA-32 Condition Codes IA-32 CC are a set of flags (EFLAGS) CC set by IA-32 add instruction OF: indicates whether integer overflow occurred SF: indicates the sign of the result ZF: indicates a zero result AF: indicates a carry or borrow out of bit 3 of the result (used for BCD arithmetic) CF: indicates a carry or borrow out of the most significant bit of the result PF: indicates parity of the least significant byte of the result. 50
51 Lazy Condition Code Evaluation CC are seldom used Lazy evaluation of CC Save the instruction that sets the CC Only compute the CC when needed During binary translation Use analysis to determine cases where CC will never be used 51
52 Lazy Condition Code Evaluation add %ebx, 0(%eax) add %ecx,%ebx jmp label1... label1: jz target R4 eax PPC to R5 ebx x86 register R6 ecx mappings.. R24 scratch register used by emulation code R25 condition code operand 1 ;registers R26 condition code operand 2 ;used for R27 condition code operation ;lazy condition ;emulation code R28 jump table base address 52
53 Lazy Condition Code Evaluation mr r25,r6 ;save operands mr r26,r5 ;and opcode for li r27, add ;lazy condition code emulation add r6,r6,r5 ;translation of add b label1... label1: bl genzf ;branch and link genzf code beq cr0,target ;branch on condition flag... genzf: add r29,r28,r27 ;add opcode to jump table base mtctr r29 ;copy to counter register bctr ;branch via jump table add : add. r24,r25,r26 ;perform PowerPC add, set cr0 blr ;return 53
54 Data Formats and Arithmetic Most formats have been standardized Integers: two s complement Floating point: IEEE standard Basic logical / arithmetic operations are mostly present Some exceptions IA-32 FP uses 80 bit intermediate results Integer divide vs FP divide and approximate Different immediate lengths 54
55 Byte Order Ordering of bytes within a word may differ Big endian vs. little endian Guest typically maintained in same order assumed by the source ISA Emulation SW modifies addresses when bytes within words are addressed Some targets support both orders MIPS, IA-64 55
56 Same ISA Emulation Emulation SW can monitor source program at the instruction-level Applications Simulation OS call emulation Program shepherding Performance optimization 56
Lecture 2: The Art of Emulation
CSCI-GA.3033-015 Virtual Machines: Concepts & Applications Lecture 2: The Art of Emulation Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com Disclaimer: Many slides of this lecture are based
More informationFor our next chapter, we will discuss the emulation process which is an integral part of virtual machines.
For our next chapter, we will discuss the emulation process which is an integral part of virtual machines. 1 2 For today s lecture, we ll start by defining what we mean by emulation. Specifically, in this
More informationMechanisms and constructs for System Virtualization
Mechanisms and constructs for System Virtualization Content Outline Design goals for virtualization General Constructs for virtualization Virtualization for: System VMs Process VMs Prevalent trends: Pros
More informationVirtual Machines and Dynamic Translation: Implementing ISAs in Software
Virtual Machines and Dynamic Translation: Implementing ISAs in Software Krste Asanovic Laboratory for Computer Science Massachusetts Institute of Technology Software Applications How is a software application
More informationAdvanced Computer Architecture
ECE 563 Advanced Computer Architecture Fall 2007 Lecture 14: Virtual Machines 563 L14.1 Fall 2009 Outline Types of Virtual Machine User-level (or Process VMs) System-level Techniques for implementing all
More informationChapter 2. lw $s1,100($s2) $s1 = Memory[$s2+100] sw $s1,100($s2) Memory[$s2+100] = $s1
Chapter 2 1 MIPS Instructions Instruction Meaning add $s1,$s2,$s3 $s1 = $s2 + $s3 sub $s1,$s2,$s3 $s1 = $s2 $s3 addi $s1,$s2,4 $s1 = $s2 + 4 ori $s1,$s2,4 $s2 = $s2 4 lw $s1,100($s2) $s1 = Memory[$s2+100]
More informationSystems Architecture I
Systems Architecture I Topics Assemblers, Linkers, and Loaders * Alternative Instruction Sets ** *This lecture was derived from material in the text (sec. 3.8-3.9). **This lecture was derived from material
More informationThe Instruction Set. Chapter 5
The Instruction Set Architecture Level(ISA) Chapter 5 1 ISA Level The ISA level l is the interface between the compilers and the hardware. (ISA level code is what a compiler outputs) 2 Memory Models An
More informationModule 3 Instruction Set Architecture (ISA)
Module 3 Instruction Set Architecture (ISA) I S A L E V E L E L E M E N T S O F I N S T R U C T I O N S I N S T R U C T I O N S T Y P E S N U M B E R O F A D D R E S S E S R E G I S T E R S T Y P E S O
More informationLecture 4: Instruction Set Architecture
Lecture 4: Instruction Set Architecture ISA types, register usage, memory addressing, endian and alignment, quantitative evaluation Reading: Textbook (5 th edition) Appendix A Appendix B (4 th edition)
More informationChapter 4 Processor Architecture: Y86 (Sections 4.1 & 4.3) with material from Dr. Bin Ren, College of William & Mary
Chapter 4 Processor Architecture: Y86 (Sections 4.1 & 4.3) with material from Dr. Bin Ren, College of William & Mary 1 Outline Introduction to assembly programing Introduction to Y86 Y86 instructions,
More informationPractical Malware Analysis
Practical Malware Analysis Ch 4: A Crash Course in x86 Disassembly Revised 1-16-7 Basic Techniques Basic static analysis Looks at malware from the outside Basic dynamic analysis Only shows you how the
More informationLIA. Large Installation Administration. Virtualization
LIA Large Installation Administration Virtualization 2 Virtualization What is Virtualization "a technique for hiding the physical characteristics of computing resources from the way in which other systems,
More information2.7 Supporting Procedures in hardware. Why procedures or functions? Procedure calls
2.7 Supporting Procedures in hardware Why procedures or functions? Procedure calls Caller: Callee: Proc save registers save more registers set up parameters do function call procedure set up results get
More informationInstruction Set Principles and Examples. Appendix B
Instruction Set Principles and Examples Appendix B Outline What is Instruction Set Architecture? Classifying ISA Elements of ISA Programming Registers Type and Size of Operands Addressing Modes Types of
More informationInstruction Set Architecture. "Speaking with the computer"
Instruction Set Architecture "Speaking with the computer" The Instruction Set Architecture Application Compiler Instr. Set Proc. Operating System I/O system Instruction Set Architecture Digital Design
More informationComputer Architecture
CS3350B Computer Architecture Winter 2015 Lecture 4.2: MIPS ISA -- Instruction Representation Marc Moreno Maza www.csd.uwo.ca/courses/cs3350b [Adapted from lectures on Computer Organization and Design,
More informationISA and RISCV. CASS 2018 Lavanya Ramapantulu
ISA and RISCV CASS 2018 Lavanya Ramapantulu Program Program =?? Algorithm + Data Structures Niklaus Wirth Program (Abstraction) of processor/hardware that executes 3-Jul-18 CASS18 - ISA and RISCV 2 Program
More informationComplex Instruction Set Computer (CISC)
Introduction ti to IA-32 IA-32 Processors Evolutionary design Starting in 1978 with 886 Added more features as time goes on Still support old features, although obsolete Totally dominate computer market
More informationASSEMBLY II: CONTROL FLOW. Jo, Heeseung
ASSEMBLY II: CONTROL FLOW Jo, Heeseung IA-32 PROCESSOR STATE Temporary data Location of runtime stack %eax %edx %ecx %ebx %esi %edi %esp %ebp General purpose registers Current stack top Current stack frame
More informationCS 31: Intro to Systems ISAs and Assembly. Kevin Webb Swarthmore College February 9, 2016
CS 31: Intro to Systems ISAs and Assembly Kevin Webb Swarthmore College February 9, 2016 Reading Quiz Overview How to directly interact with hardware Instruction set architecture (ISA) Interface between
More informationAssembly II: Control Flow. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University
Assembly II: Control Flow Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu IA-32 Processor State %eax %edx Temporary data Location of runtime stack
More informationCS 31: Intro to Systems ISAs and Assembly. Kevin Webb Swarthmore College September 25, 2018
CS 31: Intro to Systems ISAs and Assembly Kevin Webb Swarthmore College September 25, 2018 Overview How to directly interact with hardware Instruction set architecture (ISA) Interface between programmer
More informationIntroduction to Virtual Machines. Michael Jantz
Introduction to Virtual Machines Michael Jantz Acknowledgements Slides adapted from Chapter 1 in Virtual Machines: Versatile Platforms for Systems and Processes by James E. Smith and Ravi Nair Credit to
More informationInstruction Sets Ch 9-10
Instruction Sets Ch 9-10 Characteristics Operands Operations Addressing Instruction Formats 1 Instruction Set (käskykanta) Collection of instructions that CPU understands Only interface to CPU from outside
More informationInstruction Sets Ch 9-10
Instruction Sets Ch 9-10 Characteristics Operands Operations Addressing Instruction Formats 1 Instruction Set (käskykanta) Collection of instructions that CPU understands Only interface to CPU from outside
More informationIntroduction to IA-32. Jo, Heeseung
Introduction to IA-32 Jo, Heeseung IA-32 Processors Evolutionary design Starting in 1978 with 8086 Added more features as time goes on Still support old features, although obsolete Totally dominate computer
More informationINTRODUCTION TO IA-32. Jo, Heeseung
INTRODUCTION TO IA-32 Jo, Heeseung IA-32 PROCESSORS Evolutionary design Starting in 1978 with 8086 Added more features as time goes on Still support old features, although obsolete Totally dominate computer
More informationAssembly II: Control Flow. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University
Assembly II: Control Flow Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Processor State (x86-64) RAX 63 31 EAX 0 RBX EBX RCX RDX ECX EDX General-purpose
More informationCS3350B Computer Architecture MIPS Instruction Representation
CS3350B Computer Architecture MIPS Instruction Representation Marc Moreno Maza http://www.csd.uwo.ca/~moreno/cs3350_moreno/index.html Department of Computer Science University of Western Ontario, Canada
More informationLecture Outline. Code Generation. Lecture 30. Example of a Stack Machine Program. Stack Machines
Lecture Outline Code Generation Lecture 30 (based on slides by R. Bodik) Stack machines The MIPS assembly language The x86 assembly language A simple source language Stack-machine implementation of the
More informationChapter 2A Instructions: Language of the Computer
Chapter 2A Instructions: Language of the Computer Copyright 2009 Elsevier, Inc. All rights reserved. Instruction Set The repertoire of instructions of a computer Different computers have different instruction
More informationLecture 5: Instruction Set Architectures II. Take QUIZ 2 before 11:59pm today over Chapter 1 Quiz 1: 100% - 29; 80% - 25; 60% - 17; 40% - 3
Lecture 5: Instruction Set Architectures II Announcements Turn in Homework #1 XSPIM tutorials in PAI 5.38 during TA office hours Tue Feb 2: 2-3:30pm Wed Feb 3: 1:30-3pm Thu Feb 4: 3-4:30pm Take QUIZ 2
More informationAssembly II: Control Flow
Assembly II: Control Flow Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu SSE2030: Introduction to Computer Systems, Spring 2018, Jinkyu Jeong (jinkyu@skku.edu)
More informationLecture 3: Instruction Set Architecture
Lecture 3: Instruction Set Architecture Interface Software/compiler instruction set hardware Design Space of ISA Five Primary Dimensions Number of explicit operands ( 0, 1, 2, 3 ) Operand Storage Where
More informationCode Generation. Lecture 30
Code Generation Lecture 30 (based on slides by R. Bodik) 11/14/06 Prof. Hilfinger CS164 Lecture 30 1 Lecture Outline Stack machines The MIPS assembly language The x86 assembly language A simple source
More informationBasic Execution Environment
Basic Execution Environment 3 CHAPTER 3 BASIC EXECUTION ENVIRONMENT This chapter describes the basic execution environment of an Intel Architecture processor as seen by assembly-language programmers.
More informationInstruction Set. Instruction Sets Ch Instruction Representation. Machine Instruction. Instruction Set Design (5) Operation types
Instruction Sets Ch 10-11 Characteristics Operands Operations Addressing Instruction Formats Instruction Set Collection of instructions that CPU understands Only interface to CPU from outside CPU executes
More informationCSC 8400: Computer Systems. Machine-Level Representation of Programs
CSC 8400: Computer Systems Machine-Level Representation of Programs Towards the Hardware High-level language (Java) High-level language (C) assembly language machine language (IA-32) 1 Compilation Stages
More informationCS 31: Intro to Systems ISAs and Assembly. Martin Gagné Swarthmore College February 7, 2017
CS 31: Intro to Systems ISAs and Assembly Martin Gagné Swarthmore College February 7, 2017 ANNOUNCEMENT All labs will meet in SCI 252 (the robot lab) tomorrow. Overview How to directly interact with hardware
More informationInstruction-set Design Issues: what is the ML instruction format(s) ML instruction Opcode Dest. Operand Source Operand 1...
Instruction-set Design Issues: what is the format(s) Opcode Dest. Operand Source Operand 1... 1) Which instructions to include: How many? Complexity - simple ADD R1, R2, R3 complex e.g., VAX MATCHC substrlength,
More informationCommunicating with People (2.8)
Communicating with People (2.8) For communication Use characters and strings Characters 8-bit (one byte) data for ASCII lb $t0, 0($sp) ; load byte Load a byte from memory, placing it in the rightmost 8-bits
More informationMachine-level Representation of Programs. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University
Machine-level Representation of Programs Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Program? 짬뽕라면 준비시간 :10 분, 조리시간 :10 분 재료라면 1개, 스프 1봉지, 오징어
More informationECE 486/586. Computer Architecture. Lecture # 7
ECE 486/586 Computer Architecture Lecture # 7 Spring 2015 Portland State University Lecture Topics Instruction Set Principles Instruction Encoding Role of Compilers The MIPS Architecture Reference: Appendix
More informationAssembly Language. Lecture 2 x86 Processor Architecture
Assembly Language Lecture 2 x86 Processor Architecture Ahmed Sallam Slides based on original lecture slides by Dr. Mahmoud Elgayyar Introduction to the course Outcomes of Lecture 1 Always check the course
More informationTopics Power tends to corrupt; absolute power corrupts absolutely. Computer Organization CS Data Representation
Computer Organization CS 231-01 Data Representation Dr. William H. Robinson November 12, 2004 Topics Power tends to corrupt; absolute power corrupts absolutely. Lord Acton British historian, late 19 th
More informationCSE 141 Computer Architecture Spring Lecture 3 Instruction Set Architecute. Course Schedule. Announcements
CSE141: Introduction to Computer Architecture CSE 141 Computer Architecture Spring 2005 Lecture 3 Instruction Set Architecute Pramod V. Argade April 4, 2005 Instructor: TAs: Pramod V. Argade (p2argade@cs.ucsd.edu)
More informationCompiler Construction D7011E
Compiler Construction D7011E Lecture 8: Introduction to code generation Viktor Leijon Slides largely by Johan Nordlander with material generously provided by Mark P. Jones. 1 What is a Compiler? Compilers
More informationInstruction Set Architecture
CS:APP Chapter 4 Computer Architecture Instruction Set Architecture Randal E. Bryant adapted by Jason Fritts http://csapp.cs.cmu.edu CS:APP2e Hardware Architecture - using Y86 ISA For learning aspects
More informationInstruction-set Design Issues: what is the ML instruction format(s) ML instruction Opcode Dest. Operand Source Operand 1...
Instruction-set Design Issues: what is the format(s) Opcode Dest. Operand Source Operand 1... 1) Which instructions to include: How many? Complexity - simple ADD R1, R2, R3 complex e.g., VAX MATCHC substrlength,
More informationProcess Layout and Function Calls
Process Layout and Function Calls CS 6 Spring 07 / 8 Process Layout in Memory Stack grows towards decreasing addresses. is initialized at run-time. Heap grow towards increasing addresses. is initialized
More informationCSC 2400: Computer Systems. Towards the Hardware: Machine-Level Representation of Programs
CSC 2400: Computer Systems Towards the Hardware: Machine-Level Representation of Programs Towards the Hardware High-level language (Java) High-level language (C) assembly language machine language (IA-32)
More informationCS 152 Computer Architecture and Engineering. Lecture 22: Virtual Machines
CS 152 Computer Architecture and Engineering Lecture 22: Virtual Machines Krste Asanovic Electrical Engineering and Computer Sciences University of California, Berkeley http://www.eecs.berkeley.edu/~krste
More informationCS 252 Graduate Computer Architecture. Lecture 15: Virtual Machines
CS 252 Graduate Computer Architecture Lecture 15: Virtual Machines Krste Asanovic Electrical Engineering and Computer Sciences University of California, Berkeley http://www.eecs.berkeley.edu/~krste http://inst.eecs.berkeley.edu/~cs252
More informationCS429: Computer Organization and Architecture
CS429: Computer Organization and Architecture Warren Hunt, Jr. and Bill Young Department of Computer Sciences University of Texas at Austin Last updated: October 1, 2014 at 12:03 CS429 Slideset 6: 1 Topics
More informationInstruction Set Principles. (Appendix B)
Instruction Set Principles (Appendix B) Outline Introduction Classification of Instruction Set Architectures Addressing Modes Instruction Set Operations Type & Size of Operands Instruction Set Encoding
More informationInstructions: MIPS ISA. Chapter 2 Instructions: Language of the Computer 1
Instructions: MIPS ISA Chapter 2 Instructions: Language of the Computer 1 PH Chapter 2 Pt A Instructions: MIPS ISA Based on Text: Patterson Henessey Publisher: Morgan Kaufmann Edited by Y.K. Malaiya for
More informationChapter 2. Instructions: Language of the Computer. Adapted by Paulo Lopes
Chapter 2 Instructions: Language of the Computer Adapted by Paulo Lopes Instruction Set The repertoire of instructions of a computer Different computers have different instruction sets But with many aspects
More informationAssembly Language. Lecture 2 - x86 Processor Architecture. Ahmed Sallam
Assembly Language Lecture 2 - x86 Processor Architecture Ahmed Sallam Introduction to the course Outcomes of Lecture 1 Always check the course website Don t forget the deadline rule!! Motivations for studying
More informationEC-801 Advanced Computer Architecture
EC-801 Advanced Computer Architecture Lecture 5 Instruction Set Architecture I Dr Hashim Ali Fall 2018 Department of Computer Science and Engineering HITEC University Taxila!1 Instruction Set Architecture
More informationUnsigned Binary Integers
Unsigned Binary Integers Given an n-bit number x x n 1 n 2 1 0 n 12 xn 22 x12 x02 Range: 0 to +2 n 1 Example 2.4 Signed and Unsigned Numbers 0000 0000 0000 0000 0000 0000 0000 1011 2 = 0 + + 1 2 3 + 0
More informationUnsigned Binary Integers
Unsigned Binary Integers Given an n-bit number x x n 1 n 2 1 0 n 12 xn 22 x12 x02 Range: 0 to +2 n 1 Example 2.4 Signed and Unsigned Numbers 0000 0000 0000 0000 0000 0000 0000 1011 2 = 0 + + 1 2 3 + 0
More informationInstruction Set Architecture
CS:APP Chapter 4 Computer Architecture Instruction Set Architecture Randal E. Bryant Carnegie Mellon University http://csapp.cs.cmu.edu CS:APP Instruction Set Architecture Assembly Language View Processor
More informationCOSC 6385 Computer Architecture. Instruction Set Architectures
COSC 6385 Computer Architecture Instruction Set Architectures Spring 2012 Instruction Set Architecture (ISA) Definition on Wikipedia: Part of the Computer Architecture related to programming Defines set
More informationComputer Architecture
Computer Architecture Chapter 2 Instructions: Language of the Computer Fall 2005 Department of Computer Science Kent State University Assembly Language Encodes machine instructions using symbols and numbers
More informationInstruction Set Architecture
CS:APP Chapter 4 Computer Architecture Instruction Set Architecture Randal E. Bryant Carnegie Mellon University http://csapp.cs.cmu.edu CS:APP Instruction Set Architecture Assembly Language View! Processor
More informationForecast. Instructions (354 Review) Basics. Basics. Instruction set architecture (ISA) is its vocabulary. Instructions are the words of a computer
Instructions (354 Review) Forecast Instructions are the words of a computer Instruction set architecture (ISA) is its vocabulary With a few other things, this defines the interface of computers But implementations
More informationReading assignment. Chapter 3.1, 3.2 Chapter 4.1, 4.3
Reading assignment Chapter 3.1, 3.2 Chapter 4.1, 4.3 1 Outline Introduc5on to assembly programing Introduc5on to Y86 Y86 instruc5ons, encoding and execu5on 2 Assembly The CPU uses machine language to perform
More informationLecture 3 Machine Language. Instructions: Instruction Execution cycle. Speaking computer before voice recognition interfaces
Lecture 3 Machine Language Speaking computer before voice recognition interfaces 1 Instructions: Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow Very
More informationThe MIPS Instruction Set Architecture
The MIPS Set Architecture CPS 14 Lecture 5 Today s Lecture Admin HW #1 is due HW #2 assigned Outline Review A specific ISA, we ll use it throughout semester, very similar to the NiosII ISA (we will use
More informationCSE2421 FINAL EXAM SPRING Name KEY. Instructions: Signature
CSE2421 FINAL EXAM SPRING 2013 Name KEY Instructions: This is a closed-book, closed-notes, closed-neighbor exam. Only a writing utensil is needed for this exam. No calculators allowed. If you need to go
More informationWhat is a Compiler? Compiler Construction SMD163. Why Translation is Needed: Know your Target: Lecture 8: Introduction to code generation
Compiler Construction SMD163 Lecture 8: Introduction to code generation Viktor Leijon & Peter Jonsson with slides by Johan Nordlander Contains material generously provided by Mark P. Jones What is a Compiler?
More informationComputer Organization Chapter 4. Prof. Qi Tian Fall 2013
Computer Organization Chapter 4 Prof. Qi Tian Fall 2013 1 Topics Dec. 6 (Friday) Final Exam Review Record Check Dec. 4 (Wednesday) 5 variable Karnaugh Map Quiz 5 Dec. 2 (Monday) 3, 4 variables Karnaugh
More informationSecond Part of the Course
CSC 2400: Computer Systems Towards the Hardware 1 Second Part of the Course Toward the hardware High-level language (C) assembly language machine language (IA-32) 2 High-Level Language g Make programming
More informationCSCE 5610: Computer Architecture
HW #1 1.3, 1.5, 1.9, 1.12 Due: Sept 12, 2018 Review: Execution time of a program Arithmetic Average, Weighted Arithmetic Average Geometric Mean Benchmarks, kernels and synthetic benchmarks Computing CPI
More informationAssembly Language: IA-32 Instructions
Assembly Language: IA-32 Instructions 1 Goals of this Lecture Help you learn how to: Manipulate data of various sizes Leverage more sophisticated addressing modes Use condition codes and jumps to change
More informationProcessor Architecture. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University
Processor Architecture Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Moore s Law Gordon Moore @ Intel (1965) 2 Computer Architecture Trends (1)
More informationChapter 12. CPU Structure and Function. Yonsei University
Chapter 12 CPU Structure and Function Contents Processor organization Register organization Instruction cycle Instruction pipelining The Pentium processor The PowerPC processor 12-2 CPU Structures Processor
More informationLecture 2: RISC V Instruction Set Architecture. Housekeeping
S 17 L2 1 18 447 Lecture 2: RISC V Instruction Set Architecture James C. Hoe Department of ECE Carnegie Mellon University Housekeeping S 17 L2 2 Your goal today get bootstrapped on RISC V RV32I to start
More informationEN164: Design of Computing Systems Topic 03: Instruction Set Architecture Design
EN164: Design of Computing Systems Topic 03: Instruction Set Architecture Design Professor Sherief Reda http://scale.engin.brown.edu Electrical Sciences and Computer Engineering School of Engineering Brown
More informationCSIS1120A. 10. Instruction Set & Addressing Mode. CSIS1120A 10. Instruction Set & Addressing Mode 1
CSIS1120A 10. Instruction Set & Addressing Mode CSIS1120A 10. Instruction Set & Addressing Mode 1 Elements of a Machine Instruction Operation Code specifies the operation to be performed, e.g. ADD, SUB
More informationGoals of Today s Lecture
Computer Architecture and Assembly Language Prof. David August COS 217 1 Goals of Today s Lecture Computer architecture o Central processing unit (CPU) o Fetch-decode-execute cycle o Memory hierarchy,
More informationComputer Architecture and Assembly Language. Prof. David August COS 217
Computer Architecture and Assembly Language Prof. David August COS 217 1 Goals of Today s Lecture Computer architecture o Central processing unit (CPU) o Fetch-decode-execute cycle o Memory hierarchy,
More informationLecture 2: RISC V Instruction Set Architecture. James C. Hoe Department of ECE Carnegie Mellon University
18 447 Lecture 2: RISC V Instruction Set Architecture James C. Hoe Department of ECE Carnegie Mellon University 18 447 S18 L02 S1, James C. Hoe, CMU/ECE/CALCM, 2018 Your goal today Housekeeping get bootstrapped
More informationOutline. What Makes a Good ISA? Programmability. Implementability
Outline Instruction Sets in General MIPS Assembly Programming Other Instruction Sets Goals of ISA Design RISC vs. CISC Intel x86 (IA-32) What Makes a Good ISA? Programmability Easy to express programs
More informationIntroduction to the MIPS. Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University
Introduction to the MIPS Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University Introduction to the MIPS The Microprocessor without Interlocked Pipeline Stages
More informationLectures 3-4: MIPS instructions
Lectures 3-4: MIPS instructions Motivation Learn how a processor s native language looks like Discover the most important software-hardware interface MIPS Microprocessor without Interlocked Pipeline Stages
More informationThe Hardware/Software Interface CSE351 Spring 2013
The Hardware/Software Interface CSE351 Spring 2013 x86 Programming II 2 Today s Topics: control flow Condition codes Conditional and unconditional branches Loops 3 Conditionals and Control Flow A conditional
More informationare Softw Instruction Set Architecture Microarchitecture are rdw
Program, Application Software Programming Language Compiler/Interpreter Operating System Instruction Set Architecture Hardware Microarchitecture Digital Logic Devices (transistors, etc.) Solid-State Physics
More informationCISC 662 Graduate Computer Architecture. Lecture 4 - ISA MIPS ISA. In a CPU. (vonneumann) Processor Organization
CISC 662 Graduate Computer Architecture Lecture 4 - ISA MIPS ISA Michela Taufer http://www.cis.udel.edu/~taufer/courses Powerpoint Lecture Notes from John Hennessy and David Patterson s: Computer Architecture,
More informationCISC 360 Instruction Set Architecture
CISC 360 Instruction Set Architecture Michela Taufer October 9, 2008 Powerpoint Lecture Notes for Computer Systems: A Programmer's Perspective, R. Bryant and D. O'Hallaron, Prentice Hall, 2003 Chapter
More informationAssembly level Programming. 198:211 Computer Architecture. (recall) Von Neumann Architecture. Simplified hardware view. Lecture 10 Fall 2012
19:211 Computer Architecture Lecture 10 Fall 20 Topics:Chapter 3 Assembly Language 3.2 Register Transfer 3. ALU 3.5 Assembly level Programming We are now familiar with high level programming languages
More informationProcessor Architecture
Processor Architecture Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu SSE2030: Introduction to Computer Systems, Spring 2018, Jinkyu Jeong (jinkyu@skku.edu)
More informationInstruction Set Design
Instruction Set Design software instruction set hardware CPE442 Lec 3 ISA.1 Instruction Set Architecture Programmer's View ADD SUBTRACT AND OR COMPARE... 01010 01110 10011 10001 11010... CPU Memory I/O
More informationInstruction Set Architecture
CISC 360 Instruction Set Architecture Michela Taufer October 9, 2008 Powerpoint Lecture Notes for Computer Systems: A Programmer's Perspective, R. Bryant and D. O'Hallaron, Prentice Hall, 2003 Chapter
More informationX86 Addressing Modes Chapter 3" Review: Instructions to Recognize"
X86 Addressing Modes Chapter 3" Review: Instructions to Recognize" 1 Arithmetic Instructions (1)! Two Operand Instructions" ADD Dest, Src Dest = Dest + Src SUB Dest, Src Dest = Dest - Src MUL Dest, Src
More informationComputer Science 104:! Y86 & Single Cycle Processor Design!
Computer Science 104:! Y86 & Single Cycle Processor Design! Alvin R. Lebeck! Slides based on those from Randy Bryant 1! CS:APP! CS:APP! Administrative! 2! CS:APP! Instruction Set Architecture! Application!
More informationCS241 Computer Organization Spring 2015 IA
CS241 Computer Organization Spring 2015 IA-32 2-10 2015 Outline! Review HW#3 and Quiz#1! More on Assembly (IA32) move instruction (mov) memory address computation arithmetic & logic instructions (add,
More informationComputer Science 104:! Y86 & Single Cycle Processor Design!
Computer Science 104: Y86 & Single Cycle Processor Design Alvin R. Lebeck Slides based on those from Randy Bryant 1 CS:APP Administrative Homework #4 My office hours today 11:30-12:30 Reading: text 4.3
More informationReduced Instruction Set Computer (RISC)
Reduced Instruction Set Computer (RISC) Focuses on reducing the number and complexity of instructions of the ISA. RISC Goals RISC: Simplify ISA Simplify CPU Design Better CPU Performance Motivated by simplifying
More information