0% found this document useful (0 votes)
5 views

Assignment No 2 of Computer Organization and Assembly Language

Uploaded by

Assad Leo
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Assignment No 2 of Computer Organization and Assembly Language

Uploaded by

Assad Leo
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Assignment: Computer Organization and Assembly Language

Objective:

The objective of this assignment is to gain a deeper understanding of the underlying hardware
of a computer, its architecture, and how assembly language interacts with the hardware. You
will write assembly programs, analyze CPU architecture, and work with memory
management.

Assignment Tasks:

Part 1: Understanding Computer Architecture

1. CPU Architecture and Registers


o Task 1.1: Describe the basic components of a CPU (Central Processing Unit),
including the Control Unit (CU), Arithmetic Logic Unit (ALU), and registers.
Explain the role of each component.
o Task 1.2: List the types of registers found in most CPUs (e.g., general-purpose
registers, status registers, program counter) and explain their functions.
o Task 1.3: Discuss the concept of the instruction cycle (Fetch-Decode-Execute
cycle) and how the CPU processes instructions.
2. Memory Hierarchy
o Task 2.1: Explain the different levels of memory hierarchy (Registers, Cache,
RAM, Disk Storage). Discuss their relative speed, size, and cost.
o Task 2.2: Define and differentiate between volatile and non-volatile memory.
Provide examples of each.
3. Instruction Set Architecture (ISA)
o Task 3.1: Define Instruction Set Architecture and discuss its role in the
communication between software and hardware.
o Task 3.2: List and explain the common types of instructions in a typical ISA
(e.g., data movement, arithmetic, control, and logical operations).
4. Addressing Modes
o Task 4.1: Explain the following addressing modes with examples:
 Immediate addressing
 Register addressing
 Direct addressing
 Indirect addressing
 Indexed addressing
o Task 4.2: Discuss the advantages and disadvantages of different addressing
modes.

Part 2: Assembly Language Programming

1. Basic Assembly Program


o Task 5.1: Write an assembly program to add two numbers stored in memory
and store the result in a third memory location. Assume the use of a simple
ISA (like x86, ARM, or MIPS) and use basic operations like MOV, ADD, and
STO.
o Task 5.2: Convert the following high-level pseudo-code into assembly
language: (try it in C++ Emulator)

css
Copy code
if (a > b)
c = a - b;
else
c = b - a;

2. Loop and Control Structures in Assembly


o Task 6.1: Write an assembly program to compute the factorial of a given
number n using a loop.
o Task 6.2: Implement a program that uses conditional branching (IF, ELSE,
ENDIF) to check whether a number is even or odd.
3. Function Calls and Stacks
o Task 7.1: Write an assembly program that defines a function to calculate the
square of a number. Demonstrate function calling and returning values using
the stack.
o Task 7.2: Explain how the stack is used for function calls, argument passing,
and storing local variables. Provide an example program that demonstrates the
use of the stack.
4. Memory and Pointers in Assembly
o Task 8.1: Write an assembly program to access and manipulate values in an
array. The array should be stored in memory, and your program should be able
to add an element to the array and print the array values.
o Task 8.2: Demonstrate pointer arithmetic by writing a program that traverses
an array using pointers.

Part 3: Advanced Topics

1. Optimizing Assembly Code


o Task 9.1: Optimize a given assembly code for performance. Explain the
changes you made and why they improve efficiency (e.g., reducing instruction
count, minimizing memory access).
o Task 9.2: Discuss how compiler optimizations relate to assembly code and
provide an example where assembly programmers can manually optimize their
code.
2. Interrupts and I/O Operations
o Task 10.1: Describe the concept of interrupts in computer architecture. How
does the CPU handle interrupts?
o Task 10.2: Write an assembly program that handles basic I/O operations, such
as reading input from a user and printing output to the console. Use
appropriate system calls or BIOS interrupts.
Part 4: Practical Exercises

1. Assembler Tools
o Task 11.1: Download and install an assembler tool (e.g., NASM, MASM, or
any suitable assembler for your architecture). Write, assemble, and run a
simple program on your chosen platform.
o Task 11.2: Explain the steps involved in assembling and linking an assembly
program to produce an executable file.
2. Simulation of CPU Execution
o Task 12.1: Using a CPU simulator (such as a MIPS or ARM simulator), write
a simple program and trace the program's execution cycle (Fetch-Decode-
Execute). Provide a screenshot of the simulator output and explain the results.

Deliverables:

 Part 1: A detailed report discussing the CPU architecture, memory hierarchy,


instruction set architecture, and addressing modes. Include diagrams wherever
applicable.
 Part 2: Source code for each of the assembly programs written in the tasks. Include
comments to explain each part of the code.
 Part 3: A report on optimizing assembly code, including the original code and the
optimized version.
 Part 4: A practical submission demonstrating the use of an assembler tool and CPU
simulator. Include screenshots, code, and explanations.

Submit Your Assignment by Hard Copy or Email to: [email protected]

Thanks Students

Najam ul Hassan

You might also like