You are on page 1of 61

MICROPROCESSOR and

MICROCONTROLER SYSTEM
IBB20204
LECTURE 1
Lecturer: MOHD SALLEHIN MOHD KASSIM
Room : 10.11
No Tel : 019-6692935
Email : msallehin@unikl.edu.my
Topics
 Introduction
 Instruction Set & Assembler Directives
 Assembly Language Programming
 Basic Peripherals & Their Interfacing
 (Data Acquisition Systems)
 (Applications)
Assessment
Assessment:
1. Coursework 60%
 Test 20%
 Lab Assignments 20%
 Project and Presentation 10%
 (Quiz) 10%

2. Final Exam 40%

*Courseworks are subject to change


Course Introduction
 This course uses the 8086 microprocessor to explain the

fundamentals of microprocessor architecture, programming


and hardware.

 This course will help students to understand the


hardware/software fundamentals to interface with real
applications at outside world via the mostly commonly used
microprocessor support ICs.
Learning Outcomes
 Upon completion of this course students should be able to:

1. Demonstrate and understanding of the microprocessor


architecture, its instructions and addressing modes.
2. Identify the internal registers and memory organization
for assembly language programming.
3. Design and develop a simple applications or programs
in assembly language.
4. Demonstrate the skills to use methods and tools of
assembly language or microprocessor applications.
Reference Textbook
 “The 8088 and 8086 Microprocessors: Programming,

Interfacing, Software, Hardware and Applications”, 4th.


Edition, by Walter A.Triebel, Avtar Singh, (2003), Prentice
Hall. ISBN :0-13-093081-4
 What is computer?

 Collection of software and hardware with a


medium of BUS.
 BUS?
 A communication system that transfers data between
components inside a computer, or between computers.
What is a Computer?

Memory I/O

Processor

Data Bus

Address Bus

Control Bus
Microprocessor – Basic Concept
What is a Computer? – is basically a machine
that consists:
 Central Processing Unit (CPU) /microprocessor
 To do arithmetic and logic operations and control I/O devices
according to the program stored in memory
 Memory
 Stores programs and data; RAM (random access memory),
ROM (read-only memory)
 Input/output Devices
 Allow CPU to communicate with external hardware
 System Bus
 Connects everything together
 Address, Data, Control signals
 Basic Computer Concept

 Hardware perspective – Microprocessor/microcontroller


architecture – components

 Software perspective –
To program the instructions in order to perform
computations /I/O ports logic control
 Example:
 High level language – C programming, java, VB, MatLab
 Low level language - machine language, assembly
language
12
Microprocessor
• Microprocessor is an IC which has only the CPU inside them
i.e. Intel’s Pentium 1,2,3,4, core 2 duo, i3, i5 etc.
• These microprocessors don’t have RAM, ROM, and other
peripheral on the chip.
• Application of microprocessor includes Desktop PC’s, Laptops,
notepads etc.
• Microprocessor performs unspecific tasks like developing
software, games, websites, photo editing, creating documents
etc.
• They need high amount of resources like RAM, ROM, I/O
ports etc.
13
Microcontrollers
• Microcontroller has a CPU, and a fixed amount of RAM, ROM
and other peripherals all embedded on a single chip.
• Microcontrollers are designed to perform specific tasks.
• For example, keyboards, mouse, washing machine, digicam,
pendrive, remote, microwave, cars, bikes, telephone, mobiles,
watches, etc.
• Since the applications are very specific, they need small
resources like RAM, ROM, I/O ports etc. and hence can be
embedded on a single chip.

14
Data Representation
 In assembly language the use of the binary and
hexadecimal numbering systems are crucial in order to
represent the data and memory locations/address.
 Understanding numbering systems is important because
their use simplifies complex topics including Boolean
algebra and logic design, signed numeric representation,
character codes.
Numbering System

Microprocessor Signal

CPU consists of transistors operations that deal strictly with two


logic states 0’s (Off) and 1’s (On) on discrete digits that represent
numbers, letters, or symbols.
Binary as a Voltage

Voltages are used to represent logic values:

A voltage present (called Vcc or Vdd) = 1

Zero Volts or ground (called gnd or Vss) = 0

A simple switch can provide a logic high or a logic low.


A Simple Switch
 Here is a simple switch used to provide a logic value:

Vcc Vcc

Vcc, or 1
Gnd, or 0

There are other ways to connect a switch.


Numbering Systems

 A numbering system defines how a number can be represented


using discrete symbols.
 A number can be represented differently in different systems.

 For example, the two numbers 2AH and 42D might be the same
value, but their representations are different.
Numbering System

Binary, Octal, Decimal and Hex digits

System Base Possible digits

Binary 2 01

Octal 8 01234567

Decimal 10 0123456789

Hexadecimal 16 0123456789ABCDEF
Numbering System

Decimal Number System

This system uses the symbols 0 to 9.


It is also called as Base 10 system, because it has 10 different
symbols.

