Introduction to Assembly Language Programming
Objective:
The purpose of this assignment is to help students understand and refresh their knowledge of basic
assembly language programming concepts. Students will practice simple assembly instructions,
familiarize themselves with register usages and write basic programs to reinforce their
understanding.
Materials:
- Access to an assembler and emulator (e.g., MASM, NASM, or an online assembly emulator
like OneCompiler).
OneCompiler: [Link]
- Reference sheets for x86 assembly language instructions.
- A code editor (VS Code, Sublime Text, or any preferred editor with assembly language
support).
Breakdown:
• Activity 1: Basic Assembly Language Syntax
• Activity 2: Simple Arithmetic Operations
• Activity 3: Loops and Conditional Statements
Activity 1: Basic Assembly Language Syntax
1. Overview of Assembly Language: Assembly language is a low-level programming language
that directly communicates with a computer's hardware. Each line of code in assembly
typically corresponds to a single machine instruction.
2. Registers: Common registers in x86 assembly:
- EAX, EBX, ECX, EDX: General-purpose registers.
- ESP, EBP: Stack pointer and base pointer.
- ESI, EDI: Index registers for string operations.
3. Practice: Below is a simple assembly snippet. Analyze the code and identify the purpose of
each line.
4. Task:
- Describe the purpose of mov eax, 4, mov ebx, 1, and int 0x80.
- Explain how system calls work in this context.
Example code to print the value of eax register
Activity 2: Simple Arithmetic Operations
1. Objective: Students will perform basic arithmetic operations in assembly, such as addition,
subtraction, and multiplication.
2. Example:
3. Task:
- Run the provided snippet in your assembler.
- Modify the program to divide the result by 2 using the div instruction.
- Prints the output of modified program.
4. Discussion:
- What are the final contents of the eax register after the arithmetic operations?
Activity 3: Loops and Conditional Statements
1. Objective: Learn how to create loops and conditional statements in assembly using jump
instructions.
2. Example: Loop to Sum Numbers 1 to 10:
3. Task:
- Run the program and verify the result.
- Modify the program to calculate the sum of numbers from 1 to 20
- Prints the output of modified program.
4. Discussion:
- What changes did you make to handle numbers beyond 10?
- Why is loop a useful instruction for this task?
Assignment Submission:
Submit the following on Moodle:
1. The codes from Activities 2 and 3.
2. Your descriptions, explanations, and discussions from Activity 1, 2, and 3.