Skip to content
Snippets Groups Projects
Commit 51b71dc9 authored by Nguyen13.Minh@live.uwe.ac.uk's avatar Nguyen13.Minh@live.uwe.ac.uk
Browse files

Update file README.md

parent 1c0d0800
No related branches found
No related tags found
No related merge requests found
......@@ -10,9 +10,17 @@ This worksheet focuses on the implementation of assembler programs, use of exter
---
## Repository Structure
repo-name/
**Repository Structure**
```
ws-os/
├──worksheet1
├── image/
├── 1.png
├── 1.2.png
├── 2.1.png
├── 2.2.png
├── 2.3.png
├── Makefile.png
├── README.md
├── asm_io.inc
├── asm_io.asm
......@@ -24,11 +32,9 @@ repo-name/
├── task2.3.asm
├── Makefile
## Task 1
Task 1: Adding Two Integers
Task 1.1: Basic Addition
```
**Task 1: Adding Two Integers**
#Task 1.1: Basic Addition
![Reference Image](/home/nguyen13-minh/ws-os/worksheet1/image/1.png)
The program initializes two integers, computes their sum, and displays the result using print_int from asm_io.
......@@ -45,18 +51,22 @@ Output: The sum is printed on the console.
Testing and Build Instructions:
Assemble the code:
```
nasm -f elf task1.asm -o task1.o
```
Link the object file with asm_io.o:
```
gcc -m32 task1.o asm_io.o -o task1
```
Run the executable:
```
./task1
```
Output:
```
21
Task 1.2: User-Defined Addition
```
**Task 1.2: User-Defined Addition**
![Reference Image](/home/nguyen13-minh/ws-os/worksheet1/image/1.2.png)
Extends Task 1.1 to accept user input for two integers and prints their sum with a formatted message.
......@@ -67,20 +77,28 @@ Add the integers and store the result in a register.
Use print_string and print_int to format and display the result.
Build Instructions:
Assemble the code:
**Assemble the code:**
```
nasm -f elf task1.2.asm -o task1.2.o
Link the object file with asm_io.o:
```
**Link the object file with asm_io.o:**
```
gcc -m32 task1.2.o asm_io.o -o task1.2
Run the executable:
```
**Run the executable:**
```
./task1_2
Output Example:
```
**Output Example:**
```
Enter a number: 15
Enter a number: 6
The sum of 15 and 6 is: 21
```
## Task 2
Task 2: Loops, Conditions, and Arrays
##Task 2.1
**Task 2: Loops, Conditions, and Arrays**
#Task 2.1
Task 2.1: User Interaction and Validation
![Reference Image](/home/nguyen13-minh/ws-os/worksheet1/image/2.1.png)
......@@ -91,16 +109,25 @@ This task implements a program that:
3 Validates user input, shows error if number is not valid
Build Instructions:
**Assemble the code:**
```
nasm -f elf task2.1.asm -o task2.1.o
```
**Link the object file with asm_io.o:**
```
gcc -m32 task2.1.o asm_io.o -o task2.1
```
**Run the executable:**
```
./task2.1
Output Example:
```
**Output Example:**
```
Enter your name: Minh
Enter the number of times to print the welcome message: 5
The number must be greater than 50 and less than 100!
##Task 2.2
```
#Task 2.2
Task 2.2: Array Initialization and Summation
![Reference Image](/home/nguyen13-minh/ws-os/worksheet1/image/2.2.png)
......@@ -113,17 +140,23 @@ Use another loop to compute the sum of the array elements.
Display the result using print_int.
Build Instructions:
Assemble the code:
**Assemble the code:**
```
nasm -f elf task2.2.asm -o task2.2.o
Link the object file with asm_io.o:
```
**Link the object file with asm_io.o:**
```
gcc -m32 task2.2.o asm_io.o -o task2.2
Run the executable:
```
**Run the executable:**
```
./task2.2
Output Example:
```
**Output Example:**
```
Sum of array: 5050
##Task 2.3
```
#Task 2.3
Task 2.3: Summing a Range in an Array
![Reference Image](/home/nguyen13-minh/ws-os/worksheet1/image/2.3.png)
......@@ -137,25 +170,33 @@ Use a loop to compute the sum of elements in the specified range.
Display the result using print_int.
Build Instructions:
Assemble the code:
**Assemble the code:**
```
nasm -f elf task2.3.asm -o task2.3.o
Link the object file with asm_io.o:
```
**Link the object file with asm_io.o:**
```
gcc -m32 task2.3.o asm_io.o -o task2.3
Run the executable:
```
**Run the executable:**
```
./task2.3
Output Example:
```
**Output Example:**
```
Enter start of index(0-99): 10
Enter end index: 20
The sum of the range is: 165
```
## Task 3
Task 3: Automating the Build Process with Make
**Task 3: Automating the Build Process with Make**
Objective:
The Makefile automates the compilation of all tasks for streamlined testing and execution.
Sample Makefile:
**Sample Makefile:**
![Reference Image](/home/nguyen13-minh/ws-os/worksheet1/image/Makefile.png)
```
all: task1 task1.2 task2.1 task2.2 task2.3
task1: task1.o asm_io.o
......@@ -175,17 +216,21 @@ task2_3: task2.3.o asm_io.o
clean:
rm -f *.o task1 task1.2 task2.1 task2.2 task2.3
Commands:
make all
./task1
./task1.2
./task2.1
./task2.2
./task2.3
```
**Commands:**
**Build the Kernel and ISO**
```
make
```
**Clean the Workspace**
```
make clean
Lessons Learned:
```
**Run the OS in QEMU**
```
make run
```
**Lessons Learned:**
1 Gained familiarity with assembler programming for basic operations, user interaction, and array manipulation.
2 Learned how to call external libraries and integrate assembler code with C.
3 Automated repetitive build tasks with a Makefile.
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment