Skip to content
Snippets Groups Projects
Commit 1e483fea authored by Hazal2.Veziroglu@live.uwe.ac.uk's avatar Hazal2.Veziroglu@live.uwe.ac.uk
Browse files

Update 24 files

- /Worksheet_1/src/task2.asm
- /Worksheet_1/src/task3.asm
- /Worksheet_1/asm_io.o
- /Worksheet_1/driver.o
- /Worksheet_1/print_int.o
- /Worksheet_1/task1
- /Worksheet_1/task1.o
- /Worksheet_1/task2
- /Worksheet_1/task2.o
- /Worksheet_1/task3
- /Worksheet_1/task3.o
- /Worksheet_1/Makefile
- /Worksheet_1/README.md
- /Worksheet_1/src/task2_2.asm
- /Worksheet_1/src/task1
- /Worksheet_1/src/task2_1.asm
- /Worksheet_1/src/task2_1
- /Worksheet_1/src/task1.o
- /Worksheet_1/src/driver.o
- /Worksheet_1/src/print_int.o
- /Worksheet_1/src/task2_2.o
- /Worksheet_1/src/task2_2
- /Worksheet_1/src/asm_io.o
- /Worksheet_1/src/task2_1.o
parent 679ee47b
No related branches found
No related tags found
No related merge requests found
all: task1 task2 task3 all: task1 task2_1 task2_2
task1: src/task1.o src/driver.o src/asm_io.o task1: src/task1.o src/driver.o src/asm_io.o
gcc -m32 -o src/task1 src/task1.o src/driver.o src/asm_io.o gcc -m32 -o src/task1 src/task1.o src/driver.o src/asm_io.o
task2: src/task2.o src/driver.o src/asm_io.o src/print_int.o task2_1: src/task2_1.o src/driver.o src/asm_io.o src/print_int.o
gcc -m32 -o src/task2 src/task2.o src/driver.o src/asm_io.o src/print_int.o gcc -m32 -o src/task2_1 src/task2_1.o src/driver.o src/asm_io.o src/print_int.o
task3: src/task3.o src/driver.o src/asm_io.o src/print_int.o task2_2: src/task2_2.o src/driver.o src/asm_io.o src/print_int.o
gcc -m32 -o src/task3 src/task3.o src/driver.o src/asm_io.o src/print_int.o gcc -m32 -o src/task2_2 src/task2_2.o src/driver.o src/asm_io.o src/print_int.o
src/task1.o: src/task1.asm src/task1.o: src/task1.asm
nasm -f elf src/task1.asm -o src/task1.o nasm -f elf src/task1.asm -o src/task1.o
src/task2.o: src/task2.asm src/task2_1.o: src/task2_1.asm
nasm -f elf src/task2.asm -o src/task2.o nasm -f elf src/task2_1.asm -o src/task2_1.o
src/task3.o: src/task3.asm src/task2_2.o: src/task2_2.asm
nasm -f elf src/task3.asm -o src/task3.o nasm -f elf src/task2_2.asm -o src/task2_2.o
src/driver.o: src/driver.c src/driver.o: src/driver.c
gcc -m32 -c src/driver.c -o src/driver.o gcc -m32 -c src/driver.c -o src/driver.o
...@@ -28,4 +28,4 @@ src/print_int.o: src/print_int.c ...@@ -28,4 +28,4 @@ src/print_int.o: src/print_int.c
gcc -m32 -c src/print_int.c -o src/print_int.o gcc -m32 -c src/print_int.c -o src/print_int.o
clean: clean:
rm -f src/*.o src/task1 src/task2 src/task3 rm -f src/*.o src/task1 src/task2_1 src/task2_2
...@@ -61,11 +61,11 @@ apt install -y libc6-dev ...@@ -61,11 +61,11 @@ apt install -y libc6-dev
``` ```
- Task 2: - Task 2:
```bash ```bash
./src/task2 ./src/task2_1
``` ```
- Task 3: - Task 2_2:
```bash ```bash
./src/task3 ./src/task2_2
``` ```
- Clean up object files and executables: - Clean up object files and executables:
```bash ```bash
...@@ -113,11 +113,11 @@ call _print_int ...@@ -113,11 +113,11 @@ call _print_int
#### How to Compile and Run: #### How to Compile and Run:
1. Compile the assembly file: 1. Compile the assembly file:
```bash ```bash
nasm -f elf32 src/task1.asm -o task1.o nasm -f elf32 src/task1.asm -o src/task1.o
``` ```
2. Link with `driver.o` and `print_int.o`: 2. Link the compiled task1.o, driver.o, and print_int.o files using gcc to create an executable file:
```bash ```bash
gcc -m32 task1.o src/driver.o src/print_int.o -o src/task1 gcc -m32 src/task1.o src/driver.o src/print_int.o -o src/task1
``` ```
3. Run the executable: 3. Run the executable:
```bash ```bash
...@@ -133,8 +133,8 @@ call _print_int ...@@ -133,8 +133,8 @@ call _print_int
--- ---
## Task 2: Loops and Conditionals ## Task 2_1: Loops and Conditionals
- **File**: `task2.asm` - **File**: `task2_1.asm`
- **Description**: Implements a loop to sum an array of integers and validates user input. - **Description**: Implements a loop to sum an array of integers and validates user input.
### Code Explanation: ### Code Explanation:
...@@ -186,33 +186,34 @@ call _print_int ...@@ -186,33 +186,34 @@ call _print_int
#### How to Compile and Run: #### How to Compile and Run:
1. Compile the assembly file: 1. Compile the assembly file:
```bash ```bash
nasm -f elf32 src/task2.asm -o task2.o nasm -f elf32 src/task2_1.asm -o src/task2_1.o
``` ```
2. Link with `driver.o`: 2. Link the compiled task2_1.o, driver.o, and print_int.o files using gcc to create an executable file:
```bash ```bash
gcc -m32 task2.o driver.o asm_io.o -o task2 gcc -m32 src/task2_1.o src/driver.o src/print_int.o -o src/task2_1
``` ```
3. Run the executable: 3. Run the executable:
```bash ```bash
./src/task2 ./src/task2_1
``` ```
# Task 2 Output # Task 2_1 Output
## Screenshot of Task 2 ## Screenshot of Task 2_1
The following screenshot demonstrates the successful execution of Task 2. It showcases the program's ability to validate user input and sum an array of integers within a specified range. The following screenshot demonstrates the successful execution of Task 2. It showcases the program's ability to validate user input and sum an array of integers within a specified range.
![Task 2 Output](images/photo2.png) ![Task 2_1 Output](images/photo2.png)
## Explanation ## Explanation
In Task 2, the program performs two main functions: In Task 2_1, the program performs two main functions:
1. Validates user input to ensure the entered number is within a specified range (50–100). 1. Validates user input to ensure the entered number is within a specified range (50–100).
2. Sums integers from an array and displays the result. 2. Sums integers from an array and displays the result.
--- ---
### Task 3: Loops and Conditionals ### Task 2_2: Loops and Conditionals
- **File**: `task3.asm` - **File**: `task2_2.asm`
- **Description**: This task sums integers within a specified range using loops in assembly. - **Description**: This task sums integers within a specified range using loops in assembly.
It calculates the total sum of all numbers between two user-provided inputs. It calculates the total sum of all numbers between two user-provided inputs.
...@@ -252,22 +253,24 @@ Uses a loop to add all integers between start and end inclusively. ...@@ -252,22 +253,24 @@ Uses a loop to add all integers between start and end inclusively.
#### How to Compile and Run: #### How to Compile and Run:
1. Compile the assembly file: 1. Compile the assembly file:
```bash ```bash
nasm -f elf32 src/task3.asm -o task3.o nasm -f elf32 src/task2_2.asm -o src/task2_2.o
``` ```
2. Link with driver.o to create the executable: 2. Link the compiled task1.o, driver.o, and print_int.o files using gcc to create an executable file:
```bash ```bash
gcc -m32 task3.o driver.o asm_io.o -o task3 gcc -m32 src/task2_2.o src/driver.o src/print_int.o -o src/task2_2
``` ```
3. Run the program: 3. Run the program:
```bash ```bash
./src/task3 ./src/task2_2
``` ```
# Task 3 Output # Task 2_2 Output
## Screenshot of Task 3 ## Screenshot of Task 2_2
The following screenshot demonstrates the successful execution of Task 3. It shows the program prompting the user to enter the size of an array and values one by one. It calculates the maximum, minimum, and sum of all values. The following screenshot demonstrates the successful execution of Task 2_2. It shows the program prompting the user to enter the size of an array and values one by one. It calculates the maximum, minimum, and sum of all values.
![Task 3 Output](images/photo3.png) ![Task 2_2 Output](images/photo3.png)
## Explanation ## Explanation
In Task 3, the program performs the following operations: In Task 3, the program performs the following operations:
...@@ -294,24 +297,14 @@ worksheet_1/ ...@@ -294,24 +297,14 @@ worksheet_1/
│ ├── driver.c # Main C program calling assembly functions │ ├── driver.c # Main C program calling assembly functions
│ ├── print_int.c # Helper C program for printing integers │ ├── print_int.c # Helper C program for printing integers
│ ├── task1.asm # Assembly code for Task 1 │ ├── task1.asm # Assembly code for Task 1
│ ├── task2.asm # Assembly code for Task 2 │ ├── task2_1.asm # Assembly code for Task 2
│ ├── task3.asm # Assembly code for Task 3 │ ├── task2_2.asm # Assembly code for Task 3
├── task1 # Compiled Task 1 executable ├── task1 # Compiled Task 1 executable
├── task2 # Compiled Task 2 executable ├── task2_1 # Compiled Task 2 executable
├── task3 # Compiled Task 3 executable ├── task2_2 # Compiled Task 3 executable
└── *.o # Object files (task1.o, task2.o, task3.o, asm_io.o, driver.o, print_int.o) └── *.o # Object files (task1.o, task2.o, task2_2.o, asm_io.o, driver.o, print_int.o)
``` ```
## Screenshots and Outputs
To fulfill the documentation requirements, include screenshots of:
1. **Task 1 Output**: Showing the result of adding two integers.
2. **Task 2 Output**: Demonstrating user input validation and array summation.
3. **Task 3 Build**: Displaying the successful build process using the `Makefile`.
Include brief explanations for each screenshot.
---
## Authors ## Authors
......
File moved
File moved
File moved
File moved
File moved
No preview for this file type
File moved
No preview for this file type
No preview for this file type
File moved
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment