You are on page 1of 15

1

ECE 2211
Microprocessor and Interfacing
Br. Athaur Rahman Bin Najeeb
Room 2.105
Email: athaur@iium.edu.my
Website: http://eng.iiu.edu.my/~athaur
Consultation : Tuesday 10.00 am ( appointment)
The Basics
BASICS:
Terms and terminology
Used in this course
2
Bus
a bus is a set of wires; conductors. Basically its subsystem that transfers data
between MP and other component [ memory, peripheral devices ]
Collection of electronic signal dedicated to particular task.
1 bus = 1 wire ; The size of the bus is the number of wires in the bus
parallel data communication path over which information is transferred a byte
or word at a time
8 bit bus has 8 parallel bus / 16bit bus has 16 parallel wires , 32, 64,
The busses contains logic that MP controls: data transfer, instructions,
commands
Signal flow between of a bus can be UNIDIRECTIONAL or BIDIRECTIONAL
Bus - Types
All computers use three types of basic buses. The name of the bus is generally
determined by the type of signal it is carrying or the method of operation
Types:
ADDRESS BUS
DATA BUS
CONTROL BUS
3
Data Bus ( Memory Bus)
handles the transfer of all data and instructions
Its Bi-directional but data can only transmit in one direction at a time
Typical operations are
- transfer instructions from memory to the MP for execution.
- It carries data (operands) to and from the MP
- transfer data between memory and I/O devices during I/O
Operation
Reading or writing - transmitting or Receiving( from MP )
Faster processing means more data bus, but more expensive, design
consideration, heat dissipation, processor speed
Address Bus
An address is defined as labels ( set of characters in hexa) to designate a location of
a memory or I/O
Before an instruction ( Mem or I/O operations ) to take place, an address is to
transmitted over the address bus
MP selects particular address for reading/writing ( identify the memory or I/O address
the MP would like to communicate with )
Unidirectional Bus , the MP transmit the add
A MP with x-bit address bus corresponds to addresses of memory location
Ex : 8088 / 8086 has 20 bit address bus .. What is the maximum memory ?
Pentium 4 has 4G of Main memory .. How many address line it has ?
.
x
2
4
Control Bus
How do we know the address on Address bus is memory address or I/O address ? We can
have
Memory Read , Memory Write
I/O read , I/O write
Its a unidirectional bus
Controlled over Control signals provided by the MP
MULTIPLEXED BUS
On both the 8086 and 8088
processors the address and data
buses are multiplexed.
same pins are used to carry both
address and data information at
different times during the read or
write cycle.
At the start of the cycle the
address/data bus carries the
address signals, while at the end
of the cycle the pins are used for
the data bus.
How MP difference it ?
Bus Standard
5
Numbering System
Decimal ( base10) - 8(10),
Numbers- 0,1,2,3,4,5,6,7,8,9
Binary (base2) 1100(2)
Numbers- 0 and 1
Hexadecimal (base16) A8(16) /A8(H)
Numbers- 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
Binary Numbers
Bit is a binary digit that can have the value 0 or 1. Base 2
Binary numbers are used to store both instruction and data
Address, Data , Signal are transmitted in binary
ALU performs calculation in binary
Instructions are converted to MACHINE CODES ,
binary numbers EX : MOV AX, BX

