MPL Oral Question Bank Solution
MPL Oral Question Bank Solution
MPL Oral Question Bank Solution
1. What is an assembler?
- An assembler is a program that translates assembly language code into machine code
or object code. It converts mnemonic instructions and symbols into binary code that can
be understood and executed by the computer's processor.
2. What is NASM?
- NASM (Netwide Assembler) is a popular assembler used for x86 and x86-64
architectures. It is known for its simplicity and portability and is widely used in the
development of low-level software, operating systems, and embedded systems.
20. Tell the difference between conditional JMP and unconditional JMP.
- Conditional JMP instructions perform a jump to a specified memory location or label
only if a certain condition is satisfied (e.g., JZ - jump if zero, JG - jump if greater).
- Unconditional JMP instructions always perform a jump to a specified memory
location or label without any condition.
27. Explain instructions used in your program? Explain any instruction (learn all
instructions):
- It is not clear what specific instructions you want an explanation for. Assembly
language instructions encompass a wide range of operations, such as arithmetic (ADD,
SUB, MUL, DIV), logical (AND, OR, XOR, NOT), data movement (MOV, PUSH,
POP), control flow (JMP, CALL, RET), and many more. If you specify a particular
instruction, I can provide an explanation.
28. Define addressing modes:
- Addressing modes determine how the operands of an instruction are accessed or
addressed in memory. They specify the location or addressing method for the source or
destination data of an instruction. Common addressing modes include immediate,
register, memory direct, memory indirect, indexed, and more.
32. What are the directives used in your program? Explain any directives (learn all
directives):
- It is not clear which specific directives you want an explanation for. Directives in
assembly language provide instructions to the assembler or linker for various purposes
such as defining symbols, reserving memory, including libraries, and more. Some
common directives include ORG, DB, DW, DD, RESB, SECTION, GLOBAL,
EXTERN, and many others. If you specify a particular directive, I can provide an
explanation.
33. What are the steps to execute an assembly language program on NASM?
- The steps to execute an assembly language program on NASM typically include:
1. Install NASM on your system.
2. Write your assembly code using a text editor and save it with a .asm extension.
3. Open the terminal or command prompt and navigate to the directory where your
assembly file is located.
4. Assemble the code using the NASM assembler by running the command: `nasm -f
<output-format> <input-file.asm> -o <output-file>`.
5. Link the assembled object file using a linker like ld by running the command: `ld
<input-file.o> -o <output-file>`.
6. Execute the compiled program by running the command: `./<output-file>` (on
Unix-based systems) or `<output-file>` (on Windows systems).
35. What are the string instructions and how do they work?
- String instructions in assembly language are a set of instructions specifically designed
for manipulating strings of characters or bytes. They provide functionality such as
copying, comparing, searching, and manipulating strings. Examples of string instructions
include MOVSB (move byte from the source to the destination), CMPSB (compare byte
from the source with the byte at the destination), SCASB (scan byte in the string with the
byte in AL), and many more.
42. What are the different ways to write ADD instructions (using different addressing
modes)?
- The ADD instruction can be written using various addressing modes, including:
- Immediate addressing: ADD reg, immediate
- Register addressing: ADD reg1, reg2
- Memory direct addressing: ADD reg, [mem]
- Memory indirect addressing: ADD reg, [reg]
- Indexed addressing: ADD reg, [reg + offset]
43. Differentiate between a procedure and a macro.
- Procedures and macros serve different purposes in assembly language:
- Procedure: A procedure is a named block of code that performs a specific task or
operation. It is defined once and can be called multiple times from different parts of the
program. Procedures promote code reusability and modular programming.
- Macro: A macro is a sequence of instructions or statements that is defined once and
can be expanded or instantiated multiple times throughout the program. Macros allow
code reuse and simplification of repetitive tasks.
- Near Procedure:
- Resides within the same code segment as the calling code.
- Can be called directly using a simple label.
- Used for local or short-distance subroutine calls.
- Suitable for small programs or code within the same segment.
55. How to read the value from the MSW (specify instruction)?
- To read the value from the MSW (Machine Status Word), you can use the MOV
instruction to move the value of the MSW
60. How to read the content of LDTR, GDTR, IDTR, TR, MSW?
- To read the content of LDTR, GDTR, IDTR, TR (Task Register), and MSW (Machine
Status Word), you can use the MOV instruction to move the value of the corresponding
control register into a general-purpose register. For example:
- LDTR: `MOV AX, LDTR`
- GDTR: `MOV AX, GDTR`
- IDTR: `MOV AX, IDTR`
- TR: `MOV AX, TR`
- MSW: `MOV AX, CR0`
.
- Unfortunately, as a text-based AI, I cannot draw images or diagrams. However, I can
describe the formats briefly:
- Flag Register: The Flag Register (FLAGS) is a 16-bit register in the x86 architecture
that stores various status flags, such as carry, zero, sign, overflow, and others. The flags
can be modified by arithmetic and logical instructions.
- Control Register Format: The control registers (CR0, CR2, CR3, CR4) in the x86
architecture have a 32-bit format. They store control bits for various system and
processor settings.
- Descriptor Format: Segment descriptors in the x86 architecture have a specific
format. A descriptor consists of 8 bytes and includes fields for segment limit, base
address, access rights, and other attributes. The format of the descriptor varies depending
on whether it is a code segment, data segment, system segment, or gate descriptor.