23810 = 2 x 100 + 3 x 10 + 8 x 1
2 x ( 10 x 10) + 3 x 10 + 8 x 1
2 x 102 + 3 x 101 + 8 x 100
Numbering System
 The Decimal (base 10) System
 10 symbols: 0, 1, 2, 3, 4, 5, 6 , 7, 8, 9.
 Each number is a digit (from Latin for finger).

Most significant digit (MSD) & least significant digit (LSD).


Positional value may be stated as a digit multiplied by a power of 10.
Numbering System
Binary Number System
* Uses only Two symbols ( 0, 1)
* Have a Radix of 2 and commonly called the Base 2 number system,
and called a BIT
* A n-bit register bn-1 b n-2….b1 b0 can represent 2n-1 different values
If n =9 then,

b8 b7 b6 b5 b4 b3 b2 b1 b0
MSB LSB

Power of 2
28 27 26 25 24 23 22 21 20

256 128 64 32 16 8 4 2 1 Decimal


Numbering System

 The Binary (base 2) System


 2 symbols: 0,1

Positional value may


be stated as a digit
multiplied by a
power of 2.
Numbering System

Binary
Counting
Numbering System
Conversions
1. Binary to Decimal
1 0 12

22 21 20

4s+ 0s+1s = 4 + 1 = 510

Ex: Convert 11012 to its decimal no.


Numbering System
2. Decimal to Binary

43 / 2 = 21 remainder of 1
LSB

21 / 2 = 10 remainder of 1

10 / 2 = 5 remainder of 0

5 / 2 = 2 remainder of 1

2 / 2 = 1 remainder of 0

MSB
1 / 2 = 0 remainder of 1

4310 = 1 0 1 0 1 1
Ex: Convert 3110 to its binary form.
Numbering System
Binary Arithmetic
1. Binary Addition
Adding two binary numbers are same as addition of decimal
numbers. There are mainly 4 rules should follow in the process of
addition in binary numbers.

Sum Carry
Rule 1 0 + 0=0 0
Rule 2 0 + 1=1 0
Rule 3 1 + 0=1 0
Rule 4 1 + 1=0 1
Numbering System

.
1 1 1
1 0 12 510 1 0 1 12 1110
0 1 02 +210 + 0 1 1 12 0710

1 1 12 710 1 0 0 1 02 1810
Numbering System

2. Binary Subtraction

Minuend(B) Subtrahend(A) Difference Borrow out

Rule 1 0 - 0 = 0
Rule 2 0 - 1 = 1 with a borrow of 1
Rule 3 1 - 0 = 1
Rule 4 1 - 1 = 0

To perform Rule 2 you have to borrow 1 from the next column. The
weight of the binary you borrow will be 2.
Numbering System

0 0-1 cannot perform, so have to


1 1 0 borrow 1 from next column, and
- 1 0 1 perform subtraction. 10-1 = 1
0 0 1

What is left after giving 1 to


previous column
Numbering System

3. Binary Multiplication

 The four basic rules for multiplying bits are as follows:

0x0=0
0x1=0
1x0=0
1x1=1
Numbering System

Ex: Perform the following binary multiplication

1. 11 x 11
2. 101 x 111
Numbering System
Hexadecimal Number System
 Decimal, binary, and hexadecimal numbers
Numbering System
1. Hexadecimal- to -Decimal Conversion
2 B C
Hex. Number

162 X2 161 X B 160 X C


Power of 16

256 X 2 16 X 11 1 X 12 Place Value

512 176 12 Decimal

= 70010
Ex: Convert 102A16 to its decimal form.
Numbering System

2. Decimal to Hexadecimal Conversion

Ex: Convert 413810 to hexadecimal form.


Numbering System
3. Hexadecimal-to-Binary-to-Decimal Conversion

 Hex Binary  Decimal


 Example: 1C16

Hex 0 0 1 C

Bin 0000 0000 0001 1100


215214 213 212 211210 29 28 2726 25 24 2322 21 20
Dec 0 0 24x1 23x1 + 22x1 + 21x0 + 20x0
=0 =0 =16 =8+4+0+0

= 16+12 = 2810
Numbering System
4. Binary to Hexadecimal Conversion

 Break the binary number into 4-bit groups:


 Starting at right-most (MSB)
 Example: 11001010010101112

 Solution: CA5716 or CA57H (H as hexadecimal)

Bin 1100 1010 0101 0111

Hex C A 5 7

Ex: Express the binary number 11111001000010102


Numbering System

Hexadecimal to Binary Conversion

4 7 F E

0100 0111 1111 11102

Binary to Hexadecimal conversion

0001 0010 0110 1100

1 2 6 C16
Numbering System
Adding Hexadecimal numbers.
Following hexadecimal addition table will help you greatly to handle
Hexadecimal addition.
Numbering System

