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

Similar documents
Course Syllabus [1/2]

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

ECOM 2325 Computer Organization and Assembly Language. Instructor: Ruba A.Salamah INTRODUCTION

History of Computing. Ahmed Sallam 11/28/2014 1

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

Computer Organization and Assembly Language. Lab Session 01

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

Data Representation COE 301. Computer Organization Prof. Muhamed Mudawar

MACHINE LEVEL REPRESENTATION OF DATA

Number representations

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

Final Labs and Tutors

Moodle WILLINGDON COLLEGE SANGLI. ELECTRONICS (B. Sc.-I) Introduction to Number System

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

Harry H. Porter, 2006

Octal & Hexadecimal Number Systems. Digital Electronics

CHW 261: Logic Design

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

Intermediate Programming & Design (C++) Notation

Beyond Base 10: Non-decimal Based Number Systems

Beyond Base 10: Non-decimal Based Number Systems

CMPE223/CMSE222 Digital Logic Design. Positional representation

We can study computer architectures by starting with the basic building blocks. Adders, decoders, multiplexors, flip-flops, registers,...

Outline. What Digit? => Number System. Decimal (base 10) Significant Digits. Lect 03 Number System, Gates, Boolean Algebra. CS221: Digital Design

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

Agenda EE 224: INTRODUCTION TO DIGITAL CIRCUITS & COMPUTER DESIGN. Lecture 1: Introduction. Go over the syllabus 3/31/2010

Digital Systems COE 202. Digital Logic Design. Dr. Muhamed Mudawar King Fahd University of Petroleum and Minerals

Basic Concepts COE 205. Computer Organization and Assembly Language Dr. Aiman El-Maleh

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-2700: Digital Logic Design Winter Notes - Unit 4. hundreds.

COMP Overview of Tutorial #2

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

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

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

Lecture 1: Introduction to Microprocessors

Digital Fundamentals

DLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 1 DLD P VIDYA SAGAR

ECE 2030D Computer Engineering Spring problems, 5 pages Exam Two 8 March 2012

Lecture 2: Number Systems

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

EE292: Fundamentals of ECE

COE 202: Digital Logic Design Number Systems Part 2. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

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

Chapter 3: Assembly Language Fundamentals. Cristina G. Rivera

Chapter 1 Preliminaries

Chapter Overview. Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 3: Assembly Language Fundamentals.

Page 1. Where Have We Been? Chapter 2 Representing and Manipulating Information. Why Don t Computers Use Base 10?

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 3: Assembly Language Fundamentals

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-278: Digital Logic Design Fall Notes - Unit 4. hundreds.

ALT-Assembly Language Tutorial

Chapter 2 Number System

Positional notation Ch Conversions between Decimal and Binary. /continued. Binary to Decimal

Octal and Hexadecimal Integers

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

D I G I T A L C I R C U I T S E E

EXPERIMENT NO: 01. Write a program to convert decimal number to binary and vice versa.

Number System. Introduction. Decimal Numbers

Arithmetic Operations

Computer Sc. & IT. Digital Logic. Computer Sciencee & Information Technology. 20 Rank under AIR 100. Postal Correspondence

World Inside a Computer is Binary

CS & IT Conversions. Magnitude 10,000 1,

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

ENE 334 Microprocessors

Level ISA3: Information Representation

Computer Organisation CS303

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

DIGITAL SYSTEM DESIGN

Assembly Language for Intel-Based Computers, 5 th Edition. Kip Irvine. Chapter 3: Assembly Language Fundamentals

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.

The Design of C: A Rational Reconstruction"

1010 2?= ?= CS 64 Lecture 2 Data Representation. Decimal Numbers: Base 10. Reading: FLD Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

Objectives. Connecting with Computer Science 2

COMP2121: Microprocessors and Interfacing. Number Systems

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

Princeton University Computer Science 217: Introduction to Programming Systems. Goals of this Lecture. Number Systems and Number Representation

EC 413 Computer Organization

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014

Assembly Language for Intel-Based Computers, 5 th Edition

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two 26 February 2014

Le L c e t c ur u e e 2 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Variables Operators

Name: CMSC 313 Fall 2001 Computer Organization & Assembly Language Programming Exam 1. Question Points I. /34 II. /30 III.

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

Fundamentals of Programming Session 2

ECE 2030B 1:00pm Computer Engineering Spring problems, 5 pages Exam Two 10 March 2010

Number Systems CHAPTER Positional Number Systems

Number Systems and Number Representation

QUIZ: Generations of computer technology. Hardware:

17. Instruction Sets: Characteristics and Functions

The Design of C: A Rational Reconstruction

QUIZ: Generations of computer technology. Hardware:

EEM336 Microprocessors I. Arithmetic and Logic Instructions

Bits. Binary Digits. 0 or 1

Number Systems and Binary Arithmetic. Quantitative Analysis II Professor Bob Orr

Digital Arithmetic. Digital Arithmetic: Operations and Circuits Dr. Farahmand

Number Systems Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur Number Representation

