Machine Control Instruction in 8085

In this lecture, we are going to learn about Machine Control Instruction in 8085 in detail. We already learn the other instructions in the previous lecture, you can learn from the below link.


Also Read

Instruction Set of 8085 Microprocessor
1.Arithmetic Instructions of 8085
2.Data Transfer Instructions In 8085
3.Logical Instructions in 8085
4.Machine Control Instruction in 8085

Machine Control Instruction in 8085

The Machine Control Instruction in 8085 includes the following instructions:

NOPHLTEI
DIRIMSIM
IN 8-bit addressOUT 8-bit addressRST n

NOP

MnemonicNOP
OperationPC = PC + 1
When this instruction is executed no operation is performed instead of that instruction.
No. of Bytes1 byte
opcode of NOP
Machine cycles1 (OF)
AlgorithmPC  PC + 1
FlagsNo flags are modified.
Addressing ModeImplied Addressing Mode
T-states4

HLT

MnemonicHLT
Operation
No. of Bytes1 byte
opcode of HLT
Machine cycles1 + 1 T-state
(OF + 1 T-state)
Algorithm
FlagsNo flags are modified.
Addressing ModeImplied Addressing Mode
T-states5 (4+1)
DescriptionWhen this instruction is executed, the microprocessor halts i.e. this instruction stops the microprocessor. it can be restarted by a valid interrupt or RESET signal.
The registers and status flags remain unaffected.
timing diagram of HLT

This instruction halts the microprocessor. it requires only the opcode fetch machine cycle. The program counter gives the memory address on the low-order and high-order address bus. The opcode of the halt instruction is read and decoded by the microprocessor. The program counter is incremented by 1 but all buses are tri-stated. now to come out of this state either a reset is required or an interrupt


EI

MnemonicEI
OperationIE flip-flop = 1
No. of Bytes1 byte
opcode of EI
Machine cycles1(OF)
AlgorithmIE flip-flop 1
FlagsNo flags are modified.
Addressing ModeImplied Addressing Mode
T-states4
DescriptionWhen this instruction is executed the interrupt enable flip-flop is set so that all maskable interrupts are enabled.
After an interrupt is acknowledged, the interrupt enables flip-flop is reset to re-enable the interrupts.

DI

MnemonicDI
OperationIE flip-flop = 0
No. of Bytes1 byte
opcode of EI
Machine cycles1(OF)
AlgorithmIE flip-flop 0
FlagsNo flags are modified.
Addressing ModeImplied Addressing Mode
T-states4
DescriptionWhen this instruction is executed the interrupt enable flip-flop is reset so that all maskable interrupts are disabled.
Apart from TRAP, all other maskable interrupts can be disabled.

RIM

MnemonicRIM
OperationA = status of interrupts
No. of Bytes1 byte
Machine cycles1(OF)
AlgorithmA status of interrputs and serial pate
FlagsNo flags are modified.
Addressing ModeImplied Addressing Mode
T-states4
DescriptionWhen this instruction is executed the status of the interrupts is copied into the accumulator.
It also reads serial data through the SID pin.
Example(a) RI instruction is executed and the accumulator bit pattern is 0010 0000. The bit pattern indicates that RST 6.5 is pending interrupt.
(b) RIM instruction is executed and the accumulator bit pattern is 0000 1010. Th ebit pattern indicates interrupt enable flip flop is set, RST 6.5 is masked and RST 7.5 and RST 5.5 are unmasked.
RIM register format
  • Bit D7 is the status of the serial port. When RIP instruction is executed the logic level of the SID pin is copied at bit D7.
  • Bits D6, D5, and D4 are the status of pending interrupts. If RST 7.5 and RST 5.5 interrupt occurs the 8085 will branch to ISR of RST 7.5. As RST 5.5 is having less priority than RST 7.5, so RST 5.5 will be pending interrupt. When RIM instruction is executed the status of RST 7.5, RST 6.5, and RST 5.5 pending is copied at bits D6, D5, and D4 respectively.
  • Bits D3 to D0 are the status of interrupt enable flip flop, mask 7.5, mask 6.5, and mask 5.5. When RIM instruction is executed the status of masking is loaded at bits D3 to D0.