To use this table, simply follow the directions used in this example −
Add A16 and 516. Locate A in the X column then locate the 5 in the Y
column. The point in 'sum' area where these two columns intersect is
the sum of two numbers.

Example 1: A16 + 516 = F16

Example 2: 4A616 + 1B316 = 65916


Numbering System

Add the following hexadecimal numbers

5 6 716 A B C16
A 0 C16 A 1 116
F 7 316 1 4 C D16
Numbering System
Alphanumeric Codes
• ASCII CODE- American standard code for information interchange.
• Information expressed in ASCII codes can also be directly processed by the 8088/86
microprocessor.
• It is being used for most micro computers. ASCII code is 7-bit code.
• Note that there are also another extended-ASCII codes recorded.
• ASCII is used when interfacing computer’s keyboards, printers and video displays.
• Other Alphanumeric codes you may encounter are:
* 7-bit BCDIC- Binary Coded Decimal Interchange code
* 8-bit EBCDIC-Extended Binary Coded Decimal Interchange code
* 7-bit Selectric, used to control the spinning ball in IBM
typewriters.
* 12-bit Hollerith used on punched cards
Numbering System
ASCII Codes
Numbering System
ASCII Codes
Example: Byte addresses 0110016 through 0110416 contain the ASCII
data 01000001, 01010011, 01000011, 01001001, and 01001001,
respectively.What do the data stand for?
Numbering System

Complements of Binary Numbers

 1’s complements
 2’s complements
Numbering System
Complements of Binary Numbers

 1’s complement
Numbering System
Complements of Binary Numbers
 2’s complement
 Once 1’s complement is done, to perform 2’s complement, we just
add the binary equivalent of 1 (0000 0001)
 Useful when we want to express a negative signed numbers Ex: -5
Data Organization
 In pure mathematics a value may take an arbitrary number of
bits.
 Computers work with some specific number of bits.
 Common collections used in Intel 80x86 chips are :

 single bits,
 groups of four bits (called nibbles),
 groups of eight bits (called bytes),
 groups of 16 bits (called words)
Bits
 The smallest “unit” of data on a binary computer
 A single bit represent only two different values
 zero or one (0/1)
 true or false,
 on or off,
 male or female, and
 right or wrong.
 Computer data structures: data is what you define it to be
(program code).
 Bits will play an important role in your programs.
Nibbles
 A group of four bits.
 BCD (binary coded decimal) numbers, hexadecimal numbers.
 It takes four bits to represent a single BCD or hexadecimal
digit.
 Can represent up to 16 distinct values.
 Hexadecimal numbers, the values 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
A, B, C, D, E, and F are represented with four bits.
 BCD uses ten different digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
Bytes
 The most important data structure used by the 80x86
microprocessor.
 Eight bits and is the smallest addressable data item on the
80x86 microprocessor.
 Main memory and I/O addresses are all byte addresses.
 The smallest data length that can be individually accessed by
an 80x86 program.
 Bit 0 is the low order bit or least significant bit, bit 7 is the high
order bit or most significant bit of the byte.
Bytes

Bits 0..3 comprise the low order nibble, bits 4..7 form the high
order nibble. A byte contains exactly two nibbles, byte values
require two hexadecimal digits.
Bytes
 A byte contains eight bits, it can represent 2^8, or 256,
different values.
 Generally, a byte is used to represent numeric values in the
range 0..255, signed numbers in the range -128..+127.
 ASCII/IBM character codes (i.e. 128 defined codes), and
other special data types requiring no more than 256 different
values.
 Many data types have fewer than 256 items so eight bits is
usually sufficient.
 The Boolean values true and false by 00000001B and
00000000B
Words
 A word is a group of 16 bits.

 Bit 0 is the low order bit and bit 15 is the high order bit.
Words
Double Words
 A double word is a pair of words.
 Quantity is 32 bits long
Signed Numbers
 How to represent Negative values and positive numbers in
binary?
 Negative values -128..-1 and the positive values 0..127
with a single eight bit byte.
 16-bit word we can represent values in the range
-32,768..+32,767.
 32-bit double word we can represent values in the range
-2,147,483,648..+2,147,483,647.
Signed Numbers
 80x86 microprocessor uses the two’s complement notation
to present negative numbers.
 In the two’s complement system, the H.O. bit of a number is
a sign bit.
 If the MSB is zero, the number is positive;
 If the MSB bit is one, the number is negative
 For the following 16-bit numbers, determine the sign bit.
 8000h is negative because the MSB is one.
 100h
 7FFFh
 0FFFh
Signed Numbers
Storing signed values:
 If the MSB is zero, then the number is positive and is stored
as a standard binary value.
 If the MSB is one, then the number is negative and is stored
in the two’s complement form.
 For example, to compute the eight bit equivalent of -5:
1. 0000 0101 Five (in binary).
2. 1111 1010 Invert all the bits.
3. 1111 1011 Add one to obtain result.
4. Therefore -5 = 1111 1011
Thank You

You might also like