SEM5
SEM5
1. Introduction:-
1.1. Microcomputer:-
With the development of VLSI & ULSI technology it became possible to build a digital
computer on a single IC. A digital computer build on an IC is called microcomputer or
microcontrollers.
Such computers are used in instrumentation, automatic industrial control, process control,
consumer and home appliance etc.
As it is used for control applications it is also called microcontrollers or embedded
microcontroller. It contains CPU, ROM or EPROM, RAM and I/O lines embedded in it.
Some powerful microcontrollers may contain A/D converters, DMA channels, watch dog
timer, pulse width modulator etc.
Instruction Set − It is the set of instructions that the microprocessor can understand.
Bandwidth − It is the number of bits processed in a single instruction.
Clock Speed − It determines the number of operations per second the processor can
perform. It is expressed in megahertz (MHz) or gigahertz (GHz).It is also known as
Clock Rate.
Word Length − It depends upon the width of internal data bus, registers, ALU, etc. An
8-bit microprocessor can process 8-bit data at a time. The word length ranges from 4 bits
to 64 bits depending upon the type of the microcomputer.
Data Types − The microprocessor has multiple data type formats like binary, BCD,
ASCII, signed and unsigned numbers.
Cost-effective − The microprocessor chips are available at low prices and results its low
cost.
Size − The microprocessor is of small size chip, hence is portable.
Low Power Consumption − Microprocessors are manufactured by using metaloxide
semiconductor technology, which has low power consumption.
Versatility − The microprocessors are versatile as we can use the same chip in a number
of applications by configuring the software program.
1. Accumulator
It is an 8-bit register used to perform arithmetic, logical, I/O & LOAD/STORE operations. It is
connected to internal data bus & ALU.
As the name suggests, it performs arithmetic and logical operations like Addition, Subtraction,
AND, OR, etc. on 8-bit data.
There are 6 general purpose registers in 8085 processor, i.e. B, C, D, E, H & L. Each register
can hold 8-bit data.
These registers can work in pair to hold 16-bit data and their pairing combination is like B-C,
D-E & H-L.
4. Program counter
It is a 16-bit register used to store the memory address location of the next instruction to be
executed. Microprocessor increments the program whenever an instruction is being executed, so
that the program counter points to the memory address of the next instruction that is going to be
executed.
5. Stack pointer
6. Temporary register
It is an 8-bit register, which holds the temporary data of arithmetic and logical operations.
7. Flag register
It is an 8-bit register having five 1-bit flip-flops, which holds either 0 or 1 depending upon the
result stored in the accumulator.
These are the set of 5 flip-flops −
Sign (S)
Zero (Z)
Auxiliary Carry (AC)
Parity (P)
Carry (C)
Its bit position is shown in the following table −
D7 D6 D5 D4 D3 D2 D1 D0
S Z AC P CY
It is an 8-bit register. When an instruction is fetched from memory then it is stored in the
Instruction register. Instruction decoder decodes the information present in the Instruction
register.
As the name suggests it controls the interrupts during a process. When a microprocessor is
executing a main program and whenever an interrupt occurs, the microprocessor shifts the
control from the main program to process the incoming request. After the request is completed,
the control goes back to the main program.
There are 5 interrupt signals in 8085 microprocessor: INTR, RST 7.5, RST 6.5, RST 5.5,
TRAP.
It controls the serial data communication by using these two instructions: SID (Serial input
data) and SOD (Serial output data).
The content stored in the stack pointer and program counter is loaded into the address buffer
and address-data buffer to communicate with the CPU. The memory and I/O chips are
connected to these buses; the CPU can exchange the desired data with the memory and I/O
chips.
Data bus carries the data to be stored. It is bidirectional, whereas address bus carries the location
to where it should be stored and it is unidirectional. It is used to transfer the data & Address I/O
devices.
3. Pin diagram of 8085 Microprocessor:-
The following image depicts the pin diagram of 8085 Microprocessor
Fig: Pin diagram of 8085 microprocessor
The pins of a 8085 microprocessor can be classified into seven groups −
AD7-AD0, it carries the least significant 8-bit address and data bus.
These signals are used to identify the nature of operation. There are 3 control signal and 3 status
signals.
Three control signals are RD, WR & ALE.
RD − This signal indicates that the selected IO or memory device is to be read and is
ready for accepting data available on the data bus.
WR − This signal indicates that the data on the data bus is to be written into a selected
memory or IO location.
ALE − It is a positive going pulse generated when a new operation is started by the
microprocessor. When the pulse goes high, it indicates address. When the pulse goes
down it indicates data.
Three status signals are IO/M, S0 & S1.
3.4. IO/M
This signal is used to differentiate between IO and Memory operations, i.e. when it is high
indicates IO operation and when it is low then it indicates memory operation.
3.5. S1 & S0
There are 2 power supply signals − VCC & VSS. VCC indicates +5v power supply and VSS
indicates ground signal.
Interrupts are the signals generated by external devices to request the microprocessor to perform
a task. There are 5 interrupt signals, i.e. TRAP, RST 7.5, RST 6.5, RST 5.5, and INTR. We will
discuss interrupts in detail in interrupts section.
INTA − It is an interrupt acknowledgment signal.
RESET IN − This signal is used to reset the microprocessor by setting the program
counter to zero.
RESET OUT − This signal is used to reset all the connected devices when the
microprocessor is reset.
READY − This signal indicates that the device is ready to send or receive data. If
READY is low, then the CPU has to wait for READY to go high.
HOLD − This signal indicates that another master is requesting the use of the address
and data buses.
HLDA (HOLD Acknowledge) − It indicates that the CPU has received the HOLD
request and it will relinquish the bus in the next clock cycle. HLDA is set to low after
the HOLD signal is removed.
There are 2 serial signals, i.e. SID and SOD and these signals are used for serial
communication.
SOD (Serial output data line) − The output SOD is set/reset as specified by the SIM
instruction.
SID (Serial input data line) − The data on this line is loaded into accumulator whenever a
RIM instruction is executed.
These are the instructions used to transfer the data from one register to another register, from
the memory to the register, and from the register to the memory without any alteration in the
content. Addressing modes in 8085 is classified into 5 groups
4.1. Immediate addressing mode
In this mode, the 8/16-bit data is specified in the instruction itself as one of its operand. For
example: MVI K, 20F: means 20F is copied into register K.
In this mode, the data is copied from one register to another. For example: MOV K, B: means
data in register B is copied to register K.
In this mode, the data is directly copied from the given address to the register. For
example: LDB 5000K: means the data at address 5000K is copied to register B.
In this mode, the data is transferred from one register to another by using the address pointed by
the register. For example: MOV K, B: means data is transferred from the memory address
pointed by the register to the register K.
This mode doesn’t require any operand; the data is specified by the opcode itself. For
example: CMP.
5. Interrupts in 8085
Interrupts are the signals generated by the external devices to request the microprocessor to
perform a task. There are 5 interrupt signals, i.e. TRAP, RST 7.5, RST 6.5, RST 5.5, and INTR.
Interrupt are classified into following groups based on their parameter −
Vector interrupt − In this type of interrupt, the interrupt address is known to the
processor. For example: RST7.5, RST6.5, RST5.5, TRAP.
Non-Vector interrupt − In this type of interrupt, the interrupt address is not known to
the processor so, the interrupt address needs to be sent externally by the device to
perform interrupts. For example: INTR.
Maskable interrupt − In this type of interrupt, we can disable the interrupt by writing
some instructions into the program. For example: RST7.5, RST6.5, RST5.5.
Non-Maskable interrupt − In this type of interrupt, we cannot disable the interrupt by
writing some instructions into the program. For example: TRAP.
Software interrupt − In this type of interrupt, the programmer has to add the
instructions into the program to execute the interrupt. There are 8 software interrupts in
8085, i.e. RST0, RST1, RST2, RST3, RST4, RST5, RST6, and RST7.
Hardware interrupt − There are 5 interrupt pins in 8085 used as hardware interrupts,
i.e. TRAP, RST7.5, RST6.5, RST5.5, INTA.
Note − NTA is not an interrupt, it is used by the microprocessor for sending acknowledgement.
TRAP has the highest priority, then RST7.5 and so on.
A small program or a routine that when executed, services the corresponding interrupting source
is called an ISR.
5.2. TRAP
It is a non-maskable interrupt, having the highest priority among all interrupts. Bydefault, it is
enabled until it gets acknowledged. In case of failure, it executes as ISR and sends the data to
backup memory. This interrupt transfers the control to the location 0024H.
5.3. RST7.5
It is a maskable interrupt, having the second highest priority among all interrupts. When this
interrupt is executed, the processor saves the content of the PC register into the stack and
branches to 003CH address.
It is a maskable interrupt, having the third highest priority among all interrupts. When this
interrupt is executed, the processor saves the content of the PC register into the stack and
branches to 0034H address.
5.6. INTR
It is a maskable interrupt, having the lowest priority among all interrupts. It can be disabled by
resetting the microprocessor.
When INTR signal goes high, the following events can occur −
The microprocessor checks the status of INTR signal during the execution of each
instruction.
When the INTR signal is high, then the microprocessor completes its current instruction
and sends active low interrupt acknowledge signal.
When instructions are received, then the microprocessor saves the address of the next
instruction on stack and executes the received instruction.
6. Instruction Sets:-
Instruction sets are instruction codes to perform some task. It is classified into five categories.
6.1. Control instruction
6.2. Logical instructions
6.3. Branching instructions
6.4. Arithmetic instructions
6.5. Data-transfer instructions
6.1. Control instruction:-
Opcode Operand Meaning Explanation
Halt and enter The CPU finishes executing the current instruction
HLT None
wait state and stops further execution. An interrupt or reset is
necessary to exit from the halt state.
DI None Disable The interrupt enable flip-flop is reset and all the
interrupts interrupts are disabled except TRAP.
EI None Enable The interrupt enable flip-flop is set and all the
interrupts interrupts are enabled.
Compare the
R The contents of the operand (register or memory)
CMP register or memory
are M compared with the contents of the
M with the
accumulator.
accumulator
Compare immediate
The second byte data is compared with the contents
CPI 8-bit data with the
of the accumulator.
accumulator
Logical AND
R The contents of the accumulator are logically AND
register or memory
ANA with M the contents of the register or memory, and
M with the
the result is placed in the accumulator.
accumulator
Exclusive OR
R The contents of the accumulator are Exclusive OR
register or memory
XRA with M the contents of the register or memory, and
M with the
the result is placed in the accumulator.
accumulator
RLC None Rotate the Each binary bit of the accumulator is rotated left by
one position. Bit D7 is placed in the position of D0
accumulator left as well as in the Carry flag. CY is modified
according to bit D7.
JP Jump on S=0
positive
JM Jump on S=1
minus
JZ Jump on Z=1
zero
CP Call on S=0
positive
CM Call on S=1
minus
RC Return on CY=1
Carry
RST 0 0000H
RST 1 0008H
RST 2 0010H
RST 3 0018H
RST 4 0020H
RST 5 0028H
RST 6 0030H
RST 7 0038H
The 8085 has additionally 4
interrupts, which can
generate RST instructions
internally and doesn’t
require any external
hardware. Following are
those instructions and their
Restart addresses −
Interrupt Restart
Address
TRAP 0024H
Registers in 8085:
(a) General Purpose Registers –
The 8085 has six general-purpose registers to store 8-bit data; these are identified as- B, C, D, E, H,
and L. These can be combined as register pairs – BC, DE, and HL, to perform some 16-bit
operation. These registers are used to store or copy temporary data, by using instructions, during
the execution of the program.
(b) Specific Purpose Registers –
Accumulator:
The accumulator is an 8-bit register (can store 8-bit data) that is the part of the arithmetic
and logical unit (ALU). After performing arithmetical or logical operations, the result is
stored in accumulator. Accumulator is also defined as register A.
Flag registers:
The flag register is a special purpose register and it is completely different from other
registers in microprocessor. It consists of 8 bits and only 5 of them are useful. The other three
are left vacant and are used in the future Intel versions.These 5 flags are set or reset (when
value of flag is 1, then it is said to be set and when value is 0, then it is said to be reset) after
an operation according to data condition of the result in the accumulator and other registers.
The 5 flag registers are:
1. Sign Flag: It occupies the seventh bit of the flag register, which is also known as the
most significant bit. It helps the programmer to know whether the number stored in
the accumulator is positive or negative. If the sign flag is set, it means that number
stored in the accumulator is negative, and if reset, then the number is positive.
2. Zero Flag:: It occupies the sixth bit of the flag register. It is set, when the operation
performed in the ALU results in zero(all 8 bits are zero), otherwise it is reset. It helps
in determining if two numbers are equal or not.
3. Auxiliary Carry Flag: It occupies the fourth bit of the flag register. In an arithmetic
operation, when a carry flag is generated by the third bit and passed on to the fourth
bit, then Auxiliary Carry flag is set. If not flag is reset. This flag is used internally for
BCD(Binary-Coded decimal Number) operations.
Note – This is the only flag register in 8085 which is not accessible by user.
4. Parity Flag: It occupies the second bit of the flag register. This flag tests for number
of 1’s in the accumulator. If the accumulator holds even number of 1’s, then this flag
is set and it is said to even parity. On the other hand if the number of 1’s is odd, then
it is reset and it is said to be odd parity.
5. Carry Flag: It occupies the zeroth bit of the flag register. If the arithmetic operation
results in a carry(if result is more than 8 bit), then Carry Flag is set; otherwise it is
reset.
(c) Memory Registers –
There are two 16-bit registers used to hold memory addresses. The size of these registers is 16 bits
because the memory addresses are 16 bits. They are :-
Program Counter: This register is used to sequence the execution of the instructions. The
function of the program counter is to point to the memory address from which the next byte
is to be fetched. When a byte (machine code) is being fetched, the program counter is
incremented by one to point to the next memory location.
Stack Pointer: It is used as a memory pointer. It points to a memory location in read/write
memory, called the stack. It is always incremented/decremented by 2 during push and pop
operation.
Example –
Here two binary numbers are added. The result produced is stored in the accumulator. Now lets
check what each bit means. Refer to the below explanation simultaneously to connect them with
the example.
Sign Flag (7th bit): It is reset(0), which means number stored in the accumulator is
positive.
Zero Flag (6th bit): It is reset(0), thus result of the operations performed in the ALU is
non-zero.
Auxiliary Carry Flag (4th bit): We can see that b3 generates a carry which is taken by b4,
thus auxiliary carry flag gets set (1).
Parity Flag (2nd bit): It is reset(0), it means that parity is odd. The accumulator holds odd
number of 1’s.
Carry Flag (0th bit): It is set(1), output results in more than 8 bit.
8. Multiplexing and de multiplexing of address/data bus:
Let us consider the instruction to be executed as “MOV A, C”. Here in this case the value of
8 bit in the register C must be moved to the register. The given set of registers namely B, C, D,
E, H, and L must be connected to the internal bus by means of a multiplexer (many input but
only one output) or demultiplexer the reverse of multiplexer. The register meant to carry the
work selects the specific unit and sends the appropriate code to the multiplexer such that the
contents of register C are sent out to the multiplexer through the internal bus. The data from the
internal bus is thereafter received by the Accumulator.
Let us consider the entire execution process of the given instruction “MOV D, A”. Here in
this case, the bit value of the Accumulator gets moved to the register D. The bit value of 8 is sent
to the accumulator. The registers B, C, D, E, H, and L are connected to the internal bus through a
multiplexer/demultiplexer. The given register selects the unit for the appropriate code to the
demultiplexer such that the register named D receives all the contents from the internal bus to the
demultiplexer. Actually the basic concept lies in the fact that in the multiplexer many inputs
merges to form one output. Whereas the reverse process is applicable for the demultiplexer.
Hence in the address buffer we find The operations of arithmetic and logical sequence carried
out involves two operands, among which one is operand is provided by the accumulator, and the
other operand is provided by the Temp register. For example, in the addition process the
instruction to the B register, all the contents are deliberately moved to the Temp register and then
ultimately the Arithmetic Logical Unit performs the addition of register A and Temp register. In
similarity with the W and Z.
9. Priority concept:-
9.1. TRAP
It is a non-maskable interrupt, having the highest priority among all interrupts. Bydefault, it is
enabled until it gets acknowledged. In case of failure, it executes as ISR and sends the data to
backup memory. This interrupt transfers the control to the location 0024H.
9.2. RST7.5
It is a maskable interrupt, having the second highest priority among all interrupts. When this
interrupt is executed, the processor saves the content of the PC register into the stack and
branches to 003CH address.
It is a maskable interrupt, having the third highest priority among all interrupts. When this
interrupt is executed, the processor saves the content of the PC register into the stack and
branches to 0034H address.
It is a maskable interrupt. When this interrupt is executed, the processor saves the content of the
PC register into the stack and branches to 002CH address.
9.5. INTR
It is a maskable interrupt, having the lowest priority among all interrupts. It can be disabled by
resetting the microprocessor.
When INTR signal goes high, the following events can occur −
The microprocessor checks the status of INTR signal during the execution of each
instruction.
When the INTR signal is high, then the microprocessor completes its current instruction
and sends active low interrupt acknowledge signal.
When instructions are received, then the microprocessor saves the address of the next
instruction on stack and executes the received instruction.
Unit 2
Memory