Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
84033b6
infra/actions: Add `x86_64` branch to linters
teodutu Apr 30, 2025
1dfb5c0
labs/lab-02: Add x86_64 version
CristiSima Apr 27, 2025
4751e8b
labs/lab-04: Add x86_64 version
CristianSLazar Apr 14, 2025
6927624
labs/lab-08: Add x86_64 version of lab 8
denismarian1604 May 4, 2025
4619338
labs/lab-05: Add x86_64 version
mariapana May 11, 2025
b18a362
labs/lab-06: Add x86_64 version of lab 6
PetruCristian Apr 27, 2025
3eaac8c
labs/lab-11: Adapt to x86_64
razvanvirtan May 25, 2025
1cd0396
labs/lab-09: Changed reading materials for x86-64 version
RaduMantu May 11, 2025
c970485
labs/lab-09: Added reading material for GCC Extended ASM
RaduMantu May 24, 2025
8c36d4b
labs/lab-09: Changed export-fix task
RaduMantu May 11, 2025
93d0448
labs/lab-09: Changed include-fix task
RaduMantu May 11, 2025
213237a
labs/lab-09: Changed max-c-calls task
RaduMantu May 11, 2025
13fe8a5
labs/lab-09: Changed stack-frame task
RaduMantu May 11, 2025
05fa878
labs/lab-09: Changed regs-preserve task
RaduMantu May 24, 2025
1fa3dbc
labs/lab-09: Changed max-assembly-calls task
RaduMantu May 24, 2025
7ba8733
labs/lab-09: Added 32-bit version of max-assembly-calls
RaduMantu Jun 7, 2025
a6c5cbf
labs/lab-09: Added 32-bit version of max-assembly-calls
RaduMantu Jun 7, 2025
64987a6
labs/lab-07: Add x86_64 version of lab 7
PetruCristian Jul 14, 2025
1c64dba
labs/lab-05: Fix script == check.
teodutu Feb 22, 2026
4a721b1
deployment: Change CI to build the `x86` and `main` branches.
teodutu Feb 22, 2026
e19b7c5
labs/lab-0{2,7}: Apply suggestions from @Copilot.
teodutu Feb 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
branches:
- main
- x86_64

jobs:
checkpatch:
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches:
- main
- x86_64
- x86

jobs:
deploy:
Expand All @@ -16,11 +16,11 @@ jobs:
with:
path: main

- name: Checkout `x86_64` branch
- name: Checkout `x86` branch
uses: actions/checkout@v4
with:
ref: x86_64
path: x86_64
ref: x86
path: x86

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
Expand All @@ -36,7 +36,7 @@ jobs:
cache-from: type=gha
cache-to: type=gha

- name: Build Jekyll site for x86
- name: Build Jekyll site for x86_64
run: |
echo "url: https://${{ github.repository_owner }}.github.io" >> _config.yaml
echo "baseurl: /hardware-software-interface" >> _config.yaml
Expand All @@ -48,21 +48,21 @@ jobs:
jekyll-image bundle exec jekyll build -s /base/app -d /base/app/_site
working-directory: main

- name: Build Jekyll site for x64
- name: Build Jekyll site for x86
run: |
echo "url: https://${{ github.repository_owner }}.github.io" >> _config.yaml
echo "baseurl: /hardware-software-interface/x86_64" >> _config.yaml
echo "baseurl: /hardware-software-interface/x86" >> _config.yaml

# Build Jekyll site for x86_64
# Note: The x86_64 site is built in a separate directory.
# Build Jekyll site for x86
# Note: The x86 site is built in a separate directory.
docker run --rm \
-v $(pwd):/base/app \
-u $(id -u):$(id -g) \
jekyll-image bundle exec jekyll build -s /base/app -d /base/app/_site

# Move the x86_64 site under the main site directory
mv _site ${{ github.workspace }}/main/_site/x86_64
working-directory: x86_64
# Move the x86 site under the main site directory
mv _site ${{ github.workspace }}/main/_site/x86
working-directory: x86

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ _site/

