CS 16: Assembly Language Programming for the IBM PC and Compatibles

Size: px
Start display at page:

Download "CS 16: Assembly Language Programming for the IBM PC and Compatibles"

Transcription

1 CS 16: Assembly Language Programming for the IBM PC and Compatibles

2 First, a little about you Your name Have you ever worked with/used/played with assembly language? If so, talk about it Why are you taking this course? What are your expectations/goals from me, as well as this course? Then, a little about me Background about myself Cover the syllabus, including my expectations of you and this course Finally, any additional questions before we get started

3

4 Get a quick overview of assembly language Understand the basic concept of a virtual machine See how we represent data Take a look at Boolean operations

5 Some good questions to ask Assembly language applications

6 What background should I have? You should have programmed in at least one structured high-level language, such as Java, C, Python, or C++ You should know how to use IF statements, arrays, and functions to solve programming problems What is an assembler? An assembler is a utility program that converts source code programs from assembly language into machine language

7 What hardware/software do I need? You need a computer that runs a 32-bit or 64-bit version of Microsoft Windows, along with one of the recent versions of Microsoft Visual Studio What types of programs will I create? 32-Bit Protected Mode 32-bit protected mode programs run under all 32-bit versions of Microsoft Windows They are usually easier to write and understand than real-mode programs 64-Bit Mode 64-bit programs run under all 64-bit versions of Microsoft Windows. 16-Bit Real-Address Mode 16-bit programs run under 32-bit versions of Windows and on embedded systems

8 What will I learn? Basic principles of computer architecture as applied to x86 processors Basic Boolean logic and how it applies to programming and computer hardware How x86 processors manage memory, using protected mode and virtual mode How high-level language compilers (such as C++) translate statements from their language into assembly language and native machine code How high-level languages implement arithmetic expressions, loops, and logical structures at the machine level

9 What else will I learn? Data representation, including signed and unsigned integers, real numbers, and character data How to debug programs at the machine level, as the need for this skill is vital when you work in languages such as C and C++, which generate native machine code How application programs communicate with the computer s operating system via interrupt handlers and system calls How to interface assembly language code to C++ programs How to create assembly language application programs

10 How does assembly language (AL) relate to machine language? Machine language is a numeric language specifically understood by a computer s processor (the CPU) All x86 processors understand a common machine language Assembly language consists of statements written with short mnemonics such as ADD, MOV, SUB, and CALL Assembly language has a one-to-one relationship with machine language: Each assembly language instruction corresponds to a single machine-language instruction.

11 How do C++ and Java relate to AL? High-level languages such as Python, C++, and Java have a one-tomany relationship with assembly language and machine language A single statement in C++, for example, expands into multiple assembly language or machine instructions Most people cannot read raw machine code, so in this book, we examine its closest relative, assembly language Is AL portable? Assembly language is not portable because it is designed for a specific processor family There are a number of different assembly languages widely used today, each based on a processor family

12 Beats me In all seriousness, there are applications for assembly language Embedded programs are short programs stored in a small amount of memory in single-purpose devices Real-time applications dealing with simulation and hardware monitoring require precise timing and responses Computer game consoles require their software to be highly optimized for small code size and fast execution

13 There are still more applications for assembly language Assembly language helps you to gain an overall understanding of the interaction between computer hardware, operating systems, and application programs Some high-level languages abstract their data representation to the point that it becomes awkward to perform low-level tasks such as bit manipulation Device drivers are programs that translate general operating system commands into specific references to hardware details

14 Some representative types of applications: Business application for single platform Hardware device driver Business application for multiple platforms Embedded systems & computer games

15 High-level language Formal structures, which allow: Easy organization Ability to maintain large sections of code ASM Minimal formal structure leads to programmers enforcing structure Consequence: difficult to maintain existing code

16 High-level language May not provide for direct hardware access Even if it exists, awkward coding techniques often used Consequence: difficult to maintain existing code ASM Hardware access is straightforward and simple Programs are short and welldocumented Consequence: easy to maintain existing code

17 High-level language Usually very portable Code can be recompiled on multiple operating systems with minimal changes Consequence: easy to maintain existing code ASM Must be recoded separately for each platform Often uses an assembler with different syntax Consequence: difficult to maintain existing code

18 High-level language Produces too much executable code May not run efficiently ASM Ideal because: Executable code is small Runs quickly

19 Virtual Machines Specific Machine Levels

20 Tanenbaum: Virtual machine concept Programming Language analogy: Each computer has a native machine language (language L0) that runs directly on its hardware A more human-friendly language is usually constructed above machine language, called Language L1

21 Programs written in L1 can run two different ways: INTERPRETATION: L0 program interprets and executes L1 instructions one by one TRANSLATION: L1 program is completely translated into an L0 program, which then runs on the computer hardware

22 English: Display the sum of A times B plus C. C++: cout << (A * B + C); Intel Machine Language: A F E Assembly Language: mov eax,a mul B add eax,c call WriteInt

23 High-Level Language Assembly Language Instruction Set Architecture (ISA) Digital Logic

24 Application-oriented languages C++ Java Pascal Visual Basic... Programs compile into assembly language

25 Instruction mnemonics that have a one-to-one correspondence to machine language Programs are translated into Instruction Set Architecture (ISA) Level-machine language

26 Also known as conventional machine language Executed by Digital Logic

