Lecture 2: Basic Instructions CS 2011 Fall 2014, Dr. Rozier.

Slides:



Advertisements
Similar presentations
Slides created by: Professor Ian G. Harris Efficient C Code  Your C program is not exactly what is executed  Machine code is specific to each ucontroller.
Advertisements

ARM versions ARM architecture has been extended over several versions.
F28PL1 Programming Languages Lecture 2: Assembly Language 1.
Machine Instructions Operations 1 ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson Slides4-1.ppt Modification date: March 18, 2015.
CONDITION CODE AND ARITHMETIC OPERATIONS – Microprocessor Asst. Prof. Dr. Choopan Rattanapoka and Asst. Prof. Dr. Suphot Chunwiphat.
Instruction Set Architecture Classification According to the type of internal storage in a processor the basic types are Stack Accumulator General Purpose.
ARM Microprocessor “MIPS for the Masses”.
1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 1: Bits, bytes and a simple processor dr.ir. A.C. Verschueren.
Lecture 5: Decision and Control CS 2011 Fall 2014, Dr. Rozier.
TK 2633 Microprocessor & Interfacing
COMP3221: Microprocessors and Embedded Systems Lecture 2: Instruction Set Architecture (ISA) Lecturer: Hui Wu Session.
TK 2633 Microprocessor & Interfacing Lecture 3: Introduction to 8085 Assembly Language Programming (2) 1 Prepared By: Associate Prof. Dr Masri Ayob.
1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006.
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
Chapter 4 Processor Technology and Architecture. Chapter goals Describe CPU instruction and execution cycles Explain how primitive CPU instructions are.
Lecture 5 Sept 14 Goals: Chapter 2 continued MIPS assembly language instruction formats translating c into MIPS - examples.
Topics covered: ARM Instruction Set Architecture CSE 243: Introduction to Computer Architecture and Hardware/Software Interface.
COMP3221 lec07-numbers-III.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lecture 7: Number Systems - III
EET 2261 Unit 2 HCS12 Architecture
CEG 320/520: Computer Organization and Assembly Language Programming1 CEG 320/520 Computer Organization and Assembly Language Programming.
ARM Instructions I Prof. Taeweon Suh Computer Science Education Korea University.
Arithmetic for Computers
Topic 8: Data Transfer Instructions CSE 30: Computer Organization and Systems Programming Winter 2010 Prof. Ryan Kastner Dept. of Computer Science and.
Assembly Programming on the TI-89 Created By: Adrian Anderson Trevor Swanson.
IT253: Computer Organization
Lecture 1: Performance EEN 312: Processors: Hardware, Software, and Interfacing Department of Electrical and Computer Engineering Spring 2013, Dr. Rozier.
Lecture 4. ARM Instructions #1 Prof. Taeweon Suh Computer Science Education Korea University ECM586 Special Topics in Embedded Systems.
Operations on Bits Arithmetic Operations Logic Operations
Lecture 2: Basic Instructions EEN 312: Processors: Hardware, Software, and Interfacing Department of Electrical and Computer Engineering Spring 2014, Dr.
CSCI 136 Lab 1: 135 Review.
Cis303a_chapt04.ppt Chapter 4 Processor Technology and Architecture Internal Components CPU Operation (internal components) Control Unit Move data and.
Chapter 2-2 Assembly Instructions Number Systems Number Systems Assembly Instructions Assembly Instructions Branch Branch Next Lecture Next Lecture  Addressing.
Topic 7: Control Flow Instructions CSE 30: Computer Organization and Systems Programming Winter 2011 Prof. Ryan Kastner Dept. of Computer Science and Engineering.
More on Assembly 1 CSE 2312 Computer Organization and Assembly Language Programming Vassilis Athitsos University of Texas at Arlington.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /08/2013 Lecture 10: MIPS Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL STATE.
1 Lecture 7: MARS, Computer Arithmetic Today’s topics:  MARS intro  Numerical representations  Addition and subtraction.
Lecture 2: Advanced Instructions, Control, and Branching EEN 312: Processors: Hardware, Software, and Interfacing Department of Electrical and Computer.
Unit-2 Instruction Sets, CPUs
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
1 The Instruction Set Architecture September 27 th, 2007 By: Corbin Johnson CS 146.
F28HS2 Hardware-Software Interfaces Lecture 7: ARM Assembly Language 1.
Chapter 2 — Instructions: Language of the Computer — 1 Memory Operands Main memory used for composite data – Arrays, structures, dynamic data To apply.
More on Assembly 1 CSE 2312 Computer Organization and Assembly Language Programming Vassilis Athitsos University of Texas at Arlington.
EECS 370 Discussion 1 xkcd.com. EECS 370 Discussion Topics Today: – ARM Addressing Endianness, Loading, and Storing Data – Data Layout Struct Packing.
Lecture 6: Branching CS 2011 Fall 2014, Dr. Rozier.
MICROPROCESSOR DETAILS 1 Updated April 2011 ©Paul R. Godin prgodin gmail.com.
Lecture 3: Boolean Algebra and Registers CS 2011 Spring 2016, Dr. Rozier.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
Assembly Variables: Registers Unlike HLL like C or Java, assembly cannot use variables – Why not? Keep Hardware Simple Assembly Operands are registers.
Instruction Set Architectures Early trend was to add more and more instructions to new CPUs to do elaborate operations –VAX architecture had an instruction.
Lecture 6: Decision and Control CS 2011 Spring 2016, Dr. Rozier.
Computer Architecture & Operations I
Computer Architecture & Operations I
GCSE COMPUTER SCIENCE Computers 1.5 Assembly Language.
Overview of Instruction Set Architectures
Chapter 15: Higher Level Constructs
ARM Registers Register – internal CPU hardware device that stores binary data; can be accessed much more rapidly than a location in RAM ARM has.
Morgan Kaufmann Publishers
The Cortex-M3/m4 Embedded Systems: Cortex-M3/M4 Instruction Sets
Making Decisions and Writing Loops
Lecture 4: MIPS Instruction Set
Introduction to Microprocessor Programming
Branching instructions
Overheads for Computers as Components 2nd ed.
Branch & Call Chapter 4 Sepehr Naimi
Introduction to Assembly Chapter 2
Part I Data Representation and 8086 Microprocessors
An Introduction to the ARM CORTEX M0+ Instructions
Presentation transcript:

