Chapter 2 Machine Language.

Slides:



Advertisements
Similar presentations
Stored Program Architecture
Advertisements

Instruction Set Design
Khaled A. Al-Utaibi  Computers are Every Where  What is Computer Engineering?  Design Levels  Computer Engineering Fields  What.
Lab6 – Debug Assembly Language Lab
Chapter 2 Machine Language. Machine language The only language a computer can understand directly. Each type of computer has its own unique machine language.
1 Intro to CS: Part 2 Lecture 1 Ata Kaban School of Computer Science The University of Birmingham [adapted from B Bordbar and M Kwiatkowska]
The Analytical Engine Module 6 Program Translation.
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
Computing Components 01/26/11. Announcements & Reminders Programs 1 due Friday, 9/2/11 What is my late policy? Proxy Codes for Labs  You should be able.
Chapter 4 Processor Technology and Architecture. Chapter goals Describe CPU instruction and execution cycles Explain how primitive CPU instructions are.
Recap – Our First Computer WR System Bus 8 ALU Carry output A B S C OUT F 8 8 To registers’ input/output and clock inputs Sequence of control signal combinations.
Chapter 4 H1 Assembly Language: Part 2. Direct instruction Contains the absolute address of the memory location it accesses. ld instruction:
Computer Architecture
Computer Systems CS208. Major Components of a Computer System Processor (CPU) Runs program instructions Main Memory Storage for running programs and current.
CS 0008 Day 2 1. Today Hardware and Software How computers store data How a program works Operators, types, input Print function Running the debugger.
Atmega32 Architectural Overview
How Computers Work. A computer is a machine f or the storage and processing of information. Computers consist of hardware (what you can touch) and software.
Computer Hardware and Software Chapter 1. Overview Brief History of Computers Hardware of a Computer Binary and Hexadecimal Numbers Compiling vs. Interpreting.
The Computer Systems By : Prabir Nandi Computer Instructor KV Lumding.
What is a Computer ? Computers are Electronic Machines that process (performs calculation and manipulation) Data under the control of Set of Instructions.
Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.
Instruction Set Architecture
An Introduction to Computers August 12, 2008 Mrs. C. Furman.
1 4.2 MARIE This is the MARIE architecture shown graphically.
Computer Systems Organization CS 1428 Foundations of Computer Science.
Implementation of a Stored Program Computer ITCS 3181 Logic and Computer Systems 2014 B. Wilkinson Slides2.ppt Modification date: Oct 16,
The CPU Central Processing Unit. 2 Reminder - how it fits together processor (CPU) memory I/O devices bus.
Chapter 4 MARIE: An Introduction to a Simple Computer.
Lecture 8 February 29, Topics Questions about Exercise 4, due Thursday? Object Based Programming (Chapter 8) –Basic Principles –Methods –Fields.
CPU How It Works. 2 Generic Block Diagram CPU MemoryInputOutput Address Bus Data Bus.
School of Computer Science & Information Technology G6DICP Introduction to Computer Programming Milena Radenkovic.
4-1 Chapter 4 - The Instruction Set Architecture Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles.
Lecture 14 Today’s topics MARIE Architecture Registers Buses
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.
1 i206: Lecture 4: The CPU, Instruction Sets, and How Computers Work Marti Hearst Spring 2012.
Data Manipulation CSC Overview  Computer Architecture  Machine Language  Computer Architecture  Machine Language.
ECEG-3202 Computer Architecture and Organization Chapter 6 Instruction Sets: Addressing Modes and Formats.
Computer Organization 1 Instruction Fetch and Execute.
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
An Example Architecture. A Paper Computer - Woody Woody's characteristics Word size – 8 bits One word.
20 October 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
Concepts of Engineering and Technology Copyright © Texas Education Agency, All rights reserved.
Simple ALU How to perform this C language integer operation in the computer C=A+B; ? The arithmetic/logic unit (ALU) of a processor performs integer arithmetic.
CBP 2002ITY 270 Computer Architecture1 Module Structure Whirlwind Review – Fetch-Execute Simulation Instruction Set Architectures RISC vs x86 How to build.
1 Basic Processor Architecture. 2 Building Blocks of Processor Systems CPU.
Computer Operation. Binary Codes CPU operates in binary codes Representation of values in binary codes Instructions to CPU in binary codes Addresses in.
Hello world !!! ASCII representation of hello.c.
Operating Systems A Biswas, Dept. of Information Technology.
Recap – Our First Computer WR System Bus 8 ALU Carry output A B S C OUT F 8 8 To registers’ read/write and clock inputs Sequence of control signal combinations.
“Atmega32 Architectural Overview” SIGMA INSTITUTE OF ENGINEERING Prepared By: SR.NO NAME OF STUDENT ENROLLMENT 1 Parihar Shipra A Guided By:-
Computer Basics.
Atmega32 Architectural Overview
Chapter 7.2 Computer Architecture
Computer Organization & Assembly Language Chapter 3
William Stallings Computer Organization and Architecture 8th Edition
Computer Architecture
Edited by : Noor Alhareqi
Computer Science I CSC 135.
Edited by : Noor Alhareqi
Computers: Hardware and Software
CSCE Fall 2013 Prof. Jennifer L. Welch.
ECEG-3202 Computer Architecture and Organization
MARIE: An Introduction to a Simple Computer
CSCE Fall 2012 Prof. Jennifer L. Welch.
CPU has 6 special locations called registers
Chapter 4: Computer Architecture
A Level Computer Science Topic 5: Computer Architecture and Assembly
Chapter 4 The Von Neumann Model
Presentation transcript:

