Mega Assignment:
Assembly Language Programming
Instructions:
1. Complete each question using emu8086 or any other compatible emulator.
2. Write and test each program to ensure it runs without errors.
3. Comment on each line to explain the code's purpose, especially in complex sections.
4. Submit the assignment with program outputs and a brief explanation of each task.
Question 1: Program Structure & Basic Output
Write an assembly program to display the following on the screen:
• Your name and roll number
• The string "Welcome to Assembly Language Programming"
• An instruction to the user to enter a single-digit number
The program should then read a single digit from the user, store it in a variable, and display a message
saying "You entered [digit]".
Question 2: Register Types, Swapping with Registers
Create a program that:
1. Declares two variables, VAR1 and VAR2, initialized with any values of your choice.
2. Swaps their values using only registers (e.g., AX, BX) without a temporary register.
3. After swapping, display the initial and swapped values of both variables on the screen.
Question 3: Service Routines, Interrupts, and Basic I/O
1. Use a service routine to display "Enter a character:".
2. Capture a single character input from the user using the appropriate interrupt (e.g., INT 21h).
3. Store this character in a variable and display it back to the user with the message: "You entered:
[character]".
Bonus Task: Modify the program to allow continuous character input until the user enters 'X' or 'x' to exit.
Question 4: Addressing Modes, LEA, and OFFSET
Write a program that:
1. Declares two variables, VAR_A and VAR_B, initialized with different values of your choice.
2. Uses different addressing modes to load these values into registers (e.g., direct addressing and
register indirect addressing).
3. Calculates and displays the offset of each variable using the LEA and OFFSET directives.
Question 5: Swapping with Temporary Variable
1. Declare two variables, VAR3 and VAR4, and initialize them with values of your choice.
2. Swap their values using a temporary variable.
3. Display the values of VAR3 and VAR4 before and after swapping.
Question 6: Data Types and Character I/O
1. Create a program that prompts the user to enter a single digit (0-9).
2. Use the ASCII code to convert this digit to its integer value (e.g., if the user enters '5', store the
integer 5).
3. Perform a mathematical operation on this integer (e.g., multiply by 2).
4. Display the result on the screen with a message such as "Result after doubling: [result]".
Question 7: Taking Values from User & Conditional Swapping
1. Define three variables A, B, and C.
2. Prompt the user to enter a single digit for each variable:
• Display a message, "Enter a value for A:" and store the input.
• Display a message, "Enter a value for B:" and store the input.
• Display a message, "Enter a value for C:" and store the input.
3. Perform the following swaps, if necessary:
• Swap A and B using register-based swapping.
• Swap B and C using a temporary register.
• Swap A and C using a temporary variable.
4. Display the final values of A, B, and C on the screen with proper labels.
Output Structure:
• Initial Prompt: "Enter a value for A: [input], Enter a value for B: [input], Enter a value for C: [input]"
• Final Output: After any swaps, display the message:
Final values:
A = [final value of A]
B = [final value of B]
C = [final value of C]
Submission Checklist:
1. Completed code for each question.
2. Outputs for each program.
3. Comments and explanations were necessary.
4. Code and output screen shot are mandatory.
5. Code should be mentioned in text as well as.
6. The assignment should be in soft form.
7. Having more than 20% AI & plagiarism is not acceptable.