2.1. Unit 2. Integer Operations (Arithmetic, Overflow, Bitwise Logic, Shifting)

Selection from Susta:Computer System Structures & John Loomis: Computer organization & M.Mudawar:Computer Architecture & Assembly Language. Cvičení 1.

Modesto Junior College Course Outline of Record CMPSC 241

The Building Blocks: Binary Numbers, Boolean Logic, and Gates. Purpose of Chapter. External Representation of Information.

Binary Addition. Add the binary numbers and and show the equivalent decimal addition.

Transcription:

Assembly Language for Intel-Based Computers, 4 th Edition Kip R. Irvine Chapter 1: Basic Concepts Chapter Overview Welcome to Assembly Language Virtual Machine Concept Data Representation Boolean Operations 3 Printing this Slide Show Welcome to Assembly Language (cont) To print this slide show with black characters on a white background, do the following: Select Print... from the File menu. Select Handouts in the Print what drop-down box. Select 2 or 3 in the Slides per page drop-down box. Select the Pure black and white check box (optional) Click on OK to begin printing. Assembly language is the oldest programming language. Of all languages, it bears the closest resemblance to the native language of a computer. Direct access to a computer s hardware To understand a great deal about your computer s architecture and operating system 2 4 1

Some Good Questions to Ask What is an assembler? A program that converts source-code programs from assembly language into machine language MASM (Microsoft Assembler), TASM (Borland Turbo Assembler) Linker (a companion program of Assembler) combines individual files created by an assembler into a single executable program. Debugger provides a way for a programmer to trace the execution of a program and examine the contents of memory. Some Good Questions to Ask (Cont.) How do C++ and Java relate to AL? E.g., X=(Y+4) *3 How does assembly language (AL) relate to machine language? One-to-one relationship Is AL portable? A language whose source program can be compiled and run on a wide variety of computer systems is said to be portable. AL makes no attempt to be portable. It is tied to a specific processor family 5 7 Some Good Questions to Ask (Cont.) Some Good Questions to Ask (Cont.) What hardware/software do I need? A computer with an Intel386, Intel486 or one of the Pentium processors (IA-32 processor family) OS: Microsoft Windows, MS-DOS, LINUX running a DOS emulator Editor Assembler Linker (Microsoft 16-bit linker: LINK.EXE, 32-bit linker: LINK32.EXE), Debugger (16-bit MS-DOS programs: MASM CodeView, TASM Turbo Debugger. 32-bit Windows console programs: Microsoft Visual Studio msdev.exe) What types of programs will I create? 16-Bit Real-Address Mode: MS-DOS, DOS emulator 32-Bit Protected Mode: Microsoft Windows Why learn AL? Embedded system programs Programs to be highly optimized for both space and runtime speed To gain an overall understanding of the interaction between the hardware, OS and application programs Device driver: programs that translate general operating system commands into specific references to hardware details 6 8 2

Assembly Language Applications Virtual Machine Concept AL is used to optimize certain sections of application programs for speed and to access computer hardware Virtual Machines Specific Machine Levels Some representative types of applications: Business application for single platform Hardware device driver Business application for multiple platforms Embedded systems & computer games (see next panel) * HL = high-level 9 11 Comparing ASM to High-Level Languages Virtual Machines Virtual machine concept A most effective way to explain how a computer s hardware and software are related In terms of programming Language: 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 Programs written in L1 can run two different ways: Interpretetation 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 10 12 3

Virtual Machines (Cont.) In terms of a hypothetical computer VM1 can execute commands written in language L1. VM2 can execute commands written in language L2. The process can repeat until a virtual machine VMncan be designed that supports a powerful, easy-to-use language. The Java programming language is based on the virtual machine concept. A program written in the Java language is translated by a Java compiler into Java byte code. Java byte code: a low-level language that is quickly executed at run time by Java virtual machine (JVM). The JVM has been implemented on many different computer systems, making Java programs relatively systemindependent Digital Logic Level 0 CPU, constructed from digital logic gates System bus Memory 13 15 Specific Machine Levels Microarchitecture High-Level Language Assembly Language Operating System Instruction Set Architecture Level 5 Level 4 Level 3 Level 2 Level 1 Interprets conventional machine instructions (Level 2) Executed by digital hardware (Level 0) Microarchitecture Level 1 Digital Logic Level 0 14 16 4

Instruction Set Architecture Assembly Language Level 2 Also known as conventional machine language Executed by Level 1 program (microarchitecture, Level 1) Each machine-language instruction is executed by several microinstructions Level 4 Instruction mnemonics such as ADD, SUB and MOV that are easily translated to the instruction set architecture level (Level 2) Calls functions written at the operating system level (Level 3) Programs are translated into machine language (Level 2) 17 19 Operating System High-Level Language Level 3 Provides services to Level 4 programs Programs translated and run at the instruction set architecture level (Level 2) Level 5 Application-oriented languages C++, C#, Virtual Basic Programs compile into assembly language (Level 4) 18 20 5