.view/

*.ref
.gdb_history

# Ruby files for the local Jekyll server
.sass-cache/
.jekyll-cache/
Expand Down
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"files.associations": {
"*.c": "c",
"param.h": "c"
}
}
2 changes: 1 addition & 1 deletion labs/lab-02/media/arit.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions labs/lab-02/reading/memory-operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ For example:
char *char_ptr = 1000;
short *short_ptr = 2000;
int *int_ptr = 3000;
long long *long_long_ptr = 4000;

++char_ptr; /* char_ptr will point to address 1001 */
++short_ptr; /* short_ptr points to address 2002 */
++int_ptr; /* int_ptr points to address 3004 */
++long_long_ptr; /* long_long_ptr points to address 4008 */
```

![A diagram which visualizes arithmetic operations on pointers](../media/arit.svg)
Expand Down
11 changes: 6 additions & 5 deletions labs/lab-02/tasks/iterate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ Here is the given piece of C code:
#include <stdio.h>

int main() {
int v[] = {0xCAFEBABE, 0xDEADBEEF, 0x0B00B135, 0xBAADF00D, 0xDEADC0DE};
int v[] = {0xCAFEBABE, 0xDEADBEEF, 0x0B00B135, 0xBAADF00D, 0xDEADC0DE, 0x1EE71EE7};

return 0;
}
```

Display the addresses of the elements in the `v` array along with their values.
Iterate through the addresses in `v` byte by byte, two bytes at a time, and four bytes at a time.
Iterate through the addresses in `v` byte by byte, two bytes at a time, four bytes at a time, and eight bytes at a time.

> **TIP:** You can iterate through memory byte by byte starting from a specific address using a pointer of type `unsigned char*` (since the `char` type is represented by one byte).
>
Expand All @@ -43,9 +43,10 @@ make check
In case of a correct solution, you will get an output such as:

```text
test_chars ........................ passed ... 33
test_shorts ........................ passed ... 33
test_ints ........................ passed ... 34
test_chars ........................ passed ... 25
test_shorts ........................ passed ... 25
test_ints ........................ passed ... 25
test_long_longs ........................ passed ... 25

Total: 100/100
```
Expand Down
2 changes: 1 addition & 1 deletion labs/lab-02/tasks/iterate/solution/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

#include "array.h"

int v[5] = {0xCAFEBABE, 0xDEADBEEF, 0x0B00B135, 0xBAADF00D, 0xDEADC0DE};
int v[6] = {0xCAFEBABE, 0xDEADBEEF, 0x0B00B135, 0xBAADF00D, 0xDEADC0DE, 0x1EE71EE7};
2 changes: 1 addition & 1 deletion labs/lab-02/tasks/iterate/solution/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
#ifndef ARRAY_H
#define ARRAY_H 1

extern int v[5];
extern int v[6];

#endif // ARRAY_H
15 changes: 15 additions & 0 deletions labs/lab-02/tasks/iterate/solution/iterate.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,18 @@ void print_ints_ref(void)
}
printf("-------------------------------\n");
}

void print_long_longs_ref(void)
{
unsigned long long *long_long_ptr = (unsigned long long *) &v;
unsigned long long i;
/**
* Iterate through 8 bytes at a time, we have only a quarter of the steps because we are
* displaying 8 bytes at each step.
*/
for (i = 0 ; i < sizeof(v) / sizeof((*long_long_ptr)); ++i) {
printf("%p -> %p\n", long_long_ptr, *long_long_ptr);
++long_long_ptr;
}
printf("-------------------------------\n");
}
1 change: 1 addition & 0 deletions labs/lab-02/tasks/iterate/solution/iterate.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
void print_chars_ref(void);
void print_shorts_ref(void);
void print_ints_ref(void);
void print_long_longs_ref(void);

#endif // ITERATE_REF_H
1 change: 1 addition & 0 deletions labs/lab-02/tasks/iterate/solution/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ int main(void)
print_chars_ref();
print_shorts_ref();
print_ints_ref();
print_long_longs_ref();