Lecture 2: Basic Instructions CS 2011 Fall 2014, Dr. Rozier

PROBLEM SETS

Consider the following processors, P1, P2, and P3 executing the same instruction set with clock rates and CPI as indicated 1.Which processor has the highest performance in terms of instructions per second? 2.If the processors each execute a program in 10s, find the number of cycles and the number of instructions 3.We are trying to reduce the execution time by 30% but this leads to an increase in CPI of 20%. What clock rate should we have to get this reduction? ProcessorClock RateCPI P13 GHz1.5 P22.5 GHz1.0 P34 GHz2.2

Consider a computer running code with four main routines, A, B, C, and D. 1.How much is the total time reduced if the time for Routine A is reduced by 20%? 2.How much is the time for Routine B reduced if the total time is reduced by 20%? 3.Can the total time be reduced by 20% by only reducing the time for Routine D? Routine ARoutine BRoutine CRoutine DTotal Time 40s90s60s20s210s

Consider a computer running code with four main routines, A, B, C, and D. 1.How much is the total time reduced if the time for Routine A is reduced by 20%? 2.How much is the time for Routine B reduced if the total time is reduced by 20%? 3.Can the total time be reduced by 20% by only reducing the time for Routine D? Routine ARoutine BRoutine CRoutine DTotal Time Exec Time40s90s60s20s210s Instructions50x10^6110x10^680x10^616x10^6- Avg CPI1142-