27 CPU, constructed from digital logic gates System bus Memory Implemented using bipolar transistors

28 Binary Numbers Translating between binary and decimal Binary Addition Integer Storage Sizes Hexadecimal Integers Translating between decimal and hexadecimal Hexadecimal subtraction Signed Integers Binary subtraction Character Storage

29 Digits are 1 and 0 1 = true 0 = false MSB: most significant bit LSB: least significant bit Bit numbering

30 Each digit (bit) is either 1 or 0 Each bit represents a power of 2

31 2 n Decimal Value n Decimal Value , , , , , ,768 Every binary number is a sum of powers of 2

32 Weighted positional notation shows how to calculate the decimal value of each binary bit: dec = (D n-1 2 n-1 ) + (D n-2 2 n-2 ) (D ) + (D ) D = binary digit Binary = decimal 9: (1 2 3 ) + (1 2 0 ) = 9

33 Repeatedly divide the decimal integer by 2 Each remainder is a binary digit in the translated value: 37 = Division Quotient Remainder 37/ / / / / /2 0 1

34 Starting with the LSB, add each pair of digits, include the carry if present

35 Standard sizes Ranges of unsigned integers Storage Type Range (Low High) Powers of 2 Unsigned byte 0 to to (2 8 1) Unsigned word 0 to to (2 16 1) Unsigned doubleword 0 to 4,294,967,295 0 to (2 32 1) Unsigned quadword 0 to 18,446,744,073,709,551,615 0 to (2 64 1) What is the largest unsigned integer that may be stored in 20 bits?

36 Binary Decimal Hexadecimal Binary Decimal Hexadecimal A B C D E F

37 Each hexadecimal digit corresponds to 4 binary bits Example: Translate the binary integer to hexadecimal 1 6 A

38 Multiply each digit by its corresponding power of 16: dec = (D ) + (D ) + (D ) + (D ) Hex 1234 equals ( ) + ( ) + ( ) + ( ) or decimal 4,660 Hex 3BA4 equals ( ) + (11 * 16 2 ) + ( ) + ( ) or decimal 15,268

39 Used when calculating hexadecimal values up to 8 digits long 16 n Decimal Value , , ,048, ,777, ,435,456

40 decimal 422 = 1A6 hexadecimal Division Quotient Remainder 422/ /16 1 A 1/16 0 1

41 Divide the sum of two digits by the number base (16) The quotient becomes the carry value and the remainder is the sum digit A B 78 6D 80 B5 21 / 16 = 1, rem 5 Important skill: Programmers frequently add and subtract the addresses of variables and instructions.

42 When a borrow is required from the digit to the left, add 16 (decimal) to the current digit's value = 21-1 C6 75 A E Practice: The address of var1 is The address of the next variable after var1 is A. How many bytes are used by var1?

43 The highest bit indicates the sign 1 = negative 0 = positive If the highest digit of a hexadecimal integer is > 7, the value is negative Examples: 8A, C5, A2, 9D

44 Negative numbers are stored in two's complement notation Represents the additive inverse Starting Value Step 1: Reverse the bits Step 2: Add 1 to the value from Step Sum: 2 s Complement Representation Note that =

45 When subtracting A B, convert B to its two's complement Add A to ( B) Practice: Subtract 0101 from 1001

46 Form the two's complement of a hexadecimal integer Convert signed binary to decimal Convert signed decimal to binary Convert signed decimal to hexadecimal Convert signed hexadecimal to decimal

47 Ranges of unsigned integers Storage Type Range (Low High) Powers of 2 Signed byte -128 to to (2 7 1) Signed word -32,768 to +32, to (2 15 1) Signed doubleword -2,147,483,648 to +2,147,483, to (2 31 1) Signed quadword -9,223,372,036,854,775,808 to -9,223,372,036,854,775, to (2 63 1) What is the largest signed integer that may be stored in 20 bits?

48 Character sets Standard ASCII (0 127) Extended ASCII (0 255) ANSI (0 255) Unicode (0 65,535) Null-terminated String Array of characters followed by a null byte Using the ASCII table Back inside cover of book

49 Pure binary Can be calculated directly ASCII binary String of digits: " " ASCII decimal String of digits: "65" ASCII hexadecimal String of digits: "9C"

50

51 NOT AND OR Operator Precedence Truth Tables

52 Based on symbolic logic, designed by George Boole Boolean expressions created from: NOT, AND, OR Expression X X Y X Y X Y Description NOT X X AND Y X OR Y (NOT X) OR Y (X Y) NOT (X AND Y) X Y X AND (NOT Y)

53 Inverts (reverses) a Boolean value Truth table for Boolean NOT operator Digital gate diagram for NOT: X X F T T F NOT

54 Truth table for Boolean AND operator X Y X Y F F F F T F T F F T T T Digital gate diagram for AND: AND

55 Truth table for Boolean OR operator X Y X Y F F F F T T T F T T T T Digital gate diagram for OR: OR

56 Examples showing the order of operations Expression X Y (X Y) X (Y Z) Order of Operations NOT, then OR OR, then NOT AND, then OR

57 A Boolean function has one or more Boolean inputs and returns a single Boolean output A truth table shows all the inputs and outputs of a Boolean function

58 Example: X Y X X Y X Y F T F T F T T T T F F F T F T T

59 Example: X Y X Y Y X Y F F T F F T F F T F T T T T F F

