0% found this document useful (0 votes)
85 views25 pages

1.introduction To Computing-2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views25 pages

1.introduction To Computing-2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 25

80x86 Microprocessors

Assembly Language
Dr. Ali Mohamed
Faculty of Engineering at Aswan
Aswan University
Text Books

The 80x86 IBM PC and Compatible Computers


Assembly Language, Design, and Interface
3rd Edition
Muhammed Ali Mazidi
Janice Gillisipie Mazidi

Introduction to 80x86 Assembly Language and


Computer Architecture
Richard C. Detmer

The 80x86 Microprocessors 1.2 Assembly Language


Course Outline
Chapter 0: Introduction to Computing
Chapter 1: The 80x86 Microprocessor
Chapter 2: Assembly Language Programming
Chapter 3: Arithmetic and Logic Instructions and Programs
Chapter 4: BOIS and DOS Programming in Assembly and C
Chapter 5: Macros and the Mouse
Chapter 6: Signed Numbers, Strings, and Tables
Chapter 7: Modules: Modular and C Programming
Chapter 8: 32-bit Programming for 386 and 486 machines

The 80x86 Microprocessors 1.3 Assembly Language


Chapter 0
Introduction to Computing

The 80x86 Microprocessors 1.4 Assembly Language


Numbering and Coding Systems
 Human beings use the decimal system (base 10)
 Decimal digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

 Computer systems use the binary system (base 2)


 Binary digits: 0, 1

 Bit (Binary Digit): 0 or 1

 The Octal system (base 8) has 8 digits


 0, 1, 2, 3, 4, 5, 6, 7

 The hexadecimal system (base 16) has 16 digits


 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

The 80x86 Microprocessors 1.5 Assembly Language


Decimal, Binary, and Hex
Decimal Binary Hexadecimal
0 0000 0
1 0001 1
2 0010 2
3 0011 3
4 0100 4
5 0101 5
6 0110 6
7 0111 7
8 1000 8
9 1001 9
10 1010 A
11 1011 B
12 1100 C
13 1101 D
14 1110 E
15 1111 F
The 80x86 Microprocessors 1.6 Assembly Language
Example: Convert (35)10 to binary
 Dividing the decimal number by 2 repeatedly
 Keeping track of the remainders
 This process continues until the quotient becomes zero.
 The remainders are then written in reverse order to obtain the binary.

Quotient Remainder
35/2 = 17 1 (LSB) Beside the binary point (100011.0)2
17/2 = 8 1
8/2 = 4 0
4/2 = 2 0
2/2 = 1 0
1/2 = 0 1 (MSB)

(35)10 = (100011)2
The 80x86 Microprocessors 1.7 Assembly Language
Example: Convert (0.35)10 to binary

0.35*2 = 0.7 + 0 (MSB) Beside the binary point (0.01011)2


0.7*2 = 0.4 + 1
0.4*2 = 0.8 + 0
0.8*2 = 0.6 + 1
0.6*2 = 0.2 + 1
0.2*2 = 0.4 + 0 (LSB)

(0.35)10 = (0.010110)2

The 80x86 Microprocessors 1.8 Assembly Language


Converting from Binary to Decimal
 There is a weight associated with each digit position
 Multiply the weigh of each digit position by the content of position
 Sum the weight of all digits
 Example: Convert (315)10 from decimal to decimal !!!

3 1 5

3102 1101 5100

3100 110 51

3100 + 110 + 51 = 315

The 80x86 Microprocessors 1.9 Assembly Language


Example: Convert (110101)2 to Decimal

1 1 0 1 0 1

125 124 023 122 021 120

132 + 116 + 08 + 14 + 02 + 11


(110101)2 = (53)10

The 80x86 Microprocessors 1.10 Assembly Language


Example: Convert (0.110101)2 to Decimal

1 1 0 1 0 1

12-1 12-2 02-3 12-4 02-5 12-6

1/2 + 1/4 + 0/8 + 1/16 + 0/32 + 1/64


(0.110101)2 = (0.828125)10

The 80x86 Microprocessors 1.11 Assembly Language


Converting between Binary and Hex
 Converting from binary to hex
 Start from the right and group 4 bits at a time
 Replace each 4-bit binary number with its hex equivalent
 Example: Represent binary 100111110101 in hex
 1001 1111 0101
