Assembly Language for x86 Processors 6th Edition

Slides:



Advertisements
Similar presentations
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify and.
Advertisements

The Assembly Language Level
Basic Concepts COE 205 Computer Organization and Assembly Language
Data Representation Computer Organization &
Data Representation COE 205
Introduction to Microprocessors Number Systems and Conversions No /6/00 Chapter 1: Introduction to 68HC11 The 68HC11 Microcontroller.
Assembly Language for Intel-Based Computers, 4th Edition
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify.
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify.
1 Introduction Chapter 1 n What is Assembly Language? n Data Representation.
Basic Concepts Computer Organization and Assembly Language.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#1) By Dr. Syed Noman.
Joseph L. Lindo Assembly Programming Sir Joseph Lindo University of the Cordilleras.
Assembly Language for Intel-Based Computers, 5th Edition
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify.
Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify and copy this slide show for your personal use, or for.
Computers Organization & Assembly Language
CSU0014 Assembly Languages Homepage: Textbook: Kip R. Irvine, Assembly Language for Intel-Based Computers,
Summer 2014 Chapter 1: Basic Concepts. Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Chapter Overview Welcome to Assembly Language.
Assembly Language for x86 Processors 7th Edition
Comp Sci 251 Intro 1 Computer organization and assembly language Wing Huen.
Chapter 1: Basic Concepts
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
1 Introduction Chapter 1 n What is Assembly Language? n Data Representation.
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
Assembly Language for x86 Processors 7 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify and copy this.
CPU Internal memory I/O interface circuit System bus
Chapter 19 Number Systems. Irvine, Kip R. Assembly Language for Intel-Based Computers, Translating Languages English: Display the sum of A times.
Introduction to Programming Instructor: Yong Tang Brookhaven National Laboratory Working on accelerator control (BNL Phone #)
ACOE2511 Assembly Language for the 80X86/Pentium Intel Microprocessors Lecturer: Dr. Konstantinos Tatas.
Computer Organization and Assembly Languages 2007/11/10
 Programming - the process of creating computer programs.
Sahar Mosleh California State University San MarcosPage 1 Assembly language and Digital Circuit By Sahar Mosleh California State University San Marcos.
Chapter 4 Software. Introduction Program: is a set of sequence instructions that tell the computer what to do. Software: is a collection of programs,
Suffolk County Community College Mathematics and Computer Science Ammerman Campus CST 121Spring 2013 Section 151CRN: Computer Organization And System.
1 The user’s view  A user is a person employing the computer to do useful work  Examples of useful work include spreadsheets word processing developing.
1 Chapter 1: Introduction Appendix A: Binary and Hexadecimal Tutorial Assembly Language for Intel-Based Computers, 3rd edition Kip R. Irvine.
1 Chapter 1: Basic Concepts Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine 9/6/2003.
Computer Basics.
Computer Architecture and Number Systems
CSC235 Computer Organization & Assembly Language
Lec 3: Data Representation
Assembly Language for x86 Processors 6th Edition
Assembly Language (CSW 353)
CSCI-235 Micro-Computer Applications
Data Representation Binary Numbers Binary Addition
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
Microprocessor Systems Design I
Microprocessor and Assembly Language
Computer System and Programming
Microprocessor Systems Design I
Course: Introduction to Computers
Java programming lecture one
Fundamentals & Ethics of Information Systems IS 201
University of Gujrat Department of Computer Science
Data Structures Mohammed Thajeel To the second year students
COAL Chapter 1,2,3.
Unit# 8: Introduction to Computer Programming
Translators & Facilities of Languages
Computers: Hardware and Software
Chapter 6 System and Application Software
Assembly Language for Intel-Based Computers
Computer Organization and Assembly Language
University of Gujrat Department of Computer Science
Introduction to Microprocessor Programming
Chapter 6 System and Application Software
Chapter 6 System and Application Software
Computer Organization and Assembly Language
Chapter 6 System and Application Software
Presentation transcript:

Assembly Language for x86 Processors 6th Edition Kip Irvine Chapter 1: Basic Concepts Prepared By: Mr. Muhammad Hanif Lecturer Information Technology MBBS Campus Dadu University of Sindh

Chapter Overview Welcome to Assembly Language Virtual Machine Concept Data Representation Boolean Operations

Chapter Overview Welcome to Assembly Language Virtual Machine Concept Assembler, Linker and Debugger Types of Assembler Types of Programming Modes Characteristics of Assembly Language Importance of Assembly Language Assembly Language Versus High Level Languages Virtual Machine Concept Specific Machine Levels Data Representation Boolean Operations

Welcome to Assembly Language The x86 processor type starts from 80386 and includes Intel Pentium Intel Pentium 4 Intel Pentium Core Duo Advanced Micro Devices (AMD) Athlon Mostly all processors run under Microsoft Windows.

Assembly Language Vs. Machine Language Slightly higher-level language Readability of instructions is better than machine language One-to-one correspondence with machine language instructions Machine language Native to a processor: executed directly by hardware Instructions consist of binary code: 1s and 0s

A Hierarchy of Languages

Assemblers, Linkers & Debuggers An assembler is a program that converts source-code programs from assembly language into machine language. Linker It combines individual files created by an assembler (Object Files) into a single executable program. Debugger It provides a way for a programmer to trace the execution of a program and examine the contents of memory. Debugger is a computer program that is used to find bugs/errors in other programs. 

Compiler Vs. Assembler Compiler is a computer program that reads a program written in one language and translates it in to another language. An assembler is a special type of compiler which translates only Assembly language to machine code. Assembly language has a one to one mapping with machine code, an assembler may be used for producing code that runs very efficiently for occasions in which performance is very important (for e.g. graphics engines, embedded systems with limited hardware resources compared to a personal computer like microwaves, washing machines, etc.). Mostly compiler and debugger are combined in single package.

Source Code Vs. Object Code Source program is written by a programmer usually using a higher level language. Source programs usually contain meaningful variable names and helpful comments to make it more readable. Object program is typically a machine executable program created by compiling a source program. Object program is usually a machine executable file, which is the result of compiling a source file using a compiler. Intermediate between source code and executable file.

Types of Assembler & Programming Modes Microsoft Macro Assembler (MASM) Turbo Assembler (TASM) Netwide Assembler (NASM) GNU Assembler Types of programming modes 16 bit address mode programs Also called as real mode Run under MS DOS operating system 32 bit address mode programs Also called protected mode Run under MS Windows operating system

Characteristics of Assembly language One-one relationship with machine language It has one-one relationship with machine language i-e single assembly language instruction is equal to single machine language instruction. (C++ & Java has 1 to * relationship) Not portable Program written in assembly language supports only specific processor family. Usage: Used to code device drivers and hardware interface routines Mnemonics Assembly language consists of statements written with short mnemonics such as ADD, MOV, SUB, and CALL.

Importance of Assembly Language Used for code optimization Higher level language miss full control of machine. Assembly language deals with finest detail of the processing. It will do only whatever it is told to do, not less or more.

Importance of Assembly Language Used for embedded programs Embedded programs are short programs stored in a small amount of memory in single-purpose devices such as telephones, automobile fuel and ignition systems, air-conditioning control systems, security systems, data acquisition instruments, video cards, sound cards, hard drives, modems and printers. Real Time Application Real-time applications dealing with simulation and hardware monitoring require precise timing and responses. High-level languages do not give programmers exact control over machine code generated by compilers. Assembly language permits you to precisely specify a program’s executable code.

Importance of Assembly Language (Continue…) Used in games controllers: Programmers for games need accuracy and efficiency hence Assembly is best tool as it permits direct access to computer hardware. Used to understand Computer architecture Used to test theoretical concept of computer hardware, operating system and application software. Device Drivers Device drivers are programs that translate general operating system commands into specific references to hard-ware details. Printer manufacturers, for example, create a different MS-Windows device driver for each model they sell. The same is true for Mac OS, Linux, and other operating systems.

Assembly Language Versus High Level Languages Type of Application High-Level Languages Assembly Language Commercial or scientific Written for single platform Medium to large size Formal structures Easy to maintain large sections of code. Minimal formal structure. Difficult to maintain. Written for multiple platforms (different operating systems) Usually portable The source code can be recompiled on each target operating system with minimal changes. Easy to maintain Not portable Must be recoded separately for each platform, using an assembler with a different syntax. Hardware device driver May not provide for direct hardware access. If it does provide then very difficult to perform. Hardware access is direct. Easy to maintain short program. Embedded systems Computer games (Requiring direct hardware access) Produces too much executable code May not run efficiently. Executable code is small Runs quickly

Chapter Overview Welcome to Assembly Language Virtual Machine Concept Specific Machine Levels Data Representation Boolean Operations

Virtual Machines An effective way to explain how a computer’s hardware and software are related is called the virtual machine concept. Or A software program that emulates the functions of some other physical computer 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 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

Virtual Machine 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 is a low-level coding quickly executed at runtime by a program known as a Java virtual machine (JVM). The JVM has been implemented on many different computer systems, making Java programs relatively system independent.

Translating Languages English: Display the sum of A times B plus C. C++: cout << (A * B + C); Assembly Language: mov eax,A mul B add eax,C call WriteInt Intel Machine Language: A1 00000000 F7 25 00000004 03 05 00000008 E8 00500000

Virtual Machine: Specific Machine Levels

Virtual Machine: Specific Machine Levels Level 1: Digital Logic Interprets conventional machine instructions Executed by digital hardware CPU constructed from digital logic gates, system bus memory etc. Level 2: Instruction Set Architecture Carry out basic operations move, add or multiply. Directly run by hardware or micro-program Micro-program: Program written in microprocessor.

Virtual Machine: Specific Machine Levels Level 3: Assembly Language Instruction mnemonics that have a one-to-one correspondence to machine language Use short mnemonics ADD, SUB, MOV, which are translated into ISA Level. Programs are translated into machine language. Level 4: High-Level Languages Application-oriented languages, c++, Java. Programs compile into assembly language (Level 3)

Chapter Overview Welcome to Assembly Language Virtual Machine Concept Data Representation Boolean Operations

Binary Numbers Each number system has a base or a number of symbols that can be assigned to a single digit. Binary number system has two symbols 1 or 0 1 = true 0 = false MSB – most significant bit: The lest most bit of binary number. LSB – least significant bit: The right most bit of binary number.

The Binary Number System Computer uses a binary system to recognize two states 0 and 1, called bits (short for binary digits). Decimal numbers may be converted into binary numbers or vise versa.

Decimal to Binary Conversion Conversion of 143 Conversion of 256 Remainder Remainder 143 ÷ 2 = 71 remainder is 1 256 ÷ 2 = 128 0 71 ÷ 2 = 35 remainder is 1 128 ÷ 2 = 64 0 35 ÷ 2 = 17 remainder is 1 64 ÷ 2 = 32 0 17 ÷ 2 = 8 remainder is 1 32 ÷ 2 = 16 0 8 ÷ 2 = 4 remainder is 0 16 ÷ 2 = 8 0 4 ÷ 2 = 2 remainder is 0 8 ÷ 2 = 4 0 2 ÷ 2 = 1 remainder is 0 http://www.electronic.electrical4u.com/binary-decimal-conversion.php 4 ÷ 2 = 2 0 1÷ 2 = 0 remainder is 1 2 ÷ 2 = 1 0 1÷ 2 = 0 1 1 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0

Decimal to Binary Conversion (Whole Part: Repeated Division)  97  2  quotient = 48, remainder = 1 (LSB) 48  2  quotient = 24, remainder = 0. 24  2  quotient = 12, remainder = 0. 12  2  quotient = 6, remainder = 0. 6  2  quotient = 3, remainder = 0. 3  2  quotient = 1, remainder = 1. 1  2  quotient = 0 (Stop) remainder = 1 (MSB)  Result = 1 1 0 0 0 0 12

Binary to Decimal Conversion 10101011 needs to be converted to decimal 20= 1 21 = 2 22 = 4 23 = 8 24 = 16 25 = 32 26 = 64 27 = 128 1 0 1 0 1 0 1 1 27 26 25 24 23 22 21 20 20 x 1 = 1 21 x 1 = 2 22 x 0 = 0 23 x 1 = 8 24 x 0 = 0 25 x 1 = 32 26 x 0 = 0 1 + 2 + 8 + 32 + 128 = 171 27 x 1 = 128

Decimal to Binary Convert 8 decimal to binary. 00001000 Convert 88 decimal to binary. 01011000 Convert 204 decimal to binary. 11001100 Convert 255 decimal to binary. 11111111

Binary to Decimal Convert 00101100 binary to decimal. 44 Convert 10000000 binary to decimal. 128 Convert 00001000 binary to decimal. 8 Convert 01010101 binary to decimal. 85

Binary Addition Binary Integers can be signed (positive or negative) and unsigned (positive only). Zero is considered positive. When addition is performed bit by bit, starting with low-order pair of bits on the right and add each subsequent pair of bits. Online conversion: http://ncalculators.com/digital-computation/binary-addition-calculator.htm

Binary Addition Starting with the LSB, add each pair of digits, include the carry if present.

Integer Storage Sizes The basic storage unit for all data in an x86 computer is a byte. At-least one byte is reserved for each storage If we store binary number 1111, then 00001111 will be stored in memory with additional four zeros at start of the number.

Ranges of Unsigned Integers Integer Storage Sizes Standard sizes Ranges of Unsigned Integers

Hexadecimal Integers Large binary numbers are difficult to read, so hexadecimal digits are used for this purpose. Two hexadecimal digits represent a byte. 4FA3.54B1 Each digit in a hexadecimal integer represents four binary bits. Each digital represents decimal 0 to hexadecimal 0 to 15. It includes 0-9 numbers and A to F for numbers 10 to 15.

Decimal to Hexadecimal There are few steps to convert number from decimal to hexadecimal number. Steps: Divide the number by 16 and write down the remainder in hexadecimal. Divide the quotient obtained by 16 and again write remainder in hexadecimal. Repeat the above steps until quotient will become less than 16. Convert to hexadecimal and write down last quotient. Arrange the list of quotient and last quotient from left to right. Direct Conversion http://www.binaryhexconverter.com/hex-to-binary-converter Conversion Steps: http://www.wikihow.com/Convert-from-Decimal-to-Hexadecimal

Hexadecimal to Decimal Hexadecimal number is giving increasing power of 16 to each digit from right to left.

Hexadecimal to Binary Hexadecimal number is converted into binary number by converting each binary digit into its equivalent 4-bit binary number.

Boolean Operations NOT AND OR Operator Precedence Truth Tables

Boolean Algebra Based on symbolic logic, designed by George Boole Boolean expressions created from: NOT, AND, OR

Digital gate diagram for NOT: Inverts (reverses) a boolean value Truth table for Boolean NOT operator: Digital gate diagram for NOT:

Digital gate diagram for AND: Truth table for Boolean AND operator: Digital gate diagram for AND:

Digital gate diagram for OR: Truth table for Boolean OR operator: Digital gate diagram for OR:

Operator Precedence Examples showing the order of operations: