CS 111 – Sept. 16 Machine language examples Instruction execution

Slides:



Advertisements
Similar presentations
Chapter 2: Data Manipulation
Advertisements

 Suppose for a moment that you were asked to perform a task and were given the following list of instructions to perform:
2.3) Example of program execution 1. instruction  B25 8 Op-code B means to change the value of the program counter if the contents of the indicated register.
Instruction Set Architecture & Design
TK 2633 Microprocessor & Interfacing
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
Chapter 0 Introduction to Computing
Computer Processing CSCE 110 J. Michael Moore.
Chapter 2.2 Machine Language.
1 Sec (2.3) Program Execution. 2 In the CPU we have CU and ALU, in CU there are two special purpose registers: 1. Instruction Register 2. Program Counter.
Lecture 13 - Introduction to the Central Processing Unit (CPU)
How Computers Work Dr. John P. Abraham Professor UTPA.
1 Programming in Machine Language SCSC 311 Spring 2011.
GCSE Computing#BristolMet Session Objectives#11 MUST identify what program instructions consist of SHOULD describe how instructions are coded as bit patterns.
Assembly Language A Brief Introduction. Unit Learning Goals CPU architecture. Basic Assembler Commands High level Programming  Assembler  Machine Language.
Ch. 2 Data Manipulation 4 The central processing unit. 4 The stored-program concept. 4 Program execution. 4 Other architectures. 4 Arithmetic/logic instructions.
CS 111 – Sept. 15 Chapter 2 – Manipulating data by performing instructions “What is going on in the CPU?” Commitment: –Please read through section 2.3.
Important Concepts  Parts of the CPU  Arithmetic/Logic Unit  Control Unit  Registers  Program Counter  Instruction Register  Fetch/Decode/Execute.
Computer Architecture Memory, Math and Logic. Basic Building Blocks Seen: – Memory – Logic & Math.
Computer Science 101 Computer Systems Organization ALU, Control Unit, Instruction Set.
Chapter 2 Data Manipulation. © 2005 Pearson Addison-Wesley. All rights reserved 2-2 Chapter 2: Data Manipulation 2.1 Computer Architecture 2.2 Machine.
Fetch-execute cycle.
CMSC 150 PROGRAM EXECUTION CS 150: Wed 1 Feb 2012.
Represents different voltage levels High: 5 Volts Low: 0 Volts At this raw level a digital computer is instructed to carry out instructions.
Chapter 10 Instruction Sets: Characteristics and Functions Felipe Navarro Luis Gomez Collin Brown.
Chapter 2 Data Manipulation © 2007 Pearson Addison-Wesley. All rights reserved.
Data Manipulation, part two Introduction to computer, 2 nd semester, 2010/2011 Mr.Nael Aburas Faculty of Information.
Computer Systems – Machine & Assembly code. Objectives Machine Code Assembly Language Op-code Operand Instruction Set.
What is a program? A sequence of steps
CS61C L20 Datapath © UC Regents 1 Microprocessor James Tan Adapted from D. Patterson’s CS61C Copyright 2000.
MICROPROCESSOR DETAILS 1 Updated April 2011 ©Paul R. Godin prgodin gmail.com.
Chapter 2 Data Manipulation © 2007 Pearson Addison-Wesley. All rights reserved.
27 October 2015 Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
Microprocessor & Assembly Language
Computer and Information Sciences College / Computer Science Department CS 206 D Computer Organization and Assembly Language.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
Logic Gates Dr.Ahmed Bayoumi Dr.Shady Elmashad. Objectives  Identify the basic gates and describe the behavior of each  Combine basic gates into circuits.
First Foray into Programming (the hard way). A reminder from last lesson: A machine code instruction has two parts:  Op-code  Operand An instruction.
© 2015 Pearson Education Limited 2015 Quiz in last 15 minutes Midterm 1 is next Sunday Assignment 1 due today at 4pm Assignment 2 will be up today; due.
Computer Architecture. Instruction Set “The collection of different instructions that the processor can execute it”. Usually represented by assembly codes,
Dr.Ahmed Bayoumi Dr.Shady Elmashad
Programming in Machine Language
Lecture 13 - Introduction to the Central Processing Unit (CPU)
CPU Organisation & Operation
Microcomputer Programming
Computer Architecture
Data Representation – Instructions
The fetch-execute cycle
The Processor and Machine Language
Computer Science 210 Computer Organization
Functional Units.
CS149D Elements of Computer Science
CSCE Fall 2013 Prof. Jennifer L. Welch.
MIPS Processor.
Shift & Rotate Instructions)
8085 MICROPROCESSOR 8085 CPU Registers and Status Flags S Z AC P C A B
ECEG-3202 Computer Architecture and Organization
Sequencing, Selection, and Loops in Machine Language
ECEG-3202 Computer Architecture and Organization
CSCE Fall 2012 Prof. Jennifer L. Welch.
Chapter 4: Representing instructions
Program Execution.
Basic components Instruction processing
CS334: MIPS language _Mars simulator Lab 2_1
Information Representation: Machine Instructions
Instruction execution and ALU
Part I Data Representation and 8086 Microprocessors
Sec (2.3) Program Execution.
Presentation transcript:

CS 111 – Sept. 16 Machine language examples Instruction execution Don’t memorize… Instruction execution Closer look at operations in instruction set Commitment: Please read sections 2.5 and 2.6. Quiz next Wednesday.

More instructions Opcode 1 is for loading a memory value into a register Expects a register operand (4 bits), and a memory address from which to load (8 bits). Ex. 1820 means to go out to memory at address [20], grab the contents and load it into register 8. (It does not mean put the number 20 in register 8.) Opcode 3 is a store = opposite of load Ex. 3921 means to take the value in register 9, and put it into memory at location [21]. (It does not mean put the number 9 into memory location 21.) Opcode C (hex code for 12) is for telling CPU it’s done. Expects operand to be 12 zero-bits.

Some practice Refer to appendix C… How would we put the number 64 into memory at address 12? How would we add the numbers 6 and 8 and put the result in register 1? How would we add register 7 to register 5 and put the answer in memory at address 32? More examples: p. 91

Execution In our example, each instruction is 2 bytes long. Program counter (PC) begins at address of first instruction. For each instruction: Fetch (and increment PC by 2) Decode Execute Examples pp. 98-99 Note that RAM contains both instructions and data, separated from each other. For example, addresses 0-99 could be reserved for code.

Logic operations Work just like gates, but we do several bits in parallel. Examples 10101110 01101011 AND 11110000 AND 00011111 Try the same examples with “OR” and “XOR” Observations: What happens when you AND with a 1? With a 0? What about OR’ing with a 1 versus a 0? What about XOR?

Shift operations Given a bit pattern like 00011100, we can shift the bits left to obtain: 00111000. If we shift to the right instead, 00011100 becomes this: 00001110. We can even shift by more than one position. Shifting 01010000 by 3 bits right  00001010. Sometimes when we shift, 1’s fall off the edge. Shifting 01010000 by 2 bits left  01000000. When we shift, the “vacated” bits are usually 0.

Why shift? One application of a shift operation is to: Multiply by 2: left shift Divide by 2: right shift Try some examples – should look familiar with our earlier work on binary numbers. One funny exception: dividing a (signed) negative number by 2. In this case, we want the vacated bit to be 1 Example: –12 in signed is 11110100. If we shift right by 1, we get 01111010, but it should be this: 11111010.

Rotate Rotate operations work the same as shift… except that the vacated bits come from the other end of the number. So, instead of 1’s falling off the edge, they rotate. For example, 01010000 rotated left by 2 becomes 01000001. Also: 00001111 rotated right by 3 becomes: 11100001. Examples pp. 103-104.