SIM

MnemonicSIM
Operation
No. of Bytes1 byte
Machine cycles1(OF)
AlgorithmInterrupts masks and serial part A
FlagsNo flags are modified.
Addressing ModeImplied Addressing Mode
T-states4
DescriptionWhen this instruction is executed the status of the interrupts is copied into the accumulator.
It also reads serial data through the SID pin.
ExampleTo enable RST 6.5 and disable RST 7.5 and RST 5.5 the following SIM format is required.
MVI A, 0DH: Load SIM format in the accumulator
SIM: set the interrupt mask
SIM register format
  • 1-interrupt is pending/masked, 0-interrupt is not pending/masked
  • SOD bit specifies serial o/p data.
  • Bits D7 and D6 are serial port control. The SDE is an enable-bit used to enable/disable serial output data.
  • Bit D4 is R 7.5 part of interrupt control logic. It is used to reset R 7.5 flip flop regardless of RST 7.5 masking.
  • Bits D3 to Do are part of interrupt control logic. These bits are used to mask RST 5.5, RST 6.5, and RST 7.5 interrupts. The MSE bit is master control over M 7.5, M 6.5, and M 5.5 bits. If MSE = 0, the M bits have no effect, but if MSE = 1, the M bits decide to mask or unmask respective interrupts.

IN 8-bit address

MnemonicIN 8-bit I/O address
OperationA = (8-bit I/O address)
No. of Bytes2 byte
1st Byte: Opcode of IN
2nd byte: 8-bit address
Machine cycles3(OF + MR + IOR)
Algorithm A (8-bit address)
FlagsNo flags are modified.
Addressing ModeDirect Addressing Mode
T-states10 (4 + 3 + 3)

Description of IN 8-bit address instruction:

  • This instruction is used to copy data from the input port address specified into the accumulator.
  • When this instruction is executed the contents of the port whose address is specified are copied into the accumulator.

Example: IN 20H

  • This instruction will copy the contents at the port whose address is 20 H into the accumulator
  • The storing format of this IN 20 H instruction is (i) Opcode for IN and (ii) 20 H Operand (20 H is the address of the I/O device). The sequence of events occurring can be well shown by the timing diagram as shown in the figure below.
  • OPCODE fetch: The program counter places address on the lower order address bus and the higher order address bus. This cycle is used to read the OPCODE of IN instruction i.e. DB H. The address for this machine cycle is given by PC. The PC is then incremented by 1.
  • Memory read: The Program Counter places the address on the lower order address bus and the higher order address bus. The data byte is read from the addressed input port. The program counter is incremented by 1.
  • I/O Read: In this I/O read machine cycle the address is given by a temporary register. It is an 8-bit address so the same contents are transferred on ADo-AD and As A and ALE are made high. The status of the IO/M line will be high, as it is an I/O operation. All other operations are the same as memory read operations.
timing daigram of IN instruction

OUT 8-bit address

MnemonicOUT 8-bit I/O address
Operation(8-bit I/O address) = A
No. of Bytes2 byte
1st Byte: Opcode of IN
2nd byte: 8-bit address
Machine cycles3(OF + MR + IOW)
Algorithm(8-bit address) A
FlagsNo flags are modified.
Addressing ModeDirect Addressing Mode
T-states10 (4 + 3 + 3)

Description of OUT 8-bit address instruction:

  • This instruction is sued to copy the contents of the accumulator to the output port whose address is specified in the instruction.

