How the examiner runs a microprocessor lab viva
A microprocessor and microcontroller lab usually starts with 8085 assembly programs on a trainer kit or a simulator such as GNUSim8085: 8-bit and 16-bit addition and subtraction, multiplication by repeated addition, the largest or smallest number in an array, sorting, block transfer and BCD or hex conversions. Then come 8086 programs written with MASM, TASM or emu8086, interfacing with the 8255 PPI to drive LEDs, a seven-segment display, a stepper motor or a DAC, and a few 8051 programs.
- First, your program: 'which memory locations hold your inputs and output?', 'why did you use JNC here?'
- Then the instruction: 'how many bytes is LDA 2050H?', 'what does DAD H do?', 'which flags does INR affect?'
- Then architecture: register set, flags, buses, ALE, BIU and EU, segment registers.
- Then interrupts: priority, vector addresses, maskable versus non-maskable.
- Then interfacing: the 8255 control word for your experiment, and microprocessor versus microcontroller.
Know your own addresses
Before the viva, write down the input addresses, output address, every jump label and the expected result of each program in your record, with one worked example in hexadecimal. 'Data at 2050H and 2051H, sum at 2052H, carry at 2053H' answers the first question in one breath.
Microprocessor basics
What is a microprocessor?
A microprocessor is a programmable integrated circuit that contains the arithmetic and logic unit, the registers and the control unit of a computer on one chip. It fetches instructions from memory, decodes and executes them, and exchanges data with memory and input-output devices over its buses. The Intel 8085 is an 8-bit microprocessor.
What is the difference between a microprocessor and a microcontroller?
A microprocessor contains only the CPU, so it needs external memory, ports and timers to form a system, and suits general-purpose computing. A microcontroller puts the CPU, RAM, ROM, I/O ports, timers and a serial port on one chip, so it suits dedicated embedded control, like the 8051 in a washing machine controller.
What are the three buses in a microprocessor system?
The address bus carries the address of the memory location or I/O port and is unidirectional, from the processor out. The data bus carries data in both directions. The control bus carries signals such as read, write, IO or memory select and interrupt acknowledge that coordinate the transfer.
What is the word length of a processor?
Word length is the number of bits the processor processes at a time in its ALU and general registers, usually equal to the width of its data bus. The 8085 has an 8-bit word length and the 8086 a 16-bit word length. A longer word handles larger numbers in one operation.
What is the fetch, decode and execute cycle?
The processor places the program counter's address on the address bus, reads the opcode from memory and increments the program counter; this is the fetch. It then decodes the opcode to find the operation and operands, reads any further bytes, and executes the operation. Then the cycle repeats with the next instruction.
What are a T-state, a machine cycle and an instruction cycle?
A T-state is one clock period. A machine cycle is the time for one basic operation such as an opcode fetch, memory read or I/O write, and takes three to six T-states in the 8085. An instruction cycle is the time to fetch and execute a whole instruction and consists of one to five machine cycles.
What are the machine cycles of the 8085?
Opcode fetch, memory read, memory write, I/O read, I/O write, interrupt acknowledge and bus idle. Every instruction begins with an opcode fetch, usually four T-states. LDA 2050H, for example, needs an opcode fetch, two memory reads for the address and a third memory read for the data.
8085 architecture and pins
Give the main features of the 8085.
The 8085 is an 8-bit NMOS microprocessor in a 40-pin package running from a single plus 5 volt supply. It has an 8-bit data bus, a 16-bit address bus addressing 64 KB of memory, multiplexed lower address and data lines AD0 to AD7, an on-chip clock generator, five hardware interrupts and serial I/O through the SID and SOD pins.
Why can the 8085 address 64 KB of memory?
It has 16 address lines, and 2 to the power 16 is 65,536 distinct addresses, each holding one byte, which is 64 KB. Addresses run from 0000H to FFFFH.
Name the registers of the 8085.
The 8-bit accumulator A; six 8-bit general-purpose registers B, C, D, E, H and L, which can pair as BC, DE and HL for 16-bit operations; the 16-bit stack pointer and program counter; the flag register; and the temporary register and instruction register, which the programmer cannot access.
What is the role of the accumulator?
The accumulator is the 8-bit register that holds one operand of most arithmetic and logic operations and receives the result. IN and OUT instructions also move data through it. That is why most 8085 programs begin by loading data into A, and why ADD B means A equals A plus B.
What are the flags of the 8085, and when is each set?
There are five. Sign is set when bit 7 of the result is 1; zero when the result is zero; auxiliary carry when there is a carry from bit 3 to bit 4, used for BCD; parity when the result has an even number of 1s; and carry when there is a carry out of bit 7, or a borrow in subtraction.
Why are AD0 to AD7 multiplexed, and what does ALE do?
To save pins on a 40-pin package, the lower address byte and the data byte share the same eight lines. In the first T-state of a machine cycle they carry the address, and ALE, address latch enable, goes high so an external latch such as the 74LS373 captures it. For the rest of the cycle the lines carry data.
What are the IO/M, S0 and S1 signals?
IO/M tells whether the current operation is for an I/O device, when high, or memory, when low. S1 and S0 give the status of the machine cycle: 1 and 1 for opcode fetch, 1 and 0 for read, 0 and 1 for write, and 0 and 0 when halted. Together with RD and WR they generate the memory and I/O control signals.
What do the READY, HOLD and HLDA pins do?
READY lets a slow memory or device stretch the cycle: while it is low, the processor inserts wait states. HOLD is a request from a DMA controller to use the buses; the processor finishes the current machine cycle, floats its buses and answers with HLDA, hold acknowledge, until HOLD goes low.
What is the clock frequency of the 8085?
The crystal or clock input on X1 and X2 is divided by two inside the chip, so a 6 MHz crystal gives a 3 MHz operating frequency, which is the rating of the standard 8085A. CLK OUT provides this system clock to other chips on the board.
What happens when the 8085 is reset?
When RESET IN is made low, the program counter is cleared to 0000H, the interrupt enable and the HLDA flip-flops are reset, and the buses are tri-stated while reset lasts. RESET OUT goes high to reset other devices. Execution then begins from address 0000H, where the monitor program of a trainer kit sits.
What is DMA?
Direct memory access lets a fast device such as a disk controller transfer a block of data directly to or from memory without the processor moving each byte. A DMA controller such as the 8257 asserts HOLD, the processor releases the buses and answers with HLDA, and the controller drives the address and control lines until the transfer ends.
8085 instructions and addressing modes
How many instructions does the 8085 have, and how are they grouped?
The 8085 instruction set is usually counted as 74 instructions, with 246 opcodes when all register combinations are counted. They fall into five groups: data transfer, arithmetic, logical, branching, and machine control such as HLT, NOP, EI, DI, SIM and RIM.
What are the addressing modes of the 8085? Give an example of each.
Immediate, where the data is in the instruction: MVI A, 32H. Register, where data is in a register: MOV A, B. Direct, where the instruction gives the 16-bit address: LDA 2050H. Register indirect, where a register pair holds the address: MOV A, M uses HL, and LDAX B uses BC. Implied, where the operand is understood: CMA complements A.
What are one-byte, two-byte and three-byte instructions?
The size depends on what follows the opcode. MOV A, B needs only the opcode, so it is one byte. MVI A, 32H needs the opcode and 8-bit data, two bytes. LDA 2050H and JMP 2000H need the opcode and a 16-bit address, three bytes, stored with the low byte first.
What does MOV A, M do?
It copies the byte from the memory location whose address is in the HL register pair into the accumulator. M stands for that memory location. Before using it, I load HL with LXI H, 2050H, so MOV A, M reads the data at 2050H.
What is the difference between LDA and LDAX?
LDA 2050H loads the accumulator from the memory address given directly in the instruction, so it is a three-byte instruction. LDAX B or LDAX D loads the accumulator from the address held in the BC or DE register pair, so it is a one-byte instruction using register indirect addressing. LDAX cannot use HL; MOV A, M does that.
What does DAD do?
DAD rp adds the 16-bit contents of a register pair to HL and puts the result in HL. Only the carry flag is affected. DAD H doubles HL, which is a quick way to multiply a 16-bit number by two. My 16-bit addition program used LHLD, XCHG and DAD D.
What does the DAA instruction do?
DAA, decimal adjust accumulator, corrects the result of adding two packed BCD numbers. If the lower nibble is above 9 or the auxiliary carry is set, it adds 06H; if the upper nibble is above 9 or the carry is set, it adds 60H. In the 8085 it works only after addition, and the result is a valid BCD number.
What is the difference between INR and INX?
INR increments an 8-bit register or memory location by one and affects all flags except carry. INX increments a 16-bit register pair and affects no flags at all. So a loop counter in a register pair decremented with DCX needs a separate check, because the zero flag is not set by DCX.
How is a compare done in the 8085?
CMP r or CPI data subtracts the operand from the accumulator internally, sets the flags and leaves A unchanged. If A is less than the operand, carry is set; if they are equal, zero is set; if A is greater, both are reset. My largest-number program uses CMP M followed by JNC to keep the larger value.
How do you multiply two 8-bit numbers on the 8085?
The 8085 has no multiply instruction, so I use repeated addition: load one number as a counter, clear the result, and add the other number to the result in a loop, decrementing the counter until it is zero, while incrementing a carry register on every carry. Shift-and-add with DAD is faster for larger numbers.
What do the rotate instructions RLC, RAL, RRC and RAR do?
RLC rotates the accumulator left by one bit, moving bit 7 into both bit 0 and the carry. RAL rotates left through the carry, so bit 7 goes into carry and the old carry goes into bit 0. RRC and RAR are the right-rotate versions. They are used for multiplication and division by two and for checking individual bits.
What is the difference between JMP and CALL?
JMP transfers control to a new address and never returns. CALL saves the return address, the address of the next instruction, on the stack and then jumps to the subroutine; RET pops that address back into the program counter. Conditional versions such as JZ, CNC and RP test a flag first.
Stack, I/O and interrupts of the 8085
What is the stack, and how does the 8085 use it?
The stack is a reserved area of RAM used in last in, first out order to save return addresses and register contents. The stack pointer holds the address of the top. PUSH decrements SP and stores a register pair, high byte first; POP reads the pair back and increments SP. In the 8085 the stack grows towards lower addresses.
Why must the stack pointer be initialised?
Because CALL, PUSH and interrupts write to the address in SP. If SP is left pointing at random memory, the return address may overwrite the program or data, or land in ROM where it cannot be written, and the program crashes on RET. So programs that use the stack start with LXI SP and a free RAM address.
What is the difference between memory-mapped I/O and I/O-mapped I/O?
In I/O-mapped I/O, devices have a separate 8-bit address space of 256 ports and are accessed only with IN and OUT through the accumulator, with IO/M high. In memory-mapped I/O, devices occupy memory addresses, so any memory instruction such as MOV or LDA can access them, at the cost of using part of the 64 KB memory space.
What are the hardware interrupts of the 8085?
TRAP, RST 7.5, RST 6.5, RST 5.5 and INTR, in decreasing order of priority. TRAP is non-maskable. The three RST interrupts are maskable and vectored, and can be masked individually with SIM. INTR is maskable and non-vectored: the interrupting device must place an RST or CALL instruction on the data bus during the acknowledge cycle.
What is the difference between maskable and non-maskable interrupts?
A maskable interrupt can be disabled by software, using DI or masking with SIM, so the processor ignores it while masked. A non-maskable interrupt cannot be disabled and is always serviced, so it is used for critical events such as power failure. In the 8085, TRAP is the only non-maskable interrupt.
What are vectored and non-vectored interrupts?
For a vectored interrupt the processor jumps automatically to a fixed address, for example RST 7.5 to 003CH. For a non-vectored interrupt the device must supply the address or the instruction during acknowledge. INTR is the non-vectored interrupt of the 8085.
What do SIM and RIM do?
SIM, set interrupt mask, sends the accumulator's contents to set or clear the masks of RST 7.5, 6.5 and 5.5, reset the RST 7.5 flip-flop and output a bit on the SOD line. RIM, read interrupt mask, loads into the accumulator the current masks, the interrupt enable status, the pending interrupts and the bit on the SID line.
What are the software interrupts RST 0 to RST 7?
They are one-byte restart instructions that act like a CALL to a fixed address, eight times the restart number: RST 0 to 0000H, RST 1 to 0008H, up to RST 7 to 0038H. Trainer kits often use RST 1 or RST 5 at the end of a program to return control to the monitor.
How is a time delay generated in an 8085 program?
With a counting loop: load a register with a count, then decrement it and jump back while it is not zero. The delay is the total number of T-states multiplied by the clock period. In a loop of DCR C and JNZ, each pass takes 4 plus 10 T-states, and the last pass 4 plus 7, so the count sets the delay; nested loops give longer delays.
8085 interrupt vector table
8086 architecture and programming
Give the main features of the 8086.
The 8086 is a 16-bit microprocessor in a 40-pin package with a 16-bit data bus and a 20-bit address bus, so it addresses 1 MB of memory. It uses segmented memory, a 6-byte instruction queue for pipelining, and can work in minimum or maximum mode. Versions run at 5, 8 and 10 MHz.
What are the BIU and the EU?
The bus interface unit fetches instructions and data, computes physical addresses using the segment registers and the instruction pointer, and fills the 6-byte instruction queue. The execution unit decodes and executes instructions from the queue using the ALU, general registers and flags. They work in parallel, which is the 8086's simple pipelining.
What is memory segmentation in the 8086?
The 1 MB memory is divided into segments of up to 64 KB, each starting at an address that is a multiple of 16. Four segments are active at a time, pointed to by CS for code, DS for data, SS for stack and ES for extra data. Segmentation lets 16-bit registers address 1 MB and keeps code, data and stack separate.
How is the physical address calculated? Give an example.
Physical address equals the segment register value multiplied by 16, that is shifted left by four bits, plus the 16-bit offset. With CS equal to 2000H and IP equal to 0100H, the physical address is 20000H plus 0100H, which is 20100H.
Name the registers of the 8086.
Four general-purpose registers AX, BX, CX and DX, each usable as two 8-bit halves such as AH and AL; the pointer and index registers SP, BP, SI and DI; the segment registers CS, DS, SS and ES; the instruction pointer IP; and the flag register. CX is the default counter for LOOP and string repeats.
What are the flags of the 8086?
There are nine. Six status flags: carry, parity, auxiliary carry, zero, sign and overflow. Three control flags: trap, which enables single-stepping; interrupt, which enables maskable interrupts; and direction, which makes string instructions step down through memory when set and up when clear.
What is the difference between the carry and overflow flags?
Carry shows an unsigned result that does not fit, a carry out of the most significant bit. Overflow shows a signed result that does not fit, as when adding two positive numbers gives a negative result. Adding 7FH and 01H as bytes gives 80H with overflow set and carry clear.
What are minimum and maximum modes?
The MN/MX pin selects the mode. In minimum mode, with the pin high, the 8086 generates the bus control signals itself, for a single-processor system. In maximum mode, with the pin low, it outputs status signals to an 8288 bus controller, which generates the control signals, allowing coprocessors such as the 8087 and multiprocessor systems.
What are the addressing modes of the 8086?
Immediate: MOV AX, 1234H. Register: MOV AX, BX. Direct: MOV AX, a memory offset in brackets. Register indirect: memory addressed by BX, SI or DI. Based: BX or BP plus a displacement. Indexed: SI or DI plus a displacement. Based indexed, with or without displacement. String and I/O instructions also have their own implied modes.
How do string instructions and REP work?
String instructions such as MOVSB, CMPSB, SCASB, LODSB and STOSB work on data addressed by DS:SI as the source and ES:DI as the destination, and update SI and DI after each element according to the direction flag. The REP prefix repeats the instruction CX times, so a block transfer needs just REP MOVSB after setting SI, DI and CX.
How are interrupts handled in the 8086?
The 8086 supports 256 interrupt types. The interrupt vector table occupies the first 1 KB of memory, 00000H to 003FFH, with four bytes per type holding the new IP and CS. On an interrupt the processor pushes the flags, CS and IP, clears IF and TF, and loads the new CS and IP from address type times 4. NMI is type 2.
What are assembler directives? Give examples.
Directives are instructions to the assembler, not to the processor, so they produce no machine code themselves. ASSUME tells the assembler which segment register holds which segment, DB and DW define bytes and words, SEGMENT and ENDS mark a segment, ORG sets the location counter, EQU defines a constant and END ends the program.
What is the difference between the 8086 and the 8088?
Internally they are the same 16-bit processor. The 8088 has an 8-bit external data bus, so a 16-bit word takes two bus cycles, and a 4-byte instruction queue instead of six. It was chosen for the original IBM PC because 8-bit support chips were cheaper.
What is the difference between a near and a far procedure in the 8086?
A near procedure is in the same code segment, so CALL pushes only IP and RET pops only IP. A far procedure is in a different segment, so CALL pushes both CS and IP and the far RET pops both. The assembler chooses the right form from the NEAR or FAR attribute of the PROC directive.
Interfacing chips and the 8051
What is the 8255, and what are its ports?
The 8255 programmable peripheral interface provides 24 I/O lines as three 8-bit ports, A, B and C. Port C can be split into upper and lower 4-bit halves, each set as input or output, or used bit by bit. A control register, written by the processor, selects the mode and direction of each port.
What are the operating modes of the 8255?
In I/O mode there are three: mode 0, simple input or output without handshake; mode 1, strobed input or output with handshake lines taken from port C; and mode 2, a bidirectional bus with handshake, available only on port A. In bit set-reset mode, individual bits of port C are set or cleared.
What control word makes all 8255 ports outputs in mode 0?
80H. In binary it is 1000 0000: bit 7 is 1 for I/O mode, the mode bits for groups A and B are 0, and every direction bit is 0, meaning output. With all direction bits set to 1, 9BH, every port becomes an input in mode 0.
How did you drive the stepper motor through the 8255?
I configured port A as output with control word 80H and sent the energising sequence for the four windings, such as 09H, 0CH, 06H and 03H for one direction, with a delay subroutine between steps. Reversing the order reverses the direction, and a shorter delay increases the speed.
What do the 8253 or 8254, 8259 and 8251 do?
The 8253 and the later 8254 are programmable interval timers with three independent 16-bit counters and six modes, used for delays, rate generation and square waves. The 8259 is a programmable interrupt controller handling eight interrupt inputs, cascadable to 64. The 8251 is a USART for serial communication.
Give the main features of the 8051.
The 8051 is an 8-bit microcontroller with 4 KB of on-chip ROM, 128 bytes of on-chip RAM, four 8-bit I/O ports giving 32 lines, two 16-bit timers or counters, one full-duplex serial port and five interrupt sources, in a 40-pin package. It can address 64 KB of external program memory and 64 KB of external data memory.
What is the difference between Harvard and von Neumann architecture?
Von Neumann architecture uses one memory and one bus for both instructions and data, as in the 8085 and 8086. Harvard architecture has separate memories and buses for program and data, so both can be accessed at the same time; the 8051 has separate program and data memory spaces.
What are the register banks of the 8051?
The lowest 32 bytes of the 8051's internal RAM form four register banks of eight registers each, R0 to R7. The RS1 and RS0 bits in the PSW select the active bank, so an interrupt routine can switch banks instead of saving registers on the stack. Bank 0 is active after reset.
Common mistakes in a microprocessor viva
- Not knowing the input and output addresses or the expected result of your own program.
- Saying the 8085 has a 16-bit data bus. It has an 8-bit data bus and a 16-bit address bus.
- Saying INX or DCX sets the zero flag. Register pair increments and decrements affect no flags.
- Mixing up the RST 7.5, 6.5 and 5.5 vector addresses. They are 003CH, 0034H and 002CH: the number multiplied by eight, in hex.
- Forgetting to multiply the segment by 16 when computing an 8086 physical address.
- Saying mode 2 of the 8255 is available on port B. Only port A supports mode 2.
- Storing a 16-bit address high byte first. The 8085 and 8086 store the low byte at the lower address.
What the ExamPilot AI examiner checks when you practise
In an ECE or EE lab viva session on ExamPilot you name your microprocessor experiment, for example 16-bit addition on the 8085 or stepper motor control through the 8255, and an AI examiner questions you by voice for about twelve minutes: what your program does, the flags and registers involved, an instruction's size and addressing mode, an interrupt or segment calculation said aloud, and an interfacing question. It follows up whenever an answer is vague, and you can answer in English or Hindi.
- Exact numbers: bus widths, memory sizes, vector addresses and control words, said in hexadecimal correctly.
- Instruction knowledge: size, addressing mode and the flags each instruction affects.
- Calculations said step by step: physical address, delay count, control word bits.
- Comparisons with the deciding difference first: microprocessor versus microcontroller, 8085 versus 8086.
- Brevity and honesty: two or three sentences, and a clean 'I am not sure' rather than a guess.
Start with the ECE/EE lab viva mock. You get a transcript, the questions you fumbled and a tighter answer to say again.
The night before the microprocessor lab exam
- 1
Write out each program with addresses
For every experiment, list the memory addresses of data and result, the expected output for one example, and what each jump does.
- 2
Say the numbers aloud
Bus widths of the 8085 and 8086, the five 8085 flags, the nine 8086 flags, the interrupt vector table and the 8255 control word for your experiment.
- 3
Work two calculations
An 8086 physical address from a segment and offset, and an 8255 control word for port A output, port B input and port C output in mode 0.
- 4
Run one mock viva
Twelve minutes with the AI examiner on your own experiment shows which answers come out clearly and which need work.
The logic behind flags, latches and decoders comes from digital electronics viva questions. If the same semester has a circuits lab, see basic electrical engineering viva questions, and for how every lab viva works, the engineering viva hub.
Frequently asked questions
- What are the most important microprocessor viva questions?
- 8085 features and pin functions, the registers and five flags, ALE and demultiplexing, addressing modes with examples, instruction sizes, the stack and stack pointer, the five hardware interrupts with vector addresses, SIM and RIM, 8086 segmentation and physical address, BIU and EU, the nine 8086 flags, minimum and maximum mode, 8255 modes and control words, and microprocessor versus microcontroller.
- Is 8085 still taught when processors are 64-bit?
- Yes. The 8085 is simple enough to see every bus cycle, flag and register, so it is still used to teach how any processor fetches, decodes and executes instructions, handles interrupts and talks to memory and I/O. The 8086 then introduces segmentation and pipelining, which lead to the x86 processors used today.
- What is MPMC?
- MPMC stands for microprocessors and microcontrollers, the name many universities use for the course and lab that cover the 8085 or 8086, peripheral chips such as the 8255, 8253 and 8259, and the 8051 microcontroller. The viva questions on this page cover that whole syllabus.
- Do I need to remember opcodes in hexadecimal?
- Usually not for the viva, because trainer kits and simulators come with an opcode sheet. You should know the mnemonics, the size of each instruction, the addressing mode and the flags affected. Some examiners do ask a few common opcodes, such as 3EH for MVI A and 76H for HLT, so it helps to know the ones in your own programs.
- How can I practise microprocessor viva questions out loud?
- On ExamPilot you can run an ECE or EE lab viva by voice. Name your microprocessor experiment and the AI examiner asks about your program, flags, addressing modes, interrupts and the 8255, follows up like an external examiner, then gives you a transcript with tighter answers to repeat. It is free to start.
Practise out loud
Practise your microprocessor viva aloud
The AI examiner asks about your 8085 or 8086 program, its flags, addressing modes, interrupts and 8255 control word, and follows up like an external examiner.
Engineering Viva · ECE / EE lab viva