9 F 5
 Therefore, (100111110101)2 = (9F5)16 hexadecimal.
 Converting from hex to binary
 Replace each hex digit with its 4-bit binary equivalent
 Example: Convert hex 29B to binary
 2 9 B
0010 1001 1011
 After dropping the leading zeros, (29B)16 = (1010011011)10

The 80x86 Microprocessors 1.12 Assembly Language


Converting from Decimal to Hex
 Converting from decimal to hex could be approached in two ways:
1. Convert to binary first and then convert to hex.
 Example: Convert (45)10 to hex
 (45)10 = (101101)2 = (0010 1101)2 = (2D)16
2. Convert directly from decimal to hex by the method of repeated division,
keeping track of the remainders.
 Example: Convert (45)10 to hex
Quotient Remainder
45/16 2 13 (hex D) (L.S.D)
2/16 0 2 (M.S.Digit)
 (45)10 = (101101)2 = (0010 1101)2 = (2D)16
 Example: Convert decimal (629)10 to hexadecimal.
 (629)10 = (0010 0111 0101)2 = (275)16

The 80x86 Microprocessors 1.13 Assembly Language


Converting from Hex to Decimal
 Conversion from hex to decimal can also be approached in two ways:
1. Convert from hex to binary and then to decimal.
 Example: Convert hexadecimal (6B2)16 to decimal.
 (6B2)16 = (0110 1011 0010)2 =
(129+128+027+126+025+124+123+022+022+121+020)10 =
(1714)10
2. Convert directly from hex to decimal by summing the weight of all
digits.
 Example: Convert hexadecimal (6B2)16 to decimal.
 (6B2)16 = (6162+B161+2160)10 = (1714)10

The 80x86 Microprocessors 1.14 Assembly Language


Addition of Binary and Hex numbers
Add the following unsigned binary Ci A B Carry Sum
numbers
(1010100)2 + (1100100)2 = ? 0 0 0 0 0

0 0 1 0 1
000100
0 1 0 0 1
1010100
0 1 1 1 0
1100100
__________ 1 0 0 0 1

10111000 1 0 1 1 0

1 1 0 1 0
(84)10 + (100)10 = (184)10
1 1 1 1 1

The 80x86 Microprocessors 1.15 Assembly Language


Signed Addition
Add the following signed binary numbers
(01010100)2 + (01100100)2 = ?

+
01000100
01010100 +84
ERROR
01100100 +100

__________
-72
10111000

2’s complement 10111000 of is 01001000 (-72)

The 80x86 Microprocessors 1.16 Assembly Language


Unsigned Subtraction
 There is no separate circuitry for subtractiors.
 Instead, adders are used in conjunction with 2's complement circuitry to
perform subtraction.
 To implement "x - y", the computer takes the 2's complement of y and
adds it to x.
 Example: Subtract the following unsigned numbers (100 – 80 = 20)
 1100100 – 1010000 (note that each number has the same number of
digits)
 1100100 + 0110000 = 10010100 The result is +ve
+(0010100) 2= +(20)

 Example: Subtract the following unsigned numbers (80 - 100 = -20)


 1010000 - 1100100
 1010000 + 0011100 = 1101100 (Note: no extra digit)
The result is -ve
-(0010100) 2= -(20)
The 80x86 Microprocessors 1.17 Assembly Language
Signed Subtraction
 Example: Subtract the following signed numbers (100 – 80 = 20)
 (+100) – (+80)
 01100100 – 01010000
 
01100100 + 10110000 = 100010100  00010100  +20
 Any carry out of the sign-bit position is discarded
 The negative result is automatically in the 2’s complement form
 Example: Subtract the following unsigned numbers (80 - 100 = -20)
 (+80) – (+100)
 01010000 - 01100100
 01010000 + 10011100 = 11101100  - 00010100  -20

The 80x86 Microprocessors 1.18 Assembly Language


ASCII Code
 ASCII: American Standard Code for Information Interchange
 The great advantage of this system is that it is used by most computers,