return 0;
}
2 changes: 1 addition & 1 deletion labs/lab-02/tasks/iterate/support/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

#include "array.h"

int v[5] = {0xCAFEBABE, 0xDEADBEEF, 0x0B00B135, 0xBAADF00D, 0xDEADC0DE};
int v[6] = {0xCAFEBABE, 0xDEADBEEF, 0x0B00B135, 0xBAADF00D, 0xDEADC0DE, 0x1EE71EE7};
2 changes: 1 addition & 1 deletion labs/lab-02/tasks/iterate/support/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
#ifndef ARRAY_H
#define ARRAY_H 1

extern int v[5];
extern int v[6];

#endif // ARRAY_H
10 changes: 10 additions & 0 deletions labs/lab-02/tasks/iterate/support/iterate.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,13 @@ void print_ints(void)

printf("-------------------------------\n");
}

void print_long_longs(void)
{
/**
* TODO: Implement function
*/
(void) v;

printf("-------------------------------\n");
}
1 change: 1 addition & 0 deletions labs/lab-02/tasks/iterate/support/iterate.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
void print_chars(void);
void print_shorts(void);
void print_ints(void);
void print_long_longs(void);

#endif // ITERATE_H
1 change: 1 addition & 0 deletions labs/lab-02/tasks/iterate/support/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ int main(void)
print_chars();
print_shorts();
print_ints();
print_long_longs();

return 0;
}
27 changes: 24 additions & 3 deletions labs/lab-02/tasks/iterate/tests/test_iterate.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
#define CHAR_OUTPUT "char.out"
#define SHORT_OUTPUT "short.out"
#define INT_OUTPUT "int.out"
#define LONG_LONG_OUTPUT "long_long.out"
#define CHAR_REF "char.ref"
#define SHORT_REF "short.ref"
#define INT_REF "int.ref"
#define LONG_LONG_REF "long_long.ref"

static int fd, stdout_fd;

Expand Down Expand Up @@ -120,10 +122,29 @@ static int test_ints(void)
return status == 0 ? 1 : 0;
}

static int test_long_longs(void)
{
int status;

prep_io(LONG_LONG_OUTPUT);
print_long_longs();
fflush(stdout);
restore_io();

prep_io(LONG_LONG_REF);
print_long_longs_ref();
fflush(stdout);
restore_io();

status = system("diff -q " LONG_LONG_OUTPUT " " LONG_LONG_REF);
return status == 0 ? 1 : 0;
}

static struct graded_test all_tests[] = {
{ test_chars, "test_chars", 33 },
{ test_shorts, "test_shorts", 33},
{ test_ints, "test_ints", 34},
{ test_chars, "test_chars", 25 },
{ test_shorts, "test_shorts", 25},
{ test_ints, "test_ints", 25},
{ test_long_longs, "test_long_long", 25},
};

int main(void)
Expand Down
38 changes: 19 additions & 19 deletions labs/lab-04/guides/discovering-assembly/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@ nav_order: 10
To follow this guide, you will need to navigate to the `guides/discovering-assembly/support` directory.

1. Open the `ex1.asm` file and read the comments.
Assemble it by using the `make` utility and run it.
Using gdb, go through the program line by line (the `start` command followed by `next`) and observe the changes in register values after executing the `mov` and `add` instructions.
Ignore the sequence of `PRINTF32` instructions.
Assemble it by using the `make` utility and run it.
Using gdb, go through the program line by line (the `start` command followed by `next`) and observe the changes in register values after executing the `mov` and `add` instructions.
Ignore the sequence of `PRINTF64` instructions.

1. Open the `ex2.asm` file and read the comments.
Assemble it by using the `make` utility and run it.
Using gdb, observe the change in the `eip` register when executing the `jmp` instruction.
To skip the `PRINTF32` instructions, add a breakpoint at the `jump_incoming` label (the `break` command followed by `run`).
Assemble it by using the `make` utility and run it.
Using gdb, observe the change in the `rip` register when executing the `jmp` instruction.
To skip the `PRINTF64` instructions, add a breakpoint at the `jump_incoming` label (the `break` command followed by `run`).

