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
* HL = high-level
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
Specific Machine Levels
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 10
High-Level Language
• Level 5
• Application-oriented languages
• Programs compile into assembly language
(Level 4)
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 11
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 12
Operating System
• Level 3
• Provides services to Level 4 programs
• 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 13
Instruction Set Architecture
• Level 2
• Also known as conventional machine
language
• Executed by Level 1 program
(microarchitecture, Level 1)
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 14
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 15
Digital Logic
• Level 0
• CPU, constructed from digital logic gates
• System bus
• Memory
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 16
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 17
Binary Numbers
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 18
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 19
Translating Binary to Decimal
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 20
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 21
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 22
Integer Storage Sizes
Standard sizes:
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 23
Hexadecimal Integers
All values in memory are stored in binary. Because long
binary numbers are hard to read, we use hexadecimal
representation.
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 24
Translating Binary to Hexadecimal
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 25
Converting Hexadecimal to Decimal
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 26
Powers of 16
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 27
Converting Decimal to Hexadecimal
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 28
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 29
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 30
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 31
Forming the Two's Complement
• Negative numbers are stored in two's complement notation
• Additive Inverse of any binary integer
• Steps:
• Complement (reverse) each bit
• Add 1
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 32
Binary Subtraction
• When subtracting A – B, convert B to its two's
complement
• Add A to (–B)
1100 1100
– 0011 1101
1001
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 33
Learn How To Do the Following:
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 34
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 35
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 36
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 37
Boolean Operations
• NOT
• AND
• OR
• Operator Precedence
• Truth Tables
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 38
Boolean Algebra
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 39
NOT
NOT
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 40
AND
• Truth table for Boolean AND operator:
AND
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 41
OR
• Truth table for Boolean OR operator:
OR
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 42
Operator Precedence
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 43
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 44
Truth Tables (2 of 3)
• Example: X Y
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 45
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 46
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 47
Printing this Slide Show
Irvine, Kip R. Assembly Language for Intel-Based Computers, 2003. Web site Examples 48