The computer memory and the binary number system.

Slides:



Advertisements
Similar presentations
CHAPTER 2 GC101 Program’s algorithm 1. COMMUNICATING WITH A COMPUTER  Programming languages bridge the gap between human thought processes and computer.
Advertisements

 Suppose for a moment that you were asked to perform a task and were given the following list of instructions to perform:
1 Chapter 2 The Digital World. 2 Digital Data Representation.
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Lecture 1: Overview of Computers & Programming
Microprocessors. Microprocessor Buses Address Bus Address Bus One way street over which microprocessor sends an address code to memory or other external.
COE Computer Organization & Assembly Language
Computer Algorithms. Fact: computers are dumb machines Basic property of a computer (a machine): Computers do what we tell them to do Unfortunately, computer.
The computer memory and the binary number system.
The Binary Machine Modern high-level programming languages are designed to make programming easier. On the other end, the low level, all modern digital.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
The Analytical Engine Module 6 Program Translation.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
Introduction to Computers and Programming. Some definitions Algorithm: –A procedure for solving a problem –A sequence of discrete steps that defines such.
Chapter 16 Programming and Languages: Telling the Computer What to Do.
Topic 1: Introduction to Computers and Programming
Introduction to Computers and Programming. Some definitions Algorithm: Algorithm: A procedure for solving a problem A procedure for solving a problem.
9-Aug-15 Vocabulary. Programming Vocabulary Watch closely, you might even want to take some notes. There’s a short quiz at the end of this presentation!
Programming a computer. What does programming a computer mean ? Programming a computer: Since a computer can only execute machine instructions (encoded.
CS1044 – Intro. To Programming in C++ Dr. Craig A. Struble.
Introduction to computer: storing instructions and information.
1 I.Introduction to Algorithm and Programming Algoritma dan Pemrograman – Teknik Informatika UK Petra 2009.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Chapter Introduction to Computers and Programming 1.
Introduction to Programming Dr Masitah Ghazali Programming Techniques I SCJ1013.
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
Floating point variables of different lengths. Trade-off: accuracy vs. memory space Recall that the computer can combine adjacent bytes in the RAM memory.
1 Intro to Computer Science I Chapter 1 Introduction to Computation Algorithms, Processors, and Programs.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
The CPU The Central Presentation Unit Main Memory and Addresses Address bus and Address Space Data Bus Control Bus The Instructions set Mnemonics Opcodes.
COP1220/CGS2423 Introduction to C++/ C for Engineers Professor: Dr. Miguel Alonso Jr. Fall 2008.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.
Computer Programming I. Today’s Lecture  Components of a computer  Program  Programming language  Binary representation.
Bits & Bytes Created by Chris McAbee For AAMU AGB199 Extra Credit Created from information copied and pasted from
Floating point numerical information. Previously discussed Recall that: A byte is a memory cell consisting of 8 switches and can store a binary number.
What does a computer program look like: a general overview.
Robert Crawford, MBA West Middle School.  Explain how the binary system is used by computers.  Describe how software is written and translated  Summarize.
Introduction to programming in the Java programming language.
OOP with Java, David J. Barnes Bits, Bytes, and Java1 The Challenge Writing programs well is a challenge. –From coder to software engineer. We want programs.
Chapter 2 Data Manipulation Yonsei University 1 st Semester, 2015 Sanghyun Park.
1 WELCOME TO CIS 1068! Instructor: Alexander Yates.
Represents different voltage levels High: 5 Volts Low: 0 Volts At this raw level a digital computer is instructed to carry out instructions.
1.4 Representation of data in computer systems Instructions.
Chapter 1 : Overview of Computer and Programming By Suraya Alias
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
Computer Operation. Binary Codes CPU operates in binary codes Representation of values in binary codes Instructions to CPU in binary codes Addresses in.
Representation of Data - Instructions Start of the lesson: Open this PowerPoint from the A451 page – Representation of Data/ Instructions How confident.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
First Foray into Programming (the hard way). A reminder from last lesson: A machine code instruction has two parts:  Op-code  Operand An instruction.
Chapter 7: Low-Level Programming Languages Chapter 7 Low-Level Programming Languages Page 66 In order to execute instructions on a CPU, those instructions.
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
INTRODUCTION TO COMPUTER PROGRAMMING ITC-314. Computer Programming  Computer Programming means creating a sequence of instructions to enable a computer.
Introduction to computer software. Programming the computer Program, is a sequence of instructions, written to perform a specified task on a computer.
 Human language : commonly used to express feeling and understand what other people expression.  Computer language : are a languages by which a user.
Computer Basics.
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Computers: Hardware and Software
CSCE Fall 2013 Prof. Jennifer L. Welch.
MIPS Instruction Encoding
MIPS Instruction Encoding
CSCE Fall 2012 Prof. Jennifer L. Welch.
The computer memory and the binary number system
Computer Algorithms.
LO1 – Understand Computer Hardware
The computer memory and the binary number system
Presentation transcript:

The computer memory and the binary number system

Representing numbers using a row of switches (cont.) We can represent each number using a different state of the switches. Example:

The binary number system The binary number system uses 2 digits to encode a number: That means that you can only use the digits 0 and 1 to write a binary number –Example: some binary numbers 0 = represents no value 1 = represents a unit value and so on.

The binary number system (cont.) The value that is encoded (represented) by a binary number is computed as follows: Binary numberValue encoded by the binary number d n-1 d n-2... d 1 d 0 d n-1 ×2 n-1 + d n-2 ×2 n d 1 ×2 1 + d 0 ×2 0

The binary number system (cont.) Example:

The binary number system (cont.) Now you should understand how the different states of these 3 switches represent the numbers 0-7 using the binary number system:

A cute binary number joke Try to understand this joke: (Read: there are binary 10 (= 2) types of people: those who understand binary (numbers) and those who don't)

What does all this have to do with a computer ? Recall what we have learned about the Computer RAM memory: The RAM consists of multiple memory cells: Each memory cell stores a number

What does all this have to do with a computer ? (cont.) The connection between the computer memory and the binary number system is: The computer system uses the binary number encoding to store the number Example:

Combining adjacent memory cells A byte has 8 bits and therefore, it can store: 2 8 = 256 different patterns (These 256 patterns are: , , , , )

Combining adjacent memory cells (cont.) Each pattern can are encoded exactly one number: Therefore, one byte can store one of 256 possible values (You can store the number 34 into a byte, but you cannot store the number 456, the value is out of range) = = = = = 255

Computer memory jargon: bit = (binary digit) a smallest memory device A bit is in fact a switch that can remember 0 or 1 (The digits 0 and 1 are digits used in the binary number system) Byte = 8 bits A byte is in fact one row of the RAM memory KByte = kilo byte = 1024 (= 2 10 ) bytes (approximately 1,000 bytes) MByte = mega byte = (= 2 20 ) bytes (approximately 1,000,000 bytes) GByte = giga byte = (= 2 30 ) bytes (approximately 1,000,000,000 bytes) TByte = tera byte

What does all this have to do with a computer ? (cont.) Note: the address is also expressed as a binary number So a 32 bites computer can have over 4,000,000,000 bytes (4 Gigabytes) of memory.

Combining adjacent memory cells (cont.) The computer can combine adjacent bytes (memory cells) and use it as a larger memory cell Schematically: A 16 bits memory cell can store one of 2 16 = different patterns. Therefore, it can represent (larger) numbers ranging from: 0 −

Combining adjacent memory cells (cont.) The computer can also: combine 4 consecutive bytes and use them as a 32 bits memory cell combine 8 consecutive bytes and use them as a 64 bits memory cell Such a memory call can represent numbers ranging from: 0 − ( ) or 0 − Such a memory call can represent numbers ranging from: 0 − ( ) or 0 −

Combining adjacent memory cells (cont.) When the computer accesses the RAM memory, it specifies: The memory location (address) The number of bytes it needs

Algorithm

Definition: algorithm Dictionary definition: Algorithm = a step-by-step procedure for solving a problem or accomplishing some task, especially by means of a computer

Computer Algorithms Computer Algorithm: is an algorithm that can be executed by a computer

Computer Algorithms (cont.) Properties of computer algorithms: The steps in an algorithm must be consists of operations that can be executed by a computer The step in an algorithm must be unambiguous (Remember that a dumb machine like a computer will do what it is told to do. Resolving ambiguity requires some thinking (intelligence) which computers cannot do !) Computers cannot think.

Programming a computer

What does programming a computer mean ? Programming a computer: Since a computer can only execute machine instructions (encoded in binary numbers), this means: Programming a computer = instruct a computer to perform a task/solve a problem Write the steps of an algorithm using machine instructions !!!

Types of languages used in computer programming Machine language The machine language (or instruction code) consists of (binary) numbers that encode instructions for the computer Every computer (CPU) has its own machine language (I.e., the instruction code 1 can encode a different instruction for different CPUs) Instruction encoding was discussed in this webnote: click here

Types of languages used in computer programming (cont.) Assembler language or low level programming language An assembler language consists of (English like) mnemonics There is one mnemonic for each machine instruction of the computer

Types of languages used in computer programming (cont.) What an assembler program look like: Each assembler instruction is a mnemonic that corresponds to a unique machine instruction start add x, y <-- one assembler instruction sub x, y <-- one assembler instruction... end

Instructing a computer to execute an algorithm (cont.) We have developed specialized languages (based on the English language) to instruct/command a computer These specialized languages are called: High level programming languages

High level programming language A high level programming language consists of (English- like) "people" language to simplify the writing computer algorithms A high level programming language allows the programmer to write sentences in this language which can be easily translated into machine instructions The sentences written in a high level programming language are called: statements

High level programming language (cont.) What an assembler program look like: main( ) { if ( x > y ) // One sentence (statement) in a high level prog. lang. { max = x; } else { max = y; }..... }

High level programming language (cont.) One statement in a high level programming language is usually translated into multiple machine instruction that achieve the effect specified by the statement

Some well-known programming languages Well-known programming languages:

Computer Programs Computer Program: Computer program = a computer algorithm that is expressed (written) in some programming language Most programming languages are “English-like” They use words from the English language

Representation gap: algorithm in programming and comp instructions Notice the following representation gap: 1.An algorithm expressed in a programming language is "English-like" 1.However: the instructions that a computer executes are numbers (that encode the instruction)

Representation gap: algorithm in programming and comp instr. (cont.) Solution Someone (or something) must translate the algorithm expressed in a programming language into numbers that encode the same instructions as the original algorithm

Bridging the translation gap: compiler (cont.) The (pretty complex) computer program that does this translation is called: a compiler

The compilation (= translation) process (cont.) Now we can execute the program in machine instruction by using the command: The following figure summarizes the translation process: >> a.out

Writing computer programs: trust your compiler ! When you write a computer program, you will write it in a high level programming language and trust the compiler (translator) to do the translation It is virtually impossible to write a large computer program in machine language (binary numbers)