1. Open the `ex3.asm` file and read the comments.
Assemble it by using the `make` utility and run it.
Using gdb, navigate through the program using breakpoints.
Follow the program flow.
Why is `15` displayed first and then `3`?
Because of the jump at line 9.
Where does the jump at line 25 point to?
To the `zone1` label.
Assemble it by using the `make` utility and run it.
Using gdb, navigate through the program using breakpoints.
Follow the program flow.
Why is `15` displayed first and then `3`?
Because of the jump at line 9.
Where does the jump at line 25 point to?
To the `zone1` label.

1. Open the `ex4.asm` file and read the comments.
Assemble it by using the `make` utility and run it.
Using gdb, go through the program.
Why isn't the jump at line 12 taken?
Because the `je` instruction jumps if the `ZF` bit in the `FLAGS` register is set.
This bit is set by the `cmp` instruction, which calculates the difference between the values of the `eax` and `ebx` registers without storing the result.
However, the `add` instruction at line 11 clears this flag because the result of the operation is different from 0.
Assemble it by using the `make` utility and run it.
Using gdb, go through the program.
Why isn't the jump at line 12 taken?
Because the `je` instruction jumps if the `ZF` bit in the `FLAGS` register is set.
This bit is set by the `cmp` instruction, which calculates the difference between the values of the `eax` and `ebx` registers without storing the result.
However, the `add` instruction at line 11 clears this flag because the result of the operation is different from 0.
6 changes: 3 additions & 3 deletions labs/lab-04/guides/discovering-assembly/support/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ RM = rm
SRCS := $(shell find . -name "*.asm")
OBJS := $(SRCS:.asm=.o)

UTILSDIR := ..utils/
UTILSDIR := ../utils/

ASFLAGS ?= -f elf32 -F dwarf -I "$(UTILSDIR)"
ASFLAGS ?= -f elf64 -F dwarf -I "$(UTILSDIR)"
CFLAGS ?= -Wall
LDFLAGS ?= -m32 -no-pie
LDFLAGS ?= -no-pie

all: ex1 ex2 ex3 ex4

Expand Down
16 changes: 11 additions & 5 deletions labs/lab-04/guides/discovering-assembly/support/ex1.asm
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
; SPDX-License-Identifier: BSD-3-Clause

%include "printf32.asm"
%include "printf64.asm"

section .text
global main
extern printf

main:
mov eax, 7 ; load the eax register with the value 7
mov ebx, 8 ; load the ebx register with the value 8
add eax, ebx ; add the value from ebx to the value from eax
push rbp
mov rbp, rsp

mov rax, 7 ; load the eax register with the value 7
mov r8, 8 ; load the ebx register with the value 8
add rax, r8 ; add the value from ebx to the value from eax
; and store the result in eax
PRINTF32 `%d\n\x0`, eax ; print the value from the eax register
PRINTF64 `%d\n\x0`, rax ; print the value from the eax register

leave
ret
18 changes: 11 additions & 7 deletions labs/lab-04/guides/discovering-assembly/support/ex2.asm
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
; SPDX-License-Identifier: BSD-3-Clause

%include "printf32.asm"
%include "printf64.asm"

section .text
global main
extern printf

main:
mov eax, 4
PRINTF32 `%d\n\x0`, eax
push rbp
mov rbp, rsp

mov r9, 4
PRINTF64 `%d\n\x0`, r9

jump_incoming:
jmp exit ; unconditional jump to the "exit" label

mov eax, 7 ; this code is unreachable, therefore not executed
mov ebx, 8
add eax, ebx
PRINTF32 `%d\n\x0`, eax
mov r9, 7 ; this code is unreachable, therefore not executed
mov rbx, 8
add r9, rbx
PRINTF64 `%d\n\x0`, r9

exit:
leave
ret
Loading