Notes
Notes
CS250
1
Microprocessor is a processor (cpu) that is contained on a single silicon chip.
Intel 4004: the world’s first microprocessor developed by Intel Corporation in 1971.
- 4-bit cpu
- 4096 4-bit memory locations
- 45 instructions
- Speed: 50k 1ps (instructions per second)
Other Intel Microprocessors
1) 8008 (later in 1971): and extended 8-bit version of 4004, memory size: 16k bytes, 48
instructions, 50k 1ps.
2) 8080 (1973): 8-bit cpu, 64k byte memory, 500k 1ps.
3) 8088/8086 (1977,1978): 16bit cpu, 1M byte memory, 2.5M 1ps.
4) 80186: a similar version of 8086, it has more instructions.
5) 80286 (1983): an extended 16M-byte memory of 8086, 8MHz cpu, 4M 1ps.
6) 80386 (1986): fully 32-bit cpu, up to 4G byte memory, hardware memory
management and memory assignment. Pipelined instruction execution, 33M 1ps.
7) 80486 (DX, SX) (1989): an improvement of 80386, 50M 1ps, with built-in math
processor (for floating-point and extended-precision number operations)
8) Pentium (1993): P5 or 80586, 60-133M2, 16k cache, 4G memory, 2 integer units.
9) Pentium with MMX
10) Pentium Pro (1995): P6, 150-166 M2, 16k cache, 156k-second level cache, three
integer units.
11) Pentium 4
12) …
2
that 8088 uses 8 dada lines in its data bus while 8086 uses 16 data lines in its data bus.
Whenever an instruction calls for an arithmetic or logical function, the EU passes the data to
Arithmetic and Logic Unit together with a command telling the ALU what to do with the data.
The EU then accepts the resulting data from the ALU and sees to it that it is stored into correct
location (register or memory), as designated by the instruction.
3
result is too big to be stored in a byte or word. The EU checks the status of those Flag bits
whenever executing conditional jump instructions.
Memory
Up to one megabyte of system memory, including that which is on the system board, the
video adapter card, and any add-on memory boards.
Timer chip
Generates an external interrupt every fifty-five milliseconds to allow the PC to keep track
of real time (system data and time).
8259 Interrupt Controller chip
Processes hardware (external) interrupts.
6845 CRT Controller
Located on the video adapter card. Controls the video signals to the monitor.
NEC D765 or Intel 8272 Floppy Disk Controller
Located on the disk adapter card. Acts as an interface between the processor and the disk
drive.
Inter 8237 Direct Memory Access (DMA) Controller
Located on the system board. Used by the disk controller to transfer data between disk
and memory.
4
8250 Asynchronous Communications Element or Universal Asynchronous
Receiver/Transmitter (UART)
Located on each serial communications adapter card (COM1, COM2, etc.).
2.6.2 System Bus: is a series of conductive traces of signal lines on the system board, which is
used to communicate between 8086/8088 (cpu) and all other devices.
System bus
To read from memory, for example, the Bus Interface Unit puts the correct memory address onto
the Address Bus and puts the command to read from memory onto the Control Bus. All devices
connected to the bus see this address and command simultaneously, but only the memory-control
circuitry respond to it. The memory-control circuitry is then responsible for decoding the
address, retrieving the data from the appropriate memory chips, and placing the data onto the
Data Bus for retrieval by the BIU.
To write to memory, the BIU puts the memory address onto the Address Bus, the byte of data
onto the Data Bus, and a command to write data onto memory of the control bus. The memory-
control circuitry decodes the command and the address, retrieves the data from the Data Bus, and
stores it into the correct memory chips. All other circuitry simply ignores the command.
5
Communication with the many special-purpose microprocessors attached to the System Bus is
accomplished through I/O ports. I/O ports are used for the transfer of data between the
8086/8088 processor and the other support hardware within the system. The In and OUT
instructions tell the processor to input or output data through the I/O ports.
When executing an IN instruction, the BIU puts the I/O port address onto the Address Bus and
puts the command to input data onto the Control Bus. The circuitry on some peripheral device
attacked to the bus recognizes the red command and decodes the I/O port as the address of some
register within the peripheral device. It then retrieves the data from the register and places it onto
the Data Bus from which it is retrieved by the BIU and fed to the Execution Unit within the
processor.
To execute an OUT instruction, the BIU puts the command to output data onto the Control Bus,
and I/O address onto the Address Bus, and the data to be output onto the Data Bus. The circuitry
of a peripheral device is then responsible for recognizing the output command and the I/O
address and for retrieving the data from the data bus.
e.g.
1 1 0 1
bit 3 bit 0
6
e.g.
1 0 1 0 1 1 0 1
bit 7 bit 0
bit 15 bit 0
1 0 1 0 1 1 0 1
bit 15 bit 8
1 0 1 0 1 1 0 1
bit 7 bit 0
Note: in memory, the least significant bye (bits 0-7) is stored in lower numbered memory
location, and the most significant byte (bits 8-15) is stored in the next higher
numbered location.
7
Note: in memory, its 0-7 bits would come first; bits 8-15 would be in the next higher
numbered byte and so on.
3.2 Memory
Computer memory consists of an ordered sequence of storage units (8-bits called bytes), each
with its own address.
8086/8088’s memory is bytes-addressable, which means that each byte has its own
address, e.g. if A is the address of a word (16 bits), then A is actually the address of the
first byte (bits 0-7) of the word, A+1 is the address of the second byte (bits 8-15) of the
word, and A+2 is the address of the next word.
Memory address space: (MAS): 220= 1,048,576= 1M(bytes) (address space: 0—220- 1,
i.e.00000-fffff: in hexadecimal)
Map of the memory address space (MAS)
The whole MAS is organized by a 216 * 24 matrix: there are 216 paragraphs, each of which
with 16 (24) bytes.
Paragraph numbers:
8
Hexadecimal number system
The hexadecimal number system uses sixteen characters to represent umbers:0 through 9
and A through F; A is worth ten, B is worth eleven, …, and F is fifteen. In assembly
program, the hexadecimal will be indicated by the letter h.
Example: 7Fh is the number 127(7*16+15*1) and its equivalent binary number is
01111111b.
The conversion between binary and hexadecimal is simple. To covert from hexadecimal
to binary: just represent each hexadecimal digit by four binary digits: Example: 74Dh =
011101001101b
To convert from binary to hexadecimal: break the binary number into groups of four
digits, and convert each group into one hexadecimal digit:
Example: 101001001110b = A4Fh
Character representation
Each character is represented by a byte or two hexadecimal digits according to ASCII
code.
41h A
42h B
. .
. .
5Ah Z
61h a
62h b
. .
9
. .
7Ah z
30h 0
. .
. .
39h 9
Segment-relative addresses.
1) There are 16 bits in a segment register. The content of the segment register
represents the paragraph number of the paragraph at which it begins.
2) All memory address are formed by segment-relative format which is computed as
follows:
e.g.
CS: 1110000000000000
CS*16: 11100000000000000000 (Beginning of code segment)
IP: 0000000000001101 (offset)
--------------------------------------------------------------------------
CS : IP = 11100000000000001101 (Actual location (absolute
address) in memory)
10
A program stack is a region of memory (RAM), which is defined by the assembly program. The
program stack is implemented by setting the SS (stack segment) register and by initializing the
SP (stack pointer) register to the byte immediately above the top of the sack segment. Data is
moved onto the stack in word- sized units by an operation called a push and retrieved from the
stack in word-sized units by an operation called pop in the reversed order (last in- first out).
A Push operation decrements the SP register twice (-2) and put the word at SS : SP. A Pop
operation retrieves the word at SS: SP and increments the SP register twice (+2)
11
Example: A program stack is to use 100h bytes and SS= 58A1h, A = 1234h and B = 5678h.
Figure 3 shows the “empty” stock, where the initial value of SP register = 100h and the stack
starts at address of 58A10h and ends at address of 58B0Fh (100 bytes). Figure 4 shows the stack
after two Push operations: Push A and Push B, and Figure 5 shows the stack after two Pushes and
one Pop operations (Pop B).
12
Figure 4: Stack after two Pushes
13
4) The instruction pointer register
5) The flag register (status register)
OF IF SF AF PF CF
? ? ? ? ? ? ?
DF TF ZF
1) CF (bit 0): the carry flag.
2) PF (bit 2): the parity flag.
3) AF (bit 4): the auxiliary flag.
4) ZF (bit 6): the zero flag.
5) SF (bit 7): the sign flag.
6) TF (bit 8): the trap flag.
7) IF (bit 9): the interrupt flag.
8) DF (bit 10): the direction flag.
9) OF (bit 11): the overflow flag.
14
Figure 6: Register Map of 8086/8088
15
4) Extra data segment register (ES): points to the beginning of the extra data
AX AH AL
BX BH BL
CH CL
CX
DH DL
DX
15 8 7 0
16
There are two basic stack operations in 8086/8088. a. PUSH (operand) it decreases the SP
by 1 word (2 bytes), then stores a word on the stack e.g. current SP=204. AX=0010.
Execution of PUSH AX will result: SP=204-2=202 and store 0010 at memory location at
address 202. b. POP (operand it removes the top word from the stack, and then add 1
word (2 bytes) to the SP.
The base pointer (BP): BP is also can be used to point to offset within stack segment.
Primarily it is used for base indexed addressing modes.
There are two index registers:
1) Source index register (SI)
2) Destination index register (DI) there is no significance to the words source and
destination, and SI and DI can be used interchangeably. Index registers are used in
the same way subscripts that are used in high-level language. That enable us to
access the elements in an array or table.
17