Consider a computer running code with four main routines, A, B, C, and D. 1.How much must we improve the CPI of Routine A if we want the program to run twice as fast? 2.How much must we improve the CPI of Routine C if we want the program to run twice as fast? 3.How much is the execution time improved if the CPI of routines A and B are reduced by 40%, and the CPI of routines C and D are reduced by 30%? Routine ARoutine BRoutine CRoutine DTotal Time Exec Time40s90s60s20s210s Instructions50x10^6110x10^680x10^616x10^6- Avg CPI1142-

REPRESENTING NUMBERS

Networking and Communication What if we encode the signal into pulses? Detect if the value is above or below some threshold, and decide it represents a 1, or a 0. Strings of 1’s and 0’s can be interpreted as a number.

Some simple things we can represent with 1’s and 0’s True or false… – 1 – true – 0 – false – We already were doing this with pure signals.

Some simple things we can represent with 1’s and 0’s Integers Examples – – – – – 10 – – – 147

Unsigned Binary Integers Given an n-bit number Range: 0 to +2 n – 1 Example = 0 + … + 1× ×2 2 +1×2 1 +1×2 0 = 0 + … = Using 32 bits 0 to +4,294,967,295

Hexadecimal Base 16 – Compact representation of bit strings – 4 bits per hex digit c d a1010e b1011f1111 Example: eca

BASIC INSTRUCTIONS

Instruction Set The repertoire of instructions of a computer Different computers have different instruction sets – But with many aspects in common Early computers had very simple instruction sets – Simplified implementation Many modern computers also have simple instruction sets

MIPS vs ARMv6 The book uses the MIPS instruction set. We will be using ARMv6 in our labs. Both are RISC (reduced instruction set computer) architectures. – Many similarities.

MIPS Used in many embedded systems – Routers, gateways – Playstation 2 and PSP Invented by Prof John Hennessy at Stanford, the first RISC architecture.

ARM Introduced in 1985 Focused on low-power friendly operation. Since 2005, over 98% of all mobile phones had at least one ARM processor. Over 37 billion ARM processors in use in Rapidly becoming the dominant processor architecture in the world.

Instructions C code: – f = (g + h) – (i + j); Compile ARM code: – add r0, r3, r4 # temp t0 = g + h – add r1, r5, r6 # temp t1 = i + j – sub r2, r0, r1 # f = t0 – t1

Register Operands Instructions use registers for operands. Registers are extremely fast SRAM locations that are directly accessible by the processor. – Very fast, but very expensive, so very small.

Registers Each register holds a word (4 bytes). Registers r0-r12 are general purpose. NameFunctionNameFunction r0General Purposer8General Purpose r1General Purposer9General Purpose r2General Purposer10General Purpose r3General Purposer11General Purpose r4General Purposer12General Purpose r5General Purposer13Stack Pointer r6General Purposer14Link Register r7General Purposer15Program Counter

Registers Registers r13 – r15 have special purposes The PC, r15, is very dangerous. NameFunctionNameFunction r0General Purposer8General Purpose r1General Purposer9General Purpose r2General Purposer10General Purpose r3General Purposer11General Purpose r4General Purposer12General Purpose r5General Purposer13Stack Pointer r6General Purposer14Link Register r7General Purposer15Program Counter

Registers The register r13 holds the stack pointer – Also called sp – Points to a special part of memory called the stack. – More about this later.

Registers The register r14 holds the link register – Also called lr – Holds the value of a return address that allows for fast and efficient implementation of subroutines.

Registers The register r15 holds the program counter – Also called pc – Holds an address of an instruction. Keeps track of where your program is in its execution of machine code. – PC holds the address of the instruction to be fetched next.

Registers One additional register, the “current program status register” Four most significant bits hold flags which indicate the presence or absence of certain conditions …87654…0 NZCVReservedIFTMODE

Registers N – negative flag Z – zero flag C – carry flag V – overflow flag …87654…0 NZCVReservedIFTMODE

Registers N – set by an instruction if the result is negative (set equal to the two’s complement sign bit) N – negative flag Z – zero flag C – carry flag V – overflow flag …87654…0 NZCVReservedIFTMODE