60 Example: (Y S) (X S) X Y S (Y S) S (X S) (Y S) (X S) F F F F T F F F T F F T F F T F F F T T T T T F F T T T F F T F F F F F T T T F F T T F T F F F F T T T T F F T X Y S mux Z Two-input multiplexer A multiplexer is a device that selects one of several analog or digital input signals and forwards the selected input into a single output line

61 Assembly language helps you learn how software is constructed at the lowest levels Assembly language has a one-to-one relationship with machine language Each layer in a computer's architecture is an abstraction of a machine Layers can be hardware or software Boolean expressions are essential to the design of computer hardware and software

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

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 1: Basic Concepts. Chapter Overview. Welcome to Assembly Language Assembly Language for Intel-Based Computers, 4 th Edition Kip R. Irvine Chapter 1: Basic Concepts Slides prepared by Kip R. Irvine Revision date: 10/27/2002 Chapter corrections (Web) Printing a slide show

More information

Chapter 1 Basic Concepts

Chapter 1 Basic Concepts Chapter 1 Basic Concepts 1.1 Welcome to Assembly Language 1 1.1.1 Good Questions to Ask 2 1.1.2 Assembly language Applications 5 1.1.3 Section Review 6 1.2 Virtual Machine Concept 7 1.2.1 History of PC

More information

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

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 1: Basic Concepts Assembly Language for Intel-Based Computers, 4 th Edition Kip R. Irvine Chapter 1: Basic Concepts Slides prepared by Kip R. Irvine Revision date: 07/21/2002 Chapter corrections (Web) Assembly language

More information

Introduction. Pu-Jen Cheng 2008/09/15

Introduction. Pu-Jen Cheng 2008/09/15 Computer Organization & Assembly Languages Introduction Pu-Jen Cheng 2008/09/15 Course Administration Instructor: Pu-Jen Cheng (CSIE R323) pjcheng@csie.ntu.edu.tw http://www.csie.ntu.edu.tw/~pjcheng Class

More information

1.3 Data Representation

1.3 Data Representation 8628-28 r4 vs.fm Page 9 Thursday, January 2, 2 2:4 PM.3 Data Representation 9 appears at Level 3, uses short mnemonics such as ADD, SUB, and MOV, which are easily translated to the ISA level. Assembly

More information

Basic Concepts. 1.1 Welcome to Assembly Language

Basic Concepts. 1.1 Welcome to Assembly Language 1 Basic Concepts 1.1 Welcome to Assembly Language 1.1.1 Good Questions to Ask 1.1.2 Assembly Language Applications 1.1.3 Section Review 1.2 Virtual Machine Concept 1.2.1 History of PC Assemblers 1.2.2

More information

Course overview. Logistics. Prerequisites. Textbook. Meeting time: 2:20pm-5:20pm, Monday

Course overview. Logistics. Prerequisites. Textbook. Meeting time: 2:20pm-5:20pm, Monday Course overview Computer Organization and Assembly Languages g Yung-Yu Chuang with slides by Kip Irvine Logistics Meeting time: 2:20pm-5:20pm, Monday Classroom: CSIE Room 103 Instructor: 莊永裕 Yung-Yu Chuang

More information

Codes and number systems

Codes and number systems Coding Codes and number systems Assume that you want to communicate with your friend with a flashlight in a night, what will you do? Introduction to Computer Yung-Yu Chuang light painting? What s the problem?

More information

Computer Science 281 Binary and Hexadecimal Review

Computer Science 281 Binary and Hexadecimal Review Computer Science 281 Binary and Hexadecimal Review 1 The Binary Number System Computers store everything, both instructions and data, by using many, many transistors, each of which can be in one of two

More information

Number Systems and. Data Representation

Number Systems and. Data Representation Number Systems and Data Representation 1 Lecture Outline Number Systems Binary, Octal, Hexadecimal Representation of characters using codes Representation of Numbers Integer, Floating Point, Binary Coded

More information

Chapter II Binary Data Representation

Chapter II Binary Data Representation Chapter II Binary Data Representation The atomic unit of data in computer systems is the bit, which is actually an acronym that stands for BInary digit. It can hold only 2 values or states: 0 or 1, true

More information

8051 Programming. The 8051 may be programmed using a low-level or a high-level programming language.

8051 Programming. The 8051 may be programmed using a low-level or a high-level programming language. 8051 Programming The 8051 may be programmed using a low-level or a high-level programming language. Low-Level Programming Assembly language programming writes statements that the microcontroller directly

More information

Logic Design. Dr. Yosry A. Azzam

Logic Design. Dr. Yosry A. Azzam Logic Design Dr. Yosry A. Azzam Binary systems Chapter 1 Agenda Binary Systems : Binary Numbers, Binary Codes, Binary Logic ASCII Code (American Standard Code for Information Interchange) Boolean Algebra

More information

By the end of the lecture, you should be able to:

By the end of the lecture, you should be able to: Extra Lecture: Number Systems Objectives - To understand: Base of number systems: decimal, binary, octal and hexadecimal Textual information stored as ASCII Binary addition/subtraction, multiplication

More information

Oct: 50 8 = 6 (r = 2) 6 8 = 0 (r = 6) Writing the remainders in reverse order we get: (50) 10 = (62) 8