Chapter 2 Machine Language

Machine language The only language a computer can understand directly. Each type of computer has its own unique machine language. We will study the machine language of the H1 computer. This is a simulated computer. look for info Exercise: Find examples of different machine languages and the computers they run on.

Computer Architecture A computer’s machine language and its corresponding assembly language are often seen as the expression of the computer’s architecture because the instructions in these languages determine the physical layout of the computer CPU.

H1 Simplified model of a modern computer Easy to learn Simulated by the sim program in the H1 Software Package. sim runs on DOS, Windows, X86 Linux, Sun Sparc Solaris, and Macintosh OS X. Exercise: Download and install the H1 package from www.course.com Select Computer Science Go to Page 2 and Find Prof. Dos Reis’ book Select Student Downloads

Central Processing Unit (CPU) of H1 Heart of H1: central processing unit (CPU). The CPU contains computational circuits, control circuits, and registers. A register is a special memory area that can hold one 16-bit number. The design or arrangement of circuits of the CPU are determined by the instructions it needs to understand. Exercise: Recall adder design of Chapter 1

Registers on H1 Program counter (pc) Accumulator (ac) contains the address of the next instruction to be executed Accumulator (ac) contains the result of the most recent calculation Stack pointer (sp) points to the area of memory being used by most recently called function

Clock Generates stream of pulses that determines the speed at which the CPU performs its operation. One Hertz is 1 pulse per second. One megaHertz is 1 million pulses per second. One gigaHertz is 1 billion pulses per second. How fast are computers today?

Everything that happens in the CPU happens with the clock +ve voltage -ve or 0 voltage one clock tick Everything that happens in the CPU happens with the clock keeping time. Exercise: What is the name used to describe the above wave?

Machine language instructions Binary numbers Tell the CPU what to do The only kind of instruction the CPU can understand The CPU does NOT understand C++ or Java instructions. Instructions in these languages have to be translated to machine language (compiled).

Main memory Holds machine instructions, data, and results. CPU gets data and machine instructions from main memory. CPU places results into main memory. low addr code data heap stack high addr

Data and instructions are moved between the CPU and main memory on the data bus. The data bus is a ribbon of parallel wires; bits travel in parallel along adjacent wires 16-bit data bus bits

Why computers are fast The CPU and main memory are all electronic. They have NO moving parts to slow them down. As long as main memory can provide the CPU with machine instructions and data fast enough, the CPU can perform computations at an enormous rate. Exercise: How fast was the first IBM PC? How much faster are current PCs?

Organization of main memory An indexed array of memory slots Each slot is one word (16 bits) on the H1. On most computers, each slot is one byte (8 bits). (word-addressable vs byte-addressable) Each slot has an index called its address. Addresses are sequential integers starting from 0. What is in a memory slot is called its contents.

H1 has 4k words of memory Ex: How many bytes? contents

Be sure to distinguish between the address of a main memory slot and its contents. The contents is the binary number in the slot. The address is the number that identifies or locates that slot.

I/O devices Input devices provide main memory and/or the CPU with data from the outside world. Output devices provide information to the outside world from main memory or the CPU. Some devices perform both input and output (e.g., a disk drive). “I/O” refers to input, output, and input/output devices.

Location of OS in main memory

Load machine instruction Opcode 0000 000000000100 address (12 bits) 0004 in hex This instruction loads the ac register from location 4 of main memory. ac  mem

Some opcodes 0000 load ac register from memory 0001 store ac register into memory 0010 add memory contents to ac register 1111111111111111 halt

Add machine instruction Opcode 0010 000000000101 address (only one argument!!) 2005 in hex ac = ac + mem implicit argument

Store machine instruction ac  mem Opcode 0001 000000000110 address 1006 in hex

Halt machine instruction Opcode (16 bits) 1111111111111111 FFFF in hex

Machine language program

Important reminder We use hex numbers as a shorthand representation of binary numbers. All the numbers in the computer are in binary. The next slide shows what our simple machine language program really looks like as it sits in memory.

sim sim is a program that makes your computer act like H1. sim runs on DOS, Windows, Sun Sparc Solaris, X86 Linux, and Macintosh OS X. sim is better for our purposes than a real H1: With sim we can easily make changes to H1. sim has a powerful debugger.

Some commands for sim’s debugger

When a register changes its contents, sim’s debugger shows its before and after values.

Mnemonics A mnemonic is an easy-to-remember representation of an opcode. ld mnemonic for the load opcode st mnemonic for the store opcode add mnemonic for the add opcode halt mnemonic for the halt opcode

Debugger’s prompt provides a lot of information just hit <enter>

The next slide shows how to use the debugger to enter and run our simple machine language program. The bold type corresponds to user input.

enter command – e0

Creating a log file

sim does not prompt for arguments if they are provided on the command line when sim is first invoked.

Getting help on sim Enter one of the following: sim /h sim –h sim /? Avoid ‘?’ on Sun, Linux, and OS X

Getting help on sim’s debugger Enter one of the following: h ? when the debugger is active.