Computer Organization and Assembly Language Lab                   CS-222L
LAB REPORT - 02
Computer organization and Assembly language Lab
Course Title: Computer organization and Assembly language
Lab Title: Programming with NASM and Linux System call
Name: Muhammad Salman
Reg. #: UW-23-SW-BS-023
Semester: 4th
Date: 04/03/2025
Submitted To: Engr. Armughan
LAB REPORT
 Presentation/Procedure         Code      Comments     Response   Total
                                              &
                                          conclusion
1|Page
Computer Organization and Assembly Language Lab   CS-222L
                                         Tasks
Lab Task 1: Run Example 1
Save the file as a “hello.nasm” and execute
Output:
Procedure:
   1. Start program with _start label.
   2. Use eax = 4 for sys_write.
   3. Use ebx = 1 for stdout.
   4. Use ecx = msg for message address.
   5. Use edx = 13 for message length.
   6. Call int 0x80 to print message.
   7. Use eax = 1 for sys_exit.
   8. Use ebx = 0 for exit code.
   9. Call int 0x80 to exit.
2|Page
Computer Organization and Assembly Language Lab                         CS-222L
Lab Task 2: Run Example 2
Save the file as a “read_print.asm” and execute
                        Output:
Procedure:
   1.   Start program with _start label.
   2.   Use eax = 4, ebx = 1, ecx = msg, edx = len to display prompt.
   3.   Call int 0x80.
   4.   Use eax = 3, ebx = 0, ecx = buffer, edx = 100 to read input.
   5.   Call int 0x80.
   6.   Use eax = 4, ebx = 1, ecx = buffer, edx = 100 to print input.
   7.   Call int 0x80.
   8.   Use eax = 1, ebx = 0, then int 0x80 to exit.
3|Page
Computer Organization and Assembly Language Lab                CS-222L
Lab Task 3: Modify Example 1
Output:
Procedure:
   1.   Start program with _start label.
   2.   Define new message Welcome to Assembly Programming!.
   3.   Use eax = 4, ebx = 1, ecx = msg, edx = 30.
   4.   Call int 0x80 to print message.
   5.   Use eax = 1, ebx = 0.
   6.   Call int 0x80 to exit.
4|Page
Computer Organization and Assembly Language Lab                         CS-222L
Lab Task 4: Modify Example 2
Output:
Procedure:
   1.   Start program with _start label.
   2.   Use eax = 4, ebx = 1, ecx = msg, edx = len to display prompt.
   3.   Call int 0x80.
   4.   Use eax = 3, ebx = 0, ecx = buffer, edx = 50 to read input.
   5.   Call int 0x80.
   6.   Use eax = 4, ebx = 1, ecx = buffer, edx = 50 to print input.
   7.   Call int 0x80.
   8.   Use eax = 1, ebx = 0, then int 0x80 to exit.
5|Page
Computer Organization and Assembly Language Lab                                      CS-222L
Comments;
•     This lab exercise was a valuable introduction to the fundamentals of x86 assembly
      language programming using NASM and Linux system calls.
•     The tasks were structured in a way that gradually built up the learner’s understanding—
      from printing a simple message to handling user input and modifying behavior based on
      program logic.
•     By directly working with system calls like sys_write, sys_read, and sys_exit, and using
      registers such as eax, ebx, ecx, and edx, students experienced how arguments are
      passed and how the processor communicates with the operating system.
•     The hands-on nature of the lab helped in visualizing the flow of control at the machine
      level, and the use of sections like .data, .bss, and .text illustrated how memory and
      code are organized in assembly.
•     The requirement to modify the existing code (e.g., changing the message or limiting
      input size) encouraged critical thinking and gave students confidence to experiment with
      assembly instructions.
•     Overall, the lab effectively blended theory with practice, making abstract architectural
      concepts more tangible and easier to grasp.
Conclusion;
    In conclusion, Lab #02 served as an excellent stepping stone into the world of low-level
    programming using assembly language. It achieved its goal of helping students understand
    how a processor interacts with memory, handles input/output, and executes instructions
    using system calls. Writing programs using NASM on a Linux environment gave a real-world
    context to theoretical topics like CPU registers, memory segmentation, and system-level
    programming. The experience of assembling, linking, and executing the code helped
    students understand the complete lifecycle of a program, from source code to executable.
    Moreover, tasks like modifying code and changing buffer sizes reinforced the importance
    of precision and control that is unique to assembly language. This lab has laid a solid
    foundation for future topics in computer architecture, operating systems, and embedded
    system development by fostering a deeper appreciation of how computers operate at the
    most fundamental level.
    _________________END_______________
6|Page