Oct: 50 8 = 6 (r = 2) 6 8 = 0 (r = 6) Writing the remainders in reverse order we get: (50) 10 = (62) 8 ECE Department Summer LECTURE #5: Number Systems EEL : Digital Logic and Computer Systems Based on lecture notes by Dr. Eric M. Schwartz Decimal Number System: -Our standard number system is base, also

More information

Unit 2: Number Systems, Codes and Logic Functions

Unit 2: Number Systems, Codes and Logic Functions Unit 2: Number Systems, Codes and Logic Functions Introduction A digital computer manipulates discrete elements of data and that these elements are represented in the binary forms. Operands used for calculations

More information

CS1101: Lecture 37 Introduction to Assembly Language

CS1101: Lecture 37 Introduction to Assembly Language CS1101: Lecture 37 Introduction to Assembly Language Dr. Barry O Sullivan b.osullivan@cs.ucc.ie Introduction What is Translation? Types of Translator Lecture Outline What is an Assembly Language? Assembly

More information

CPE 323 Data Types and Number Representations

CPE 323 Data Types and Number Representations CPE 323 Data Types and Number Representations Aleksandar Milenkovic Numeral Systems: Decimal, binary, hexadecimal, and octal We ordinarily represent numbers using decimal numeral system that has 10 as

More information

Number Representation

Number Representation Number Representation COMP375 Computer Organization and darchitecture t How do we represent data in a computer? At the lowest level, a computer is an electronic machine. works by controlling the flow of

More information

SIT102 Introduction to Programming

SIT102 Introduction to Programming SIT102 Introduction to Programming After working through this session you should: Understand the relationships between operating systems, their user interfaces, and programs; Understand the difference

More information

ORG ; ZERO. Introduction To Computing

ORG ; ZERO. Introduction To Computing Dec 0 Hex 0 Bin 00000000 ORG ; ZERO Introduction To Computing OBJECTIVES this chapter enables the student to: Convert any number from base 2, base 10, or base 16 to any of the other two bases. Add and

More information

MT1 Number Systems. In general, the number a 3 a 2 a 1 a 0 in a base b number system represents the following number:

MT1 Number Systems. In general, the number a 3 a 2 a 1 a 0 in a base b number system represents the following number: MT1 Number Systems MT1.1 Introduction A number system is a well defined structured way of representing or expressing numbers as a combination of the elements of a finite set of mathematical symbols (i.e.,

More information

We Use High Level Languages. HLL Assembly Language. Assembly Language Machine Language. Machine Language Inputs to Digital System

We Use High Level Languages. HLL Assembly Language. Assembly Language Machine Language. Machine Language Inputs to Digital System We Use High Level Languages High Level Language temp = v[k]; v[k] = v[k+1]; v[k+1] = temp; There are many high level languages (HLLs) Java, C, C++, C#, Fortran, Basic, Pascal, Lisp, Ada, Matlab, etc. HLLs

More information

Introduction Number Systems and Conversion

Introduction Number Systems and Conversion UNIT 1 Introduction Number Systems and Conversion Objectives 1. Introduction The first part of this unit introduces the material to be studied later. In addition to getting an overview of the material

More information

الدكتور المھندس عادل مانع داخل

الدكتور المھندس عادل مانع داخل الدكتور المھندس عادل مانع داخل / میسان جامعة / كلیة الھندسة قسم الھندسة الكھرباي یة Chapter 1: Digital Systems Discrete Data Examples: 26 letters of the alphabet (A, B etc) 10 decimal digits (0, 1, 2 etc)

More information

Number Systems and Data Representation CS221

Number Systems and Data Representation CS221 Number Systems and Data Representation CS221 Inside today s computers, data is represented as 1 s and 0 s. These 1 s and 0 s might be stored magnetically on a disk, or as a state in a transistor, core,

More information

1 Basic Computing Concepts (4) Data Representations

1 Basic Computing Concepts (4) Data Representations 1 Basic Computing Concepts (4) Data Representations The Binary System 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. The

More information

A B C

A B C Data Representation Module 2 CS 272 Sam Houston State University Dr. Tim McGuire Copyright 2001 by Timothy J. McGuire, Ph.D. 1 Positional Number Systems Decimal (base 10) is an example e.g., 435 means

More information

CHAPTER 3 Number System and Codes

CHAPTER 3 Number System and Codes CHAPTER 3 Number System and Codes 3.1 Introduction On hearing the word number, we immediately think of familiar decimal number system with its 10 digits; 0,1, 2,3,4,5,6, 7, 8 and 9. these numbers are called

More information

Digital Fundamentals

Digital Fundamentals Digital Fundamentals with PLD Programming Floyd Chapter 2 29 Pearson Education Decimal Numbers The position of each digit in a weighted number system is assigned a weight based on the base or radix of

More information

a. Chapter 1: Exercises: =>

a. Chapter 1: Exercises: => Selected Solutions to Problem-Set #1 COE608: Computer Organization and Architecture Introduction, Instruction Set Architecture and Computer Arithmetic Chapters 1, 2 and 3 a. Chapter 1: Exercises: 1.1.1

More information

Computer is a binary digital system. Data. Unsigned Integers (cont.) Unsigned Integers. Binary (base two) system: Has two states: 0 and 1

Computer is a binary digital system. Data. Unsigned Integers (cont.) Unsigned Integers. Binary (base two) system: Has two states: 0 and 1 Computer Programming Programming Language Is telling the computer how to do something Wikipedia Definition: Applies specific programming languages to solve specific computational problems with solutions

More information

CHAPTER 1 BINARY SYSTEM

CHAPTER 1 BINARY SYSTEM STUDENT COPY DIGITAL & MICROPROCESSORS 3 CHAPTER 1 BINARY SYSTEM Base Conversion: A number a n, a n 1 a 2, a 1 a 0 a 1 a 2 a 3 expressed in a base r system has coefficient multiplied by powers of r. n

More information

The largest has a 0 in the sign position and 0's in all other positions:

The largest has a 0 in the sign position and 0's in all other positions: 10.2 Sign Magnitude Representation Sign Magnitude is straight-forward method for representing both positive and negative integers. It uses the most significant digit of the digit string to indicate the

More information

Why study the Alpha (assembly)?

Why study the Alpha (assembly)? Why study the Alpha (assembly)? The Alpha architecture is the first 64-bit load/store RISC (as opposed to CISC) architecture designed to enhance computer performance by improving clock speeding, multiple

More information

Binary Representation and Computer Arithmetic

Binary Representation and Computer Arithmetic Binary Representation and Computer Arithmetic The decimal system of counting and keeping track of items was first created by Hindu mathematicians in India in A.D. 4. Since it involved the use of fingers

More information

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.

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. Digital Logic 1 Data Representations 1.1 The Binary System 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. The system we

More information

A First Book of C++ Chapter 2 Data Types, Declarations, and Displays

A First Book of C++ Chapter 2 Data Types, Declarations, and Displays A First Book of C++ Chapter 2 Data Types, Declarations, and Displays Objectives In this chapter, you will learn about: Data Types Arithmetic Operators Variables and Declarations Common Programming Errors

More information

A Quick Start Guide to CS/COE 0447 Informal discussion about basic concepts

A Quick Start Guide to CS/COE 0447 Informal discussion about basic concepts A Quick Start Guide to CS/COE 0447 Informal discussion about basic concepts We ll refine and more formally define many of this material over the next few weeks!!! Digital Computer Stores information and

More information

Number Representation

Number Representation Number Representation Number System :: The Basics We are accustomed to using the so-called decimal number system Ten digits ::,,,3,4,5,6,7,8,9 Every digit position has a weight which is a power of Base

More information

Encoding Systems: Combining Bits to form Bytes

Encoding Systems: Combining Bits to form Bytes Encoding Systems: Combining Bits to form Bytes Alphanumeric characters are represented in computer storage by combining strings of bits to form unique bit configuration for each character, also called

More information

Here 4 is the least significant digit (LSD) and 2 is the most significant digit (MSD).

Here 4 is the least significant digit (LSD) and 2 is the most significant digit (MSD). Number System Introduction Number systems provide the basis for all operations in information processing systems. In a number system the information is divided into a group of symbols; for example, 26

More information

NUMBERING SYSTEMS C HAPTER 1.0 INTRODUCTION 1.1 A REVIEW OF THE DECIMAL SYSTEM 1.2 BINARY NUMBERING SYSTEM

NUMBERING SYSTEMS C HAPTER 1.0 INTRODUCTION 1.1 A REVIEW OF THE DECIMAL SYSTEM 1.2 BINARY NUMBERING SYSTEM 12 Digital Principles Switching Theory C HAPTER 1 NUMBERING SYSTEMS 1.0 INTRODUCTION Inside today s computers, data is represented as 1 s and 0 s. These 1 s and 0 s might be stored magnetically on a disk,

More information

CS231: Computer Architecture I

CS231: Computer Architecture I CS231: Computer Architecture I Spring 2003 January 22, 2003 2000-2003 Howard Huang 1 What is computer architecture about? Computer architecture is the study of building entire computer systems. Processor

More information

Number Representation

Number Representation Number Representation CS10001: Programming & Data Structures Pallab Dasgupta Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Topics to be Discussed How are numeric data

More information

The Assembly Language Level

The Assembly Language Level The Assembly Language Level Translators can be divided into two groups. When the source language is essentially a symbolic representation for a numerical machine language, the translator is called an assembler,

More information

CSC 1103: Digital Logic. Lecture Six: Data Representation

CSC 1103: Digital Logic. Lecture Six: Data Representation CSC 1103: Digital Logic Lecture Six: Data Representation Martin Ngobye mngobye@must.ac.ug Mbarara University of Science and Technology MAN (MUST) CSC 1103 1 / 32 Outline 1 Digital Computers 2 Number Systems

More information

Tutorial No. 1 - Solution (Introduction to Computers & Programming)

Tutorial No. 1 - Solution (Introduction to Computers & Programming) Tutorial No. 1 - Solution (Introduction to Computers & Programming) Computer Programming and Utilization (2110003) 1. Draw a block diagram of computer architecture. 2. List various components of a computer

More information

CDA 3200 Digital Systems. Instructor: Dr. Janusz Zalewski Developed by: Dr. Dahai Guo Spring 2012

CDA 3200 Digital Systems. Instructor: Dr. Janusz Zalewski Developed by: Dr. Dahai Guo Spring 2012 CDA 3200 Digital Systems Instructor: Dr. Janusz Zalewski Developed by: Dr. Dahai Guo Spring 2012 Outline Data Representation Binary Codes Why 6-3-1-1 and Excess-3? Data Representation (1/2) Each numbering

More information

Decimal Numbers: Base 10 Integer Numbers & Arithmetic

Decimal Numbers: Base 10 Integer Numbers & Arithmetic Decimal Numbers: Base 10 Integer Numbers & Arithmetic Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Example: 3271 = (3x10 3 ) + (2x10 2 ) + (7x10 1 )+(1x10 0 ) Ward 1 Ward 2 Numbers: positional notation Number

More information

Directions to Candidates

Directions to Candidates i MATRICULATION AND SECONDARY EDUCATION CERTIFICATE EXAMINATIONS BOARD UNIVERSITY OF MALTA, MSIDA SECONDARY EDUCATION CERTIFICATE LEVEL MAY 2010 SESSION SUBJECT: Computer Studies PAPER NUMBER: IIA DATE:

More information

CPEN 214 - Digital Logic Design Binary Systems

CPEN 214 - Digital Logic Design Binary Systems CPEN 4 - Digital Logic Design Binary Systems C. Gerousis Digital Design 3 rd Ed., Mano Prentice Hall Digital vs. Analog An analog system has continuous range of values A mercury thermometer Vinyl records

More information

2011, The McGraw-Hill Companies, Inc. Chapter 3

2011, The McGraw-Hill Companies, Inc. Chapter 3 Chapter 3 3.1 Decimal System The radix or base of a number system determines the total number of different symbols or digits used by that system. The decimal system has a base of 10 with the digits 0 through

More information

P A R T DIGITAL TECHNOLOGY

P A R T DIGITAL TECHNOLOGY P A R T A DIGITAL TECHNOLOGY 1 CHAPTER NUMBERING SYSTEMS 1.0 INTRODUCTION This chapter discusses several important concepts including the binary, octal and hexadecimal numbering systems, binary data organization

More information

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C Embedded Systems A Review of ANSI C and Considerations for Embedded C Programming Dr. Jeff Jackson Lecture 2-1 Review of ANSI C Topics Basic features of C C fundamentals Basic data types Expressions Selection

More information

D r = d p-1 d p-2.. d 1 d 0.d -1 d -2. D -n. EECC341 - Shaaban

D r = d p-1 d p-2.. d 1 d 0.d -1 d -2. D -n. EECC341 - Shaaban Positional Number Systems A number system consists of an order set of symbols (digits) with relations defined for +,-,*, / The radix (or base) of the number system is the total number of digits allowed

More information

Computer Number Systems

Computer Number Systems Computer Number Systems Thorne, Edition 2 : Section 1.3, Appendix I (Irvine, Edition VI : Section 1.3) SYSC3006 1 Starting from What We Already Know Decimal Numbers Based Number Systems : 1. Base defines

More information

1. True or False? A natural number is the number 0 or any number obtained by adding 1 to a natural number.

1. True or False? A natural number is the number 0 or any number obtained by adding 1 to a natural number. CS Illuminated, 5 th ed. Chapter 2 Review Quiz 1. True or False? A natural number is the number 0 or any number obtained by adding 1 to a natural number. 2. True or False? The category of numbers called

More information

Computer Organization and Architecture

Computer Organization and Architecture Computer Organization and Architecture Chapter 9 Computer Arithmetic Arithmetic & Logic Unit Performs arithmetic and logic operations on data everything that we think of as computing. Everything else in

More information

A LECTURE NOTE ON ASSEMBLY LANGUAGE PROGRAMMING (PART 1) (CSC 303) DR. ONASHOGA S.A (MRS.)

A LECTURE NOTE ON ASSEMBLY LANGUAGE PROGRAMMING (PART 1) (CSC 303) DR. ONASHOGA S.A (MRS.) A LECTURE NOTE ON ASSEMBLY LANGUAGE PROGRAMMING (PART 1) (CSC 303) COURSE LECTURER: DR. ONASHOGA S.A (MRS.) COURSE OUTLINE SECTION 1 1. Introduction to Programming languages Machine Language Low-Level

More information

A Short Introduction to Binary Numbers

A Short Introduction to Binary Numbers A Short Introduction to Binary Numbers Brian J. Shelburne Department of Mathematics and Computer Science Wittenberg University 0. Introduction The development of the computer was driven by the need to

More information

LECTURE 2: Number Systems

LECTURE 2: Number Systems LECTURE : Number Systems CIS Fall 7 Instructor: Dr. Song Xing Department of Information Systems California State University, Los Angeles Learning Objectives Review Boolean algebra. Describe numbering systems

More information

Data Types and Addressing Modes 29

Data Types and Addressing Modes 29 29 This section describes data types and addressing modes available to programmers of the Intel Architecture processors. 29.1 Fundamental Data Types The fundamental data types of the Intel Architecture

More information

CMPS 10 Winter Homework Assignment 5

CMPS 10 Winter Homework Assignment 5 CMPS 10 Winter 2011- Homework Assignment 5 Problems: Chapter 4 (p.184): 1abc, 3abcd, 4ab, 5abc, 6, 7, 9abcd, 15abcd, 17, 18, 19, 20 1. Given our discussion of positional numbering systems in Section 4.2.1,

More information

B. GENERATIONS OF PROGRAMMING LANGUAGES

B. GENERATIONS OF PROGRAMMING LANGUAGES LANGUAGE TRANSLATORS A. HIGH AND LOW LEVEL LANGUAGES Programming languages Low Level Languages Example: Assembly Language High-Level Languages Example: Pascal, Basic, Java Characteristics of LOW Level

More information

COMP2121: Microprocessors and Interfacing

COMP2121: Microprocessors and Interfacing Interfacing Lecture 3: Number Systems (I) http://www.cse.unsw.edu.au/~cs2121 Lecturer: Hui Wu Session 2, 2005 Overview Positional notation Decimal, hexadecimal and binary One complement Two s complement

More information

Computer Organization. A quick review

Computer Organization. A quick review Computer Organization A quick review Data Representation and Number Conversion Data Representation O Binary System O 2 digits 0, 1 O Trinary/Ternary System O 3 digits 0, 1, 2 O Decimal System O 10 digits

More information

198:211 Computer Architecture

198:211 Computer Architecture 198:211 Computer Architecture Topics: Lecture 8 (W5) Fall 2012 Data representation 2.1 and 2.2 of the book Floating point 2.4 of the book 1 Computer Architecture What do computers do? Manipulate stored

More information

1 / 40. Data Representation. January 9 14, 2013

1 / 40. Data Representation. January 9 14, 2013 1 / 40 Data Representation January 9 14, 2013 Quick logistical notes In class exercises Bring paper and pencil (or laptop) to each lecture! Goals: break up lectures, keep you engaged chance to work through

More information

Computer Architecture CPIT 210 LAB 1 Manual. Prepared By: Mohammed Ghazi Al Obeidallah.

Computer Architecture CPIT 210 LAB 1 Manual. Prepared By: Mohammed Ghazi Al Obeidallah. Computer Architecture CPIT 210 LAB 1 Manual Prepared By: Mohammed Ghazi Al Obeidallah malabaidallah@kau.edu.sa LAB 1 Outline: 1. Students should understand basic concepts of Decimal system, Binary system,

More information

3D1 / Microprocessor Systems I. Binary Arithmetic. Binary Arithmetic. Addition

3D1 / Microprocessor Systems I. Binary Arithmetic. Binary Arithmetic. Addition 3D / Microprocessor Systems I Addition 7 6 33 22 Carry 3D / Microprocessor Systems I What happens if we run out of digits? Adding two numbers each stored in byte (8 bits) may produce a 9-bit result 8 bits

More information

LSN 2 Number Systems. ECT 224 Digital Computer Fundamentals. Department of Engineering Technology

LSN 2 Number Systems. ECT 224 Digital Computer Fundamentals. Department of Engineering Technology LSN 2 Number Systems Department of Engineering Technology LSN 2 Decimal Number System Decimal number system has 10 digits (0-9) Base 10 weighting system... 10 5 10 4 10 3 10 2 10 1 10 0. 10-1 10-2 10-3

More information

Activity 1: Bits and Bytes

Activity 1: Bits and Bytes ICS3U (Java): Introduction to Computer Science, Grade 11, University Preparation Activity 1: Bits and Bytes The Binary Number System Computers use electrical circuits that include many transistors and

More information

Number Representation and Arithmetic in Various Numeral Systems

Number Representation and Arithmetic in Various Numeral Systems 1 Number Representation and Arithmetic in Various Numeral Systems Computer Organization and Assembly Language Programming 203.8002 Adapted by Yousef Shajrawi, licensed by Huong Nguyen under the Creative

More information

Lab 1: Information Representation I -- Number Systems

Lab 1: Information Representation I -- Number Systems Unit 1: Computer Systems, pages 1 of 7 - Department of Computer and Mathematical Sciences CS 1408 Intro to Computer Science with Visual Basic 1 Lab 1: Information Representation I -- Number Systems Objectives:

More information

Lab 1: Information Representation I -- Number Systems

Lab 1: Information Representation I -- Number Systems Unit 1: Computer Systems, pages 1 of 7 - Department of Computer and Mathematical Sciences CS 1410 Intro to Computer Science with C++ 1 Lab 1: Information Representation I -- Number Systems Objectives:

More information

Chapter 2 Logic Gates and Introduction to Computer Architecture

Chapter 2 Logic Gates and Introduction to Computer Architecture Chapter 2 Logic Gates and Introduction to Computer Architecture 2.1 Introduction The basic components of an Integrated Circuit (IC) is logic gates which made of transistors, in digital system there are

More information

CHAPTER THREE. 3.1 Binary Addition. Binary Math and Signed Representations

CHAPTER THREE. 3.1 Binary Addition. Binary Math and Signed Representations CHAPTER THREE Binary Math and Signed Representations Representing numbers with bits is one thing. Doing something with them is an entirely different matter. This chapter discusses some of the basic mathematical

More information

Binary Numbers. Binary Octal Hexadecimal

Binary Numbers. Binary Octal Hexadecimal Binary Numbers Binary Octal Hexadecimal Binary Numbers COUNTING SYSTEMS UNLIMITED... Since you have been using the 10 different digits 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 all your life, you may wonder how

More information

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T) Unit- I Introduction to c Language: C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating

More information

Part 1: Logic Design. Tutorial

Part 1: Logic Design. Tutorial CPIT2 : Computer Organization and Architecture Course Lectures by Prof. Mohamed Khamis Part : Logic Design Tutorial by Teaching Assistant. Khalid Alharbi Department of Information Technology Faculty of

More information

Digital Logic Circuits

Digital Logic Circuits Digital Logic Circuits Digital describes any system based on discontinuous data or events. Typically digital is computer data or electronic sampling of an analog signal. Computers are digital machines

More information

Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture - 04 Digital Logic II May, I before starting the today s lecture

More information

Number base conversion

Number base conversion Number base conversion The human being use decimal number system while computer uses binary number system. Therefore it is necessary to convert decimal number into its binary equivalent while feeding number

More information

Binary Representation. Number Systems. Positional Notation

Binary Representation. Number Systems. Positional Notation Binary Representation The basis of all digital data is binary representation. Binary - means two 1, 0 True, False Hot, Cold On, Off We must be able to handle more than just values for real world problems

More information

Unit 5 Central Processing Unit (CPU)

Unit 5 Central Processing Unit (CPU) Unit 5 Central Processing Unit (CPU) Introduction Part of the computer that performs the bulk of data-processing operations is called the central processing unit (CPU). It consists of 3 major parts: Register