Example: OUT 20H

  • This instruction will copy the content of the accumulator to the output port whose address is 20H.
  • To send data to an output device, the microprocessor sends, an 8-bit address on A0 to A7 and A8 to A15 which will be decoded and used to select one of the peripherals, with this address IOW control signal and data is required. i.e., IO/M = 1, WR = 0 and data on D0 to D7 lines.
  • The storing format of OUT 20H instruction is (1) Opcode for OUT and (2) 20H operand (20H is the address of the I/O device).
  • The sequence of events occurring can be well shown by the timing diagram as shown in the figure below.
  • The first machine cycle is an opcode fetch which takes opcode from memory and decodes it then it comes to know that the next byte after that is an operand, so the next machine cycle will be operand fetch to take port address i.e. memory read.
  • This address is stored in a temporary register and the microprocessor starts the next machine cycle i.e. I/O write.
  • In this I/O write machine cycle the address is given by a temporary register.
  • The only difference between I/O read and I/O write is the control signal, all other points are the same.
timing daigram of OUT instruction

RST n

MnemonicRST n, where n =0 to 7
Operation(SP – 1) = PCH
(SP – 2) = PCL
SP = SP – 2
PC = (n x 8 ) in hex
No. of Bytes1 byte
opcode of RST n
Machine cycles3 (OF + MW + MW)
Algorithm(SP – 1) PCH
(SP – 2) PCL
SP SP – 2
PC (n x 8 ) in hex
FlagsNo flags are modified.
Addressing ModeIndirect Addressing Mode
T-states12 (6 + 3 + 3)

Description of RST n address instruction:

  • This instruction transfers the program control to the specific
  • memory address as shown in the table below.
  • It is used as a fixed CALL instruction. These addresses are
  • referred to as vector addresses
  • The microprocessor multiplies the RST by 8 to estimate these vector addresses.
  • Before transferring the program control to the instruction following the vector address RST instruction saves the current program counter contents on the stack like CALL instruction
  • These instructions can be used as software interrupts in a program to transfer program execution to one of the 8 locations depending on which RST instruction is executed.

Example: RST 2

  • This instruction is equivalent to CALL 0010, the PC contents are stored on to stack and the program sequence is transferred to address 0010 H.
  • This instruction requires 3 machine cycles: opcode fetch, memory write, and memory write. The timing diagram of the RST n instruction is shown in the figure below.
timing daigram of RST instruction

Restart instructions and its locations are as per below table:

InstructionsLocation addresses
RST 00 X 8 = 0 0 0 0 H
RST 11 X 8 = 0 0 0 8 H
RST 22 X 8 = 0 0 1 0 H
RST 33 X 8 = 0 0 1 8 H
RST 44 X 8 = 0 0 2 0 H
RST 55 X 8 = 0 0 2 8 H
RST 66 X 8 = 0 0 3 0 H
RST 77 X 8 = 0 0 3 8 H
  • Opcode fetch: In this machine cycle the program counter places the address on the low and high order address bus. The microprocessor then reads the opcode and decodes the instruction. The opcode fetch machine cycle requires 6T states. The stack pointer is decremented by 1.
  • Memory write: In this machine cycle, the stack pointer holds the low and high order address. The microprocessor writes the high-order byte of the program counter on the addressed memory location. The stack pointer is decremented by 1.
  • Memory write: The stack pointer holds the low and high order address. The microprocessor writes the low-order byte of the program counter on the addressed memory location.

Sr. NoSubject Wise Interview Questions and Answers
1.Top 100 Analog Electronics Interview Questions And Answers
2.Top 100 Digital Electronics Interview Questions And Answers
3.Top 100 EDC Interview Questions and Answers
4.Communication Interview Questions and Answers (Topic Wise)
5.Transducer Interview Questions And Answers
6.Electrical and Electronics Measurements Interview Questions and Answers
7.Top 100 Communication System Interview Questions
8.Satellite Communication Interview Questions And Answers
9.Computer Networking Interview Questions and Answers
10.Optical Fiber Communication Interview Questions and Answers
11.Physics Interview Question with answer
12.Machine Learning Interview Questions and Answers
13.C programming questions for interview

Hello friends, my name is Trupal Bhavsar, I am the Writer and Founder of this blog. I am Electronics Engineer(2014 pass out), Currently working as Junior Telecom Officer(B.S.N.L.) also I do Project Development, PCB designing and Teaching of Electronics Subjects.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

telegram logo Join Our Telegram Group!