Upload
mohamed-nabil
View
225
Download
0
Embed Size (px)
Citation preview
8/11/2019 AR Lecture2
1/15
ECE 2211
Microprocessor and Interfacing
Br. Athaur Rahman Bin Najeeb
Room 2.105
Email: [email protected]: http://eng.iiu.edu.my/~athaur
Consultation : Tuesday 10.00 am ( appointment)
The Basics
BASICS:
Terms and terminology
Used in this course
8/11/2019 AR Lecture2
2/15
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 byteor 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
8/11/2019 AR Lecture2
3/15
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/OOperation
Reading or writing - transmitting or Receiving( from MP )
Faster processing means more data bus, but more expensive, designconsideration, 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 totransmitted over the address bus
MP selects particular address for reading/writing ( identify the memory or I/O addressthe 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 ?
.
x2
8/11/2019 AR Lecture2
4/15
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 8088processors the address and databuses are multiplexed.same pins are used to carry bothaddress and data information atdifferent times during the read orwrite cycle. At the start of the cycle theaddress/data bus carries theaddress signals, while at the endof the cycle the pins are used for
the data bus.
How MP difference it ?
Bus Standard
8/11/2019 AR Lecture2
5/15
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
126 + 125 + 124 + 123 + 022 + 121 + 120
= 164 + 132 + 116 + 18 + 04 + 12 + 11
= 123
8/11/2019 AR Lecture2
6/15
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
102
202
302
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 greaterthan 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 takethe corresponding positive number, invert all the bits, and add 1
8/11/2019 AR Lecture2
7/15
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 signedor unsignedarithmetic:
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 aresimplifed to hexa
MOV AX , 1234 has 6 HEXADIGITS ;
1670A
7B
7161 + 11160 = 123
8/11/2019 AR Lecture2
8/15
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 13 / 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 HexaConverting (123)10 into hex 123 16 = 7 remainder 11 (or B)
7/ 16 = 0 remainder 7
Answer : 123(D) = 7B(H)
BCD: Binary Coded DecimalsEach 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.
8/11/2019 AR Lecture2
9/15
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 PointOk, have you ever thought how floating points are
stored in computers ?
Or how about complex numbers ?
8/11/2019 AR Lecture2
10/15
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" inFortran. This occupies 64 bits (8 bytes) and has a significand precision of 53 bits
(about 16 decimal digits).
-352410X8.976910X5.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
8/11/2019 AR Lecture2
11/15
IEEE Precision standard - I
3 components in IEEE Floating Pointrepresentation:
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
8/11/2019 AR Lecture2
12/15
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 i n 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 Byte0Base Address+1 Byte1
Base Address+2 Byte2Base 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
8/11/2019 AR Lecture2
13/15
8/11/2019 AR Lecture2
14/15
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 'readout of memory' and placed on the data bus
The instruction is held in the instructionregister whilst it is decoded into a signalthat goes to the control circuitry. This thencarries out the instruction.
Let us suppose the instruction was to load anumber stored in memory into theaccumulator.
The program counter increments to 00000001 the contents of this address areplaced on the data bus and the controlcircuitry loads this into the accumulator.
Example
8/11/2019 AR Lecture2
15/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