Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WS OS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nguyen13.Minh@live.uwe.ac.uk
WS OS
Commits
51b71dc9
Commit
51b71dc9
authored
5 months ago
by
Nguyen13.Minh@live.uwe.ac.uk
Browse files
Options
Downloads
Patches
Plain Diff
Update file README.md
parent
1c0d0800
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
worksheet1/README.md
+105
-60
105 additions, 60 deletions
worksheet1/README.md
with
105 additions
and
60 deletions
worksheet1/README.md
+
105
−
60
View file @
51b71dc9
...
...
@@ -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

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
**

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

...
...
@@ -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

...
...
@@ -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

...
...
@@ -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:
**

```
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment