Viva Preparation Notes
Microprocessor & Assembly Language Viva Questions and Answers
Basic to intermediate-level questions based on the topics and programs studied today in 8086 assembly language.
Covered topics: 8086 basics, registers, flags, segment:offset addressing, program structure, DOS interrupts, ASCII conversion, loops, conditional jumps, and array programs.
Contents
- Basic Microprocessor Concepts
- 8086 Program Structure
- Registers, Flags, and Addressing
- Important DOS Interrupts
- Assembly Programs Studied Today
- Intermediate Viva Questions
- Quick Revision Table
1) Basic Microprocessor Concepts
Q1. What is a microprocessor?
A microprocessor is a programmable electronic device that works as the central processing unit of a computer system. It performs arithmetic operations, logical operations, and controls data movement.
Q2. Why is the 8086 microprocessor important for beginners?
The 8086 is important because it is one of the standard introductory microprocessors used to learn registers, flags, memory addressing, instruction execution, and basic assembly language programming.
Q3. What is assembly language?
Assembly language is a low-level programming language that uses mnemonic instructions such as MOV, ADD, and CMP to control the CPU directly.
Q4. Why do we learn assembly language?
We learn assembly language to understand how the CPU works internally, how memory is accessed, how registers store data, and how instructions are executed step by step.
Q5. What is the difference between machine language and assembly language?
Machine language is written in binary and is directly understood by the CPU. Assembly language uses readable mnemonics, but it still represents low-level CPU instructions and must be converted into machine code by an assembler.
2) 8086 Program Structure
.MODEL SMALL
.STACK 100H
.DATA
.CODE
MAIN PROC
; instructions go here
MAIN ENDP
END MAIN
Q6. What does .MODEL SMALL mean?
It selects the small memory model, which means the program uses one code segment and one data segment.
Q7. What is the purpose of .STACK 100H?
It reserves 100H bytes, or 256 bytes, for the stack. The stack is used for temporary storage, procedure calls, and saving register values.
Q8. What is written inside the .DATA segment?
Variables, arrays, constants, and strings are declared in the .DATA segment.
Q9. What is written inside the .CODE segment?
All executable instructions of the program are written in the .CODE segment.
Q10. What is the purpose of MAIN PROC and MAIN ENDP?
These lines mark the beginning and ending of the main procedure. The actual instructions of the program are written between them.
Q11. Why do we use END MAIN?
It tells the assembler where the program ends and from which procedure execution should begin.
3) Registers, Flags, and Addressing
Common 8086 Registers
General purpose: AX, BX, CX, DX
Pointer/index: SP, BP, SI, DI
Segment: CS, DS, SS, ES
Why Registers Matter
Registers are small storage locations inside the CPU. They are faster than memory and are heavily used in assembly instructions.
Q12. What is the use of register AX?
AX is a 16-bit general-purpose register often used in arithmetic operations and many DOS interrupt functions.
Q13. What are AH and AL?
AH is the high 8-bit part of AX and AL is the low 8-bit part of AX.
Q14. Why do we write MOV AX, @DATA and MOV DS, AX at the start of many programs?
These instructions initialize the data segment register so the program can correctly access variables and strings declared in the .DATA segment.
Q15. What is segment:offset addressing in 8086?
The 8086 uses a logical address written as segment:offset. The physical address is calculated by multiplying the segment by 10H and then adding the offset.
Q16. What is the formula for physical address?
Physical Address = Segment × 10H + Offset
Q17. Find the physical address of 5462H:2DF9H.
5462H × 10H = 54620H, then 54620H + 2DF9H = 57419H.
Q18. Find the physical address of ABC7H:8472H.
ABC7H × 10H = ABC70H, then ABC70H + 8472H = B40E2H.
Q19. What are flags in 8086?
Flags are status bits that show the result of an operation. Important flags include Carry Flag, Zero Flag, Sign Flag, Overflow Flag, Auxiliary Carry Flag, and Parity Flag.
| Flag |
Meaning |
| CF |
Carry Flag: set when there is a carry out in unsigned arithmetic. |
| ZF |
Zero Flag: set when the result becomes zero. |
| SF |
Sign Flag: copies the most significant bit of the result. |
| OF |
Overflow Flag: set when signed overflow occurs. |
| AF |
Auxiliary Carry Flag: set when there is a carry from bit 3 to bit 4. |
| PF |
Parity Flag: set when the lower byte has even parity. |
Q20. Does the MOV instruction affect flags?
No. MOV only transfers data and does not change the flags.
Q21. Which instruction is commonly used to compare two values?
CMP is used to compare two values. It subtracts internally and updates the flags, but it does not store the result.
Q22. What do JZ and JNE mean?
JZ means jump if zero, and JNE means jump if not equal. Both use the flag results set by previous instructions.
4) Important DOS Interrupts Used Today
Q23. What is the function of INT 21H?
It is a DOS interrupt used to perform input/output and program control functions such as reading a character, displaying a character, displaying a string, and terminating a program.
| AH Value |
Function |
| 01H |
Read one character from keyboard |
| 02H |
Display one character stored in DL |
| 09H |
Display a string ending with $ |
| 4CH |
Terminate the program |
Q24. Why does a string end with $ in DOS function 09H?
DOS function 09H keeps printing characters until it finds the $ symbol, so it is used as the string terminator.
5) Assembly Programs Studied Today
A) Hello World Program
.MODEL SMALL
.STACK 100H
.DATA
MSG DB 'Hello World$'
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
LEA DX, MSG
MOV AH, 09H
INT 21H
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN
Q25. How does the Hello World program work?
The message is stored in memory, its address is loaded into DX, AH is set to 09H, and INT 21H displays the string. Then AH is set to 4CH to terminate the program.
B) Display A to Z
MOV DL, 'A'
PRINT:
MOV AH, 02H
INT 21H
INC DL
CMP DL, 'Z' + 1
JNE PRINT
Q26. How does the alphabet display program work?
It starts with the ASCII value of A in DL, prints the character using INT 21H function 02H, increments DL to move to the next character, and repeats until it passes Z.
Q27. Why is the label PRINT: used?
It acts as a loop point. The program jumps back to this label until all letters are displayed.
C) Odd or Even Program
MOV AL, NUM
AND AL, 01H
JZ EVEN
Q28. How do we check whether a number is odd or even?
We check the least significant bit. If the last bit is 0, the number is even. If the last bit is 1, the number is odd.
Q29. Why is AND AL, 01H used in the odd-even program?
It isolates the last bit of the number. The result becomes 0 for even numbers and 1 for odd numbers.
D) Read Capital Letter and Display Small Letter
MOV AH, 01H
INT 21H
ADD AL, 20H
MOV DL, AL
MOV AH, 02H
INT 21H
Q30. Why does adding 20H convert a capital letter into a small letter?
In ASCII, the difference between an uppercase letter and its lowercase form is 20H. For example, A = 41H and a = 61H.
E) Read Small Letter and Display Capital Letter
MOV AH, 01H
INT 21H
SUB AL, 20H
MOV BL, AL
MOV DL, ' '
MOV AH, 02H
INT 21H
MOV DL, BL
MOV AH, 02H
INT 21H
Q31. Why is 20H subtracted to convert a small letter into a capital letter?
In ASCII, lowercase letters are 20H greater than uppercase letters, so subtracting 20H converts a lowercase letter into uppercase.
Q32. Why was the converted character saved in BL before printing a space?
Because the interrupt used for printing can affect registers. Saving the converted character in BL protects the value before printing the space.
F) Find Largest Element in an Array
LEA SI, ARR
MOV CL, COUNT
MOV AL, [SI]
INC SI
DEC CL
CHECK:
CMP AL, [SI]
JAE SKIP
MOV AL, [SI]
SKIP:
INC SI
DEC CL
JNZ CHECK
Q33. What is the logic for finding the largest element in an array?
Take the first element as the initial largest value, compare it with each remaining element, and update it whenever a larger element is found.
Q34. Why is SI used in the array program?
SI is used as an index register to point to array elements one by one.
Q35. What does JAE mean in the largest-element program?
JAE means Jump if Above or Equal. If the current largest value is already greater than or equal to the next element, the program skips updating it.
G) Find Smallest Element in an Array
LEA SI, ARR
MOV CL, COUNT
MOV AL, [SI]
INC SI
DEC CL
CHECK:
CMP AL, [SI]
JBE SKIP
MOV AL, [SI]
SKIP:
INC SI
DEC CL
JNZ CHECK
Q36. What is the logic for finding the smallest element in an array?
Take the first element as the initial smallest value, compare it with the rest of the elements, and update it whenever a smaller element is found.
Q37. What does JBE mean in the smallest-element program?
JBE means Jump if Below or Equal. If the current smallest value is already less than or equal to the next element, the program keeps it unchanged.
6) Intermediate Viva Questions
Q38. Why is ASCII knowledge important in letter conversion programs?
ASCII assigns numeric codes to characters. Understanding ASCII allows us to convert uppercase to lowercase and lowercase to uppercase using arithmetic operations like ADD and SUB.
Q39. What is the difference between LEA DX, MSG and MOV DX, MSG in string programs?
LEA DX, MSG loads the effective address of the string into DX, which is needed for INT 21H function 09H. It is used when the interrupt expects an address, not the data itself.
Q40. Why do we use loop logic with labels and jumps in assembly instead of high-level keywords?
Assembly language works at a lower level, so repetition is controlled manually using labels and jump instructions instead of keywords like for or while.
Q41. What happens if the program does not use AH = 4CH and INT 21H at the end?
The program may not terminate properly under DOS. AH = 4CH with INT 21H is the standard method to exit a program safely.
Q42. Which instructions studied today do not directly print anything but prepare values for output?
Instructions like MOV, ADD, SUB, CMP, AND, LEA, and INC prepare or modify values. The actual printing is done using INT 21H functions such as 02H or 09H.
7) Quick Revision Table
| Topic |
Key Point |
| Program Structure |
.MODEL, .STACK, .DATA, .CODE, PROC, ENDP, END |
| Data Segment |
Initialize using MOV AX, @DATA and MOV DS, AX |
| Read Character |
AH = 01H, INT 21H |
| Display Character |
AH = 02H, DL = character, INT 21H |
| Display String |
AH = 09H, DX = address of string ending with $ |
| Terminate Program |
AH = 4CH, INT 21H |
| Odd/Even Check |
AND number with 01H |
| Capital to Small |
Add 20H |
| Small to Capital |
Subtract 20H |
| Largest/Smallest in Array |
Compare each element and update current result |
| Physical Address |
Segment × 10H + Offset |
| MOV Instruction |
Transfers data, does not affect flags |
Final Preparation Tips
- Practice explaining each program line by line in simple language.
- Remember the purpose of AH values used with INT 21H.
- Revise ASCII differences between capital and small letters.
- Be ready to explain why DS must be initialized.
- Understand the logic of array comparison programs clearly.