Introduction To Assembly Langauge Programming
Introduction To Assembly Langauge Programming
Chapter Overview
Assembly Language for x86 Processors
6th Edition
Kip Irvine • Welcome to Assembly Language
• Virtual Machine Concept
• Data Representation
Chapter 1: Basic Concepts • Boolean Operations
(c) Pearson Education, 2010. All rights reserved. You may modify and copy this slide show for your personal use, or for
use in the classroom, as long as this copyright statement, the author's name, and the title are not changed. Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 2
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 3 Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 4
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 5 Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 6
Introduction: Obuhuma J. 1
Assembly Language Programming September 15
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 7 Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 8
• Level 4 • Level 3
• Application-oriented languages • Instruction mnemonics that have a one-to-
• C++, Java, Pascal, Visual Basic . . . one correspondence to machine language
• Programs compile into assembly language • Programs are translated into Instruction Set
(Level 4) Architecture Level - machine language
(Level 2)
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 9 Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 10
• Level 2 • Level 1
• Also known as conventional machine • CPU, constructed from digital logic gates
language • System bus
• Executed by Level 1 (Digital Logic) • Memory
• Implemented using bipolar transistors
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 11 Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 12
Introduction: Obuhuma J. 2
Assembly Language Programming September 15
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 13 Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 14
• 1 = true
• 0 = false
• MSB – most significant bit
• LSB – least significant bit
Every binary
MSB LSB number is a
• Bit numbering: 1011001010011100 sum of powers
15 0 of 2
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 15 Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 16
37 = 100101
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 17 Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 18
Introduction: Obuhuma J. 3
Assembly Language Programming September 15
word 16
Standard sizes:
the carry if present. doubleword 32
quadword 64
carry: 1
0 0 0 0 0 1 0 0 (4)
+ 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
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 19 Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 20
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 21 Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 22
• Multiply each digit by its corresponding power of 16: Used when calculating hexadecimal values up to 8 digits
dec = (D3 163) + (D2 162) + (D1 161) + (D0 160) long:
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 23 Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 24
Introduction: Obuhuma J. 4
Assembly Language Programming September 15
• 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
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 25 Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 26
• When a borrow is required from the digit to the left, add 16 The highest bit indicates the sign. 1 = negative,
(decimal) to the current digit's value: 0 = positive
sign bit
16 + 5 = 21
1 1 1 1 0 1 1 0
Negative
-1
C6 75 0 0 0 0 1 0 1 0 Positive
A2 47
24 2E
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 27 Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 28
00001100 00001100
– 00000011 11111101
00001001
Note that 00000001 + 11111111 = 00000000 Practice: Subtract 0101 from 1001.
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 29 Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 30
Introduction: Obuhuma J. 5
Assembly Language Programming September 15
The highest bit is reserved for the sign. This limits the range:
• 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
Practice: What is the largest positive value that may be stored in 20 bits?
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 31 Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 32
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 33 Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 34
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 35 Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 36
Introduction: Obuhuma J. 6
Assembly Language Programming September 15
• Based on symbolic logic, designed by George Boole • Inverts (reverses) a boolean value
• Boolean expressions created from: • Truth table for Boolean NOT operator:
• NOT, AND, OR
NOT
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 37 Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 38
AND OR
• Truth table for Boolean AND operator: • Truth table for Boolean OR operator:
Digital gate diagram for AND: Digital gate diagram for OR:
AND OR
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 39 Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 40
Example: X Y
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 41 Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 42
Introduction: Obuhuma J. 7
Assembly Language Programming September 15
X
mux Z
Y
Two-input multiplexer
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 43 Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 44
Introduction: Obuhuma J. 8