More information

Chapter I: Digital System and Binary Numbers

Chapter I: Digital System and Binary Numbers Chapter I: Digital System and Binary Numbers 1-1Digital Systems Digital systems are used in: - Communication - Business transaction - Traffic Control - Medical treatment - Internet The signals in digital

More information

Data Representation. Representing Data

Data Representation. Representing Data Data Representation COMP 1002/1402 Representing Data A computer s basic unit of information is: a bit (Binary digit) An addressable memory cell is a byte (8 bits) Capable of storing one character 10101010

More information

Binary Representation. Number Systems. Base 10, Base 2, Base 16. Positional Notation. Conversion of Any Base to Decimal.

Binary Representation. Number Systems. Base 10, Base 2, Base 16. Positional Notation. Conversion of Any Base to Decimal. Binary Representation The basis of all digital data is binary representation. Binary - means two 1, 0 True, False Hot, Cold On, Off We must be able to handle more than just values for real world problems

More information

EE 261 Introduction to Logic Circuits. Module #2 Number Systems

EE 261 Introduction to Logic Circuits. Module #2 Number Systems EE 261 Introduction to Logic Circuits Module #2 Number Systems Topics A. Number System Formation B. Base Conversions C. Binary Arithmetic D. Signed Numbers E. Signed Arithmetic F. Binary Codes Textbook