Registers Z – set by an instruction if the result of the instruction is zero. N – negative flag Z – zero flag C – carry flag V – overflow flag …87654…0 NZCVReservedIFTMODE

Registers C – set by an instruction if the result of an unsigned operation overflows the 32-bit register. Can be used for 64-bit arithmetic N – negative flag Z – zero flag C – carry flag V – overflow flag …87654…0 NZCVReservedIFTMODE

Registers V – works the same as the C flag, but for signed operations. N – negative flag Z – zero flag C – carry flag V – overflow flag …87654…0 NZCVReservedIFTMODE

MORE ABOUT THESE LATER…

The Memory Hierarchy

Load-Store Architecture RISC architectures, like ARM and MIPS utilize a load-store architecture. Memory cannot be part of arithmetic operations. – Only registers can do this Access memory is through loads and stores.

Register Memory Architecture Featured on many CISC architectures, like x86 Allows direct access to memory by instructions.

Load Store and ARM Register space is pretty cramped!!! LoaD to a Register with LDR SToRe to memory with STR ldr, [ {, }] – Loads a byte from + into str, [ {, }] – Stores a byte from into +

Load Store and ARM Example – ldr r0, [r1,r2] Load data from location r1+r2 into r0. – ldr r0, =string Load data from label string into r0. Special cases exist, see ARM manual – Example: ldrb loads a single byte, padded with zeros.

Constants or Immediates Operands can contain registers, or immediate values. – An immediate is like a constant – Represent immediates as follows: #20 add r0, r1, #20 – adds 20 to the value of r1 and stores it in r0.

Arithmetic Instructions Addition – add, adc, adds, etc Subtraction – sub, sbc, rsb, subs, etc Multiply – mul, mla, etc

Move Instruction mov, – mov r0, r1 – copy the contents of r1 into r0. – mov r0, #20 – copy an immediate value of 20 into r0. mvn, – Move negative, negates operand before copying it.

Compare Instructions cmp, cmn, Don’t change the operands, update special status register flags. cmp – subtracts operand2 from operand1 and discards the result. cmn – adds operand2 to operand1 and discards the result.

Status Register Flags Compare instructions and the special “S” versions of instructions (adds, subs, movs) set the status register flags. Can be used with conditional suffixes to make conditionally executed instructions.

Conditional Execution Just as the special “S” suffix can be added to set status flags, other suffixes can be added to act on status flags.

EQ: Equal Z=1 Using the EQ suffix on an instruction will cause it to only be executed if the zero flag is set. cmp r0, Set flags based on r0-r1 adds r0, r1, Set flags based on r0 = r1 + r2 movs r0, Set flags based on r0 = r1

EQ: Equal Z=1 Using the EQ suffix on an instruction will cause it to only be executed if the zero flag is set. Example cmp r0, Set flags based on r0-r1 addeq r2, r0, Conditional addition

NE: Equal Z=0 Using the NE suffix on an instruction will cause it to only be executed if the zero flag is not set.

Other conditional suffixes VS – overflow set, V=1 VC – overflow clear, V=0 MI – minus set, N=1 PL – minus clear, N=0 CS – carry set, C=1 CC – carry clear, C=0 AL – always, unconditional NV – never, unconditional

Multiple Conditional Suffixes HI – higher (unsigned), C=1 and Z=0 – Unsigned greater than LS – lower (unsigned), C=0 and Z=1 – Unsigned less than GE – greater or equal (signed), N=1, V=1 OR N=0, V=0 – Signed greater than or equal to LT – less than (signed), N=1, V=0, OR N=0,V=1 – Signed less than

Multiple Conditional Suffixes GT – greater than (signed), N=1, V=1, OR N=0, V=0 AND Z=0 – Signed greater than LE – less than or equal (signed), N=1, V=0, OR N=0, V=1, OR Z=1 – Signed less than or equal to

For next time Continue discussion on basic instructions.