Intermediate Programming & Design (C++) Notation

Similar documents
Electronic Data and Instructions

CC411: Introduction To Microprocessors

REPRESENTING INFORMATION:

Using sticks to count was a great idea for its time. And using symbols instead of real sticks was much better.

Dec Hex Bin ORG ; ZERO. Introduction To Computing

IT 1204 Section 2.0. Data Representation and Arithmetic. 2009, University of Colombo School of Computing 1

The type of all data used in a C++ program must be specified

Microprocessors I MICROCOMPUTERS AND MICROPROCESSORS

data within a computer system are stored in one of 2 physical states (hence the use of binary digits)

Module 1: Information Representation I -- Number Systems

Final Labs and Tutors

Experimental Methods I

The type of all data used in a C (or C++) program must be specified

Information Science 1

Information Science 1

COMP Computer Basics. Yi Hong May 13, 2015

The x86 Microprocessors. Introduction. The 80x86 Microprocessors. 1.1 Assembly Language

Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2

CMSC 104 -Lecture 2 John Y. Park, adapted by C Grasso

Chapter 1 Computer and Programming. By Zerihun Alemayehu

An Overview of the Computer System. Kafui A. Prebbie 24

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation

8/16/12. Computer Organization. Architecture. Computer Organization. Computer Basics

Chapter 4 The Components of the System Unit

Chapter Two. Hardware Basics: Inside the Box

Bits. Binary Digits. 0 or 1

计算机信息表达. Information Representation 刘志磊天津大学智能与计算学部

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 1: Basic Concepts. Chapter Overview. Welcome to Assembly Language

Computers Are Your Future

Data Representation. Types of data: Numbers Text Audio Images & Graphics Video

Digital Logic. The Binary System is a way of writing numbers using only the digits 0 and 1. This is the method used by the (digital) computer.

Computer Basics 1/24/13. Computer Organization. Computer systems consist of hardware and software.

Discussion. Why do we use Base 10?

2 Number Systems 2.1. Foundations of Computer Science Cengage Learning

[301] Bits and Memory. Tyler Caraza-Harter

COMPUTER ORGANIZATION & ARCHITECTURE

Chapter Overview. Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 1: Basic Concepts. Printing this Slide Show

Beyond Base 10: Non-decimal Based Number Systems

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 01, SPRING 2013

Teaching KS3 Computing. Session 3 Theory: More on binary and representing text Practical: Introducing IF

Computers Are Your Future

CMPS 10 Introduction to Computer Science Lecture Notes

Computer Basics 1/6/16. Computer Organization. Computer systems consist of hardware and software.

Lecture (01) Digital Systems and Binary Numbers By: Dr. Ahmed ElShafee

CS 261 Fall Binary Information (convert to hex) Mike Lam, Professor

THE LOGIC OF COMPOUND STATEMENTS

What Is It? Instruction Register Address Register Data Register

CHAPTER 2 Number Systems

Beyond Base 10: Non-decimal Based Number Systems

System Unit Components Chapter2

9/3/2015. Data Representation II. 2.4 Signed Integer Representation. 2.4 Signed Integer Representation

Unit - II. Computer Concepts and C Programming 06CCP13. Unit II

Full file at

Number codes nibble byte word double word

ELEG3923 Microprocessor Ch.0 & Ch.1 Introduction to Microcontroller

COMPUTER SYSTEM. COMPUTER SYSTEM IB DP Computer science Standard Level ICS3U. COMPUTER SYSTEM IB DP Computer science Standard Level ICS3U

Chapter 7: Processor and Memory

Binary Arithmetic CS 64: Computer Organization and Design Logic Lecture #2 Fall 2018

BINARY SYSTEM. Binary system is used in digital systems because it is:

INTRODUCTION TO COMPUTERS

Announcement. (CSC-3501) Lecture 3 (22 Jan 2008) Today, 1 st homework will be uploaded at our class website. Seung-Jong Park (Jay)

Binary Arithmetic CS 64: Computer Organization and Design Logic Lecture #2

Digital Computers and Machine Representation of Data

LAB A Translating Data to Binary

Homeschool Enrichment. The System Unit: Processing & Memory

Lecture (01) Introduction Number Systems and Conversion (1)

Binary Codes. Dr. Mudathir A. Fagiri

Problem Set 1 Solutions

What is a computer? Units of Measurement. - A machine that: - Counts.

Course Syllabus [1/2]

MACHINE LEVEL REPRESENTATION OF DATA

The Programming Process Summer 2010 Margaret Reid-Miller

Digital Fundamentals

Lecture Objectives. Introduction to Computing Chapter 0. Topics. Numbering Systems 04/09/2017

Chapter 1: Why Program? Computers and Programming. Why Program?

Practical Malware Analysis

Thus needs to be a consistent method of representing negative numbers in binary computer arithmetic operations.

Module 2: Computer Arithmetic

CPU. IBM PC and compatible Memory Structure

Level ISA3: Information Representation

CS 105 Review Questions #3

Memory Addressing, Binary, and Hexadecimal Review

Lecture C1 Data Representation. Computing and Art : Nature, Power, and Limits CC 3.12: Fall 2007

C H A P T E R 1. Introduction to Computers and Programming


Chapter 5. A Closer Look at Instruction Set Architectures

User. Application program. Interfaces. Operating system. Hardware

Course overview. Computer Organization and Assembly Languages Yung-Yu Chuang 2006/09/18. with slides by Kip Irvine

Chapter 1 Preliminaries

The. Binary. Number System

Data Storage. Slides derived from those available on the web site of the book: Computer Science: An Overview, 11 th Edition, by J.

Microprocessors & Assembly Language Lab 1 (Introduction to 8086 Programming)

Chapter 2. Prepared By: Humeyra Saracoglu

Chapter 3 DATA REPRESENTATION

Chapter 1: An Overview of Computers and Programming Languages. Objectives. Objectives (cont d.) Introduction

Introduction to Computers. Joslyn A. Smith

COE 202- Digital Logic. Number Systems II. Dr. Abdulaziz Y. Barnawi COE Department KFUPM. January 23, Abdulaziz Barnawi. COE 202 Logic Design

Computer Systems. IGCSE OCR AQA Edexcel Understand the term. embedded system and how an Purpose of embedded system

Chapter 1. Introduction to Computers and Programming. M hiwa ahmad aziz

CHW 261: Logic Design

Transcription:

Notation Byte = 8 bits (a sequence of 0 s and 1 s) To indicate larger amounts of storage, some prefixes taken from the metric system are used One kilobyte (KB) = 2 10 bytes = 1024 bytes 10 3 bytes One megabyte (MB) = 1024 KB = 1,048,576 bytes 10 6 bytes One gigabyte (GB) = 1024 MB = 1,073,741,824 bytes 10 9 bytes One terabyte (TB) = 1024 GB 10 12 bytes Teresa Leyk Slide 1 Data Representation

Binary and Decimal Data Representation All information on a computer is stored as sequences of 0 s and 1 s. Binary numbers have 2 as their base only two digits: 0 and 1 10111 2 = 1 2 4 + 0 2 3 + 1 2 2 + 1 2+1 Compare with decimal numbers where 10 is their base: ten digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 12345 = 1 10 4 + 2 10 3 + 3 10 2 + 4 10+5 Teresa Leyk Slide 2 Data Representation

Converting Binary/Decimal Numbers EXAMPLE. This is how we convert a binary number to a decimal number 10111 2 = 1 2 4 +0 2 3 +1 2 2 +1 2+1 = 16+4+2+1 = 23 EXAMPLE. This is how we convert the decimal number 13 to a binary number. We divide the decimal number repeatedly by 2 until a quotient of zero results. The successive remainders are the digits of the binary number from right to left. Notation: r means remainder. 13 2 = 6r1, 6 2 = 3r0, 3 2 = 1r1, 1 2 = 0r1 Therefore, the binary number is 1101 2 (we take the remainders from right to left). You can check that 1101 2 is equal to 13. Teresa Leyk Slide 3 Data Representation

Hexadecimal Number System The hexadecimal system uses the base of 16 to represent numbers The first ten digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 The next six digits are A, B, C, D, E and F representing 10, 11, 12, 13, 14, 15, respectively Programmers use this system as a convenient way of organizing groups of binary numbers. One hexadecimal digit occupies 4 bits. Therefore, 1 byte is represented by 2 hexadecimal digits. EXAMPLES The decimal number 16 is represented as 10 16 in hexadecimal notation The decimal number 26 is represented as 1A 16 The decimal number 2748 is represented as ABC 16 Teresa Leyk Slide 4 Data Representation

