Presentation is loading. Please wait.

Presentation is loading. Please wait.

Assembly Language for x86 Processors 6th Edition

Similar presentations


Presentation on theme: "Assembly Language for x86 Processors 6th Edition"— Presentation transcript:

1 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

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

3 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

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

5 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

6 A Hierarchy of Languages

7 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. 

8 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.

9 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.

10 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

11 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.

12 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.

13 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.

14 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.

15 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

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

17 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

18 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.

19 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: A F E

20 Virtual Machine: Specific Machine Levels

21 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.

22 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)

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

24 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.

25 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.

26 Decimal to Binary Conversion
Conversion of 143 Conversion of 256 Remainder Remainder 143 ÷ 2 = 71 remainder is 1 256 ÷ 2 = 71 ÷ 2 = 35 remainder is 1 128 ÷ 2 = 35 ÷ 2 = 17 remainder is 1 64 ÷ 2 = 17 ÷ 2 = 8 remainder is 1 32 ÷ 2 = 8 ÷ 2 = 4 remainder is 0 16 ÷ 2 = 4 ÷ 2 = 2 remainder is 0 8 ÷ 2 = 2 ÷ 2 = 1 remainder is 0 4 ÷ 2 = 1÷ 2 = 0 remainder is 1 2 ÷ 2 = 1÷ 2 =

27 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 =

28 Binary to Decimal Conversion
needs to be converted to decimal 20= 1 21 = 2 22 = 4 23 = 8 24 = 16 25 = 32 26 = 64 27 = 128 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 = 171 27 x 1 = 128

29 Decimal to Binary Convert 8 decimal to binary.
Convert 88 decimal to binary. Convert 204 decimal to binary. Convert 255 decimal to binary.

30 Binary to Decimal Convert 00101100 binary to decimal.
44 Convert binary to decimal. 128 Convert binary to decimal. 8 Convert binary to decimal. 85

31 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:

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

33 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 will be stored in memory with additional four zeros at start of the number.

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

35 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.

36 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 Conversion Steps:

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

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

39 Boolean Operations NOT AND OR Operator Precedence Truth Tables

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

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

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

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

44 Operator Precedence Examples showing the order of operations:


Download ppt "Assembly Language for x86 Processors 6th Edition"

Similar presentations


Ads by Google