Module Title
|
Fundamentals of Computer Systems
|
Assignment Mode
|
Individual Assignment
|
Word Count Limit
|
2000 words (+/- 10%)
|
Citation Format
|
APA
|
Marks
|
100 marks
|
Due Date
|
Last Lesson
|
Assignment Brief (Assembly Language )
Objective:
The primary aim of this assignment is to assess your proficiency in assembly language programming, specifically focusing on key areas such as simple data structure and code documentation. This includes demonstrating a good understanding of assembly language concepts when implementing AL solutions for this assignment. You are required to implement, document, and optimize code while ensuring efficiency, clarity, and adherence to best practices.
Assignment Question
|
Topics Covered
|
Learning Outcomes (LOs)
|
1. Array Initialization
|
- Topic 8
|
- Understand instructions; ALU instructions
|
2. Linear Search Implementation
|
- Topic 8
|
- Understand the Flags/Status register
- Understand instructions; ALU instructions
- Understand control, branching and loops
|
3. Target Value Handling
|
- Topic 8
- Topic 9
|
- INT 21h for inputs and outputs
- Understand the Flags/Status register
- Understand instructions; ALU instructions
- Understand control, branching and loops
- Understand exceptions and exception handling
|
4. Code Efficiency
|
- Topic 8
|
- INT 21h for inputs and outputs
- Understand the Flags/Status register
- Understand instructions; ALU instructions
- Understand control, branching and loops
|
Requirements:
1. Array Initialization (13 marks)
o Correctly initialize an array with specified values.
o Ensure array syntax is correct and values are in the expected order.
2. Linear Search Implementation (28 marks)
o Implement a Linear Search algorithm to find a target value in an array.
o Ensure the algorithm is efficient and correctly identifies the target.
3. Target Value Handling (13 marks)
o Search for a specific target value and output the corresponding index.
o Display the correct index and handle cases where the target is not found.
4. Code Efficiency (13 marks)
o Optimize code to reduce redundancy and improve execution speed.
o Use registers and instructions efficiently to achieve optimal performance.
5. Comments and Documentation (13 marks)
o Provide clear, detailed comments explaining each part of the code.
o Ensure the code is understandable and maintainable.
6. Live Demo & Communication (20 marks)
o Provide clear and confident explanation of the code’s functionality and the logic behind it.
o Demonstrated strong understanding of the code.
Deliverables:
. A comprehensive report including code snippets and explanations.
. Assignments to be written in NASM for DosBox or DosBox Staging.
. Assignment code to be submitted as linear.asm file.
Submission Guidelines:
. Submit all required files in a zip folder named as: LastName_FirstName_FCS.zip.
. Upload your assignment via the online submission portal by the stated deadline.
Detailed Rubric:
Attached Marking Rubrics
Note: Instant 0 mark will be awarded for the assignment if assembly codes are not written in NASM for DosBox, or DosBox Staging.
Implementing Linear Search
You will write an assembly program to create a linear search algorithm (refer to Appendix) to find a target value within an array of numbers (5, 3, 7, 1, 4, 9, 2, 8, 6) and display the index of the target value. The program will then display on the screen: Element found at index: 8. (Since target value is 6, the index to be displayed on the screen is 8.)
Compulsory code to be included for Assignment:
section .data
array db 5, 3, 7, 1, 4, 9, 2, 8, 6 ; Array of elements
array_size db 9 ; Size of the array (byte)
target db 6 ; Target value to search for (byte)
Expected output for Assignment:
C:\> linear.com
Element found at index: 8
Assessment Summary:
1. Array Initialization: The array is correctly initialized with the required values. This consistency shows attention to detail in setting up data for operations.
2. Linear Search Implementation: The Linear Search algorithm is correctly implemented to find the target value (6). The algorithm efficiently traverses the array to find the specified value, demonstrating a solid understanding of search techniques in assembly language.
3. Target Value Handling: The program correctly finds the target value and displays the output: "Element found at index: 8." The correct handling and output of the target index show proficiency in addressing elements in the array.
4. Code Efficiency: The code uses optimal logic and efficient register management, demonstrating an understanding of how to execute search operations effectively in assembly.
5. Comments and Documentation: The code includes detailed comments, providing clear explanations of the logic and processes. This practice aids in understanding the code’s flow and purpose, highlighting good coding habits.
6. Live Demo & Communication: Provide clear and confident explanation of the code’s functionality and the logic behind it. Demonstrate strong understanding of the code.
Appendix
LINEAR SEARCH
Linear search is a straightforward searching algorithm used to find a target value in a list or array. It works by sequentially checking each element in the list until the target is found or the end of the list is reached.
Steps:
1. Start from the beginning of the list.
2. Compare each element one by one with the target value.
o If an element matches the target, the search is successful, and the index of the element is returned.
o If no match is found by the end of the list, the target isn’t in the list.
3. End the search once the target is found or the list has been fully traversed.
Example:
Suppose we have a list:
[10,23,45,70,11,15]
and we’re searching for the target value 70.
1. Compare 10 with 70 (no match).
2. Compare 23 with 70 (no match).
3. Compare 45 with 70 (no match).
4. Compare 70 with 70 (match found!).
Since the target 70 is found at index 3, the search stops, and the index 3 is returned.
Efficiency:
. Time Complexity: O(n) in the worst and average cases, where nnn is the number of elements.
. Space Complexity: O(1) since it’s an in-place search.
Usage:
Linear search is useful for:
. Unsorted or small lists where a more complex search algorithm would add unnecessary overhead.
. Linked lists or similar data structures where random access is costly or impossible, as linear search does not rely on indexing.
While linear search is simple and flexible, it’s less efficient than binary search for sorted lists due to its O(n) time complexity.
Linear Search - CS50 Shorts:
https://www.youtube.com/watch?v=TwsgCHYmbbA