Assembly Language For Intel-Based Computers, 4 Edition
Assembly Language For Intel-Based Computers, 4 Edition
Assembly Language For Intel-Based Computers, 4 Edition
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 2
Welcome to Assembly Language
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 3
Some Good Questions to Ask
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 4
Welcome to Assembly Language (cont)
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 5
Assembly Language Applications
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 6
Comparing ASM to High-Level Languages
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 7
Virtual Machine Concept
• Virtual Machines
• Specific Machine Levels
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 8
Virtual Machines
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 9
Translating Languages
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 10
Specific Machine Levels
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 11
High-Level Language
• Level 5
• Application-oriented languages
• C++, Java, Pascal, Visual Basic . . .
• Programs compile into assembly language
(Level 4)
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 12
Assembly Language
• Level 4
• Instruction mnemonics that have a one-to-
one correspondence to machine language
• Calls functions written at the operating
system level (Level 3)
• Programs are translated into machine
language (Level 2)
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 13
Operating System
• Level 3
• Provides services to Level 4 programs
• Translated and run at the instruction set
architecture level (Level 2)
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 14
Instruction Set Architecture
• Level 2
• Also known as conventional machine
language
• Executed by Level 1 (microarchitecture)
program
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 15
Microarchitecture
• Level 1
• Interprets conventional machine instructions
(Level 2)
• Executed by digital hardware (Level 0)
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 16
Digital Logic
• Level 0
• CPU, constructed from digital logic gates
• System bus
• Memory
• Implemented using bipolar transistors
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 17
Data Representation
• 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
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 18
Binary Numbers
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 19
Binary Numbers
Every binary
number is a
sum of powers
of 2
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 20
Translating Binary to Decimal
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 21
Translating Unsigned Decimal to Binary
• Repeatedly divide the decimal integer by 2. Each
remainder is a binary digit in the translated value:
37 = 100101
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 22
Binary Addition
• Starting with the LSB, add each pair of digits, include
the carry if present.
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 23
Integer Storage Sizes
Standard sizes:
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 24
Hexadecimal Integers
Binary values are represented in hexadecimal.
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 25
Translating Binary to Hexadecimal
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 26
Converting Hexadecimal to Decimal
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 27
Powers of 16
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 28
Converting Decimal to Hexadecimal
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 29
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.
1 1
36 28 28 6A
42 45 58 4B
78 6D 80 B5
21 / 16 = 1, rem 5
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 30
Hexadecimal Subtraction
10h + 5 = 15h
1
C6 75
A2 47
24 2E
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 31
Signed Integers
The highest bit indicates the sign. 1 = negative,
0 = positive
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 32
Forming the Two's Complement
• Negative numbers are stored in two's complement
notation
• Represents the additive Inverse
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 33
Binary Subtraction
• When subtracting A – B, convert B to its two's
complement
• Add A to (–B)
00001100 00001100
– 00000011 11111101
00001001
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 34
Learn How To Do the Following:
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 35
Ranges of Signed Integers
The highest bit is reserved for the sign. This limits the range:
Practice: What is the largest positive value that may be stored in 20 bits?
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 36
Character Storage
• 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
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 37
Numeric Data Representation
• pure binary
• can be calculated directly
• ASCII binary
• string of digits: "01010101"
• ASCII decimal
• string of digits: "65"
• ASCII hexadecimal
• string of digits: "9C"
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 38
Boolean Operations
• NOT
• AND
• OR
• Operator Precedence
• Truth Tables
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 39
Boolean Algebra
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 40
NOT
NOT
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 41
AND
• Truth table for Boolean AND operator:
AND
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 42
OR
• Truth table for Boolean OR operator:
OR
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 43
Operator Precedence
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 44
Truth Tables (1 of 3)
• 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
Example: X Y
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 45
Truth Tables (2 of 3)
• Example: X Y
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 46
Truth Tables (3 of 3)
• Example: (Y S) (X S)
Two-input multiplexer
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 47
54 68 65 20 45 6E 64
What do these numbers represent?
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 48
Printing this Slide Show
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 49