Assembly Language For Intel-Based Computers, 5 Edition
Assembly Language For Intel-Based Computers, 5 Edition
(c) Pearson Education, 2006-2007. 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.
Web site
Examples
Web site
Examples
Web site
Examples
Binary Numbers
Digits are 1 and 0
1 = true
0 = false
Bit numbering:
LSB
1011001010011100
15
Web site
Examples
Binary Numbers
Every binary
number is a
sum of powers
of 2
Web site
Examples
Web site
Examples
37 = 100101
Irvine, Kip R. Assembly Language for Intel-Based Computers 5/e, 2007.
Web site
Examples
Binary Addition
Starting with the LSB, add each pair of digits, include
the carry if present.
Web site
Examples
Web site
Examples
10
Hexadecimal Integers
Binary values are represented in hexadecimal.
Web site
Examples
11
Web site
Examples
12
Hex1234equals(1163)+(2162)+(3161)+(4160),or
decimal4,660.
Hex3BA4equals(3163)+(11162)+(10161)+(4160),or
decimal15,268.
Web site
Examples
13
Web site
Examples
14
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.
36
42
78
28
45
6D
28
58
80
6A
4B
B5
21 / 16 = 1, rem 5
Web site
Examples
15
Hexadecimal Subtraction
C6
A2
24
75
47
2E
Web site
Examples
16
Signed Integers
The highest bit (MSB) indicates the sign. 1 = negative,
0 = positive
Web site
Examples
17
Web site
Examples
18
Binary Subtraction
When subtracting A B, convert B to its two's
complement
Add A to (B)
00001100
00000011
00001100
11111101
00001001
Web site
Examples
19
Web site
Examples
20
Twos of 11110000
flip all bit 00001111
Add 1
00001111 +
1
----------------00010000
Convert to decimal 16
Because the original integer
(11110000) was negative, we
infer its decimal value was -16.
Web site
Examples
21
Web site
Examples
22
Web site
Examples
23
Web site
Examples
24
Practice: What is the largest positive value that may be stored in 20 bits?
Web site
Examples
25
Character Storage
Character sets
Null-terminated String
Array of characters followed by a null byte
Web site
Examples
26
Character Storage
Web site
Examples
27
General-Purpose Registers
Registers are high-speed storage locations directly
inside the CPU, designed to be accessed at much
higher speed than conventional memory.
The general-purpose registers are primarily used for
arithmetic and data movement.
32-bit General-Purpose Registers
EAX
EBP
EBX
ESP
ECX
ESI
EDX
EDI
16-bit Segment Registers
EFLAGS
EIP
CS
ES
SS
FS
DS
GS
Web site
Examples
28
Web site
Examples
29
Web site
Examples
30
Segment
CS code segment
DS data segment
SS stack segment
ES, FS, GS - additional segments
Web site
Examples
31
Web site
Examples
32
Status Flags
Carry Flag
is set when the result of an unsigned arithmetic operation
.is too large to fit into the destination
Overflow Flag
signed arithmetic out of range
Sign Flag
Set when the result is negative
Zero Flag
Ser when the result is zero
Parity
is set if the least-significant byte in the result contains an
even number of 1 bits. Otherwise, PF is clear. In general,
it is used for error checking when there is a possibility that
data might be altered or corrupted
Web site
Examples
33