.
MSB
LSB
1111011
12
6
+ 12
5
+ 12
4
+ 12
3
+ 02
2
+ 12
1
+ 12
0
= 164 + 132 + 116 + 18 + 04 + 12 + 11
= 123
6
Binary Numbers Terms
A byte is defines as 8 bits
A nibble is half a byte
A word is 2 bytes
A doubleword is 2 words
A doubleword is 4 bytes
A quadword is 2 doublewords
A kilobyte is bytes, that is 1,024 bytes
A megabyte is bytes, that is 1,048,576 bytes
A gigabyte is bytes that is 1,073,741,824 bytes
10
2
20
2
30
2
Signed Numbers
Unsigned numbers / Signed numbers
One byte (eight bits) can be used to represent the decimal number range
0 to 255 (unsigned)
-128 to 127 (signed)
Negative binary numbers are formed by subtracting from a number one greater
than the maximum possible (i.e 2^n or 256 for a byte)
For example,
123(D) = 01111011 (B)
-123(D) = 10000101(B) = 133(D) = (256-123)(D)
To form a two's complement number that is negative you simply take
the corresponding positive number, invert all the bits, and add 1
7
Find 8 bit signed binary numbers for -35(D) ? Use direct method and 2s
complement
35(D) = 0010 0011(B)
invert -> 1101 1100(B) add 1 -> 1101 1101(B)
Golden Question:
So how can you tell the difference between:
-123(D)= 10000101(B)
and
133(D) = 10000101(B)
You cant unless you know whether youre using signed or unsigned arithmetic:
Hexadecimal Numbers
Base of 16
Six digits, 0 9 ; A F for ten fifteen
Example 70A(H) or
Convenient representation of long binaries : A series of 0,1 are
simplifed to hexa
MOV AX , 1234 has 6 HEXADIGITS ;
16
70A
7B
716
1
+ 1116
0
= 123
8
Conversion : Decimal to Binary
Example Converting (123)
10
into binary :
Division method
123 / 2 = 61 remainder 1
61 / 2 = 30 remainder 1
30 / 2 = 5 remainder 0
15 /2 = 7 remainder 1
7 /2 = 3 remainder 1
3 / 2 = 1 remainder 1
1 /2 = 0 remainder 1
Least significant bit
(rightmost)
Most significant bit
(leftmost)
Answer : (123)
10
= (1111011)
2
Conversion : Decimal to Hexa
Converting (123)10 into hex
123 16 = 7 remainder 11 (or B)
7 / 16 = 0 remainder 7
Answer : 123(D) = 7B(H)
BCD: Binary Coded Decimals
Each group of four binary bits maps on to a single hex digit. CPU uses BCD
0111 1011
7 B
1011 1001 0110 1111 1010
B 9 6 F A
E.g.
9
ASCII Characters
Computers can only understand numbers :0, 1 ..
Then, how characters such as A, a , or @ is represented ?
Binary patterns are assigned to represent letters and characters
ASCII stands for American Standard Code for Information Interchange (1960)
It represent numerical numbers ( 0 9 ), alphabets ( LC , UC), symbols
Well accepted by all manufacturers
7 bit representation, 0 -> MSB : 8 bit code
ASCII Tables : see internet
A: 41(H)
a: 61(H)
Can you write a C program to convert to ACSII numbers ?
Father of Floating Point
Ok, have you ever thought how floating points are
stored in computers ?
Or how about complex numbers ?
10
Fractional representation
Fixed point representation; Limits
Floating point representation: High Precisions : very large or very small numbers
Ex:
One well accepted standard: IEEE Floating point representation
IEEE Single Precision
called "float" in the C language family, and "real" or "real*4" in Fortran. This occupies 32
bits (4 bytes) and has a significand precision of 24 bits (about 7 decimal digits).
IEEE Double Precision
called "double" in the C language family, and "double precision" or "real*8" in
Fortran. This occupies 64 bits (8 bytes) and has a significand precision of 53 bits
(about 16 decimal digits).
-35 24
10 X 8.9769 10 X 5.675 or
Assignment No. 2
1) Write abt IEEE SP / DP
2) Hand written only
3) Elucidate (1) with 2 examples each
4) How complex is represented in IEEE single precision or double precision
5) Due Date: 12/5/2008
11
IEEE Precision standard - I
3 components in IEEE Floating Point
representation:
a) Sign bit
0 denotes a positive
number;
1 denotes a negative
number..
b) Exponents
represent both positive and negative exponents.
To do this, a bias is added to the actual exponent in order to get the stored exponent.
For IEEE single-precision floats, this value is 127.
- A stored value of 200 indicates an exponent of (200-127), or 73
For double precision, the exponent field is 11 bits, and has a bias of 1023.
c) Mantissa
The mantissa, also known as the significand, represents the precision bits of the number
12
Little Endian and Big Endian
We have seen how numbers are represented in UP. How are they stored ?
"Little Endian"
low-order byte of the number is stored in memory at the lowest address, and the high-order byte at
the highest address. (The little end comes first.)
For example, a 4 byte LongInt :
Byte3 Byte2 Byte1 Byte0
will be arranged in memory as follows
Base Address+0 Byte0
Base Address+1 Byte1
Base Address+2 Byte2
Base Address+3 Byte3
"Big Endian"
means that the high-order byte of the number is stored in memory at the lowest address, and
the low-order byte at the highest address. (The big end comes first.)
Example of big endian : Sun machine, Adobe potoshop, Motorola
Example
13
Microprocessor - General architecture
and components
Components (resources ) in a UP
1) Arithmetic Logic Unit
Perform the arithmetic function such as add,
subtract, multiply and divide , AND, OR, NOT
2) Register
Temporary storage, it could contain any info.
8 bit, 16 bit, 32 bit, 6bit
Determines bits of a UP, ex, 16 bit UP has 16 bit
internal register.
Bigger the register, better the CPU
3) Program Counter
Function: point to the address of next instruction to
be executed Once each instruction is executed,
the PC is incremented to address of next
instruction. It the content of PC is placed on
address bus to find /fetch next instruction. In IBM
PC, its known as Instruction Pointer
4) Instruction Decoder
Interpret the instruction fetched into
the MP
dictionary? Store the meaning and
what to do
How does a MP work
A microprocessor needs a set of instructions to follow that tell it what
operations to perform on what data
These instructions are stored sequentially in the memory of the system
The microprocessor fetches the first instruction from a designated area in
its memory, decodes it and executes the specified operation
This sequence of fetch, decode and execute is continued indefinitely until
the microprocessor reaches an instruction to stop.( Bus cycle )
During this process, the microprocessor uses the system bus to fetch the
binary instructions and data from memory
It uses registers for temporary storage of data and results
It performs the computing operations on the data in the ALU
And it sends out the results in binary, by using the same bus lines, to the
output unit or back into memory
14
Little deeper
One BUS CYCLE
The content of program counter initially
0000 0000 is placed on the address bus.
The instruction in this first address is 'read
out of memory' and placed on the data bus
The instruction is held in the instruction
register whilst it is decoded into a signal
that goes to the control circuitry. This then
carries out the instruction.
Let us suppose the instruction was to load a
number stored in memory into the
accumulator.
The program counter increments to 0000
0001 the contents of this address are
placed on the data bus and the control
circuitry loads this into the accumulator.
Example
15
Program counter can have value between 0000 (h) FFFF (h)
PC value is loaded with 1400(h) , the starting address. MP is ready for execution
MP puts the values 1400 on address bus [ Read signal in on ] . PC is incremented
Content of 1400(H) is put B0(H) on data bus and send to MP
Instruction decoder decodes BO(H) - instruction is to bring 21H from address in PC.
All other registers are locked except register A
PC is set to 1402(H)
And this continues

You might also like