Data Representation Binary Numbers 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 Each digit (bit) is either 1 or 0 Each bit represents a power of 2: Every binary number is a sum of powers of 2 1 1 1 1 1 1 1 1 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 21 23 Binary Numbers Translating Binary to Decimal Digits are 1 and 0 1 = true 0 = false MSB most significant bit LSB least significant bit Bit numbering: MSB LSB 1 0 1 1 0 0 1 0 1 0 0 1 1 1 0 0 15 0 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 1 2 1 ) + (D 0 2 0 ) D = binary digit binary 00001001 = decimal 9: (1 2 3 ) + (1 2 0 ) = 9 22 24 6

Translating Unsigned Decimal to Binary Integer Storage Sizes Repeatedly divide the decimal integer by 2. Each remainder is a binary digit in the translated value: Standard sizes: byte 8 word 16 doubleword 32 quadword 64 37 = 100101 Practice: What is the largest unsigned integer that may be stored in 20 bits? 25 27 Binary Addition Hexadecimal Integers Starting with the LSB, add each pair of digits, include the carry if present. carry: 0 0 0 0 0 1 0 0 1 (4) All values in memory are stored in binary. Because long binary numbers are hard to read, we use hexadecimal representation. + 0 0 0 0 0 1 1 1 (7) 0 0 0 0 1 0 1 1 (11) bit position: 7 6 5 4 3 2 1 0 26 28 7

Translating Binary to Hexadecimal Powers of 16 Each hexadecimal digit corresponds to 4 binary bits. Example: Translate the binary integer 000101101010011110010100 to hexadecimal: Used when calculating hexadecimal values up to 8 digits long: 29 31 Converting Hexadecimal to Decimal Converting Decimal to Hexadecimal Multiply each digit by its corresponding power of 16: dec= (D 3 16 3 ) + (D 2 16 2 ) + (D 1 16 1 ) + (D 0 16 0 ) Hex 1234 equals (1 16 3 ) + (2 16 2 ) + (3 16 1 ) + (4 16 0 ), or decimal 4,660. Hex 3BA4 equals (3 16 3 ) + (11 * 16 2 ) + (10 16 1 ) + (4 16 0 ), or decimal 15,268. decimal 422 = 1A6 hexadecimal 30 32 8

Hexadecimal Addition Divide the sum of two digits by the number base (16). The quotient becomes the carry value, and the remainder is the sum digit. Signed Integers The highest bit indicates the sign. 1 = negative, 0 = positive 1 1 36 28 28 6A 42 45 58 4B 78 6D 80 B5 sign bit 1 1 1 1 0 1 1 0 Negative 21 / 16 = 1, rem 5 0 0 0 0 1 0 1 0 Positive Important skill: Programmers frequently add and subtract the addresses of variables and instructions. If the highest digit of a hexadecmal integer is > 7, the value is negative. Examples: 8A, C5, A2, 9D 33 35 Hexadecimal Subtraction Forming the Two's Complement When a borrow is required from the digit to the left, add 10h to the current digit's value: 10h + 5 = 15h Negative numbers are stored in two's complement notation Additive Inverse of any binary integer Steps: Complement (reverse) each bit Add 1 1 C6 75 A2 47 24 2E Practice: The address of var1 is 00400020. The address of the next variable after var1 is 0040006A. How many bytes are used by var1? Note that 00000001 + 11111111 = 00000000 34 36 9

Binary Subtraction When subtracting A B, convert B to its two's complement Add A to ( B) Ranges of Signed Integers The highest bit is reserved for the sign. This limits the range: 1 1 0 0 1 1 0 0 0 0 1 1 1 1 0 1 1 0 0 1 Practice: Subtract 0101 from 1001. Practice: What is the largest positive value that may be stored in 20 bits? 37 39 Learn How To Do the Following: Character Storage 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 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 38 40 10

Numeric Data Representation Boolean Algebra pure binary Be a number stored in memory in its raw format Can be calculated directly Stored in multiples of 8 bits ASCII binary string of digits: "01010101" ASCII decimal string of digits: "65" ASCII hexadecimal string of digits: "9C" Format ACSII Binary ASCII decimal ASCII hexadecimal ASCII octal Value 0100000001 65 41 101 Based on symbolic logic, designed by George Boole Boolean expressions created from: NOT, AND, OR 41 43 Boolean Operations NOT NOT AND OR Operator Precedence Truth Tables Inverts (reverses) a boolean value Truth table for Boolean NOT operator: Digital gate diagram for NOT: NOT 42 44 11

AND Truth table for Boolean AND operator: Operator Precedence Examples showing the order of operations: Digital gate diagram for AND: AND 45 47 OR Truth Tables (1 of 3) Truth table for Boolean OR operator: A Boolean function has one or more Boolean inputs, and returns a single Boolean output. A truth tableshows all the inputs and outputs of a Boolean function Digital gate diagram for OR: OR Example: X Y 46 48 12

Example: X Y Truth Tables (2 of 3) 49 Truth Tables (3 of 3) Example: (Y S) (X S) S X Y mux Z Two-input multiplexer 50 13