Relation Between Hexadecimal and Binary Systems There is a close relation between hexadecimal and binary systems Bin = binary system, Hex = hexadecimal system Hex Bin Hex Bin Hex Bin Hex Bin 0 0000 4 0100 8 1000 C 1100 1 0001 5 0101 9 1001 D 1101 2 0010 6 0110 A 1010 E 1110 3 0011 7 0111 B 1011 F 1111 Note that 1 byte (8 bits) can be represented using two hexadecimal digits. Teresa Leyk Slide 5 Data Representation

Characters The schemes for the internal machine representation of characters are based on the assignment of a numeric code to each symbol to be represented. ASCII (American Standard Code for Information Interchange) is the standard coding scheme used in programming languages. It uses 8 bits to represent characters. Unfortunately, it can code only 256 different characters (some of them are called control characters). Teresa Leyk Slide 6 Data Representation

Characters (cont.) In order to increase the number of characters to be represented a new scheme called Unicode is used in some programming languages (including C++). It uses 16 bits to represent each character, so it can represent 65,536 different symbols. It is possible in Unicode to represent symbols from non-latin languages: Arabic, Russian, Greek, Hebrew, and Thai. ASCII is a subset of Unicode. Teresa Leyk Slide 7 Data Representation

ASCII Codes for Some Characters Code 10 = Decimal ASCII code, Code 16 = Hexadecimal ASCII code Code 10 47 48 49 50 51 52 53 54 55 56 57 Code 16 2F 30 31 32 33 34 35 36 37 38 39 Character / 0 1 2 3 4 5 6 7 8 9 Code 10 58 59 60 61 62 63 64 65 66 67 68 Code 16 3A 3B 3C 3D 3E 3F 40 41 42 43 44 Character : ; < = >? @ A B C D Code 10 91 92 93 94 95 96 97 98 99 100 Code 16 5B 5C 5D 5E 5F 60 61 62 63 64 Character [ \ ] ^ _ a b c d Teresa Leyk Slide 8 Data Representation

Bytes and Memory Locations A byte is a memory location that can hold eight binary digits, either 0 or 1. Byte is most often abbreviated as B, hence MB for megabyte (b is used as an abbreviation for bit). A computer main memory is divided into numbered bytes (starting from 0). The number of a byte is called its address. Memory addresses may be used as arguments for program instructions. Several (usually 2, 4, or 8) subsequent bytes are combined together (and are sometimes called word). Each group of bytes has a unique address which is equal to the address of its first byte. Teresa Leyk Slide 9 Data Representation

Program instructions Program Execution must be stored in main memory in binary form must be expressed in a form that the machine can understand they must be written in the machine language consists of two parts: a numeric opcode representing a basic machine instruction (load, multiply, add, store,... ) addresses of the operands The control unit (part of the CPU) fetches each instruction from memory to the instruction register decodes the instruction to determine the operation and the address(es) of the operand(s) fetches the operand performs the required operation (using the ALU if necessary) Teresa Leyk Slide 10 Data Representation

Input Devices CPU Control Unit Arithmetic Logic Unit Output Devices Registers Secondary Memory Main Memory Teresa Leyk Slide 11 Data Representation

Assembly language Programming Languages and Compilers uses names in place of numeric opcodes, and variable names in place of numeric addresses is translated by an assembler into machine code High-level languages (C, C++, Java) source programs written in high-level languages must be translated into machine code by a compiler or interpreter a compiler produces from the source program an object program that is specific to that machine; a linker connects the object program with libraries producing an executable program; the executable program can be executed any time later an interpreter translates source program statements into machine language, and after each statement is translated, the resulting code (machine instruction) is immediately executed Teresa Leyk Slide 12 Data Representation

Programming Languages and Compilers (cont.) A compiler of a programming language translates a source program into object program (that is specific for that computer). Usually it is not possible to run an executable program on platforms other than that where it was generated. To port a program to another platform, it is necessary to recompile it using a compiler that will generate a different executable program for that platform. Another approach is to combine compiler and interpreter. Such an approach is used for Java. a source program is compiled into machine-independent intermediate code, called bytecode the bytecode is executed by a special interpreter called Java Virtual Machine (JVM) Teresa Leyk Slide 13 Data Representation

Programming Programming is the process of translating a problem s solution into instructions that a computer can process. Software Development Life Cycle (SDLC) Analysis: analyze the problem. Design: break the problem down into simple components (use top-down or bottom-up approach) Development (coding): translate the simple components into computer code (use hardware and/or software) Test: test the working solution and fix the problems (try it with different data) Maintenance: keep it working, make requested changes/fixes. Teresa Leyk Slide 14 Data Representation