so that information can be shared among computers.
 The ASCII code assigns binary patterns for
 numbers 0 to 9,
 uppercase (capital) letters A to Z
 lowercase letters a to z
 Another characters { “ ‘ !@$
 many control codes
 The ASCII system uses a total of 7 bits to represent each code.
 Example
 100 0001  uppercase letter "A"
 110 0001  lowercase letter "a".
 Often, a zero is placed in the most significant bit position to make it an 8-
bit code.

The 80x86 Microprocessors 1.19 Assembly Language


Note That
 The pattern of ASCII codes was designed to allow for easy manipulation
of ASCII data.
 Digits (0)10 through (9)10 are represented by ASCII codes
30H or (0011 0000)2 through 39H or (0011 1001)2.
 This enables a program to easily convert ASCII to decimal by masking off
the "3" in the upper nibble.
 There is a relationship between the uppercase and lowercase letters.
 Uppercase letters are represented by ASCII codes 41H or (0100 0001)2
through 5AH or (0101 1010)2 while lowercase letters are represented by
ASCII codes 61H or (0110 0001)2 through 7AH or (0111 1010)2.
 Looking at the binary code, the only bit that is different between uppercase
"A" and lowercase "a" is bit 5.
 Therefore conversion between uppercase and low­ercase is as simple as
changing bit 5 of the ASCII code.

The 80x86 Microprocessors 1.20 Assembly Language


Some Important Terminology
 Bit: a binary digit that can have the value 0 or 1.
 Byte: 8 bits.
 Nibble: half a byte or 4 bits.
 Word: two bytes, or 16 bits.
 Kilobyte: 210 bytes, which is 1024 bytes.
 The abbreviation K is often used (356K bytes of data).
 Megabyte: 220 bytes, which is a little over 1 million bytes; it is exactly
1,048,576.
 Gigabyte: 230 bytes (over 1 billion)
 Terabyte: 240 bytes (over 1 trillion).
 RAM: random access memory (sometimes called read/write memory)
 The data in RAM is lost when the computer is turned off (volatile
memory).
 ROM: read-only memory
 The information in ROM is permanent, cannot be changed by the
user, and is not lost when the power is turned off (nonvolatile
memory).

The 80x86 Microprocessors 1.21 Assembly Language


Internal Organization of Computers
 The internal working of every computer can be broken down into three
parts:
1. CPU (central processing unit): to execute (process) information stored
in memory.
2. Memory: to store programs and data
3. I/O (input/output) devices: to provide a means of communicating with
the CPU.
 The CPU is connected to memory and I/O through strips of wire called a
bus. The bus inside a computer carries information from place to place

The 80x86 Microprocessors 1.22 Assembly Language


Computer Buses
Address Bus, Data Bus, and Control Bus.
 Address bus,
 The number of address buses for a CPU determines the number of locations
with which CPU can communicate.
 The number of locations is always equal to 2 x, where x is the number of
address lines, regardless of the size of the data bus.
 A CPU with 16 address lines can provide a total of 65,536 (2 16) or 64K, bytes of
addressable memory. Each location can have a maximum of 1 byte of data.
 Data bus: used to carry information in and out of a CPU,
 The more data buses available, the better the CPU.
 More data buses mean a more expensive CPU and computer.
 The average size of data buses in CPUs varies between 8 and 64.
 Data buses are bidirectional, since the CPU must use them either to receive or
to send data.
 The processing power of a computer is related to the size of its buses, since an
8-bit bus can send out one byte a time, but a 16-bit bus can send out 2 bytes at
a time, which is twice as fast.
 Control bus: used to provide read or write signals to the device to indicate if the
CPU is asking for information or sending it information.

The 80x86 Microprocessors 1.23 Assembly Language


Internal Organization of Computers
 For the CPU to process information, the data must be stored in RAM or ROM.
 The CPU gets the information to be processed, first from RAM (or ROM).
 Only if it is not there does the CPU seek it from a mass storage device such as a
disk, and then it transfers the information to RAM.
 For this reason, RAM and ROM are sometimes referred to as primary memory and
disks are called secondary memory.

The 80x86 Microprocessors 1.24 Assembly Language


Internal Block Diagram of a CPU
Decoder: interpret the instruction PC (IP): point to the address of the
fetched into the CPU next instruction to be executed
Fetches instructions from memory
Executes fetched instructions
CPU

Arithmetic/logic unit: perform arithmetic


functions such as add, subtract, multiply, Store information temporarily
and divide, and logic functions such as
AND, OR, and NOT
The 80x86 Microprocessors 1.25 Assembly Language

You might also like