Lecture 19–24: Procedures & Stack
1. Which instruction is used to call a procedure in assembly?
A. JMP
B. CALL
C. RET
D. PUSH
Answer: B
2. What is the primary purpose of the RET instruction?
A. Jump to procedure
B. End program
C. Return from procedure
D. Clear the stack
Answer: C
3. What register is commonly used to access parameters on the stack?
A. AX
B. BX
C. BP
D. SP
Answer: C
4. The order of accessing the first parameter passed on stack is:
A. [SP+2]
B. [BP+2]
C. [BP+4]
D. [SP+4]
Answer: C
5. Stack works on which principle?
A. FIFO
B. FILO
C. LILO
D. LIFO
Answer: D
Lecture 25–30: Macros & Conditional Assembly
6. Which instruction marks the end of a macro definition?
A. END
B. RETURN
C. ENDM
D. ENDD
Answer: C
7. Which of the following is TRUE about macros?
A. They use CALL and RET
B. They require more memory
C. They are slower than procedures
D. They are executed at runtime
Answer: B
8. Which directive is used to repeat a block of code in macros?
A. LOOP
B. REPT
C. IF
D. WHILE
Answer: B
9. Which directive is used for conditional assembly?
A. EQU
B. INCLUDE
C. IF
D. PUSH
Answer: C
Lecture 31–35: String Instructions
10. Which instruction copies a byte from [SI] to [DI]?
A. MOVSB
B. STOSB
C. CMPSB
D. LODSB
Answer: A
11. What does the REP prefix do?
A. Repeat code infinitely
B. Repeat code based on AX
C. Repeat string instruction CX times
D. Return from procedure
Answer: C
12. Which register holds the counter for REP instructions?
A. AX
B. DX
C. CX
D. BX
Answer: C
13. Which instruction compares bytes at [SI] and [DI]?
A. MOVSB
B. STOSB
C. SCASB
D. CMPSB
Answer: D
14. Which instruction is used to search for a value in a string?
A. STOSB
B. SCASB
C. CMPSB
D. MOVSB
Answer: B
Lecture 36–39: Interrupts (BIOS & DOS)
15. What does INT 21h provide access to?
A. Video services
B. Hardware registers
C. DOS functions
D. BIOS routines
Answer: C
16. What DOS function (via INT 21h) is used to display a string?
A. AH=02h
B. AH=09h
C. AH=4Ch
D. AH=3Fh
Answer: B
17. Which interrupt is used for video services?
A. INT 20h
B. INT 16h
C. INT 10h
D. INT 21h
Answer: C
18. Which register is used to specify the function number in INT 21h?
A. AX
B. AH
C. AL
D. BX
Answer: B
Lecture 40–42: File Handling
19. What function of INT 21h opens a file?
A. AH=3Fh
B. AH=3Eh
C. AH=3Dh
D. AH=42h
Answer: C
20. What does AH=40h (INT 21h) do?
A. Open file
B. Read from file
C. Write to file
D. Close file
Answer: C
21. Which AH value is used to move the file pointer?
A. 3Dh
B. 42h
C. 4Ch
D. 3Fh
Answer: B
22. Which register returns the file handle after opening a file?
A. AH
B. BX
C. AX
D. CX
Answer: C
Lecture 43–45: Mixing Assembly with C
23. Which C keyword is used to link assembly functions without name mangling?
A. static
B. inline
C. extern "C"
D. asm
Answer: C
24. To call C functions from assembly, you must:
A. Use LEA
B. Push parameters in reverse order
C. Use RET instruction only
D. Use MOV to call
Answer: B
25. In C, which block is used for inline assembly?
A. #asm
B. asm {}
C. exec()
D. include <asm>
Answer: B
Procedures & Stack (Lec 19–24)
26. Which register does NOT change automatically when CALL is executed?
A. SP
B. IP
C. BP
D. None of the above
Answer: C
27. What is stored on the stack by the CALL instruction?
A. Procedure address
B. Current IP (Instruction Pointer)
C. Segment Register
D. Return value
Answer: B
28. Which instruction cleans up local variables created on stack?
A. POP
B. ADD SP, n
C. MOV SP, 0
D. RET
Answer: B
29. Why do we save registers in a procedure?
A. To speed up execution
B. To restore values after the procedure
C. To clear memory
D. To use for file operations
Answer: B
30. Which of the following is a correct order for stack-based procedure call?
A. CALL → PUSH → RET
B. PUSH → CALL → RET
C. PUSH → RET → CALL
D. CALL → RET → PUSH
Answer: B
Macros & Conditional Assembly (Lec 25–30)
31. When is a macro expanded?
A. At runtime
B. At link time
C. At assembly time
D. At compile time
Answer: C
32. Which is TRUE about macros?
A. Macros can be recursive
B. Macros save memory
C. Macros use runtime stack
D. Macros expand inline
Answer: D
33. Which directive is used to repeat macro code for each item in a list?
A. LOOP
B. IRP
C. WHILE
D. ITER
Answer: B
34. Which of these is NOT a conditional assembly directive?
A. IF
B. ELSE
C. DO
D. ENDIF
Answer: C
String Instructions (Lec 31–35)
35. What happens to SI and DI after a MOVSB instruction?
A. Both increment
B. Both decrement
C. SI decrements, DI increments
D. No change
Answer: A
36. Which flag controls direction of string operations?
A. Zero Flag
B. Carry Flag
C. Sign Flag
D. Direction Flag (DF)
Answer: D
37. Which of the following instructions automatically use SI and DI?
A. MOV AX, BX
B. MOVSB
C. JMP
D. LODSB
Answer: B
38. What is the purpose of SCASB?
A. Store string
B. Search for a byte in string
C. Compare strings
D. Load a byte
Answer: B
Interrupts & BIOS/DOS (Lec 36–39)
39. Which of the following uses BIOS interrupts?
A. File access
B. Keyboard input via INT 16h
C. Memory allocation
D. DOS services
Answer: B
40. INT 21h AH=4Ch is used to:
A. Terminate program
B. Display character
C. Allocate memory
D. Read from file
Answer: A
41. Which function reads a single character with echo?
A. AH = 02h
B. AH = 01h
C. AH = 09h
D. AH = 0Ah
Answer: B
File Operations (Lec 40–42)
42. What happens if a file does not exist and AH=3Dh is used?
A. File is created
B. Error is returned
C. Zero is returned in AX
D. File is cleared
Answer: B
43. What register is used to pass the buffer address to read into?
A. AX
B. DX
C. DS:DX
D. SI
Answer: C
44. Which register contains number of bytes to read or write?
A. CX
B. DX
C. AX
D. BX
Answer: A
Mixing C with Assembly (Lec 43–45)
45. Which calling convention pushes arguments right to left?
A. CDECL
B. STDCALL
C. FASTCALL
D. INLINE
Answer: A
46. Which directive is used in MASM to mark external C functions?
A. extern
B. PUBLIC
C. EXTERN C
D. EXTERN
Answer: D
47. Why must we clean the stack after calling C from assembly?
A. To prevent memory leak
B. To avoid segmentation fault
C. Because CDECL requires caller cleanup
D. To terminate program
Answer: C