MPC Kee602 Solution 22-23
MPC Kee602 Solution 22-23
ANS. ALE – It is an Address Latch Enable signal. It goes high during first T state of a machine
cycle and enables the lower 8-bits of the address, if its value is 1 otherwise data bus is activated.
Q1 (b) The content of the accumulator are 93H and contents of register C are B7H. Add
both contents and determine the sign, carry and zero flag status.
ANS. CF=1, SF=0 and ZF=0
Q1 (c) Define the term RISC and CISC.
ANS. In RISC, the instruction set is reduced, and most of these instructions are very primitive,
while in CISC, the instruction set is very large that can be used for complex operations.
• RISC computer’s execution time is very less, whereas CISC computer’s execution time
is very high.
• RISC code expansion may create a problem, while CISC code expansion is not a
problem.
• In RISC, the decoding of instructions is simple, whereas, in CISC, the decoding of
instructions is complex.
• RISC doesn’t require external memory for calculations, but CISC requires external
memory for calculations.
• RISC has multiple registers sets present, while CISC has only a single register set.
ANS. Bit set reset (BSR) mode – This mode is used to set or reset the bits of port C only, and
selected when the most significant bit (D7) in the control register is 0.
ANS.RS-232C is one of the earlier versions of the long-established standard RS-232, which
defines a physical interface for relatively low-speed serial data communication between
computers and related devices. The RS in RS-232C stands for "Recommended Standard," and
the C refers to the version.
Q1 (g) Show the status of CY, AC and P flag after addition of 56H & 95H in the following
instruction.
MVI A, 56H
MVI B, 95H
ADD B
ANS. CY flag=0
AC flag=0
P flag=1
ANS.A microprocessor is a processor where the memory and I/O component are connected
externally. A microcontroller is a controlling device wherein the memory and I/O output
component are present internally. The circuit is complex due to external connection.
Microcontrollers are present on chip memory
ANS. ARM processors are a family of central processing units (CPUs) based on a reduced
instruction set computer (RISC) architecture. ARM stands for Advanced RISC Machine.
ANS.PSW (program status word) register The program status word (PSW) register is an 8-bit
register. It is also referred to as the flag register.
Q2(a) Draw the internal architecture of 8085. Also explain flag register of 8085.
D7 D6 D5 D4 D3 D2 D1 D0
S Z AC P CY
Instruction register and decoder
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.
Timing and control unit
It provides timing and control signal to the microprocessor to perform operations. Following
are the timing and control signals, which control external and internal circuits −
• Control Signals: READY, RD’, WR’, ALE
• Status Signals: S0, S1, IO/M’
• DMA Signals: HOLD, HLDA
• RESET Signals: RESET IN, RESET OUT
Interrupt control
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.
Serial Input/output control
It controls the serial data communication by using these two instructions: SID (Serial input
data) and SOD (Serial output data).
Address buffer and address-data buffer
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.
Address bus and data bus
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.
8085 Architecture
Q2 (b) Draw the pin diagram of 8086 and also discuss about BIU and EU.
An 8086 microprocessor is also a 40 pin IC but has few separate pin configuration for minimum
and maximum mode.
VCC – Pin number 40 – At this pin, the external power supply of + 5V is provided to the
processor.
VSS – Pin number 1 and 20 – These two pins acts as the ground. This pin directs the extra
current of the microprocessor to ground.
AD0 – AD15 – Pin number 2 to 16 and 39 – These are the multiplexed address and data bus.
We know that the 8086 microprocessor has 20-bit address bus and 16-bit data bus. So, the 16
lines of the address and data bus are multiplexed together so as to reduce the number of lines
inside the IC.
We are aware of the fact that at a time either address or data will be transmitted by the bus. So,
at a particular time only either the address or the data bus will be enabled from the multiplexed
buses.
A16/S3, A17/S4, A18/S5 and A19S6 – Pin number 35 to 38 – Out of 20 address bits, 4 are present
in the multiplexed form with the status signals. In the case of memory operations, these pins
act as an address bus and contain the memory address of any particular instruction or data.
However, from I/O operations these pins are low that shows the status of the processor.
Basically, the signal at S3 and S4 show that which segment is currently accessed by the
microprocessor among the four segments present in it.
The table below will show the encoding of S3 and S4:
Also, S5, when enabled, shows the presence of an interrupts in the microprocessor. So,
basically, it serves as an interrupt flag.
The signal at S6 shows the status of the bus master for the current operation. More simply we
can say, whether the 8086 is the bus master or any other proficient device is acting as the bus
master.
When 0 is present as the signal at this pin then it indicates the 8086 is holding the access of the
bus otherwise it is high i.e., 1.
BHE’ / S7 – Pin number 34 – BHE is an acronym for Bus High Enable. The combination of
the BHE signal and S7 status informs about the existence of the data on the bus. Also, different
combinations show whether the bus is containing overall 16 bit, upper byte or lower byte of
the data.
The table below represents the status for the signal at this pin:
MN/MX’ – Pin number 33 –The status at this particular pin shows whether the processor is
operating in the minimum mode or maximum mode.
A signal 0 at this pin informs that the 8086 is operating in maximum mode i.e., multiple
processors. While signal 1 shows the operation under minimum mode i.e., single processor.
RD’ – Pin number 32 – An active low signal at this pin shows that the microprocessor is
performing read operation with either memory or I/O devices.
CLK – Pin number 19 – A signal at this pin provides the timing to the internal operations that
are being executed inside the microprocessor.
NMI – Pin number 17 – NMI is Non-maskable interrupt. These are basically uncontrollable
interrupts generated inside the processor. When an NMI occurs, then an interrupt service
routine is generated by the interrupt vector table.
TEST – Pin number 23 – This pin basically shows the wait instruction. Whenever a low signal
at this pin occurs then the processing inside the processor continues. As against, in case of the
high signal, the processor has to wait for the disabling of this pin.
INTR – Pin number 18 – INTR stands for an interrupt request. The processor after each clock
cycle samples the INTR and if the signal at this pin is found to be high then the processor
controls that interrupt internally.
READY – Pin number 22 – This signal is used by the peripherals and memory devices in
order to show the readiness for the next operation.
RESET – Pin number 21 – Whenever this pin is enabled then it resets the processor and other
devices connected to the system by immediately terminating the recent task.
Pins in Minimum mode
DEN’ – Pin number 26 – DEN is used for data enable. This is an active low pin that means
whenever a 0 is present at this pin then the transceiver gets enabled and it separates the data
from the multiplexed address and data bus.
DT/R’ – Pin number 27 – This pin is used to show whether the data is getting transmitted or
is received. A high signal at this pin provides the information regarding the transmission of
data. While a low indicates reception of data.
M/IO’ – Pin number 28 – This pin indicates whether the processor is performing an operation
with memory or I/O devices. Whenever a high is present at this pin then it shows the operation
is carried out through the memory. While a low signal shows operation through I/O devices.
WR’ – Pin number 29 – An active low signal at this pin indicates that the processor is
performing write operation from either memory or I/O devices.
HOLD – Pin number 31 – When an external device enables this pin then the processor stops
accessing the buses immediately after the recent task gets over.
HLDA – Pin number 30 – This pin is used as a response pin for the hold request. Once request
for accessing the buses is produced by an external entity. Then the microprocessor
acknowledges the device that its request will be considered once it gets over by the current
operation.
Pins in Maximum mode
S0‘, S1‘ and S2‘ – Pin number 26 to 28 – These are basically 3 status pins and are active low.
This means that if the status at all the 3 pins is 0 then it shows that multiple interrupts are to be
handled in maximum mode.
The table below is representing the status of the processor in different combinations:
QS0 and QS1 – Pin number 24 and 25 – These two pins indicate the status of the 6-byte pre-
fetch queue present in the architecture of 8086.
LOCK’ – Pin number 29 –This pin is involved in maximum mode operation. So, basically,
when a single processor is accessing the buses and peripherals then it locks the resources being
used by it. So, that no other entity can access it until the recent processor frees it.
RQ’/ GT0‘ and RQ’/ GT1‘ – Pin number 30 and 31 – Due to the involvement of multiple
processors, these pins indicate the request and grant permission for accessing the buses,
memory and peripherals.
This is the clock input line ignored in slave mode. In master mode, this signal control all int
CLK
and external DMA operations. The data transfer rate depends upon the frequency of this sign
In slave mode, this signal is generated by the address decoder to select the 8237 chi
CS
communication between the CPU and 8237. In master mode, this signal is ignored.
It is an asynchronous input line. This signal clears the command, status, request, and temp
Reset
register and forces 8237 into slave mode.
READY In master mode, this signal is used to add wait states into the DMA cycle.
It is a hold request output line. It is connected to hold the input of the CPU. it is used to re
HRQ
control of the system bus.
Symbol Description
It is a hold acknowledge input line. This signal is generated by the CPU. In response to this s
HLDA
the 8237 gains control of the system bus and enters master mode.
It is an active low bi-directional tristate line. In slave mode, it acts as an input line and is us
IOR read the contents of the 8237 register. In master mode, it acts as an output line. This sign
generated during the DMA cycle to read data from the I/O device.
It is an active low bi-directional tristate line. In slave mode, it acts as an input line and is us
IOW write the contents to the 8237 register. In master mode, it acts as an output line. This sign
generated during the DMA read cycle to write data into the I/O device.
These are bi-directional, address lines. In slave mode, these lines act as input lines, used to s
A0 – A3 one of the registers of 8237. In master mode, the 8237 provides lower bits of memory addre
these lines.
These are tristate address output lines. These lines are tri-stated in slave mode. In master mod
A4 – A7
827 transfers bits of memory addressed on these lines.
It is an active low tristate output line. it is tri-stated in slave mode. In master mode, this sign
MEMR generated during the DMA read cycle or during memory to memory transfer cycle to rea
contents of source memory.
It is an active low tristate output line. it is tri-stated in slave mode. In master mode, this sign
MEMW activated during the DMA write or during the memory-to-memory transfer cycle to write dat
destination memory.
These are bi-directional tristate buffered data lines. In slave mode, these lines are used to tra
DB0 – DB7 data between the CPU and 8237 registers. In master mode, these lines act as address output
The 8237 places a higher byte of address on these lines during DMA cycles.
These are asynchronous DMA channel request lines used by the peripheral. The polarity of
DREQ0 –
signal is programmable i.e. these lines can be used as either active high or active low input. D
DREQ3
must be maintained until the corresponding DACK is activated.
DACK0 – These are DMA acknowledge output lines. The polarity of each line is programmable. The s
DACK3 indicates that the requesting peripheral has been granted for the DMA cycle.
Symbol Description
End of Process: It is an active low bi-directional signal This line is also used to terminate the D
EOP cycle. The DMA cycle can be terminated by pulling‾EOP input low. The 8237 also generat
EOP pulse, when the terminal count for any channel is reached.
The block diagram of the 8237 DMA controller is shown in the below figure. It consists of
logic blocks and internal registers.
There are 12 types of registers in 8237 DMA Controller. It contains 344 bits of internal memory
in the form of registers.
•
Each channel has a 16-bit base word count register.
•
It is a write-only register.
•
It holds the original count value during all DMA cycle i.e. the content of this
register are not updated during DMA transfers.
• When EOP is activated, the 8237 transfers contents of this register into the
current word register in auto initialization mode.
• This register is written along with the current address register during
initialization. The format is the same as the current word register.
5. Command Register
6. Mode Register
7. Request Register
• It is an 8-bit write-only register.
• It is used to request DMA through software. Each channel has a request bit
associated with it in the 4-bit request register.
• Each register bit is set or reset separately under software control The request is
automatically cleared after TC. It is also cleared by external EOC signal.
• This register is cleared by a reset signal.
• In memory-to-memory transfer, the software request for channel 0 should be
set. The format f the request register is shown in the figure below.
8. Mask Register
4. Cascade Mode
Q2 (d) State the features of 8051 and also draw the block diagram of microcontroller.
ANS. Block Diagram of Microcontroller 8051
CPU – The CPU (Central Processing Unit) comprising of ALU (Arithmetic and Logic Units)
and Control units
ALU - Arithmetic and Logic Unit performing the arithmetic and logical operations. These
operations are multiplication, addition, subtraction, logical AND,OR etc. To do these
operations one operand must be in Accumulator, and another may in B register or in general
purpose register. The ALU operation results are mostly placed in A register. Some results are
placed in B register too.
OSC - Oscillator provides clock for controller operation .Crystal oscillator is used for
providing perfect clock and stability. So this microcontroller uses crystal oscillator. For this
purpose, the crystals linked to the pins are used.
INTERRUPT CONTROLLER
Microcontroller operation needs some interrupts. Here mainly five interrupts are used. The
controller controls the operation interrupts. ie some interrupts may be allowed, some others are
disabled and priority assigned and changed. The five interrupts are:
BUS CONTROL
For both Address and data, lower byte address buses are used. The BUS control controls the
BUS usage. There are 3 control signals: PSEN , EA, and ALE. The signals like Program Store
Enable (PSEN), Address Latch Enable (ALE) and External Access (EA), are used for external
memory interfacing.
ON CHIP RAM
The 8051 has 4 kilobyte of inbuilt ROM. It is otherwise called program memory. Usually
program-code is stored in ROM. To store program into ROM, programmer is needed. If more
area is required in ROM, an external ROM may be connected. Maximum of 64kb ROM
memory can be used.
ON CHIP ROM
The 8051 has an inbuilt of 128 byte RAM, some version have 256 byte and are used as data
memory. If the system needs more memory, external RAM may be connected up to 64kb.In
128 byte RAM chip, 00h to 71Fh are the address range .In this range ,00H to 1FH are the
general purpose registers . 20H to 2F are the bit Addressable area and rest of this is byte
addressable .This is used as general purpose scratch pad. In 256 byte RAM chip, another 128
bytes are used for Special Function Registers.
I/O PORTS
There are four IO ports in 8051.These are named as P0, P1, P2, P3.All are bidirectional. Each
port have its address, output driver, latch and input buffer. Each port is output by default.
SERIAL PORT
TXD and RXD are utilised for serial port. Each pin has separate buffer registers na med as
SBUF.
TIMER/COUNTER
There are two types of counter/timer in 8051.These counter/timers are name as Timer/Counter
0 and Timer/Counter 1. Each one can be used as either Timer or Counter. 16 bit timer register
are used for counting in timer operation or counter operation. Clock pulses are counted in Timer
operation and external events are counted in counter operation.
Q2 (e) What do you mean by assembly language programming? What is the function of JUMP
and CALL instruction?
JMP Instruction:
• When it is executed, the microprocessor will store the address of the next
instruction in STACK and the PC is located with a subroutine address.
• 3-byte instruction
• Immediate/Register indirect mode
• 5 MC
• 18 T-States
• No flags are affected
Conditional CALL Instructions:
• In this case, the program is transferred to the subroutine if the condition is met
and this time it requires 5 MC and 18 T-States.
• If the condition is not met then the main program is continued and it requires 2
MC and 9 T-states.
• In this instruction, all flags are used except the AC flag.
The different ways that a microprocessor can access data are referred to as addressing modes.
Addressing Modes of 8085 Microprocessor are :
Another Types of Addressing Modes in 8085 is Register Addressing Mode in 8085 which
specifies the source operand, destination operand, or both to be contained in an 8085 registers.
This results in faster execution, since it is not necessary to access memory locations for
operands.
The Direct Addressing Mode in 8085 specifies the 16 bit address of the operand within the
instruction itself. The second and third bytes of instruction contain this 16 bit address.
In Indirect Addressing Mode in 8085, the memory address where the operand located is
specified by the contents of a register pair.
Example: LDAX B
In Implied Addressing Mode in 8085, opcode specifies the address of the operands.
Example: CMA
Q3(b) Explain the classification of the instruction set of 8085 microprocessor with suitable
examples.
ANS.Introduction of Instruction An instruction is a binary pattern designed inside a
microprocessor to perform a specified function. In another word, we can say An
instruction is a command given task on specified data.
In data transfer, the contents of the source are not destroyed; only the contents of the destination
are changed.
An I/O device can transfer or receive data from the accumulator but not from other registers
(except for the memory-mapped I/O device).
Arithmetic and logical operations are performed with the contents of the accumulator, and the
results are stored in the accumulator.
Any register including memory can be used for increment and decrement.
A program sequence can be changed either conditionally or by testing for given data conditions.
In some instructions, data is implied. Most instructions of this type operate on the content of
the accumulator.
• A one-byte instruction includes the opcode and the operand in the same byte.
• Examples of this type are:
• MOV A, B
• ADD B
• RAL
• CMA, etc.
For 1-byte Instruction:
• The above instructions are 1-byte instructions performing three different tasks.
• In the first instruction, both operand registers are specified.
• In the second instruction, operand B is specified and the accumulator is
assumed.
• Similarly, in the third instruction, the accumulator is assumed to be the implicit
operand.
• These instructions are stored in an 8-bit binary format in memory; each requires
one memory location.
2-byte or 2-word Instruction set of 8085
• In a 2-byte instruction, the 1st-byte specifies the opcode and the 2nd-byte
specifies the operand.
• MVI B, 05
• IN 01 etc.
For 2-byte Instruction:
• Assume the data byte is 32H. The assembly language instruction is written as:
• Mnemonics: MVI A, 32H
• This instruction would require two memory locations to store n memory.
3-byte or 3-word Instruction set of 8085
• In a 3-byte instruction, the 1st byte specifies the opcode, and the following two
bytes specify the 16-bit address such that the 2nd byte is a low order address
and the 3rd-byte is high order address.
• LXI H, 2400H
• LDA 2500H
• JMP 2085H etc.
For 3-byte Instruction:
• This instruction would require three memory locations to store in the memory.
Types of Instruction set of 8085 based on Addressing Modes:
• In this instruction set, the direct address contains the address of operand within
the instruction itself.
• LDA 2600 H
• IN 05
• OUT 07
• STA 2700 H
2.Register Addressing Mode Instruction set of 8085
• In this type of instruction set, operands will be present in the micro -process
registers.
• MOV A, B
• ADD B
• SUB C
3.Register Indirect Addressing Mode Instruction set of 8085
•In this type of instruction, the operands will present in memory (M) and the
address of memory is present register pair.
• It is also called “indirect addressing mode type instruction set”.
• MOV A, M
• ADD M
• LDAX B
4.Immediate Addressing Mode Instruction set of 8085
• In this type, the operand and data are specified within the instruction itself.
• In other words, we can say, this type of instruction has an operand field rather
than an address field.
• MVI A, 25
• ADI 36
5.Implicit Addressing Mode Instruction set of 8085
MOV r, M Register
Move content of
indirect
memory to MOV B, M 7T 2 MC None 1-byte
addressing
[r] ← [M] or register
mode
[r] ←
[[H,L]]
MOV M, r
Register
Move content of
[M] ← [r] or indirect
register to MOV M, C 7T 2 MC None 1-byte
addressing
memory
[[H,L]] ← mode
[r]
LDA
address Load direct
accumulator LDA 2400H addressing 13T 4 MC None 3-byte
[A] ← direct mode
[[address]]
STA address
store direct
accumulator STA 2000H addressing 13T 4 MC None 3-byte
[[address]] direct mode
← [A]
LHLD
address direct
Load H-L pair
direct LHLD 2500H addressing 16T 5 MC None 3-byte
[L] ← mode
[[address]],
[H] ←
[[address +
1]]
SHLD
address
direct
store H-L pair
[[address]] direct SHLD 2500H addressing 16T 5 MC None 3-byte
← mode
[L],[[address
+ 1]] ← [H]
LDAX rp Register
Load
indirect
accumulator LDAX B 7T 2 MC None 1-byte
addressing
[A] ← [[rp]] indirect
mode
STAX rp Register
store
indirect
accumulator STAX D 7T 2 MC None 1-byte
addressing
[[rp]] ← [A] indirect
mode
LXI H ,
2400H
MVI M, data
MVI M, Register
Move
08 indirect
[[H-L]] ← immediate data
addressing 10T 3 MC None 2-byte
[data] or [M] to memory
mode
← [data] HLT
In this group, the data is performed as addition, subtraction, increment (add 1), decrement
(subtract 1), etc.
The arithmetic operations implicitly assume that the content of the accumulator is one of the
operands.
The results of the arithmetic operations are stored in the accumulator, thus the previous content
of the accumulator is altered.
If a subtraction results in a negative number, the answer is in 2’s complement and CY is set.
The instructions INR (Increment) and DCR (Decrement) are special cases of arithmetic
operations.
ADD r
Add register to Register
the ADD B addressing 4T 1 MC All
[A]← [A] + [r] accumulator mode
ADC r
Add register
Register
with carry to
[A]← [A] + [r] ADC D addressing 4T 1 MC All
the
+ [C] mode
accumulator
ADD M
ADC M
ADI data
Add
Immediate
immediate
[A]← [A] + data to the ADI 08H addressing 7T 2 MC All
data mode
accumulator
SUB r Subtract
Register
register from
SUB B addressing 4T 1 MC All
[A]← [A] – [r] the
mode
accumulator
SBB r Subtract
register from Register
[A]← [A] – [r] the SBB B addressing 4T 1 MC All
– [C] accumulator mode
with borrow
SUB M
SBB M
Subtract
[A]← [A] – memory from
Register
[M] – [C] or the SBB M
indirect
7T 2 MC All
addressing
accumulator
[A]← [A] – mode
with borrow
[[H-L]] – [C]
SUI data
Subtract
Immediate
immediate
[A]← [A] – SUI 01H addressing 7T 2 MC All
data from the
data mode
accumulator
INR M
INX rp
Increment the
Register
content of
[rp]← [rp] + register pair by INX D addressing 6T 1 MC None
[0001] mode
1
DCR r
Decrement Register
All except
register DCR D addressing 4T 1 MC
[r]← [r] – [01] CY
content by 1 mode
DCR M
Decimal
Implicit
DAA adjust
DAA addressing 4T 1 MC All
accumulator
mode
after addition
DAD rp
Double Register
[[H-L]]← [[H- addition DAD H addressing 10T 3 MC only CY
L]] + [rp] register pair mode
The instruction set of this group performs AND, OR, EXOR operations, compare, rotate or
take the complement of data in register or memory.
The process of performing logic operations through the software instructions is slightly
different from the hardwired logic.
The sign, zero (and parity) flags are modified to reflect the status of operations. The carry
flag is reset. However, the NOT operation does not affect any flags.
After a logic operation has been performed, the answers are placed in the accumulator replacing
the original content of the accumulator.
The logic operations cannot be performed directly with the content of two registers.
The individual bits in the accumulator can be set or reset using logic instructions.
ANA M
ANI data
AND
Immediate All and
immediate data
[A] ← [A] ∧ ANI 01H addressing 7T 2 MC AC=1,
with the
data mode CY=0
accumulator
ORA r
OR register Register All and
with the ORA B addressing 4T 1 MC AC=0,
[A] ← [A] ∨ [r] accumulator mode CY=0
ORA M
ORI data
OR immediate Immediate All and
[A] ← [A] ∨ data with the ORI 01H addressing 7T 2 MC AC=0,
data accumulator mode CY=0
XRA r
EXOR register Register All and
[A] ← [A] with the XRA B addressing 4T 1 MC AC=0,
” data accumulator mode CY=0
XRA M
XRI data
EXOR
Immediate All and
immediate data
[A] ← [A] ∨ XRI 01H addressing 7T 2 MC AC=0,
with the
data mode CY=0
accumulator
CMA
Complement Implicit
the CMA addressing 4T 1 MC None
[A] → [Ā] accumulator mode
Compare Register
CMP r register with CMP B addressing 4T 1 MC All
accumulator moder
CMP M
Register
Compare
indirect
[A] ← [A] – memory with CMP M 7T 2 MC All
addressing
[M] accumulator
mode
CPI data
Compare
Immediate
immediate data
[A] ← [A] – CMP 01H addressing 7T 2 MC All
with
[data] mode
accumulator
CMC
No flag
Complement
CMC 4T 1 MC except CY
[CS] ← [CS’] the carry status
flag
STC
No flag
Set carry status STC 4T 1 MC
[CS] ← 1 except CY
RLC
Rotate
accumulator
[An+1] ← [An]
left. The Implicit
content of the addressing 4T 1 MC only CY
[Ao] ← [A7] accumulator is mode
rotated left by
[CY] ← [A7] one bit.
RRC
Rotate
accumulator
[An] ← [An+1]
right. The Implicit
content of the RRC addressing 4T 1 MC only CY
[A7] ← [A0] accumulator is mode
rotated right by
[CY] ← [A0] one bit.
Rotate
RAL
accumulator
left through
[An+1] ← [An] carry. The Implicit
content of the RAL addressing 4T 1 MC only CY
[CS] ← [A7] accumulator is mode
rotated left one
bit through
[A0] ← [CS]
carry.
Rotate
RAR
accumulator
right through
[An] ← [An+1] carry. The Implicit
content of the RAR addressing 4T 1 MC only CY
[CS] ← [A0] accumulator is mode
rotated right
one bit through
[A7] ← [CS]
carry.
The Branch Instructions are the most powerful instructions because they allow the
microprocessor to change the sequence of a program, either unconditionally or under certain
test conditions.
These instructions are the key to the flexibility and versatility of a computer.
⇒CALL Instruction:
• It is used in the main program to call a subroutine.
• When a subroutine is called, the contents of PC, which is the address of the
instruction following the CALL instruction, is stored on the stack and the
program execution is transferred to the subroutine address.
Unconditional CALL Instructions:
• When it is executed, the microprocessor will store the address of the next
instruction in STACK and the PC is located with a subroutine address.
• 3-byte instruction
• Immediate/Register indirect mode
• 5 MC
• 18 T-States
• No flags are affected
Conditional CALL Instructions:
• In this case, the program is transferred to the subroutine if the condition is met
and this time it requires 5 MC and 18 T-States.
• If the condition is not met then the main program is continued and it requires 2
MC and 9 T-states.
• In this instruction, all flags are used except the AC flag.
Opcode Operand Description
CPE 16-bit Call subroutine if parity flag is set ( P=1, even parity)
CPO 16-bit Call subroutine if parity flag is reset ( P=0, odd parity)
⇒RETURN Instruction:
• It will change the program sequence from subroutine to the main program.
• 1-byte instruction
• Implicit addressing mode
• 3 MC
• 10 T-states
• No flags are affected.
Conditional RET Instructions:
• In this case, the sequence of the program returns to the main program if the
condition is met and at this time it requires 3 MC and 12 T-States.
• If the condition is not met then the sequence of the program is continued in the
subroutine and it requires 1-MC and 6 T-states.
• In this instruction, all flags are used except the AC flag.
Opcode Operand Description
The stack in an 8085 microprocessor is a group of memory locations in the R/W memory that
is used for the temporary storage of binary information during the execution of the program.
PUSH, POP, SPHL, XHTL are the example of instruction of stack group.
IN, OUT are the example of I/O group.
NOP, EI, D, SIM, RIM, HLT are examples of the machine control groups.
PUSH rp
POP rp
SPHL
Move the Register
content of H-L SPHL addressing 6T 1 MC None
[H-L] → [SP] pair to SP mode
XTHL
Register
[L] → [[SP]] Exchange
indirect
stack top with XTHL 16T 5 MC None
addressing
H-L pair
[H] → [[SP] + 1 mode
]
IN 05
IN Port address
Input to Direct
accumulator addressing 10T 3 MC None
[Accumulator]
[A] ← [Port] from I/O Port mode
← [[05]]
OUT Port OUT 05
Output from
address Direct
the None
accumulator to [[05]] ← addressing 10T 3 MC
[Port] ← [A] [Accumulator] mode
I/O Port
Implicit
HLT Halt HLT addressing 5T 1 MC None
mode
No operation
4(a) Explain minimum and maximum operating modes of 8086 with timing diagram.
Bus Interface Unit is a gate (enhance) interface between peripheral devices and Processor.
Through the bus interface only, processor can send and receive data. The bus interface unit
contains
In 8086 Processor, instruction queue is a 6 byte register used to store permanent data from the
Input/Output (I/O) devices or processor. The queue operates in the principle of First In First
Out (FIFO) principle. i.e., the first data is fetched and that data will be taken out firstly.
ES – Extra Segment
CS – Code Segment
DS – Data Segment
SS – Stack Segment
The maximum memory access of 8086 processor is 1 MB. Each segment has some
predefined functions.
In 8086 processor, each segment has a capacity of 64 KB. So the four segments will store 256
KB of memory locations. The remaining memory locations are free and in these locations,
user can perform any other processes. These four segment registers will keep the base address
of the corresponding segment.
Instruction pointer will give the next address of the instruction to be executed. Instruction
Point cannot be used for other purposes.
Address Generation:
The I/O processor can receive data from the memory only, if that data should goes out
through the address generation.
AX, BX, CX, DX, SP, BP, SI, DI are General Purpose Registers.
1. AX register (Accumulator):
2. BX register:
BX register is the base register. It is used to save the base data (value).
3. CX register:
4. DX Register:
5. SP (Stack Pointer):
Stack Pointer keeps the top of the stack. The stack pointer operates in the principle of Last In
First Out (LIFO). Since one location can store only 8 bit data, in order to store a 16 bit data,
two memory locations are needed. So the stack pointer will decreased by two memory
locations, if a data is taken.
6. BP (Base Pointer):
Base pointer is used to store the base address of the memory or stack.
7. SI (Source Index):
Source Index is used to hold the index value of source operand for string instructions.
8. DI (Destination Index):
DI is used to hold the index value of destination operand for string instructions.
General purpose registers are used for holding data, intermediate results, counters, mode of
addressing and also for storing effective address.
Flag Registers:
Instruction Format,
15 14 13 12 11 10 9 8 7 6 5 4 3
2 1 0
U U U U CF DF IF TF SF ZF U AF U PF V CF
Symbolic Representation,
A1 A0 Result
0 0 Counter 0
0 1 Counter 1
1 0 Counter 2
X X No Selection
Control Word Register
This register is accessed when lines A 0 & A1 are at logic 1. It is used to write a command word,
which specifies the counter to be used, its mode, and either a read or write operation. Following
table shows the result for various control inputs.
A1 A0 RD WR CS Result
0 0 1 0 0 Write Counter 0
0 1 1 0 0 Write Counter 1
1 0 1 0 0 Write Counter 2
0 0 0 1 0 Read Counter 0
0 1 0 1 0 Read Counter 1
1 0 0 1 0 Read Counter 2
1 1 0 1 0 No operation
X X 1 1 0 No operation
X X X X 1 No operation
Counters
Each counter consists of a single, 16 bit-down counter, which can be operated in either binary
or BCD. Its input and output is configured by the selection of modes stored in the control word
register. The programmer can read the contents of any of the three counters without disturbing
the actual count in process.
Q5 (b) Explain 8255 PPI in detail. And discuss its mode 1 and mode 2 operation.
ANS. The 8255 PPI is a programmable peripheral interface device.
• It is a general-purpose programmable parallel I/O device.
• It contains 3 I/O ports which can be programmed in different modes.
• To program the function to all three i/O ports t contains a register called
control registers. The control register defines the function of each I/O port and
in which mode they should operate.
• 8055 PPI is general purpose in nature and provides many facilities for
connecting different devices. So it is used frequently in different
applications.of 8255 PPI
• It is a programmable parallel I/O device.
• It contains 24 programmable I/O pins arranged as 2-8 bit ports and 2-4 bit
ports.
• It has 3, 8-bit ports: Port A, Port B, and Port C, which are arranged in two
groupss of 12 pins.
• Fully compatible with Intel microprocessor families.
• TTL is compatible.
• Direct bit set/reset capability is available for port C.
• Improved DC driving capability.
• It can operate in 3 Modes:
1. Mode 0: Simple I/O
2. Mode 1: Strobed I/O
3. Mode 2: Strobed bi-directional I/O
Pin Configuration of 8255 PPI
The pin configuration of 8255 PPI (Programmable Peripheral Interface) is as shown in the
figure below:
PA0-
I/O Port A pins
PA7
RD I Read input
WR I Write input
A0-A1 I Address pins
CS I Chip select
VCC-
I +5 V supply ground
GND
iagram
1. BSR Mode
1. D7: When the bit D7=1 then I/O mode is selected, if D7=0 then BSR mode is
selected. The function of bits D0 to D6 is dependent on mode.
2. D6 and D5: In I/O mode the bit D6 and D5 specify the different I/O modes for
group A.
3. D4 and D3: In I/O mode the bits D4 and D3 select the port function for groups
A. If these bits =1 the respective port specified is used as the input port. But if
bit=0, the port is used as the output port.
4. D2: In I/O mode the bit D2 specifies the different I/O modes for group B.
5. D1 and D0: In I/O mode the bits D1 and D0 select the port function for group
B. If these bits =1 the respective port specified is used as the input port. But if
bit=0, the port is used as the output port.
8255 PPI Applications
8255 PPI is the most widely used chip for many applications:
• Mode 2 – Bidirectional I/O: In this mode only port A will work, port B can
either is in mode 0 or 1 and port C bits are used as handshake signal. The
outputs as well as inputs are latched. It has interrupt handling capab ility. Control
Register is as
follows:
The most significant bit (D7) is 1 for the I/O mode and 0 for the BSR mode. D6
& D5It is used to set the port A
mode. D4 is
used to tell whether port A is taking input or displaying the result. If it is 1 then
it is taking input otherwise displaying output. D3 is used to tell whether port C
higher bits is taking input or displaying the result. If it is 1 then it is taking input
otherwise displaying output. D2 tells the mode of port B. If it is 0 then port B is
in m0 mode otherwise in m1 mode. D1 is used to tell whether port B is taking
input or displaying the result. If it is 1 then it is taking input otherwise
displaying output. D0 is used to tell whether port C lower bits is taking input or
displaying the result. If it is 1 then it is taking input otherwise displaying output.
When 8255 microprocessor is reset, it will clear the control word register contents, setting
all the ports to input mode.
Q6(b) Draw the internal memory organization of 8051 and also Explain register banks and
stack.
ANS. The internal data memory of 8051 is divided into two groups. These are a set of eight
registers and a scratch pad memory. These eight registers are R0 toR7. The address range 00H
to 07H is used to access the registers, and the rest are scratch pad memory.
8051 Provides four register bank, but only one register bank can be used at any point in time.
To select the register bank, two bits of PSW (Program Status Word) are used.
The concept of four register banks is very useful. For servicing the interrupts, this feature is
very good. The interrupt program can use one bank, and the interrupt Service Subroutine (ISS)
can access another bank for better performance. As there are four banks, so for nested
interrupts these can be used
When all of the register banks are being used, the scratch pad area will be 20H to 7FH. But
from 20H to 2FH (16 bytes or 128 bits) can be used as bit addressable RAM. By using some
simple instructions with 8-bit memory address we can check the bit addressing. For an
example the instruction CLR 6FH, using this instruction it clears the location 6FH. As we
know the8-bit address can locate 256 different locations, but here only128-bits are addressable.
Another section of bit addressable locations is 80H to FFH. The remaining locations (30H to
7EH) of the RAM can be used to store variable data and stack.
Stack Area
The stack area in 8051always can be implemented in the internal data memory. Here the stack
pointer (SP) is an only 8-bit register, because the internal RAM area is only in range 00H to
7FH, and when all register banks are being used, the stack location will be in range 30H to
7FH. So in such a case, the SP will be initialized with 2FH.
The stack pointer SP increases before each PUSH operation and decreases after each pop
instruction.
When the 8051 is reset, the Stack Pointer will point to 07H. It means the location 08H to
7FHcan be used as a stack. We are assuming that the register bank 0 is in use and 20H to 27H
are not like bit-addressable area.
ORG (Origin)
The ORG directive is used to specify a location in program memory where the program
following directive is to be placed.
Syntax: ORG ROM-address
Address can be given in either in hex or decimal.
For example:
ORG 100
…
…
ORG 1000h
TABLE …
…
This program starts at location 100. The table containing data is to be stored at location 1024
(1000h).
EQU
SET
The SET directive is also used to replace a number by a symbol. The significant difference
compared to the EQU directive is that the SET directive can be used an unlimited number of
times.
Syntax: Name SET Constant
SPEED SET 45
SPEED SET 46
SPEED SET 57
BIT
The BIT directive is used to replace a bit address by a symbol. The bit address must be in the
range of 0 to 255 (00 H to FF H).
Syntax: Name BIT 8051-bit
For example:
TRANSMIT BIT PSW.7 ; Transmit bit (the seventh bit in PSW register); is
assigned the name “TRANSMIT”.
OUTPUT BIT 6 ; Bit at address 06 is assigned the name “OUTPUT”.
RELAY BIT 81 ; Bit at address 81 (Port 0) is assigned the name “RELAY”.
CODE
The CODE directive is used to assign a symbol to a program memory address. Since the
maximum capacity of program memory is 64K, the address must be in the range of 0 to
65535(0000 H to FFFF H).
Syntax: Name CODE code-address
For example:
RESET CODE 0 ; Memory location 00h called “RESET”.
TABLE CODE 1024 ; Memory location 1024h called “TABLE”.
DATA
The DATA directive is used to assign a symbol to an address within internal RAM and SFR.
The address must be in the range of 0 to 255 (00 H to FF H). It is possible to change or assign
a new name to any register.
Syntax: Name DATA data-address
For example:
TEMP12 DATA 32 ; Register at address 32 is named as “TEMP12”.
STATUS_R DATA D0h ; PSW register is assigned the name “STATUS_R”.
IDATA
The IDATA directive is used to change or assign a new name to an indirectly addressed
register. It is an address of entire internal RAM.
Syntax: Name IDATA idata-address
For example:
TEMP22 IDATA 32 ; Register whose address is in register ;at address
32 is named as “TEMP22”
TEMP33 IDATA T_ADR ; Register whose address is in register T_ADR
is named as “TEMP33”.
XDATA
The XDATA directive is used to assign a name to registers within external (additional) RAM
memory. The addresses of these registers cannot be larger than 65535 (0000 h to FFFF h).
Syntax: Name XDATA xdata-address
For example:
TABLE_1 XDATA 2048 ; Register stored in external; memory at
address 2048 is named; as “TABLE_1”.
USING
The USING directive is used to define which register bank (registers R0 -R7) is to be used in
the program.
Syntax: USING Bank-no.
USING 0 ; Bank 0 is used (registers R0-R7 at RAM-addresses 0-7)
USING 1 ; Bank 1 is used (registers R0-R7 at RAM-addresses 8-15)
USING 2 ; Bank 2 is used (registers R0-R7 at RAM-addresses 16-23)
USING 3 ; Bank 3 is used (registers R0-R7 at RAM-addresses 24-31).
END
The END directive is used at the end of every program. It indicates the end of program. The
assembler will stop compiling once the program encounters this directive.
Syntax: END
For example:
END ; End of program
DB (Define Byte)
The DB directive is used for writing specified value into program memory. If several values
are specified, then they are separated by a comma. Here data can be in decimal, binary, hex
or ASCII formats.
If ASCII array is specified, it should be enclosed within single quotation marks. This
directive can be used only if the CSEG segment is active.
DB directive is the only directive that can be used to define ASCII strings larger than two
characters; therefore, it should be used for all ASCII data definitions.
For example:
NUM1 DB 22,33, ‘Alarm’, 44
String_U DB ‘DBATU’
If this directive is preceded by a label, then the label will point to the first element of the
array. It is the number 22 in this example 1.
Q7 (b) What is the difference between PIC and ARM processor? Explain their application
areas.
Difference between PIC and ARM :
S.No. PIC ARM