More information

Introduction to Telecommunications and Computer Engineering Unit 2: Number Systems and Logic

Introduction to Telecommunications and Computer Engineering Unit 2: Number Systems and Logic Introduction to Telecommunications and Computer Engineering Unit 2: Number Systems and Logic Syedur Rahman Lecturer, CSE Department North South University syedur.rahman@wolfson.oon.org Acknowledgements

More information

The string of digits 101101 in the binary number system represents the quantity

The string of digits 101101 in the binary number system represents the quantity Data Representation Section 3.1 Data Types Registers contain either data or control information Control information is a bit or group of bits used to specify the sequence of command signals needed for

More information

TECH. Arithmetic & Logic Unit. CH09 Computer Arithmetic. Number Systems. ALU Inputs and Outputs. Binary Number System

TECH. Arithmetic & Logic Unit. CH09 Computer Arithmetic. Number Systems. ALU Inputs and Outputs. Binary Number System CH09 Computer Arithmetic CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer Representation Integer Arithmetic Floating-Point Representation

More information

MIPS Assembly Language Programming. Robert Britton Computer Science Department California State University, Chico Chico, California

MIPS Assembly Language Programming. Robert Britton Computer Science Department California State University, Chico Chico, California MIPS Assembly Language Programming Robert Britton Computer Science Department California State University, Chico Chico, California Instructors are granted permission to make copies of this beta version

More information

Numbering Systems. InThisAppendix...

Numbering Systems. InThisAppendix... G InThisAppendix... Introduction Binary Numbering System Hexadecimal Numbering System Octal Numbering System Binary Coded Decimal (BCD) Numbering System Real (Floating Point) Numbering System BCD/Binary/Decimal/Hex/Octal

More information

Writing Portable Programs COS 217

Writing Portable Programs COS 217 Writing Portable Programs COS 217 1 Goals of Today s Class Writing portable programs in C Sources of heterogeneity Data types, evaluation order, byte order, char set, Reading period and final exam Important

More information

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-378: Digital Logic and Microprocessor Design Winter 2015.

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-378: Digital Logic and Microprocessor Design Winter 2015. ECE-378: Digital Logic and Microprocessor Design Winter 5 UNSIGNED INTEGER NUMBERS Notes - Unit 4 DECIMAL NUMBER SYSTEM A decimal digit can take values from to 9: Digit-by-digit representation of a positive

More information

Section 1.4 Place Value Systems of Numeration in Other Bases

Section 1.4 Place Value Systems of Numeration in Other Bases Section.4 Place Value Systems of Numeration in Other Bases Other Bases The Hindu-Arabic system that is used in most of the world today is a positional value system with a base of ten. The simplest reason

More information

Representation of Data

Representation of Data Representation of Data In contrast with higher-level programming languages, C does not provide strong abstractions for representing data. Indeed, while languages like Racket has a rich notion of data type

More information

Binary Representation

Binary Representation Binary Representation The basis of all digital data is binary representation. Binary - means two 1, 0 True, False Hot, Cold On, Off We must tbe able to handle more than just values for real world problems

More information