(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
Ee353 chap1 1.0
1. EE353: : Introduction to Microprocessors
Page : 1EE353: Introduction to MicroprocessorsDr. Ridha Jemal
By Dr. Ridha Jemal
Electrical Engineering Department
College of Engineering King Saud University
Textbook: The 80X86 IBM PC and Compatible Computers: Assembly Language,
Design, and Interfacing Volumes I & II”, Muhammad al-Mazidi, Prentice Hall.
“Intel Microprocessors 8086/8088, 80186/80188, 80286, 80386,
80486, Pentium, Pentium Pro, and Pentium II Processors: Architecture,
Programming, and Interfacing”, Barry B. Brey, Prentice Hall
Email: rdjemal@ksu.edu.sa
http://faculty.ksu.edu.sa/djemal/default.aspx
Course Grading
Midterm#1 (20%)
Midterm#2 (20%)
Tutorial (10%)
Attendance & Project (10%)
Final Exam (40%)
2. EE353: : Introduction to Microprocessor
Page : 2EE351: Introduction to MicroprocessorsDr. Ridha Jemal
Course Outlines
Chapter 1: Introduction to Microprocessors and Computers
Chapter 2: Microcomputer Architecture and Programming Model
Chapter 3: Addressing Modes for the 8086 Microprocessors
Chapter 4: Data Transfer Instructions
Chapter 5: Arithmetic and Logical Instructions
Chapter 6: Program Control Instructions: Jump and Call Instructions
Chapter 7: Program Control Instructions: Software Interrupts
Chapter 8: Assembly Language Programming
Chapter 9: The 8086 Pins
Chapter 10: Hardware, software and interrupt instructions
Chapter 11: Memory interface, bus cycles, memory control signals,
and memory addressing hardware.
Chapter 11: The PIA (8259A) interrupt controller
3. Page: 3Dr. Ridha Jemal
Chapter 1 : Introduction to Microprocessors
and Computers
1.1. Introduction : Computer – Element of a Computer
1.2. Hardware and Software in Computer
1.3. Abstraction Level in the Computer
1.4. Instructions, Translation Programs and Program distribution
1.5. Number Representation in the Computer
1.6. Performing Arithmetic
1.7. Storage and Data Structure
By Dr. Ridha Jemal
Electrical Engineering Department
College of Engineering
King Saud University
1431-1432
EE353: Chapter 1 : Introduction to Microprocessors and Computers
4. Page: 4Dr. Ridha Jemal
Element of Computers
A useful microprocessor-based computer system must have :
• Central Processing Unit (CPU) :
To manipulates data and control I/O devices
according to the program stored in memory.
• Memory:
To store programs and data
• Input/Output Devices:
Allow CPU to communicate with external hardware
• Bus System:
Connect everything together
Address, Data Control signals
EE353: Chapter 1 : Introduction to Microprocessors and Computers
5. Page: 5Dr. Ridha Jemal
A Simple architecture of a Microprocessor-Based Computer :
I/O Devices
Keyboards
Monitors
Relays
I/O
Interface
Data Bus
Address Bus
Control Bus
EE353: Chapter 1 : Introduction to Microprocessors and Computers
Element of Computers
6. Page: 6Dr. Ridha Jemal
Hardware:
• The parts of the computer you can touch :
• Electronic circuits (Processor, coprocessor, memories, wires)
• Keyboard, Display
Software:
• Programs :
• Consists of instructions telling the computer what to do
• Ability to run different programs makes the computer a
General Purpose Machine
• Abstract
Hardware and Software are logically equivalent
- Simulation Programs
- Emulation of other Computers
EE353: Chapter 1 : Introduction to Microprocessors and Computers
Hardware and Software in Computer
7. Page: 7Dr. Ridha Jemal EE353: Chapter 1 : Introduction to Microprocessors and Computers
From Programmer’s Point-of-view:
• High-Level Programming Languages
• Assembly Language
• Machine code
• Logic Gates
• Transistor Level
Working at Higher Levels:
• Programming is easier
• Programs are more portable (hardware independent)
• Little or no knowledge if machine required
Working at Lower Levels:
• More control over the machine
• Possible to write very small, efficient programs
Abstraction Levels in Computer
8. Page: 8Dr. Ridha Jemal EE353: Chapter 1 : Introduction to Microprocessors and Computers
Abstraction Levels in Computer
From User’s Point-of-view:
• Applications Software
• Operating System Software (MsDos, Windows, Unix, Linux, VMS)
• Hardware (PC, Workstation, Mainframe)
• Applications are written for a given operating systems
• OS Shields the application from the hardware
• Different combinations of Hardware Platform, OS and Applications
are possible
Examples:
PC... MS-DOS... MS-Word
PC... UNIX... EMACS
Mac... System7... MS-Word
HP 9000/715... UNIX... EMACS
9. Page: 9Dr. Ridha Jemal EE353: Chapter 1 : Introduction to Microprocessors and Computers
Instructions – Translation Programs – Program
Distribution
Instructions:
• Each type of CPU has an instruction set : Move, ADD, SUB, Load Store, …
• Machine code programs use combinations of these instructions sorted as
files of binary information: Executable File = Instruction + Data
• Machine Code is different for each CPU
• Executable files won’t work on different CPU’s
• Some CPU families maintain back-compatibility
o PC: 8086, 80286, 386, 486, Pentium (586)
o Mac: 68000, 68020, 68030m 68040
Translation Programs :
• Compiler: translate High-level language (HLL) file to file of Machine
code instruction (HLL is independent of CPU) Ex: C, Fortran, Java.
• Assembler: Translates Assembly language file to Machine file
• Assembly language is specific to CPU.
10. Page: 10Dr. Ridha Jemal EE353: Chapter 1 : Introduction to Microprocessors and Computers
Instructions – Translation Programs – Program
Distribution
Translation Programs :
Interpreter: Translates HLL instructions to Lower Level instructions on-the-fly
Machine Code instructions (call sub-programs for each HLL instruction)
Alternatively: "Virtual Machine".
Generally much slower execution than machine code programs Examples:
LISP, Prolog, BASIC
Program Distribution :
Executable Files
Can't (easily) change: not human-readable
Users obtain Applications in this format
Source Code
HLL or Assembly Language: human-readable
Can change and re-compile/assemble
"portable" source code compiles/runs on different CPU's and OS's (GOOD)
11. Page: 11Dr. Ridha Jemal EE353: Chapter 1 : Introduction to Microprocessors and Computers
Number Representation in the Computer
Decimal System:
A decimal number 7251 represents a quantity equal to :
7 thousands + 2 hundreds + 5 tens + 1 unit
To be more exact this number should be written as:
7 x 103+ 2 x 102 + 5 x 101 + 1 x 100
• In general a number with decimal point is represented by a series of
coefficients as follows :
a4 a3 a2 a1 a0 • a-1 a-2 a-3
• The aj coefficients are any of the 10 digits (0, 1, 2, …, 9), and the subscript
value j gives the place value and, hence, the power of 10 by which the
coefficient must be multiplied. This can be expressed as:
a4x104 + a3x103+ a2x102 + a1x101+ a0x100 + a-1x10-1 + a-2x10-2+ a-3x10-3
• The General form can be expressed as:
anx10n + an-1x10n-1 + • • • + a0x100 + a-1x10-1 + • • • + a-mx10-m
n = (digit number before the point )-1
m = digit number after the point
12. Page: 12Dr. Ridha Jemal EE353: Chapter 1 : Introduction to Microprocessors and Computers
Number Representation in the Computer
Binary Numbers:
Binary numbers written as groups of Binary Digits ("Bits")
Value of bits:
Right-hand bit = 1 (20)
Next on left = 2 (21)
Next on left = 4 (22) etc…
Bit on right-hand side: "Least Significant Bit“ (LSB)
Bit on left-hand side: "Most Significant Bit" (MSB)
Using n bits can represent 2n different combinations
e.g. 2 bits ... 22 = 4 combinations
4 bits ... 24 = 16 combinations
8 bits ... 28 = 256 combinations
Computers deal with Bits, usually in groups of 4:
8 bits = 1 byte
4 bits = 1 nybble
13. Page: 13Dr. Ridha Jemal EE353: Chapter 1 : Introduction to Microprocessors and Computers
Number Representation in the Computer
Large binary numbers are cumbersome, easier to use Short-hand notations
OCTAL
Groups of 3 bits
3 bits: 8 combinations... use digits 0-7
Octal is Base 8
eg. 9, base 10 = 001001, base 2 = 11, base 8
HEXADECIMAL
Groups of 4 bits
4 bits: 16 combinations...
... use digits 0-9 and A, B, C, D, E, F
Hexadecimal is Base 16
eg. 30 base 10 = 00011110 base 2 = 1E base 16
Also written "$1E" or "1Eh"
Binary Numbers:
14. Page: 14Dr. Ridha Jemal EE353: Chapter 1 : Introduction to Microprocessors and Computers
Unsigned Numbers:
• Find the decimal value of the 8-bit unsigned number: 0 1 1 0 1 0 1 0
Integers Real number Characters
Data
Unsigned integers
+ve nbrs:0,1,2 …
Signed integers
+ve and –ve nbrs:
.. -3,-2,-1,0,1,2,3…
Floating point numbers
5.61, -32, -2,6x10-6
a,b, ….,z, A, … Z, ?! …
• Everything in the Computer is represented as Binary Numbers
• Represent the number 23 using 8-bit unsigned form
0 0 0 1 0 1 1 1
LSB (least Significant Bit)MSB (Most Significant Bit)
(0 1 1 0 1 0 1 0)2 = (116)10
Number Representation in the Computer
15. Page: 15Dr. Ridha Jemal EE353: Chapter 1 : Introduction to Microprocessors and Computers
Character Sets
ASCII - American Standard Code for Information Interchange
a.k.a ISO 646-1973 (international)
BS 4730: 1974 (British Standard)
7-bit code (128 different characters)
Numerals, punctuation and letters
American alphabet...
... no symbols for ö, å, ñ etc.
Still VERY widely used
EBCDIC - Extended Binary-Coded-Decimal Interchange Code
Proprietary to IBM
8-bit code
Not compatible with ASCII
ISO Latin1 - 8-bit code
Extension to ASCII (ASCII is compatible)
Has characters for European languages
Future - include ALL characters from ALL languages (!)
Unicode (16 bits)
ISO 10646 (32 bits)
16. Page: 16Dr. Ridha Jemal EE353: Chapter 1 : Introduction to Microprocessors and Computers
Number with Different Representations
Decimal
(Base 10)
Binary
(Base 2)
Octal
(Base 8)
Hexadecimal
(Base 16)
00 0000 00 0
01 0001 01 1
02 0010 02 2
03 0011 03 3
04 0100 04 4
05 0101 05 5
06 0110 06 6
07 0111 07 7
08 1000 10 8
09 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
17. Page: 17Dr. Ridha Jemal EE353: Chapter 1 : Introduction to Microprocessors and Computers
Standard Multiplication Factors and Prefixes Unit of
Storage
1 kilobyte (1k) = 210 bytes = 1024 bytes
1 Megabyte (1Mb) = 220 bytes = 1024 kbytes
1 Gigabyte (1Gb) = 230 bytes = 1024 Mbytes
1 Terabyte (1Tb) = 240 bytes = 1024 Gbytes
Multiplier Prefix Symbol
1 000 000 000 000 = 1012 tera T
1 000 000 000 = 109 giga G
1 000 000 = 106 mega M
1 000 = 103 kilo k
0.001 = 10-3 milli m
0. 000 001 = 10-6 micro
0.000 000 001 = 10-9 nano n
0.000 000 000 001 = 10-12 pico p
18. Page: 18Dr. Ridha Jemal EE353: Chapter 1 : Introduction to Microprocessors and Computers
Negative Numbers
Number line extends in both directions:
Ways to represent numbers less than zero:
Signed Magnitude
Use MSB as a flag: 0=+ve, 1=-ve ("sign bit")
All other bits hold the magnitude
eg. using 4 bits
0110 = 6
1010 = -2
The sign is represented by a bit placed in the leftmost position of the number.
The convention is to make the sign bit 0 for positive 1 for negative.
0 1010010 as unsigned number is equal to :
1 1010010 as unsigned number is equal to :
1 1010010 as signed number is equal to :
19. Page: 19Dr. Ridha Jemal EE353: Chapter 1 : Introduction to Microprocessors and Computers
Negative Numbers
Two’s Complement
One’s Complement
• Given a number N in base 2 having n digits, the 1’s complement of N is
defined as (2n – 1) –N
o N=4 ; 24= 100002 and 24 – 1=1111. The 1’s complement is obtained by
subtracting each digit from 1. We have one of the following cases :1 -0 or 1-1.
The 1’s complement is obtained by changing 1’s to 0’s and 0’s to 1’s
To negate number: Invert all bits and add 1 ; eg. -2 using 8 bits
* 0000 0010 inverted is 1111 1101
* Add 1: 1111 1110 (-2)
Another way: Start writing down the number from left.
Write the number exactly as it appears until the first one.
Write down the first one and invert all digits to its left
eg. +8 = 00001000
1000 writ number to first one
1111 invert the remaining bits
-8 = 11111000
20. Page: 20Dr. Ridha Jemal EE353: Chapter 1 : Introduction to Microprocessors and Computers
Negative Numbers Arithmetic
A-B = A+(-B) using the 2’s complement
• Example : +35 -72 = ???
+ 35 00100011 00100011
- 72 11001000 10111000 2’s complement 0f 01001000
---------------------------------------
11011011 It’s a negative number,
we take its 2’s complement which is : 00100101 equal to - 37
21. Page: 21Dr. Ridha Jemal EE353: Chapter 1 : Introduction to Microprocessors and Computers
Fractional Representation
Fixed Point
Floating Point
Represent as: (s) a.m 2e
m = mantissa
e = exponent
s = sign (+ or -)
Store as:
"Normalise" so a is always 0 (or always 1)
Gives much wider range than fixed point
Many CPUs support floating-point arithmetic