forked from open-education-hub/hardware-software-interface
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chapters/{memory-layout,stack}: Add tasks and reading material for C …
…- Assembly interaction Created standalone makefiles for solutions. Added messages in readmes to point to the path of the exercices. Modified `config.yaml` and removed guides from this lab. Signed-off-by: cezar <[email protected]> Signed-off-by: Teodor Dutu <[email protected]>
- Loading branch information
1 parent
6fa6eaf
commit 4a6220c
Showing
99 changed files
with
1,658 additions
and
0 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
chapters/memory-layout/c-assembly-interaction/drills/tasks/export-fix/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Repair Export Problems | ||
|
||
Navigate to `drills/tasks/export-fix/support/`. | ||
|
||
Each subdirectory (`support/a-func/`, `suppoer/b-var/`, `support/c-var-2/`) contains a problem related to exporting some symbols (functions or variables). | ||
In each subdirectory, run the `make` command, identify the problem and edit the files needed to fix the problem. | ||
|
||
If you're having difficulties solving this exercise, go through [this relevant section](../../../reading/memory-layout-c-asm.md) reading material. |
1 change: 1 addition & 0 deletions
1
...s/memory-layout/c-assembly-interaction/drills/tasks/export-fix/solution/a-func/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/main |
1 change: 1 addition & 0 deletions
1
...ers/memory-layout/c-assembly-interaction/drills/tasks/export-fix/solution/a-func/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../support/a-func/Makefile |
18 changes: 18 additions & 0 deletions
18
...ers/memory-layout/c-assembly-interaction/drills/tasks/export-fix/solution/a-func/hidden.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
int hidden_value; | ||
|
||
void init(void) | ||
{ | ||
hidden_value = 0; | ||
} | ||
|
||
void set(int value) | ||
{ | ||
hidden_value = value; | ||
} | ||
|
||
int get(void) | ||
{ | ||
return hidden_value; | ||
} |
15 changes: 15 additions & 0 deletions
15
chapters/memory-layout/c-assembly-interaction/drills/tasks/export-fix/solution/a-func/main.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
#include <stdio.h> | ||
#include "ops.h" | ||
|
||
int main(void) | ||
{ | ||
set(10); | ||
printf("get(): %d\n", get()); | ||
|
||
age = 33; | ||
print_age(); | ||
|
||
return 0; | ||
} |
13 changes: 13 additions & 0 deletions
13
chapters/memory-layout/c-assembly-interaction/drills/tasks/export-fix/solution/a-func/ops.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* SPDX-License-Identifier: BSD-3-Clause */ | ||
|
||
#ifndef OPS_H_ | ||
#define OPS_H_ 1 | ||
|
||
void init(void); | ||
void set(int value); | ||
int get(void); | ||
|
||
extern int age; | ||
void print_age(void); | ||
|
||
#endif |
10 changes: 10 additions & 0 deletions
10
...ters/memory-layout/c-assembly-interaction/drills/tasks/export-fix/solution/a-func/plain.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
#include <stdio.h> | ||
|
||
int age; | ||
|
||
void print_age(void) | ||
{ | ||
printf("age: %d\n", age); | ||
} |
1 change: 1 addition & 0 deletions
1
...rs/memory-layout/c-assembly-interaction/drills/tasks/export-fix/solution/b-var/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/main |
1 change: 1 addition & 0 deletions
1
...ters/memory-layout/c-assembly-interaction/drills/tasks/export-fix/solution/b-var/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../support/b-var/Makefile |
18 changes: 18 additions & 0 deletions
18
...ters/memory-layout/c-assembly-interaction/drills/tasks/export-fix/solution/b-var/hidden.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
static int hidden_value; | ||
|
||
void init(void) | ||
{ | ||
hidden_value = 0; | ||
} | ||
|
||
void set(int value) | ||
{ | ||
hidden_value = value; | ||
} | ||
|
||
int get(void) | ||
{ | ||
return hidden_value; | ||
} |
15 changes: 15 additions & 0 deletions
15
chapters/memory-layout/c-assembly-interaction/drills/tasks/export-fix/solution/b-var/main.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
#include <stdio.h> | ||
#include "ops.h" | ||
|
||
int main(void) | ||
{ | ||
set(10); | ||
printf("get(): %d\n", get()); | ||
|
||
age = 33; | ||
print_age(); | ||
|
||
return 0; | ||
} |
13 changes: 13 additions & 0 deletions
13
chapters/memory-layout/c-assembly-interaction/drills/tasks/export-fix/solution/b-var/ops.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* SPDX-License-Identifier: BSD-3-Clause */ | ||
|
||
#ifndef OPS_H_ | ||
#define OPS_H_ 1 | ||
|
||
void init(void); | ||
void set(int value); | ||
int get(void); | ||
|
||
extern int age; | ||
void print_age(void); | ||
|
||
#endif |
10 changes: 10 additions & 0 deletions
10
chapters/memory-layout/c-assembly-interaction/drills/tasks/export-fix/solution/b-var/plain.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
#include <stdio.h> | ||
|
||
int age; | ||
|
||
void print_age(void) | ||
{ | ||
printf("age: %d\n", age); | ||
} |
1 change: 1 addition & 0 deletions
1
.../memory-layout/c-assembly-interaction/drills/tasks/export-fix/solution/c-var-2/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/main |
1 change: 1 addition & 0 deletions
1
...rs/memory-layout/c-assembly-interaction/drills/tasks/export-fix/solution/c-var-2/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../support/c-var-2/Makefile |
18 changes: 18 additions & 0 deletions
18
...rs/memory-layout/c-assembly-interaction/drills/tasks/export-fix/solution/c-var-2/hidden.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
static int hidden_value; | ||
|
||
void init(void) | ||
{ | ||
hidden_value = 0; | ||
} | ||
|
||
void set(int value) | ||
{ | ||
hidden_value = value; | ||
} | ||
|
||
int get(void) | ||
{ | ||
return hidden_value; | ||
} |
15 changes: 15 additions & 0 deletions
15
...ters/memory-layout/c-assembly-interaction/drills/tasks/export-fix/solution/c-var-2/main.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
#include <stdio.h> | ||
#include "ops.h" | ||
|
||
int main(void) | ||
{ | ||
set(10); | ||
printf("get(): %d\n", get()); | ||
|
||
age = 33; | ||
print_age(); | ||
|
||
return 0; | ||
} |
12 changes: 12 additions & 0 deletions
12
chapters/memory-layout/c-assembly-interaction/drills/tasks/export-fix/solution/c-var-2/ops.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* SPDX-License-Identifier: BSD-3-Clause */ | ||
|
||
#ifndef OPS_H_ | ||
#define OPS_H_ 1 | ||
|
||
void init(void); | ||
void set(int value); | ||
int get(void); | ||
extern int age; | ||
void print_age(void); | ||
|
||
#endif |
10 changes: 10 additions & 0 deletions
10
...ers/memory-layout/c-assembly-interaction/drills/tasks/export-fix/solution/c-var-2/plain.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
#include <stdio.h> | ||
|
||
int age; | ||
|
||
void print_age(void) | ||
{ | ||
printf("age: %d\n", age); | ||
} |
1 change: 1 addition & 0 deletions
1
...rs/memory-layout/c-assembly-interaction/drills/tasks/export-fix/support/a-func/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/main |
21 changes: 21 additions & 0 deletions
21
...ters/memory-layout/c-assembly-interaction/drills/tasks/export-fix/support/a-func/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
CFLAGS = -Wall -g | ||
CXXFLAGS = -Wall -g | ||
|
||
.DEFAULT_GOAL: all | ||
|
||
.PHONY: all clean | ||
|
||
all: main | ||
|
||
main: main.o hidden.o plain.o | ||
$(CC) $(LDFLAGS) -o $@ $^ | ||
|
||
main.o: main.c ops.h | ||
|
||
hidden.o: hidden.c | ||
|
||
plain.o: plain.c | ||
|
||
clean: | ||
-rm -f main *.o | ||
-rm -f *~ |
18 changes: 18 additions & 0 deletions
18
...ters/memory-layout/c-assembly-interaction/drills/tasks/export-fix/support/a-func/hidden.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
int hidden_value; | ||
|
||
void init(void) | ||
{ | ||
hidden_value = 0; | ||
} | ||
|
||
static void set(int value) | ||
{ | ||
hidden_value = value; | ||
} | ||
|
||
int get(void) | ||
{ | ||
return hidden_value; | ||
} |
15 changes: 15 additions & 0 deletions
15
chapters/memory-layout/c-assembly-interaction/drills/tasks/export-fix/support/a-func/main.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
#include <stdio.h> | ||
#include "ops.h" | ||
|
||
int main(void) | ||
{ | ||
set(10); | ||
printf("get(): %d\n", get()); | ||
|
||
age = 33; | ||
print_age(); | ||
|
||
return 0; | ||
} |
13 changes: 13 additions & 0 deletions
13
chapters/memory-layout/c-assembly-interaction/drills/tasks/export-fix/support/a-func/ops.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* SPDX-License-Identifier: BSD-3-Clause */ | ||
|
||
#ifndef OPS_H_ | ||
#define OPS_H_ 1 | ||
|
||
void init(void); | ||
void set(int value); | ||
int get(void); | ||
|
||
extern int age; | ||
void print_age(void); | ||
|
||
#endif |
10 changes: 10 additions & 0 deletions
10
chapters/memory-layout/c-assembly-interaction/drills/tasks/export-fix/support/a-func/plain.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
#include <stdio.h> | ||
|
||
int age; | ||
|
||
void print_age(void) | ||
{ | ||
printf("age: %d\n", age); | ||
} |
1 change: 1 addition & 0 deletions
1
...ers/memory-layout/c-assembly-interaction/drills/tasks/export-fix/support/b-var/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/main |
21 changes: 21 additions & 0 deletions
21
chapters/memory-layout/c-assembly-interaction/drills/tasks/export-fix/support/b-var/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
CFLAGS = -Wall -g | ||
CXXFLAGS = -Wall -g | ||
|
||
.DEFAULT_GOAL: all | ||
|
||
.PHONY: all clean | ||
|
||
all: main | ||
|
||
main: main.o hidden.o plain.o | ||
$(CC) $(LDFLAGS) -o $@ $^ | ||
|
||
main.o: main.c ops.h | ||
|
||
hidden.o: hidden.c | ||
|
||
plain.o: plain.c | ||
|
||
clean: | ||
-rm -f main *.o | ||
-rm -f *~ |
18 changes: 18 additions & 0 deletions
18
chapters/memory-layout/c-assembly-interaction/drills/tasks/export-fix/support/b-var/hidden.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
static int hidden_value; | ||
|
||
void init(void) | ||
{ | ||
hidden_value = 0; | ||
} | ||
|
||
void set(int value) | ||
{ | ||
hidden_value = value; | ||
} | ||
|
||
int get(void) | ||
{ | ||
return hidden_value; | ||
} |
15 changes: 15 additions & 0 deletions
15
chapters/memory-layout/c-assembly-interaction/drills/tasks/export-fix/support/b-var/main.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
#include <stdio.h> | ||
#include "ops.h" | ||
|
||
int main(void) | ||
{ | ||
set(10); | ||
printf("get(): %d\n", get()); | ||
|
||
age = 33; | ||
print_age(); | ||
|
||
return 0; | ||
} |
13 changes: 13 additions & 0 deletions
13
chapters/memory-layout/c-assembly-interaction/drills/tasks/export-fix/support/b-var/ops.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* SPDX-License-Identifier: BSD-3-Clause */ | ||
|
||
#ifndef OPS_H_ | ||
#define OPS_H_ 1 | ||
|
||
void init(void); | ||
void set(int value); | ||
int get(void); | ||
|
||
extern int age; | ||
void print_age(void); | ||
|
||
#endif |
10 changes: 10 additions & 0 deletions
10
chapters/memory-layout/c-assembly-interaction/drills/tasks/export-fix/support/b-var/plain.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
#include <stdio.h> | ||
|
||
static int age; | ||
|
||
void print_age(void) | ||
{ | ||
printf("age: %d\n", age); | ||
} |
1 change: 1 addition & 0 deletions
1
...s/memory-layout/c-assembly-interaction/drills/tasks/export-fix/support/c-var-2/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/main |
21 changes: 21 additions & 0 deletions
21
...ers/memory-layout/c-assembly-interaction/drills/tasks/export-fix/support/c-var-2/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
CFLAGS = -Wall -g | ||
CXXFLAGS = -Wall -g | ||
|
||
.DEFAULT_GOAL: all | ||
|
||
.PHONY: all clean | ||
|
||
all: main | ||
|
||
main: main.o hidden.o plain.o | ||
$(CC) $(LDFLAGS) -o $@ $^ | ||
|
||
main.o: main.c ops.h | ||
|
||
hidden.o: hidden.c | ||
|
||
plain.o: plain.c | ||
|
||
clean: | ||
-rm -f main *.o | ||
-rm -f *~ |
Oops, something went wrong.