initial import
authorChristian Grothoff <christian@grothoff.org>
Fri, 14 Sep 2018 12:28:00 +0000 (14:28 +0200)
committerChristian Grothoff <christian@grothoff.org>
Fri, 14 Sep 2018 12:28:00 +0000 (14:28 +0200)
259 files changed:
asm-1-bases/.gitignore [new file with mode: 0644]
asm-1-bases/exercises/exercises-bases.pdf [new file with mode: 0644]
asm-1-bases/slides-unicode/slides-unicode.pdf [new file with mode: 0644]
asm-1-bases/slides/slides-bases-2x2.pdf [new file with mode: 0644]
asm-1-bases/slides/slides-bases.pdf [new file with mode: 0644]
asm-2-architecture/.DS_Store [new file with mode: 0644]
asm-2-architecture/.gitignore [new file with mode: 0644]
asm-2-architecture/exercises/exercises-architecture.pdf [new file with mode: 0644]
asm-2-architecture/slides/slides-architecture-2x2.pdf [new file with mode: 0644]
asm-2-architecture/slides/slides-architecture.pdf [new file with mode: 0644]
asm-3-memory/.DS_Store [new file with mode: 0644]
asm-3-memory/.gitignore [new file with mode: 0644]
asm-3-memory/exercises/exercises-memory.pdf [new file with mode: 0644]
asm-3-memory/exercises/resources/boy.bmp [new file with mode: 0644]
asm-3-memory/slides/slides-linux-2x2.pdf [new file with mode: 0644]
asm-3-memory/slides/slides-linux.pdf [new file with mode: 0644]
asm-3-memory/slides/slides-memory-2x2.pdf [new file with mode: 0644]
asm-3-memory/slides/slides-memory.pdf [new file with mode: 0644]
asm-4-codification/.DS_Store [new file with mode: 0644]
asm-4-codification/.gitignore [new file with mode: 0644]
asm-4-codification/examples/helloWorld/eatsyscall.asm [new file with mode: 0644]
asm-4-codification/examples/helloWorld/eatsyscall64.asm [new file with mode: 0644]
asm-4-codification/examples/helloWorld/makefile [new file with mode: 0644]
asm-4-codification/exercises/exercises-codification.pdf [new file with mode: 0644]
asm-4-codification/slides/slides-developmentProcess-2x2.pdf [new file with mode: 0644]
asm-4-codification/slides/slides-developmentProcess.pdf [new file with mode: 0644]
asm-5-programming/.DS_Store [new file with mode: 0644]
asm-5-programming/.gitignore [new file with mode: 0644]
asm-5-programming/examples/bits/bits.asm [new file with mode: 0644]
asm-5-programming/examples/bits/bits2.asm [new file with mode: 0644]
asm-5-programming/examples/bits/makefile [new file with mode: 0644]
asm-5-programming/examples/eatsyscall/eatsyscall.asm [new file with mode: 0644]
asm-5-programming/examples/eatsyscall/eatsyscall64.asm [new file with mode: 0644]
asm-5-programming/examples/eatsyscall/makefile [new file with mode: 0644]
asm-5-programming/examples/flags/flags.asm [new file with mode: 0644]
asm-5-programming/examples/flags/flags2 [new file with mode: 0644]
asm-5-programming/examples/flags/flags2.asm [new file with mode: 0644]
asm-5-programming/examples/flags/makefile [new file with mode: 0644]
asm-5-programming/examples/jumps/jumps.asm [new file with mode: 0644]
asm-5-programming/examples/jumps/makefile [new file with mode: 0644]
asm-5-programming/examples/move/makefile [new file with mode: 0644]
asm-5-programming/examples/move/move.asm [new file with mode: 0644]
asm-5-programming/examples/move/move2.asm [new file with mode: 0644]
asm-5-programming/examples/move/move3.asm [new file with mode: 0644]
asm-5-programming/examples/sandbox/makefile [new file with mode: 0644]
asm-5-programming/examples/sandbox/sandbox.asm [new file with mode: 0644]
asm-5-programming/examples/stack/makefile [new file with mode: 0644]
asm-5-programming/examples/stack/stack.asm [new file with mode: 0644]
asm-5-programming/exercises/exercise-programming2.pdf [new file with mode: 0644]
asm-5-programming/exercises/exercises-programming.pdf [new file with mode: 0644]
asm-5-programming/slides/slides-assemblerProgramming-2x2.pdf [new file with mode: 0644]
asm-5-programming/slides/slides-assemblerProgramming.pdf [new file with mode: 0644]
asm-6-bits-branching/.gitignore [new file with mode: 0644]
asm-6-bits-branching/examples/hexdump1/gazabo.txt [new file with mode: 0644]
asm-6-bits-branching/examples/hexdump1/hexdump1.asm [new file with mode: 0644]
asm-6-bits-branching/examples/hexdump1/hexout.txt [new file with mode: 0644]
asm-6-bits-branching/examples/hexdump1/makefile [new file with mode: 0644]
asm-6-bits-branching/exercises/exercises-bits-branching.pdf [new file with mode: 0644]
asm-6-bits-branching/slides/slides-bits-branching-2x2.pdf [new file with mode: 0644]
asm-6-bits-branching/slides/slides-bits-branching.pdf [new file with mode: 0644]
asm-7-procedures/.gitignore [new file with mode: 0644]
asm-7-procedures/examples/hexdump2/gazabo.txt [new file with mode: 0644]
asm-7-procedures/examples/hexdump2/hexdump2 [new file with mode: 0644]
asm-7-procedures/examples/hexdump2/hexdump2.asm [new file with mode: 0644]
asm-7-procedures/examples/hexdump2/hexsample.txt [new file with mode: 0644]
asm-7-procedures/examples/hexdump2/makefile [new file with mode: 0644]
asm-7-procedures/examples/hexdump2/textlib.asm [new file with mode: 0644]
asm-7-procedures/exercises/exercises-procedures.pdf [new file with mode: 0644]
asm-7-procedures/slides/slides-procedures-2x2.pdf [new file with mode: 0644]
asm-7-procedures/slides/slides-procedures.pdf [new file with mode: 0644]
asm-8-strings/.gitignore [new file with mode: 0644]
asm-8-strings/examples/clib/eatclib [new file with mode: 0644]
asm-8-strings/examples/clib/eatclib.asm [new file with mode: 0644]
asm-8-strings/examples/clib/eatclib2 [new file with mode: 0644]
asm-8-strings/examples/clib/eatclib2.asm [new file with mode: 0644]
asm-8-strings/examples/clib/eatclib3 [new file with mode: 0644]
asm-8-strings/examples/clib/eatclib3.asm [new file with mode: 0644]
asm-8-strings/examples/clib/makefile [new file with mode: 0644]
asm-8-strings/examples/movestring/makefile [new file with mode: 0644]
asm-8-strings/examples/movestring/movestring1mov [new file with mode: 0644]
asm-8-strings/examples/movestring/movestring1mov.asm [new file with mode: 0644]
asm-8-strings/examples/movestring/movestring2stosbreset [new file with mode: 0644]
asm-8-strings/examples/movestring/movestring2stosbreset.asm [new file with mode: 0644]
asm-8-strings/examples/movestring/movestring3stosb [new file with mode: 0644]
asm-8-strings/examples/movestring/movestring3stosb.asm [new file with mode: 0644]
asm-8-strings/examples/movestring/movestring4movsb [new file with mode: 0644]
asm-8-strings/examples/movestring/movestring4movsb.asm [new file with mode: 0644]
asm-8-strings/examples/movestring/movestring5rep [new file with mode: 0644]
asm-8-strings/examples/movestring/movestring5rep.asm [new file with mode: 0644]
asm-8-strings/examples/movestring/movestring6repmovsb [new file with mode: 0644]
asm-8-strings/examples/movestring/movestring6repmovsb.asm [new file with mode: 0644]
asm-8-strings/examples/showargs/makefile [new file with mode: 0644]
asm-8-strings/examples/showargs/showargs1 [new file with mode: 0644]
asm-8-strings/examples/showargs/showargs1.asm [new file with mode: 0644]
asm-8-strings/examples/showargs/showargs64 [new file with mode: 0644]
asm-8-strings/examples/showargs/showargs64.asm [new file with mode: 0644]
asm-8-strings/exercises/exercises-strings.pdf [new file with mode: 0644]
asm-8-strings/slides/slides-strings-2x2.pdf [new file with mode: 0644]
asm-8-strings/slides/slides-strings.pdf [new file with mode: 0644]
asm-project/homework-asm-HS1819.pdf [new file with mode: 0644]
c-1-basics/.gitignore [new file with mode: 0644]
c-1-basics/examples/fundamentalsC/constants.c [new file with mode: 0644]
c-1-basics/examples/fundamentalsC/constants2.c [new file with mode: 0644]
c-1-basics/examples/fundamentalsC/makefile [new file with mode: 0644]
c-1-basics/examples/helloC/helloWorld.c [new file with mode: 0644]
c-1-basics/examples/helloC/helloWorld2.c [new file with mode: 0644]
c-1-basics/examples/helloC/helloWorld3.c [new file with mode: 0644]
c-1-basics/examples/helloC/makefile [new file with mode: 0644]
c-1-basics/examples/operatorsC/library.c [new file with mode: 0644]
c-1-basics/examples/operatorsC/library2.c [new file with mode: 0644]
c-1-basics/examples/operatorsC/makefile [new file with mode: 0644]
c-1-basics/examples/operatorsC/operators.c [new file with mode: 0644]
c-1-basics/examples/operatorsC/operators2.c [new file with mode: 0644]
c-1-basics/exercises/exercises-basics.pdf [new file with mode: 0644]
c-1-basics/slides/slides-basics-2x2.pdf [new file with mode: 0644]
c-1-basics/slides/slides-basics.pdf [new file with mode: 0644]
c-2-controlStructures/.gitignore [new file with mode: 0644]
c-2-controlStructures/examples/controlStatements/average.c [new file with mode: 0644]
c-2-controlStructures/examples/controlStatements/breaks.c [new file with mode: 0644]
c-2-controlStructures/examples/controlStatements/continue.c [new file with mode: 0644]
c-2-controlStructures/examples/controlStatements/goto.c [new file with mode: 0644]
c-2-controlStructures/examples/controlStatements/ifthenelse.c [new file with mode: 0644]
c-2-controlStructures/examples/controlStatements/loops.c [new file with mode: 0644]
c-2-controlStructures/examples/controlStatements/makefile [new file with mode: 0644]
c-2-controlStructures/examples/controlStatements/switches.c [new file with mode: 0644]
c-2-controlStructures/examples/controlStatements/while.c [new file with mode: 0644]
c-2-controlStructures/examples/inputsoutputs/getsputs.c [new file with mode: 0644]
c-2-controlStructures/examples/inputsoutputs/input.txt [new file with mode: 0644]
c-2-controlStructures/examples/inputsoutputs/inputs.c [new file with mode: 0644]
c-2-controlStructures/examples/inputsoutputs/interactive.c [new file with mode: 0644]
c-2-controlStructures/examples/inputsoutputs/makefile [new file with mode: 0644]
c-2-controlStructures/examples/inputsoutputs/outputs.c [new file with mode: 0644]
c-2-controlStructures/examples/inputsoutputs/sscanf.c [new file with mode: 0644]
c-2-controlStructures/exercises/exercises-cControlStructures.pdf [new file with mode: 0644]
c-2-controlStructures/exercises/resources/result.txt [new file with mode: 0644]
c-2-controlStructures/exercises/resources/test.txt [new file with mode: 0644]
c-2-controlStructures/slides/slides-cControlStructures-2x2.pdf [new file with mode: 0644]
c-2-controlStructures/slides/slides-cControlStructures.pdf [new file with mode: 0644]
c-3-libraries/.gitignore [new file with mode: 0644]
c-3-libraries/examples/c-arrays/array1 [new file with mode: 0644]
c-3-libraries/examples/c-arrays/array1.c [new file with mode: 0644]
c-3-libraries/examples/c-arrays/array2 [new file with mode: 0644]
c-3-libraries/examples/c-arrays/array2.c [new file with mode: 0644]
c-3-libraries/examples/c-arrays/array3 [new file with mode: 0644]
c-3-libraries/examples/c-arrays/array3.c [new file with mode: 0644]
c-3-libraries/examples/c-arrays/array4 [new file with mode: 0644]
c-3-libraries/examples/c-arrays/array4.c [new file with mode: 0644]
c-3-libraries/examples/c-arrays/makefile [new file with mode: 0644]
c-3-libraries/examples/c-functions/function1 [new file with mode: 0644]
c-3-libraries/examples/c-functions/function1.c [new file with mode: 0644]
c-3-libraries/examples/c-functions/helloWorld [new file with mode: 0644]
c-3-libraries/examples/c-functions/helloWorld.c [new file with mode: 0644]
c-3-libraries/examples/c-functions/makefile [new file with mode: 0644]
c-3-libraries/examples/c-functions/myFirstLibrary.c [new file with mode: 0644]
c-3-libraries/examples/c-functions/myFirstLibrary.h [new file with mode: 0644]
c-3-libraries/examples/c-functions/useLibrary [new file with mode: 0644]
c-3-libraries/examples/c-functions/useLibrary.c [new file with mode: 0644]
c-3-libraries/examples/c-lowlevel/bitwiseoperations [new file with mode: 0644]
c-3-libraries/examples/c-lowlevel/bitwiseoperations.c [new file with mode: 0644]
c-3-libraries/examples/c-lowlevel/makefile [new file with mode: 0644]
c-3-libraries/examples/c-lowlevel/shift [new file with mode: 0644]
c-3-libraries/examples/c-lowlevel/shift.c [new file with mode: 0644]
c-3-libraries/examples/c-variables/automatic1 [new file with mode: 0644]
c-3-libraries/examples/c-variables/automatic1.c [new file with mode: 0644]
c-3-libraries/examples/c-variables/automatic2 [new file with mode: 0644]
c-3-libraries/examples/c-variables/automatic2.c [new file with mode: 0644]
c-3-libraries/examples/c-variables/external.c [new file with mode: 0644]
c-3-libraries/examples/c-variables/global1 [new file with mode: 0644]
c-3-libraries/examples/c-variables/global1.c [new file with mode: 0644]
c-3-libraries/examples/c-variables/global2 [new file with mode: 0644]
c-3-libraries/examples/c-variables/global2.c [new file with mode: 0644]
c-3-libraries/examples/c-variables/makefile [new file with mode: 0644]
c-3-libraries/examples/c-variables/static1 [new file with mode: 0644]
c-3-libraries/examples/c-variables/static1.c [new file with mode: 0644]
c-3-libraries/exercises/exercises-libraries.pdf [new file with mode: 0644]
c-3-libraries/slides/slides-libraries-2x2.pdf [new file with mode: 0644]
c-3-libraries/slides/slides-libraries.pdf [new file with mode: 0644]
c-4-pointers/.gitignore [new file with mode: 0644]
c-4-pointers/examples/c-pointers/dynamic1.c [new file with mode: 0644]
c-4-pointers/examples/c-pointers/functions.c [new file with mode: 0644]
c-4-pointers/examples/c-pointers/makefile [new file with mode: 0644]
c-4-pointers/examples/c-pointers/multidimentionarray1.c [new file with mode: 0644]
c-4-pointers/examples/c-pointers/multidimentionarray2.c [new file with mode: 0644]
c-4-pointers/examples/c-pointers/pointerArithmetic1.c [new file with mode: 0644]
c-4-pointers/examples/c-pointers/pointerArithmetic2.c [new file with mode: 0644]
c-4-pointers/examples/c-pointers/pointers1.c [new file with mode: 0644]
c-4-pointers/examples/c-pointers/pointers2.c [new file with mode: 0644]
c-4-pointers/examples/c-pointers/pointers3.c [new file with mode: 0644]
c-4-pointers/examples/c-pointers/pointers4.c [new file with mode: 0644]
c-4-pointers/examples/c-pointers/pointers5.c [new file with mode: 0644]
c-4-pointers/examples/c-pointers/pointers6.c [new file with mode: 0644]
c-4-pointers/examples/c-pointers/pointers7.c [new file with mode: 0644]
c-4-pointers/exercises/exercises-pointers.pdf [new file with mode: 0644]
c-4-pointers/slides/slides-pointers-2x2.pdf [new file with mode: 0644]
c-4-pointers/slides/slides-pointers.pdf [new file with mode: 0644]
c-5-structuresFiles/.gitignore [new file with mode: 0644]
c-5-structuresFiles/examples/c-files/makefile [new file with mode: 0644]
c-5-structuresFiles/examples/c-files/output.bin [new file with mode: 0644]
c-5-structuresFiles/examples/c-files/output.txt [new file with mode: 0644]
c-5-structuresFiles/examples/c-files/output2.txt [new file with mode: 0644]
c-5-structuresFiles/examples/c-files/readFile [new file with mode: 0644]
c-5-structuresFiles/examples/c-files/readFile.c [new file with mode: 0644]
c-5-structuresFiles/examples/c-files/writeBinary [new file with mode: 0644]
c-5-structuresFiles/examples/c-files/writeBinary.c [new file with mode: 0644]
c-5-structuresFiles/examples/c-files/writeFile [new file with mode: 0644]
c-5-structuresFiles/examples/c-files/writeFile.c [new file with mode: 0644]
c-5-structuresFiles/examples/c-files/writeFile2 [new file with mode: 0644]
c-5-structuresFiles/examples/c-files/writeFile2.c [new file with mode: 0644]
c-5-structuresFiles/examples/c-structures/makefile [new file with mode: 0644]
c-5-structuresFiles/examples/c-structures/structures1 [new file with mode: 0644]
c-5-structuresFiles/examples/c-structures/structures1.c [new file with mode: 0644]
c-5-structuresFiles/examples/c-structures/structures2 [new file with mode: 0644]
c-5-structuresFiles/examples/c-structures/structures2.c [new file with mode: 0644]
c-5-structuresFiles/examples/c-structures/structures3 [new file with mode: 0644]
c-5-structuresFiles/examples/c-structures/structures3.c [new file with mode: 0644]
c-5-structuresFiles/examples/c-structures/structures4 [new file with mode: 0644]
c-5-structuresFiles/examples/c-structures/structures4.c [new file with mode: 0644]
c-5-structuresFiles/examples/c-structures/unions [new file with mode: 0644]
c-5-structuresFiles/examples/c-structures/unions.c [new file with mode: 0644]
c-5-structuresFiles/examples/enum1.c [new file with mode: 0644]
c-5-structuresFiles/examples/makefile [new file with mode: 0644]
c-5-structuresFiles/exercises/exercises-structuresFiles.pdf [new file with mode: 0644]
c-5-structuresFiles/slides/slides-structuresFiles-2x2.pdf [new file with mode: 0644]
c-5-structuresFiles/slides/slides-structuresFiles.pdf [new file with mode: 0644]
c-6-additional/.gitignore [new file with mode: 0644]
c-6-additional/examples/c-paralelism/fork1.c [new file with mode: 0644]
c-6-additional/examples/c-paralelism/fork2.c [new file with mode: 0644]
c-6-additional/examples/c-paralelism/makefile [new file with mode: 0644]
c-6-additional/examples/c-paralelism/thread0.c [new file with mode: 0644]
c-6-additional/examples/c-paralelism/thread1.c [new file with mode: 0644]
c-6-additional/examples/c-variousexamples/cars.h [new file with mode: 0644]
c-6-additional/examples/c-variousexamples/cars.txt [new file with mode: 0644]
c-6-additional/examples/c-variousexamples/commandline [new file with mode: 0644]
c-6-additional/examples/c-variousexamples/commandline.c [new file with mode: 0644]
c-6-additional/examples/c-variousexamples/commandlinemultiply [new file with mode: 0644]
c-6-additional/examples/c-variousexamples/commandlinemultiply.c [new file with mode: 0644]
c-6-additional/examples/c-variousexamples/exercise2writecars [new file with mode: 0644]
c-6-additional/examples/c-variousexamples/exercise2writecars.c [new file with mode: 0644]
c-6-additional/examples/c-variousexamples/macro.c [new file with mode: 0644]
c-6-additional/examples/c-variousexamples/macro2.c [new file with mode: 0644]
c-6-additional/examples/c-variousexamples/makefile [new file with mode: 0644]
c-6-additional/exercises/exercises-additional.pdf [new file with mode: 0644]
c-6-additional/slides/slides-cAdditional-2x2.pdf [new file with mode: 0644]
c-6-additional/slides/slides-cAdditional.pdf [new file with mode: 0644]
c-7-compilation/.gitignore [new file with mode: 0644]
c-7-compilation/examples/autotools/Makefile.am [new file with mode: 0644]
c-7-compilation/examples/autotools/configure.ac [new file with mode: 0644]
c-7-compilation/examples/autotools/exercise1logarithm.c [new file with mode: 0644]
c-7-compilation/examples/autotools/exercise2toupercase.c [new file with mode: 0644]
c-7-compilation/examples/autotools/exercise3threads.c [new file with mode: 0644]
c-7-compilation/examples/autotools/myLib.c [new file with mode: 0644]
c-7-compilation/examples/autotools/myLib.h [new file with mode: 0644]
c-7-compilation/exercises/exercises-compilation.pdf [new file with mode: 0644]
c-7-compilation/slides/slides-cCompilation-2x2.pdf [new file with mode: 0644]
c-7-compilation/slides/slides-cCompilation.pdf [new file with mode: 0644]
c-project/.gitignore [new file with mode: 0644]
c-project/INSTRUCTIONS.txt [new file with mode: 0644]
c-project/test.sh [new file with mode: 0755]
makefile [new file with mode: 0644]

diff --git a/asm-1-bases/.gitignore b/asm-1-bases/.gitignore
new file mode 100644 (file)
index 0000000..63dc4ab
--- /dev/null
@@ -0,0 +1,7 @@
+*.aux
+*.log
+*.nav
+*.out
+*.snm
+*.toc
+
diff --git a/asm-1-bases/exercises/exercises-bases.pdf b/asm-1-bases/exercises/exercises-bases.pdf
new file mode 100644 (file)
index 0000000..75821ae
Binary files /dev/null and b/asm-1-bases/exercises/exercises-bases.pdf differ
diff --git a/asm-1-bases/slides-unicode/slides-unicode.pdf b/asm-1-bases/slides-unicode/slides-unicode.pdf
new file mode 100644 (file)
index 0000000..018b84b
Binary files /dev/null and b/asm-1-bases/slides-unicode/slides-unicode.pdf differ
diff --git a/asm-1-bases/slides/slides-bases-2x2.pdf b/asm-1-bases/slides/slides-bases-2x2.pdf
new file mode 100644 (file)
index 0000000..c0f5403
Binary files /dev/null and b/asm-1-bases/slides/slides-bases-2x2.pdf differ
diff --git a/asm-1-bases/slides/slides-bases.pdf b/asm-1-bases/slides/slides-bases.pdf
new file mode 100644 (file)
index 0000000..3b4fd40
Binary files /dev/null and b/asm-1-bases/slides/slides-bases.pdf differ
diff --git a/asm-2-architecture/.DS_Store b/asm-2-architecture/.DS_Store
new file mode 100644 (file)
index 0000000..b535251
Binary files /dev/null and b/asm-2-architecture/.DS_Store differ
diff --git a/asm-2-architecture/.gitignore b/asm-2-architecture/.gitignore
new file mode 100644 (file)
index 0000000..63dc4ab
--- /dev/null
@@ -0,0 +1,7 @@
+*.aux
+*.log
+*.nav
+*.out
+*.snm
+*.toc
+
diff --git a/asm-2-architecture/exercises/exercises-architecture.pdf b/asm-2-architecture/exercises/exercises-architecture.pdf
new file mode 100644 (file)
index 0000000..87b9b6b
Binary files /dev/null and b/asm-2-architecture/exercises/exercises-architecture.pdf differ
diff --git a/asm-2-architecture/slides/slides-architecture-2x2.pdf b/asm-2-architecture/slides/slides-architecture-2x2.pdf
new file mode 100644 (file)
index 0000000..acfd430
Binary files /dev/null and b/asm-2-architecture/slides/slides-architecture-2x2.pdf differ
diff --git a/asm-2-architecture/slides/slides-architecture.pdf b/asm-2-architecture/slides/slides-architecture.pdf
new file mode 100644 (file)
index 0000000..a6009b0
Binary files /dev/null and b/asm-2-architecture/slides/slides-architecture.pdf differ
diff --git a/asm-3-memory/.DS_Store b/asm-3-memory/.DS_Store
new file mode 100644 (file)
index 0000000..b535251
Binary files /dev/null and b/asm-3-memory/.DS_Store differ
diff --git a/asm-3-memory/.gitignore b/asm-3-memory/.gitignore
new file mode 100644 (file)
index 0000000..63dc4ab
--- /dev/null
@@ -0,0 +1,7 @@
+*.aux
+*.log
+*.nav
+*.out
+*.snm
+*.toc
+
diff --git a/asm-3-memory/exercises/exercises-memory.pdf b/asm-3-memory/exercises/exercises-memory.pdf
new file mode 100644 (file)
index 0000000..eee48dd
Binary files /dev/null and b/asm-3-memory/exercises/exercises-memory.pdf differ
diff --git a/asm-3-memory/exercises/resources/boy.bmp b/asm-3-memory/exercises/resources/boy.bmp
new file mode 100644 (file)
index 0000000..d1933e2
Binary files /dev/null and b/asm-3-memory/exercises/resources/boy.bmp differ
diff --git a/asm-3-memory/slides/slides-linux-2x2.pdf b/asm-3-memory/slides/slides-linux-2x2.pdf
new file mode 100644 (file)
index 0000000..cb7216c
Binary files /dev/null and b/asm-3-memory/slides/slides-linux-2x2.pdf differ
diff --git a/asm-3-memory/slides/slides-linux.pdf b/asm-3-memory/slides/slides-linux.pdf
new file mode 100644 (file)
index 0000000..962e263
Binary files /dev/null and b/asm-3-memory/slides/slides-linux.pdf differ
diff --git a/asm-3-memory/slides/slides-memory-2x2.pdf b/asm-3-memory/slides/slides-memory-2x2.pdf
new file mode 100644 (file)
index 0000000..d142892
Binary files /dev/null and b/asm-3-memory/slides/slides-memory-2x2.pdf differ
diff --git a/asm-3-memory/slides/slides-memory.pdf b/asm-3-memory/slides/slides-memory.pdf
new file mode 100644 (file)
index 0000000..14b787f
Binary files /dev/null and b/asm-3-memory/slides/slides-memory.pdf differ
diff --git a/asm-4-codification/.DS_Store b/asm-4-codification/.DS_Store
new file mode 100644 (file)
index 0000000..b535251
Binary files /dev/null and b/asm-4-codification/.DS_Store differ
diff --git a/asm-4-codification/.gitignore b/asm-4-codification/.gitignore
new file mode 100644 (file)
index 0000000..63dc4ab
--- /dev/null
@@ -0,0 +1,7 @@
+*.aux
+*.log
+*.nav
+*.out
+*.snm
+*.toc
+
diff --git a/asm-4-codification/examples/helloWorld/eatsyscall.asm b/asm-4-codification/examples/helloWorld/eatsyscall.asm
new file mode 100644 (file)
index 0000000..afc908d
--- /dev/null
@@ -0,0 +1,63 @@
+;  Executable name : EATSYSCALL
+;  Version         : 1.0
+;  Created date    : 1/7/2009
+;  Last update     : 2/18/2009
+;  Author          : Jeff Duntemann
+;  Description     : A simple program in assembly for Linux, using NASM 2.05,
+;    demonstrating the use of Linux INT 80H syscalls to display text.
+; 
+;  Build using these commands:
+;    nasm -f elf -g -F stabs eatsyscall.asm
+;    ld -o eatsyscall eatsyscall.o
+;
+
+SECTION .data                  ; Section containing initialised data
+       
+       EatMsg: db "Eat at Joe's!",10
+       EatLen: equ $-EatMsg    
+       
+SECTION .bss                   ; Section containing uninitialized data 
+
+SECTION .text                  ; Section containing code
+
+global         _start                  ; Linker needs this to find the entry point!
+       
+_start:
+       nop                     ; This no-op keeps gdb happy...
+       mov eax,4               ; Specify sys_write call
+       mov ebx,1               ; Specify File Descriptor 1: Standard Output
+       mov ecx,EatMsg          ; Pass offset of the message
+       mov edx,EatLen          ; Pass the length of the message
+       int 80H                 ; Make kernel call
+
+       MOV eax,1               ; Code for Exit Syscall
+       mov ebx,0               ; Return a code of zero 
+       int 80H                 ; Make kernel call
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/asm-4-codification/examples/helloWorld/eatsyscall64.asm b/asm-4-codification/examples/helloWorld/eatsyscall64.asm
new file mode 100644 (file)
index 0000000..808384c
--- /dev/null
@@ -0,0 +1,63 @@
+;  Executable name : EATSYSCALL64
+;  Version         : 1.0
+;  Created date    : 08/30/2016
+;  Last update     : 08/30/2016
+;  Author          : Emmanuel Benoist
+;  Description     : A simple program in assembly for Linux, using NASM,
+;    demonstrating the use of Linux 64-bit syscalls to display text.
+; 
+;  Build using these commands:
+;    nasm -f elf64 -g eatsyscall64.asm
+;    ld -o eatsyscall64 eatsyscall64.o
+;
+
+SECTION .data                  ; Section containing initialised data
+       
+       EatMsg: db "Eat at Joe's!",10
+       EatLen: equ $-EatMsg    ; Compute the length of the string
+       
+SECTION .bss                   ; Section containing uninitialized data 
+
+SECTION .text                  ; Section containing code
+
+global         _start                  ; Linker needs this to find the entry point!
+       
+_start:
+       nop                     ; This no-op keeps gdb happy...
+       mov rax,1                 ; Code for Sys_write call
+       mov rdi, 1                ; Specify File Descriptor 1: Standard Output
+       mov rsi, EatMsg           ; Pass offset of the message
+       mov rdx, EatLen           ; Pass the length of the message
+       syscall                 ; Make kernel call      
+
+       mov rax, 60             ; Code for exit
+       mov rdi, 0              ; Return a code of zero
+       syscall                 ; Make kernel call
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/asm-4-codification/examples/helloWorld/makefile b/asm-4-codification/examples/helloWorld/makefile
new file mode 100644 (file)
index 0000000..044bd1a
--- /dev/null
@@ -0,0 +1,13 @@
+all: eatsyscall eatsyscall64
+
+eatsyscall: eatsyscall.o
+       ld -o eatsyscall eatsyscall.o
+
+eatsyscall.o: eatsyscall.asm
+       nasm -f elf64 -g -F dwarf  eatsyscall.asm
+
+eatsyscall64: eatsyscall64.o
+       ld -o eatsyscall64 eatsyscall64.o
+
+eatsyscall64.o: eatsyscall64.asm
+       nasm -f elf64 -g -F dwarf eatsyscall64.asm
diff --git a/asm-4-codification/exercises/exercises-codification.pdf b/asm-4-codification/exercises/exercises-codification.pdf
new file mode 100644 (file)
index 0000000..8ac2664
Binary files /dev/null and b/asm-4-codification/exercises/exercises-codification.pdf differ
diff --git a/asm-4-codification/slides/slides-developmentProcess-2x2.pdf b/asm-4-codification/slides/slides-developmentProcess-2x2.pdf
new file mode 100644 (file)
index 0000000..c5c948d
Binary files /dev/null and b/asm-4-codification/slides/slides-developmentProcess-2x2.pdf differ
diff --git a/asm-4-codification/slides/slides-developmentProcess.pdf b/asm-4-codification/slides/slides-developmentProcess.pdf
new file mode 100644 (file)
index 0000000..c8f3299
Binary files /dev/null and b/asm-4-codification/slides/slides-developmentProcess.pdf differ
diff --git a/asm-5-programming/.DS_Store b/asm-5-programming/.DS_Store
new file mode 100644 (file)
index 0000000..b535251
Binary files /dev/null and b/asm-5-programming/.DS_Store differ
diff --git a/asm-5-programming/.gitignore b/asm-5-programming/.gitignore
new file mode 100644 (file)
index 0000000..63dc4ab
--- /dev/null
@@ -0,0 +1,7 @@
+*.aux
+*.log
+*.nav
+*.out
+*.snm
+*.toc
+
diff --git a/asm-5-programming/examples/bits/bits.asm b/asm-5-programming/examples/bits/bits.asm
new file mode 100644 (file)
index 0000000..043e735
--- /dev/null
@@ -0,0 +1,67 @@
+;  Executable name : bits.asm
+;  Version         : 1.0
+;  Created date    : September 6, 2016
+;  Last update     : Sptember 6, 2016
+;  Author          : Emmanuel Benoist
+;  Description     : A simple program in assembly for demonstrating the
+;                    bit manipulation methods in assembler
+; 
+;  Build using these commands:
+;    nasm -f elf64 -g bits.asm
+;    ld -o bits bits.o
+;  Or simply 
+;    make
+;
+
+SECTION .data                  ; Section containing initialised data
+       
+SECTION .bss                   ; Section containing uninitialized data 
+
+SECTION .text                  ; Section containing code
+
+global         _start                  ; Linker needs this to find the entry point!
+       
+_start:
+       nop                     ; This no-op keeps gdb happy...
+
+       mov AX, 0B76FH          ; Initialize value of AX
+       SHL AX,1                ; Shit one bit the the left
+       ;; AX contains 6EDEh (one bit was forgotten)
+       ;; it remains in Carry Flag     
+
+       mov AX, 0FFFFH  ; Move a value in AX
+       RCL AX, 1       ; Rotate using Carry
+       RCL AX, 2       ; Rotate twice using Carry
+
+       mov AX, 0FFFFH  ; Move a value in AX
+       ROL AX, 1       ; Rotate without Carry
+       ROL AX, 2       ; Rotate twice without Carry
+
+       
+       mov RAX, 10             ; Write 0Ah into RAX
+       mov RBX, 10             ; Write 0Ah into RBX
+       mov RCX, 3              ; Write 03h into RCX
+       mov RDX, 7              ; Write 07h into RDX
+       
+       mov R8, -1              ; Write a negative value in R8
+       mov R9, -10             ; Write a negative value in R9
+       
+       shl RAX, 2              ; Shift two times RAX to the left
+       shl RCX, 1              ; Shift one time RCX to the left
+
+       shr RBX, 2              ; Shift two times RBX to the right
+       shr RDX, 5              ; Shift five times RDX to the right
+
+       shl R8,1                ; Shift R8 one bit to the left
+       shr R9,1                ; Shift R9 one bit to the right
+
+       
+
+       ;; The Code for a clean exit of the program
+       ;; Needed to produce no error when the program is finishing
+       mov rax, 60             ; Code for exit
+       mov rdi, 0              ; Return a code of zero
+       syscall                 ; Make kernel call
+
+
+
diff --git a/asm-5-programming/examples/bits/bits2.asm b/asm-5-programming/examples/bits/bits2.asm
new file mode 100644 (file)
index 0000000..9b369e2
--- /dev/null
@@ -0,0 +1,54 @@
+;  Executable name : bits2.asm
+;  Version         : 1.0
+;  Created date    : September 6, 2016
+;  Last update     : Sptember 6, 2016
+;  Author          : Emmanuel Benoist
+;  Description     : A simple program in assembly for demonstrating the
+;                    bit manipulation methods in assembler
+; 
+;  Build using these commands:
+;    nasm -f elf64 -g bits2.asm
+;    ld -o bits2 bits2.o
+;  Or simply 
+;    make bits2
+;
+
+SECTION .data                  ; Section containing initialised data
+       
+SECTION .bss                   ; Section containing uninitialized data 
+
+SECTION .text                  ; Section containing code
+
+global         _start                  ; Linker needs this to find the entry point!
+       
+_start:
+       nop                     ; This no-op keeps gdb happy...
+       
+       ;; Multiply using bit shifting
+       
+       mov al,3 
+       shl al,1                ; times 2
+       shl al,1                ; times 2
+       shl al,2                ; times 4
+       ;; Result: AL = 48
+
+       ;; Multiply by 3
+       mov rdx, rax    ; copy the number
+       shl rdx, 1      ; multiply by two
+       add rdx, rax    ; add x*2 and x
+
+       ;; Multiply by 7
+       mov rdx, rcx
+       shl rdx,2       ; edx multiplied by 4
+       add rdx, rcx  ; edx is value times 5 
+       add rdx, rcx  ; times 6
+       add rdx, rcx  ; times 7
+       
+       ;; The Code for a clean exit of the program
+       ;; Needed to produce no error when the program is finishing
+       mov rax, 60             ; Code for exit
+       mov rdi, 0              ; Return a code of zero
+       syscall                 ; Make kernel call
+
+
+
diff --git a/asm-5-programming/examples/bits/makefile b/asm-5-programming/examples/bits/makefile
new file mode 100644 (file)
index 0000000..7efbd6f
--- /dev/null
@@ -0,0 +1,16 @@
+all: bits bits2 
+
+clean:
+       rm *.o
+
+bits: bits.o
+       ld -o bits bits.o
+bits.o: bits.asm
+       nasm -f elf64 -g -F dwarf bits.asm
+
+
+bits2: bits2.o
+       ld -o bits2 bits2.o
+bits2.o: bits2.asm
+       nasm -f elf64 -g -F dwarf bits2.asm
+
diff --git a/asm-5-programming/examples/eatsyscall/eatsyscall.asm b/asm-5-programming/examples/eatsyscall/eatsyscall.asm
new file mode 100644 (file)
index 0000000..881cc18
--- /dev/null
@@ -0,0 +1,32 @@
+;  Executable name : EATSYSCALL
+;  Version         : 1.0
+;  Created date    : 1/7/2009
+;  Last update     : 2/18/2009
+;  Author          : Jeff Duntemann
+;  Description     : A simple program in assembly for Linux, using NASM 2.05,
+;    demonstrating the use of Linux INT 80H syscalls to display text.
+;
+;  Build using these commands:
+;    nasm -f elf -g eatsyscall.asm
+;    ld -o eatsyscall eatsyscall.o
+;
+SECTION .data                  ; Section containing initialised data
+       
+       EatMsg: db "Eat at Joe's!",10
+       EatLen: equ $-EatMsg    
+
+SECTION .bss                   ; Section containing uninitialized data 
+
+SECTION .text                  ; Section containing code
+global         _start                  ; Linker needs this to find the entry point!    
+_start:
+       nop                     ; This no-op keeps gdb happy...
+       mov eax,4               ; Specify sys_write call
+       mov ebx,1               ; Specify File Descriptor 1: Standard Output
+       mov ecx,EatMsg          ; Pass offset of the message
+       mov edx,EatLen          ; Pass the length of the message
+       int 80H                 ; Make kernel call
+       nop
+       MOV eax,1               ; Code for Exit Syscall
+       mov ebx,0               ; Return a code of zero 
+       int 80H                 ; Make kernel call
diff --git a/asm-5-programming/examples/eatsyscall/eatsyscall64.asm b/asm-5-programming/examples/eatsyscall/eatsyscall64.asm
new file mode 100644 (file)
index 0000000..a6408e3
--- /dev/null
@@ -0,0 +1,38 @@
+;  Executable name : EATSYSCALL64
+;  Version         : 1.0
+;  Created date    : 08/30/2016
+;  Last update     : 08/30/2016
+;  Author          : Emmanuel Benoist
+;  Description     : A simple program in assembly for Linux, using NASM,
+;    demonstrating the use of Linux 64-bit syscalls to display text.
+; 
+;  Build using these commands:
+;    nasm -f elf64 -g eatsyscall64.asm
+;    ld -o eatsyscall64 eatsyscall64.o
+;
+
+SECTION .data                  ; Section containing initialised data
+       
+       EatMsg: db "Eat at Joe's!",10
+       EatLen: equ $-EatMsg    
+       
+SECTION .bss                   ; Section containing uninitialized data 
+
+SECTION .text                  ; Section containing code
+
+global         _start                  ; Linker needs this to find the entry point!
+       
+_start:
+       nop                     ; This no-op keeps gdb happy...
+       mov rax,1                 ; Code for Sys_write call
+       mov rdi, 1                ; Specify File Descriptor 1: Standard Output
+       mov rsi, EatMsg           ; Pass offset of the message
+       mov rdx, EatLen           ; Pass the length of the message
+       syscall                 ; Make kernel call      
+
+       mov rax, 60             ; Code for exit
+       mov rdi, 0              ; Return a code of zero
+       syscall                 ; Make kernel call
+
+
+
diff --git a/asm-5-programming/examples/eatsyscall/makefile b/asm-5-programming/examples/eatsyscall/makefile
new file mode 100644 (file)
index 0000000..554c035
--- /dev/null
@@ -0,0 +1,16 @@
+all: eatsyscall eatsyscall64
+
+clean:
+       rm *.o
+
+eatsyscall: eatsyscall.o
+       ld -o eatsyscall eatsyscall.o
+eatsyscall.o: eatsyscall.asm
+       nasm -f elf64 -g  -F dwarf eatsyscall.asm
+
+
+eatsyscall64: eatsyscall64.o
+       ld -o eatsyscall64 eatsyscall64.o
+eatsyscall64.o: eatsyscall64.asm
+       nasm -f elf64 -g -F dwarf eatsyscall64.asm
+
diff --git a/asm-5-programming/examples/flags/flags.asm b/asm-5-programming/examples/flags/flags.asm
new file mode 100644 (file)
index 0000000..b8c6389
--- /dev/null
@@ -0,0 +1,30 @@
+;;; File flags.asm
+;;; Author: E. Benoist
+;;; Date: September 2, 2016
+;;; Compile with: make
+;;; Execute inside a debugger : ddd flags
+       
+;;; This program contains examples for the MOV instruction.
+;;; You can see in a debugger what happens inside the registers.
+;;; It does not terminate properly
+;;; Neither does it do anything,
+;;; It is used to test functions in the debugger.
+
+section .data
+
+section .text
+       global  _start
+_start:
+       nop ; Put your experiments between the two nops
+       mov eax, 0FFFFFFFFh
+       mov ebx, 02Dh
+       dec ebx
+       inc eax
+
+       nop 
+       ;;  A first loop
+       mov eax, 5
+DoMore:        dec eax
+       jnz DoMore
+       
+       nop  ; Put your experiments between the two nops
diff --git a/asm-5-programming/examples/flags/flags2 b/asm-5-programming/examples/flags/flags2
new file mode 100644 (file)
index 0000000..07338ed
Binary files /dev/null and b/asm-5-programming/examples/flags/flags2 differ
diff --git a/asm-5-programming/examples/flags/flags2.asm b/asm-5-programming/examples/flags/flags2.asm
new file mode 100644 (file)
index 0000000..c618bd1
--- /dev/null
@@ -0,0 +1,24 @@
+;;; File flags2.asm
+;;; Author: E. Benoist
+;;; Date: September 2, 2016
+;;; Compile with: make
+;;; Execute inside a debugger : ddd flags2
+       
+;;; This program contains examples for the manipulation of data
+;;; 
+
+section .data
+       Snippet db "KANGAROO"
+section .text
+       global  _start
+_start:
+       nop
+; Put your experiments between the two nops...
+       mov ebx,Snippet
+       mov eax,8
+DoMore:        add byte [ebx],32
+       inc ebx
+       dec eax
+       jnz DoMore
+; Put your experiments between the two nops...
+       nop
diff --git a/asm-5-programming/examples/flags/makefile b/asm-5-programming/examples/flags/makefile
new file mode 100644 (file)
index 0000000..3d45382
--- /dev/null
@@ -0,0 +1,16 @@
+all: flags flags2
+
+clean:
+       rm *.o
+
+flags: flags.o
+       ld -o flags flags.o
+flags.o: flags.asm
+       nasm -f elf64 -g  -F dwarf flags.asm
+
+
+flags2: flags2.o
+       ld -o flags2 flags2.o
+flags2.o: flags2.asm
+       nasm -f elf64 -g  -F dwarf flags2.asm
+
diff --git a/asm-5-programming/examples/jumps/jumps.asm b/asm-5-programming/examples/jumps/jumps.asm
new file mode 100644 (file)
index 0000000..105b4b4
--- /dev/null
@@ -0,0 +1,47 @@
+;  Executable name : jumps.asm
+;  Version         : 1.0
+;  Created date    : September 6, 2016
+;  Last update     : Sptember 6, 2016
+;  Author          : Emmanuel Benoist
+;  Description     : A simple program in assembly for demonstrating the
+;                    way jumps work
+; 
+;  Build using these commands:
+;    nasm -f elf64 -g jumps.asm
+;    ld -o jumps jumps.o
+;  Or simply 
+;    make jumps
+;
+
+SECTION .data                  ; Section containing initialised data
+
+       
+SECTION .bss                   ; Section containing uninitialized data 
+Runningsum: resq 1             ; Reserve one quadword (8bytes) for the variable
+       
+SECTION .text                  ; Section containing code
+
+global         _start                  ; Linker needs this to find the entry point!
+       
+_start:
+       nop                     ; This no-op keeps gdb happy...
+       mov word [Runningsum],0 ; Clear the running  total
+       mov rcx, 17                     ; We will loop 17 times
+WorkLookup:    
+        add word [Runningsum],3        ; Add 3 to the running total
+       dec rcx                 ; substract one to the counter
+       jz SomewereElse         ; If the counter is zero, we are done!
+       jmp WorkLookup          ;  We loop otherwise 
+SomewereElse:                  ; End of the loop
+
+
+       
+       
+       ;; The Code for a clean exit of the program
+       ;; Needed to produce no error when the program is finishing
+       mov rax, 60             ; Code for exit
+       mov rdi, 0              ; Return a code of zero
+       syscall                 ; Make kernel call
+
+
+
diff --git a/asm-5-programming/examples/jumps/makefile b/asm-5-programming/examples/jumps/makefile
new file mode 100644 (file)
index 0000000..23f8c61
--- /dev/null
@@ -0,0 +1,10 @@
+all: jumps
+
+clean:
+       rm *.o
+
+jumps: jumps.o
+       ld -o jumps jumps.o
+jumps.o: jumps.asm
+       nasm -f elf64 -g -F dwarf jumps.asm
+
diff --git a/asm-5-programming/examples/move/makefile b/asm-5-programming/examples/move/makefile
new file mode 100644 (file)
index 0000000..44e8140
--- /dev/null
@@ -0,0 +1,21 @@
+all: move move2 move3
+
+clean:
+       rm *.o
+
+move: move.o
+       ld -o move move.o
+move.o: move.asm
+       nasm -f elf64 -g  -F dwarf  move.asm
+
+
+move2: move2.o
+       ld -o move2 move2.o
+move2.o: move2.asm
+       nasm -f elf64 -g  -F dwarf move2.asm
+
+
+move3: move3.o
+       ld -o move3 move3.o
+move3.o: move3.asm
+       nasm -f elf64 -g  -F dwarf move3.asm
diff --git a/asm-5-programming/examples/move/move.asm b/asm-5-programming/examples/move/move.asm
new file mode 100644 (file)
index 0000000..1eb6238
--- /dev/null
@@ -0,0 +1,29 @@
+;;; File move.asm
+;;; Author: E. Benoist
+;;; Date: August 31, 2016
+;;; Compile with: make
+;;; Execute inside a debugger : ddd move
+       
+;;; This program contains examples for the MOV instruction.
+;;; You can see in a debugger what happens inside the registers.
+;;; It does not terminate properly
+;;; Neither does it do anything,
+;;; It is used to test functions in the debugger.
+
+section .data 
+
+section .text
+       global  _start
+_start:
+       nop
+       mov RAX,42              ; Copy the value 42 inside RAX (64-bit register)
+       mov RBX, 'Hello'        ; Copy a string inside a register (totaly odd)
+       mov RCX, 0A89h          ; Copy a number inside RCX
+
+       mov EBP, ESI            ; Copy the 32.bit register esi inside register ebp
+       mov BL, CH              ; Copy 8 bits (from high C to low B
+
+       add DX, AX
+       add ECX, EDX
+       
+       nop
diff --git a/asm-5-programming/examples/move/move2.asm b/asm-5-programming/examples/move/move2.asm
new file mode 100644 (file)
index 0000000..b13e049
--- /dev/null
@@ -0,0 +1,36 @@
+;;; File move.asm
+;;; Author: E. Benoist
+;;; Date: September 2, 2016
+;;; Compile with: make
+;;; Execute inside a debugger : ddd move2
+       
+;;; This program contains examples for the MOV instruction.
+;;; You can see in a debugger what happens inside the registers.
+;;; It does not terminate properly
+;;; Neither does it do anything,
+;;; It is used to test functions in the debugger.
+
+section .data
+       Snippet: db "This is data"
+       Data2: dq 100
+       
+section .text
+       global  _start
+_start:
+       nop
+       mov ax,067FEh
+       mov bx, ax
+       mov cl,bh
+       mov ch,bl
+
+       ;; Move to and from memory
+       mov rbx, Snippet        ;the address of the string in memory
+       mov rcx, 3              ; the offset in the string
+       mov ax, [rbx]           ; Move 16 bits
+       mov rax, [rbx+3]        ; Move 64 bits
+       mov eax, [rbx+rcx]      ; Move 32 bits
+       mov rdx, rbx    ; Move 64 bits
+
+
+       
+       nop
diff --git a/asm-5-programming/examples/move/move3.asm b/asm-5-programming/examples/move/move3.asm
new file mode 100644 (file)
index 0000000..e2c90fc
--- /dev/null
@@ -0,0 +1,21 @@
+;;; File move.asm
+;;; Author: E. Benoist
+;;; Date: September 2, 2016
+;;; Compile with: make
+;;; Execute inside a debugger : ddd move3
+       
+;;; This program contains examples for the MOV instruction.
+;;; You can see in a debugger what happens inside the registers.
+;;; It does not terminate properly
+;;; Neither does it do anything,
+;;; It is used to test functions in the debugger.
+
+section .data
+       EatMsg  db "Eat at Joe's"
+section .text
+       global  _start
+_start:
+       nop ; Put your experiments between the two nops
+       mov rcx, EatMsg ; copy the address
+       mov rdx, [EatMsg]       ; Copy 64 first bits of the message
+       nop  ; Put your experiments between the two nops
diff --git a/asm-5-programming/examples/sandbox/makefile b/asm-5-programming/examples/sandbox/makefile
new file mode 100644 (file)
index 0000000..c0b1b90
--- /dev/null
@@ -0,0 +1,9 @@
+all: sandbox
+
+clean:
+       rm *.o
+
+sandbox: sandbox.o
+       ld -o sandbox sandbox.o
+sandbox.o: sandbox.asm
+       nasm -f elf64 -g  -F dwarf sandbox.asm
diff --git a/asm-5-programming/examples/sandbox/sandbox.asm b/asm-5-programming/examples/sandbox/sandbox.asm
new file mode 100644 (file)
index 0000000..4c681b5
--- /dev/null
@@ -0,0 +1,35 @@
+;;; File sandbox.asm
+;;; Author: E. Benoist
+;;; Date: August 31, 2016
+;;; Compile with: make
+       
+;;; This program is just a sandbox.
+;;; It does not terminate properly
+;;; Neither does it do anything,
+;;; It is used to test functions in the debugger.
+
+section .data 
+
+section .text
+       global  _start
+_start:
+       nop
+       mov rdx, 45
+       mov rax, 7
+       mov rbx, 3
+       mul rbx
+
+       nop
+       mov rax, 23
+       div rbx
+
+       mov rax, -1
+       mov rbx, 3
+       mov rcx, -3
+       mul rbx
+
+       nop
+       mov rax, -1
+       imul rbx
+       
+       nop
diff --git a/asm-5-programming/examples/stack/makefile b/asm-5-programming/examples/stack/makefile
new file mode 100644 (file)
index 0000000..e8dd02c
--- /dev/null
@@ -0,0 +1,9 @@
+all: stack
+
+clean:
+       rm *.o
+
+stack: stack.o
+       ld -o stack stack.o
+stack.o: stack.asm
+       nasm -f elf64 -g  -F dwarf stack.asm
diff --git a/asm-5-programming/examples/stack/stack.asm b/asm-5-programming/examples/stack/stack.asm
new file mode 100644 (file)
index 0000000..f58dd70
--- /dev/null
@@ -0,0 +1,65 @@
+;  Executable name : stack
+;  Version         : 1.0
+;  Created date    : September 2, 2016
+;  Last update     : September 2, 2016
+;  Author          : Emmanuel Benoist
+;  Description     : A simple program in assembly for Linux, using NASM,
+;    demonstrating the use of Linux 64-bit syscalls to display text.
+; 
+;  Build using these commands:
+;    nasm -f elf64 -g stack.asm
+;    ld -o stack stack.o
+;  Or use make to compile
+;    make stack
+
+SECTION .data                  ; Section containing initialised data
+vars1: dq 1,2,3,4,5            ; contains an array of numbers
+                               ; (on 8 bytes qwords)
+var2:  db "Hello World",10     ; 10 stands for \n
+       
+
+SECTION .bss                   ; Section containing uninitialized data 
+
+SECTION .text                  ; Section containing code
+
+       
+global         _start                  ; Linker needs this to find the entry point!
+       
+_start:
+       nop                     ; This no-op keeps gdb happy.
+       mov rax,10              ;Copy the value 10 (=0Ah) in RAX
+       mov rbx, vars1          
+       mov edx, var2           
+;      pusha        ; Not supported in 64-bit mode
+;      pushad       ; Not supported in 64-bit mode
+       push ax     ; Push the AX register
+;      push ebx   ; push the EAX register not supported in 64-bit mode
+       push rax    ; Push the RAX register
+       push word[rbx]   ; Push the word stored at rbx 
+       push qword[rdx] ; Push the quad word stored at rdx
+       push rdi    ; Push the RDI register
+
+       pushf           ; Push the flags on the stack
+
+       nop                     ;See the memory in the debugger
+
+       popf                    ;Pop the flags out of the stack
+
+       pop CX     ; Pop the top 2 bytes from the stack into CX
+       pop RSI    ; Pop the top 16 bytes from the stack into RSI
+       pop qword[rbx] ; Pop the top 8 bytes from the stack into the memory at EBX 
+       pop qword[vars1] ; Pop the top 8 bytes from the stack into the memory at var1 
+
+       
+
+
+       
+       
+;;; Normal exit of the program (to finish properly)
+       nop
+       mov rax, 60             ; Code for exit
+       mov rdi, 0              ; Return a code of zero
+       syscall                 ; Make kernel call
+
+
+
diff --git a/asm-5-programming/exercises/exercise-programming2.pdf b/asm-5-programming/exercises/exercise-programming2.pdf
new file mode 100644 (file)
index 0000000..4235682
Binary files /dev/null and b/asm-5-programming/exercises/exercise-programming2.pdf differ
diff --git a/asm-5-programming/exercises/exercises-programming.pdf b/asm-5-programming/exercises/exercises-programming.pdf
new file mode 100644 (file)
index 0000000..2f4721f
Binary files /dev/null and b/asm-5-programming/exercises/exercises-programming.pdf differ
diff --git a/asm-5-programming/slides/slides-assemblerProgramming-2x2.pdf b/asm-5-programming/slides/slides-assemblerProgramming-2x2.pdf
new file mode 100644 (file)
index 0000000..bceae9b
Binary files /dev/null and b/asm-5-programming/slides/slides-assemblerProgramming-2x2.pdf differ
diff --git a/asm-5-programming/slides/slides-assemblerProgramming.pdf b/asm-5-programming/slides/slides-assemblerProgramming.pdf
new file mode 100644 (file)
index 0000000..7c93297
Binary files /dev/null and b/asm-5-programming/slides/slides-assemblerProgramming.pdf differ
diff --git a/asm-6-bits-branching/.gitignore b/asm-6-bits-branching/.gitignore
new file mode 100644 (file)
index 0000000..63dc4ab
--- /dev/null
@@ -0,0 +1,7 @@
+*.aux
+*.log
+*.nav
+*.out
+*.snm
+*.toc
+
diff --git a/asm-6-bits-branching/examples/hexdump1/gazabo.txt b/asm-6-bits-branching/examples/hexdump1/gazabo.txt
new file mode 100644 (file)
index 0000000..03b1bc4
--- /dev/null
@@ -0,0 +1 @@
+gazabo
diff --git a/asm-6-bits-branching/examples/hexdump1/hexdump1.asm b/asm-6-bits-branching/examples/hexdump1/hexdump1.asm
new file mode 100644 (file)
index 0000000..9574e0b
--- /dev/null
@@ -0,0 +1,93 @@
+;  Executable name : hexdump1
+;  Version         : 1.0
+;  Created date    : 4/4/2009
+;  Last update     : 4/4/2009
+;  Author          : Jeff Duntemann
+;  Description     : A simple program in assembly for Linux, using NASM 2.05,
+;    demonstrating the conversion of binary values to hexadecimal strings.
+;    It acts as a very simple hex dump utility for files, though without the
+;    ASCII equivalent column.
+;
+;  Run it this way:
+;    hexdump1 < (input file)  
+;
+;  Build using these commands:
+;    nasm -f elf64 -g -F stabs hexdump1.asm
+;    ld -o hexdump1 hexdump1.o
+;
+SECTION .bss                   ; Section containing uninitialized data
+
+       BUFFLEN equ 16          ; We read the file 16 bytes at a time
+       Buff:   resb BUFFLEN    ; Text buffer itself
+       
+SECTION .data                  ; Section containing initialised data
+
+       HexStr: db " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",10
+       HEXLEN equ $-HexStr
+
+       Digits: db "0123456789ABCDEF"
+               
+SECTION .text                  ; Section containing code
+
+global         _start                  ; Linker needs this to find the entry point!
+       
+_start:
+       nop                     ; This no-op keeps gdb happy...
+
+; Read a buffer full of text from stdin:
+Read:
+       mov eax,3               ; Specify sys_read call
+       mov ebx,0               ; Specify File Descriptor 0: Standard Input
+       mov ecx,Buff            ; Pass offset of the buffer to read to
+       mov edx,BUFFLEN         ; Pass number of bytes to read at one pass
+       int 80h                 ; Call sys_read to fill the buffer
+       mov ebp,eax             ; Save # of bytes read from file for later
+       cmp eax,0               ; If eax=0, sys_read reached EOF on stdin
+       je Done                 ; Jump If Equal (to 0, from compare)
+
+; Set up the registers for the process buffer step:
+       mov esi,Buff            ; Place address of file buffer into esi
+       mov edi,HexStr          ; Place address of line string into edi
+       xor ecx,ecx             ; Clear line string pointer to 0
+
+; Go through the buffer and convert binary values to hex digits:
+Scan:
+       xor eax,eax             ; Clear eax to 0
+
+; Here we calculate the offset into the line string, which is ecx X 3
+       mov edx,ecx             ; Copy the pointer into line string into edx
+;      shl edx,1               ; Multiply pointer by 2 using left shift
+;      add edx,ecx             ; Complete the multiplication X3
+       lea edx,[edx*2+edx]
+; Get a character from the buffer and put it in both eax and ebx:
+       mov al,byte [esi+ecx]   ; Put a byte from the input buffer into al
+       mov ebx,eax             ; Duplicate the byte in bl for second nybble
+
+; Look up low nybble character and insert it into the string:
+       and al,0Fh                 ; Mask out all but the low nybble
+       mov al,byte [Digits+eax]   ; Look up the char equivalent of nybble
+       mov byte [HexStr+edx+2],al ; Write the char equivalent to line string
+
+; Look up high nybble character and insert it into the string:
+       shr bl,4                ; Shift high 4 bits of char into low 4 bits
+       mov bl,byte [Digits+ebx] ; Look up char equivalent of nybble
+       mov byte [HexStr+edx+1],bl ; Write the char equivalent to line string
+
+; Bump the buffer pointer to the next character and see if we're done:
+       inc ecx         ; Increment line string pointer
+       cmp ecx,ebp     ; Compare to the number of characters in the buffer
+       jna Scan        ; Loop back if ecx is <= number of chars in buffer
+
+; Write the line of hexadecimal values to stdout:
+       mov eax,4               ; Specify sys_write call
+       mov ebx,1               ; Specify File Descriptor 1: Standard output
+       mov ecx,HexStr          ; Pass offset of line string
+       mov edx,HEXLEN          ; Pass size of the line string
+       int 80h                 ; Make kernel call to display line string
+       jmp Read                ; Loop back and load file buffer again
+
+; All done! Let's end this party:
+Done:
+       mov eax,1               ; Code for Exit Syscall
+       mov ebx,0               ; Return a code of zero 
+       int 80H                 ; Make kernel call
diff --git a/asm-6-bits-branching/examples/hexdump1/hexout.txt b/asm-6-bits-branching/examples/hexdump1/hexout.txt
new file mode 100644 (file)
index 0000000..4dadc8d
--- /dev/null
@@ -0,0 +1,73 @@
+ 3B 20 20 45 78 65 63 75 74 61 62 6C 65 20 6E 61
+ 6D 65 20 3A 20 45 40 54 53 59 53 43 40 4C 4C 0D
+ 0A 3B 20 20 56 65 72 73 69 6F 6E 20 20 20 20 20
+ 20 20 20 20 3A 20 30 2E 30 0D 0A 3B 20 20 43 72
+ 65 60 74 65 64 20 64 60 74 65 20 20 20 20 3A 20
+ 30 2F 37 2F 32 30 30 39 0D 0A 3B 20 20 4C 60 73
+ 74 20 75 70 64 60 74 65 20 20 20 20 20 3A 20 32
+ 2F 30 38 2F 32 30 30 39 0D 0A 3B 20 20 40 75 74
+ 68 6F 72 20 20 20 20 20 20 20 20 20 20 3A 20 4A
+ 65 66 66 20 44 75 6E 74 65 6D 60 6E 6E 0D 0A 3B
+ 20 20 44 65 73 63 72 69 70 74 69 6F 6E 20 20 20
+ 20 20 3A 20 40 20 73 69 6D 70 6C 65 20 70 72 6F
+ 67 72 60 6D 20 69 6E 20 60 73 73 65 6D 62 6C 79
+ 20 66 6F 72 20 4C 69 6E 75 78 2C 20 75 73 69 6E
+ 67 20 4E 40 53 4D 20 32 2E 30 35 2C 0D 0A 3B 20
+ 20 20 20 64 65 6D 6F 6E 73 74 72 60 74 69 6E 67
+ 20 74 68 65 20 75 73 65 20 6F 66 20 4C 69 6E 75
+ 78 20 49 4E 54 20 38 30 48 20 73 79 73 63 60 6C
+ 6C 73 20 74 6F 20 64 69 73 70 6C 60 79 20 74 65
+ 78 74 2E 0D 0A 3B 0D 0A 3B 20 20 42 75 69 6C 64
+ 20 75 73 69 6E 67 20 74 68 65 73 65 20 63 6F 6D
+ 6D 60 6E 64 73 3A 0D 0A 3B 20 20 20 20 6E 60 73
+ 6D 20 2D 66 20 65 6C 66 20 2D 67 20 2D 46 20 73
+ 74 60 62 73 20 65 60 74 73 79 73 63 60 6C 6C 2E
+ 60 73 6D 0D 0A 3B 20 20 20 20 6C 64 20 2D 6F 20
+ 65 60 74 73 79 73 63 60 6C 6C 20 65 60 74 73 79
+ 73 63 60 6C 6C 2E 6F 0D 0A 3B 0D 0A 0D 0A 53 45
+ 43 54 49 4F 4E 20 2E 64 60 74 60 09 09 09 3B 20
+ 53 65 63 74 69 6F 6E 20 63 6F 6E 74 60 69 6E 69
+ 6E 67 20 69 6E 69 74 69 60 6C 69 73 65 64 20 64
+ 60 74 60 0D 0A 09 0D 0A 09 45 60 74 4D 73 67 3A
+ 20 64 62 20 22 45 60 74 20 60 74 20 4A 6F 65 27
+ 73 20 22 2C 30 30 0D 0A 09 45 60 74 4C 65 6E 3A
+ 20 65 70 75 20 24 2D 45 60 74 4D 73 67 09 0D 0A
+ 09 0D 0A 53 45 43 54 49 4F 4E 20 2E 62 73 73 09
+ 09 09 3B 20 53 65 63 74 69 6F 6E 20 63 6F 6E 74
+ 60 69 6E 69 6E 67 20 75 6E 69 6E 69 74 69 60 6C
+ 69 7A 65 64 20 64 60 74 60 09 0D 0A 0D 0A 53 45
+ 43 54 49 4F 4E 20 2E 74 65 78 74 09 09 09 3B 20
+ 53 65 63 74 69 6F 6E 20 63 6F 6E 74 60 69 6E 69
+ 6E 67 20 63 6F 64 65 0D 0A 0D 0A 67 6C 6F 62 60
+ 6C 20 09 5F 73 74 60 72 74 09 09 09 3B 20 4C 69
+ 6E 6B 65 72 20 6E 65 65 64 73 20 74 68 69 73 20
+ 74 6F 20 66 69 6E 64 20 74 68 65 20 65 6E 74 72
+ 79 20 70 6F 69 6E 74 20 0D 0A 09 0D 0A 5F 73 74
+ 60 72 74 3A 0D 0A 09 6E 6F 70 09 09 09 3B 20 54
+ 68 69 73 20 6E 6F 2D 6F 70 20 6B 65 65 70 73 20
+ 67 64 62 20 68 60 70 70 79 2E 2E 2E 0D 0A 09 6D
+ 6F 76 20 65 60 78 2C 34 09 09 3B 20 53 70 65 63
+ 69 66 79 20 73 79 73 5F 77 72 69 74 65 20 63 60
+ 6C 6C 0D 0A 09 6D 6F 76 20 65 62 78 2C 30 09 09
+ 3B 20 53 70 65 63 69 66 79 20 46 69 6C 65 20 44
+ 65 73 63 72 69 70 74 6F 72 20 30 3A 20 53 74 60
+ 6E 64 60 72 64 20 4F 75 74 70 75 74 0D 0A 09 6D
+ 6F 76 20 65 63 78 2C 45 60 74 4D 73 67 09 09 3B
+ 20 50 60 73 73 20 6F 66 66 73 65 74 20 6F 66 20
+ 74 68 65 20 6D 65 73 73 60 67 65 0D 0A 09 6D 6F
+ 76 20 65 64 78 2C 45 60 74 4C 65 6E 09 09 3B 20
+ 50 60 73 73 20 74 68 65 20 6C 65 6E 67 74 68 20
+ 6F 66 20 74 68 65 20 6D 65 73 73 60 67 65 0D 0A
+ 09 69 6E 74 20 38 30 48 09 09 09 3B 20 4D 60 6B
+ 65 20 6B 65 72 6E 65 6C 20 63 60 6C 6C 0D 0A 0D
+ 0A 09 4D 4F 56 20 65 60 78 2C 30 09 09 3B 20 43
+ 6F 64 65 20 66 6F 72 20 45 78 69 74 20 53 79 73
+ 63 60 6C 6C 0D 0A 09 6D 6F 76 20 65 62 78 2C 30
+ 09 09 3B 20 52 65 74 75 72 6E 20 60 20 63 6F 64
+ 65 20 6F 66 20 7A 65 72 6F 09 0D 0A 09 69 6E 74
+ 20 38 30 48 09 09 09 3B 20 4D 60 6B 65 20 6B 65
+ 72 6E 65 6C 20 63 60 6C 6C 0D 0A 0D 0A 0D 0A 0D
+ 0A 0D 0A 0D 0A 0D 0A 0D 0A 0D 0A 0D 0A 0D 0A 0D
+ 0A 0D 0A 0D 0A 0D 0A 0D 0A 0D 0A 0D 0A 0D 0A 0D
+ 0A 0D 0A 0D 0A 0D 0A 0D 0A 0D 0A 0D 0A 0D 0A 0D
+ 0A 0D 0A 0D 0A 0D 0A 0D 0A 0D 0A 0D 0A 0D 0A 0D
diff --git a/asm-6-bits-branching/examples/hexdump1/makefile b/asm-6-bits-branching/examples/hexdump1/makefile
new file mode 100644 (file)
index 0000000..2279893
--- /dev/null
@@ -0,0 +1,4 @@
+lhexdump1: hexdump1.o
+       ld -o hexdump1 hexdump1.o
+hexdump1.o: hexdump1.asm
+       nasm -f elf64 -g -F stabs hexdump1.asm
diff --git a/asm-6-bits-branching/exercises/exercises-bits-branching.pdf b/asm-6-bits-branching/exercises/exercises-bits-branching.pdf
new file mode 100644 (file)
index 0000000..77763eb
Binary files /dev/null and b/asm-6-bits-branching/exercises/exercises-bits-branching.pdf differ
diff --git a/asm-6-bits-branching/slides/slides-bits-branching-2x2.pdf b/asm-6-bits-branching/slides/slides-bits-branching-2x2.pdf
new file mode 100644 (file)
index 0000000..7b46acc
Binary files /dev/null and b/asm-6-bits-branching/slides/slides-bits-branching-2x2.pdf differ
diff --git a/asm-6-bits-branching/slides/slides-bits-branching.pdf b/asm-6-bits-branching/slides/slides-bits-branching.pdf
new file mode 100644 (file)
index 0000000..4907882
Binary files /dev/null and b/asm-6-bits-branching/slides/slides-bits-branching.pdf differ
diff --git a/asm-7-procedures/.gitignore b/asm-7-procedures/.gitignore
new file mode 100644 (file)
index 0000000..63dc4ab
--- /dev/null
@@ -0,0 +1,7 @@
+*.aux
+*.log
+*.nav
+*.out
+*.snm
+*.toc
+
diff --git a/asm-7-procedures/examples/hexdump2/gazabo.txt b/asm-7-procedures/examples/hexdump2/gazabo.txt
new file mode 100644 (file)
index 0000000..03b1bc4
--- /dev/null
@@ -0,0 +1 @@
+gazabo
diff --git a/asm-7-procedures/examples/hexdump2/hexdump2 b/asm-7-procedures/examples/hexdump2/hexdump2
new file mode 100644 (file)
index 0000000..4d370fe
Binary files /dev/null and b/asm-7-procedures/examples/hexdump2/hexdump2 differ
diff --git a/asm-7-procedures/examples/hexdump2/hexdump2.asm b/asm-7-procedures/examples/hexdump2/hexdump2.asm
new file mode 100644 (file)
index 0000000..178d504
--- /dev/null
@@ -0,0 +1,234 @@
+;  Executable name : hexdump2
+;  Version         : 1.0
+;  Created date    : 4/15/2009
+;  Last update     : 4/20/2009
+;  Author          : Jeff Duntemann
+;  Modified by     : Emmanuel Benoist
+;  Date modification: 11/14/2016
+;  Description     : A simple hex dump utility demonstrating the use of
+;                      assembly language procedures
+;
+;  Modification    : Adapatation for 64-bit architecture 
+;
+;  Build using these commands:
+;    nasm -f elf64 -g -F stabs hexdump2.asm
+;    ld -o hexdump2 hexdump2.o 
+;
+
+SECTION .bss                   ; Section containing uninitialized data
+
+       BUFFLEN EQU 10
+       Buff    resb BUFFLEN
+
+SECTION .data                  ; Section containing initialised data
+
+; Here we have two parts of a single useful data structure, implementing
+; the text line of a hex dump utility. The first part displays 16 bytes in
+; hex separated by spaces. Immediately following is a 16-character line 
+; delimited by vertical bar characters. Because they are adjacent, the two
+; parts can be referenced separately or as a single contiguous unit.
+; Remember that if DumpLin is to be used separately, you must append an
+; EOL before sending it to the Linux console.
+
+DumpLin:       db " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "
+DUMPLEN                EQU $-DumpLin
+ASCLin:                db "|................|",10
+ASCLEN         EQU $-ASCLin
+FULLLEN                EQU $-DumpLin
+
+; The HexDigits table is used to convert numeric values to their hex
+; equivalents. Index by nybble without a scale: [HexDigits+eax]
+HexDigits:     db "0123456789ABCDEF"
+
+; This table is used for ASCII character translation, into the ASCII
+; portion of the hex dump line, via XLAT or ordinary memory lookup. 
+; All printable characters "play through" as themselves. The high 128 
+; characters are translated to ASCII period (2Eh). The non-printable
+; characters in the low 128 are also translated to ASCII period, as is
+; char 127.
+DotXlat: 
+       db 2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh
+       db 2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh
+       db 20h,21h,22h,23h,24h,25h,26h,27h,28h,29h,2Ah,2Bh,2Ch,2Dh,2Eh,2Fh
+       db 30h,31h,32h,33h,34h,35h,36h,37h,38h,39h,3Ah,3Bh,3Ch,3Dh,3Eh,3Fh
+       db 40h,41h,42h,43h,44h,45h,46h,47h,48h,49h,4Ah,4Bh,4Ch,4Dh,4Eh,4Fh
+       db 50h,51h,52h,53h,54h,55h,56h,57h,58h,59h,5Ah,5Bh,5Ch,5Dh,5Eh,5Fh
+       db 60h,61h,62h,63h,64h,65h,66h,67h,68h,69h,6Ah,6Bh,6Ch,6Dh,6Eh,6Fh
+       db 70h,71h,72h,73h,74h,75h,76h,77h,78h,79h,7Ah,7Bh,7Ch,7Dh,7Eh,2Eh
+       db 2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh
+       db 2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh
+       db 2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh
+       db 2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh
+       db 2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh
+       db 2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh
+       db 2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh
+       db 2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh
+                       
+       
+SECTION .text                  ; Section containing code
+
+;-------------------------------------------------------------------------
+; ClearLine:   Clear a hex dump line string to 16 0 values
+; UPDATED:     4/15/2009
+; IN:          Nothing
+; RETURNS:     Nothing
+; MODIFIES:    Nothing
+; CALLS:       DumpChar
+; DESCRIPTION: The hex dump line string is cleared to binary 0 by
+;              calling DumpChar 16 times, passing it 0 each time.
+
+ClearLine:
+       push rax        ; Save all used registers
+       push rdx
+       mov edx,15      ; We're going to go 16 pokes, counting from 0
+.poke: mov eax,0       ; Tell DumpChar to poke a '0'
+       call DumpChar   ; Insert the '0' into the hex dump string
+       sub edx,1       ; DEC doesn't affect CF!
+       jae .poke       ; Loop back if EDX >= 0
+       pop rdx         ; Restore all used registers
+       pop rax         ; 
+       ret             ; Go home
+
+
+;-------------------------------------------------------------------------
+; DumpChar:    "Poke" a value into the hex dump line string.
+; UPDATED:     4/15/2009
+; IN:          Pass the 8-bit value to be poked in EAX.
+;              Pass the value's position in the line (0-15) in EDX 
+; RETURNS:     Nothing
+; MODIFIES:    EAX, ASCLin, DumpLin
+; CALLS:       Nothing
+; DESCRIPTION: The value passed in EAX will be put in both the hex dump
+;              portion and in the ASCII portion, at the position passed 
+;              in EDX, represented by a space where it is not a
+;              printable character.
+
+DumpChar:
+       push rbx                ; Save caller's RBX
+       push rdi                ; Save caller's RDI
+; First we insert the input char into the ASCII portion of the dump line
+       mov bl,byte [DotXlat+eax]       ; Translate nonprintables to '.'
+       mov byte [ASCLin+edx+1],bl      ; Write to ASCII portion
+; Next we insert the hex equivalent of the input char in the hex portion
+; of the hex dump line:
+       mov ebx,eax             ; Save a second copy of the input char
+       lea edi,[edx*2+edx]     ; Calc offset into line string (ECX X 3)
+; Look up low nybble character and insert it into the string:
+       and eax,0000000Fh            ; Mask out all but the low nybble
+       mov al,byte [HexDigits+eax]  ; Look up the char equiv. of nybble
+       mov byte [DumpLin+edi+2],al  ; Write the char equiv. to line string
+; Look up high nybble character and insert it into the string:
+       and ebx,000000F0h       ; Mask out all the but second-lowest nybble
+       shr ebx,4               ; Shift high 4 bits of byte into low 4 bits
+       mov bl,byte [HexDigits+ebx] ; Look up char equiv. of nybble
+       mov byte [DumpLin+edi+1],bl ; Write the char equiv. to line string
+;Done! Let's go home:
+       pop rdi                 ; Restore caller's RDI
+       pop rbx                 ; Restore caller's RBX
+       ret                     ; Return to caller
+
+
+;-------------------------------------------------------------------------
+; PrintLine:   Displays DumpLin to stdout
+; UPDATED:     4/15/2009
+; IN:          Nothing
+; RETURNS:     Nothing
+; MODIFIES:    Nothing
+; CALLS:       Kernel sys_write
+; DESCRIPTION: The hex dump line string DumpLin is displayed to stdout 
+;              using INT 80h sys_write. All GP registers are preserved.
+
+PrintLine:
+       push rax                  ; Save all used registers
+       push rbx                  ; Save all used registers
+       push rcx                  ; Save all used registers
+       push rdx                  ; Save all used registers
+       mov eax,4         ; Specify sys_write call
+       mov ebx,1         ; Specify File Descriptor 1: Standard output
+       mov ecx,DumpLin   ; Pass offset of line string
+       mov edx,FULLLEN   ; Pass size of the line string
+       int 80h           ; Make kernel call to display line string
+       pop rdx           ; Restore all caller's registers
+       pop rcx           ; 
+       pop rbx           ; 
+       pop rax           ; 
+       ret               ; Return to caller
+
+
+;-------------------------------------------------------------------------
+; LoadBuff:    Fills a buffer with data from stdin via INT 80h sys_read
+; UPDATED:     4/15/2009
+; IN:          Nothing
+; RETURNS:     # of bytes read in EBP
+; MODIFIES:    ECX, EBP, Buff
+; CALLS:       Kernel sys_write
+; DESCRIPTION: Loads a buffer full of data (BUFFLEN bytes) from stdin 
+;              using INT 80h sys_read and places it in Buff. Buffer
+;              offset counter ECX is zeroed, because we're starting in
+;              on a new buffer full of data. Caller must test value in
+;              EBP: If EBP contains zero on return, we hit EOF on stdin.
+;              Less than 0 in EBP on return indicates some kind of error.
+
+LoadBuff:
+       push rax          ; Save caller's EAX
+       push rbx          ; Save caller's EBX
+       push rdx          ; Save caller's EDX
+       mov eax,3         ; Specify sys_read call
+       mov ebx,0         ; Specify File Descriptor 0: Standard Input
+       mov ecx,Buff      ; Pass offset of the buffer to read to
+       mov edx,BUFFLEN   ; Pass number of bytes to read at one pass
+       int 80h           ; Call sys_read to fill the buffer
+       mov ebp,eax       ; Save # of bytes read from file for later
+       xor ecx,ecx       ; Clear buffer pointer ECX to 0
+       pop rdx           ; Restore caller's EDX
+       pop rbx           ; Restore caller's EBX
+       pop rax           ; Restore caller's EAX
+       ret               ; And return to caller
+
+
+GLOBAL _start
+
+; ------------------------------------------------------------------------
+; MAIN PROGRAM BEGINS HERE
+;-------------------------------------------------------------------------
+_start:
+       nop                     ; No-ops for GDB
+       nop
+
+; Whatever initialization needs doing before the loop scan starts is here:
+       xor esi,esi             ; Clear total byte counter to 0
+       call LoadBuff           ; Read first buffer of data from stdin
+       cmp ebp,0               ; If ebp=0, sys_read reached EOF on stdin
+       jbe Exit
+
+; Go through the buffer and convert binary byte values to hex digits:
+Scan:
+       xor eax,eax             ; Clear EAX to 0
+       mov al,byte[Buff+ecx]   ; Get a byte from the buffer into AL
+       mov edx,esi             ; Copy total counter into EDX
+       and edx,0000000Fh       ; Mask out lowest 4 bits of char counter
+       call DumpChar           ; Call the char poke procedure
+
+; Bump the buffer pointer to the next character and see if buffer's done:
+       inc esi                 ; Increment total chars processed counter
+       inc ecx                 ; Increment buffer pointer
+       cmp ecx,ebp             ; Compare with # of chars in buffer
+       jb .modTest             ; If we've processed all chars in buffer...
+       call LoadBuff           ; ...go fill the buffer again
+       cmp ebp,0               ; If ebp=0, sys_read reached EOF on stdin
+       jbe Done                ; If we got EOF, we're done
+
+; See if we're at the end of a block of 16 and need to display a line:
+.modTest:
+       test esi,0000000Fh      ; Test 4 lowest bits in counter for 0
+       jnz Scan                ; If counter is *not* modulo 16, loop back
+       call PrintLine          ; ...otherwise print the line
+       call ClearLine          ; Clear hex dump line to 0's
+       jmp Scan                ; Continue scanning the buffer
+
+; All done! Let's end this party:
+Done:
+       call PrintLine          ; Print the "leftovers" line
+Exit:  mov eax,1               ; Code for Exit Syscall
+       mov ebx,0               ; Return a code of zero 
+       int 80H                 ; Make kernel call
diff --git a/asm-7-procedures/examples/hexdump2/hexsample.txt b/asm-7-procedures/examples/hexdump2/hexsample.txt
new file mode 100644 (file)
index 0000000..ffd5530
--- /dev/null
@@ -0,0 +1,7 @@
+ 68 65 78 64 75 6D 70 32 3A 20 68 65 78 64 75 6D |hexdump2: hexdum|
+ 70 32 2E 6F 0A 09 6C 64 20 2D 6F 20 68 65 78 64 |p2.o..ld -o hexd|
+ 75 6D 70 32 20 68 65 78 64 75 6D 70 32 2E 6F 0A |ump2 hexdump2.o.|
+ 68 65 78 64 75 6D 70 32 2E 6F 3A 20 68 65 78 64 |hexdump2.o: hexd|
+ 75 6D 70 32 2E 61 73 6D 0A 09 6E 61 73 6D 20 2D |ump2.asm..nasm -|
+ 66 20 65 6C 66 20 2D 67 20 2D 46 20 73 74 61 62 |f elf -g -F stab|
+ 73 20 68 65 78 64 75 6D 70 32 2E 61 73 6D 0A 00 |s hexdump2.asm..|
diff --git a/asm-7-procedures/examples/hexdump2/makefile b/asm-7-procedures/examples/hexdump2/makefile
new file mode 100644 (file)
index 0000000..184309b
--- /dev/null
@@ -0,0 +1,9 @@
+all: hexdump2
+
+clean:
+       rm *.o *~
+
+hexdump2: hexdump2.o
+       ld -o hexdump2 hexdump2.o
+hexdump2.o: hexdump2.asm
+       nasm -f elf64 -g -F stabs hexdump2.asm
diff --git a/asm-7-procedures/examples/hexdump2/textlib.asm b/asm-7-procedures/examples/hexdump2/textlib.asm
new file mode 100644 (file)
index 0000000..15b15b2
--- /dev/null
@@ -0,0 +1,139 @@
+;  Executable name : textlib
+;  Version         : 1.0
+;  Created date    : 4/10/2009
+;  Last update     : 4/10/2009
+;  Author          : Jeff Duntemann
+;  Description     : A linkable library of text-oriented procedures and tables
+;
+;  Build using these commands:
+;    nasm -f elf -g -F stabs textlib.asm
+;
+SECTION .bss                   ; Section containing uninitialized data
+       BUFFLEN EQU 10
+       Buff    resb BUFFLEN
+
+SECTION .data                  ; Section containing initialised data
+
+; Here we have two parts of a single useful data structure, implementing the
+; text line of a hex dump utility. The first part displays 16 bytes in hex
+; separated by spaces. Immediately following is a 16-character line delimited
+; by vertical bar characters. Because they are adjacent, they can be
+; referenced separately or as a single contiguous unit. Remember that if
+; DumpLin is to be used separately, you must append an EOL before sending it
+; to the Linux console.
+DumpLin:       db " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "
+DUMPLEN                EQU $-DumpLin
+ASCLin:                db "|................|",10
+ASCLEN         EQU $-ASCLin
+FULLLEN                EQU $-DumpLin
+
+; The HexDigits table is used to convert numeric values to their hex
+; equivalents. Index by nybble without a scale: [HexDigits+eax]
+HexDigits:     db "0123456789ABCDEF"
+
+; This table allows us to generate text equivalents for binary numbers. 
+; Index into the table by the nybble using a scale of 4: 
+; [BinDigits + ecx*4]
+BinDigits:     db "0000","0001","0010","0011"
+               db "0100","0101","0110","0111"
+               db "1000","1001","1010","1011"
+               db "1100","1101","1110","1111"
+
+; This table is used for ASCII character translation, into the ASCII
+; portion of the hex dump line, via XLAT or ordinary memory lookup. 
+; All printable characters "play through" as themselves. The high 128 
+; characters are translated to ASCII period (2Eh). The non-printable
+; characters in the low 128 are also translated to ASCII period, as is
+; char 127.
+       DotXlat: 
+       db 2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh
+       db 2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh
+       db 20h,21h,22h,23h,24h,25h,26h,27h,28h,29h,2Ah,2Bh,2Ch,2Dh,2Eh,2Fh
+       db 30h,31h,32h,33h,34h,35h,36h,37h,38h,39h,3Ah,3Bh,3Ch,3Dh,3Eh,3Fh
+       db 40h,41h,42h,43h,44h,45h,46h,47h,48h,49h,4Ah,4Bh,4Ch,4Dh,4Eh,4Fh
+       db 50h,51h,52h,53h,54h,55h,56h,57h,58h,59h,5Ah,5Bh,5Ch,5Dh,5Eh,5Fh
+       db 60h,61h,62h,63h,64h,65h,66h,67h,68h,69h,6Ah,6Bh,6Ch,6Dh,6Eh,6Fh
+       db 70h,71h,72h,73h,74h,75h,76h,77h,78h,79h,7Ah,7Bh,7Ch,7Dh,7Eh,2Eh
+       db 2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh
+       db 2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh
+       db 2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh
+       db 2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh
+       db 2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh
+       db 2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh
+       db 2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh
+       db 2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh,2Eh
+               
+SECTION .text                  ; Section containing code
+
+GLOBAL ClearLine, DumpChar, PrintLine, DumpLin, DUMPLEN, HexDigits
+GLOBAL BinDigits
+
+;-------------------------------------------------------------------------
+; ClearLine:   Clear a hex dump line string to 16 0 values
+; IN:          Nothing
+; RETURNS:     Nothing
+; TRASHES:     Nothing
+; The hex dump line string is cleared to binary 0. 
+
+ClearLine:
+       push edx        ; Save caller's EDX
+       mov edx,15      ; We're going to go 16 pokes, counting from 0
+.Poke: mov eax,0       ; Tell DumpChar to poke a '0'
+       call DumpChar   ; Insert the '0' into the hex dump string
+       sub edx,1       ; DEC doesn't affect CF!
+       jae .Poke       ; Loop back if EDX >= 0
+       pop edx         ; Restore caller's EDX
+       ret             ; Go home
+
+;-------------------------------------------------------------------------
+; DumpChar:    "Poke" a value into the hex dump line string.
+; IN:          Pass the 8-bit value to be poked in EAX.
+;              Pass the value's position in the line (0-15) in EDX 
+; RETURNS:     Nothing
+; TRASHES:     EAX
+; DESCRIPTION: The value passed in EAX will be placed in both the hex dump
+;              portion and in the ASCII portion, at the position passed 
+;              in ECX, represented by a space where it is not a printable 
+;              character.
+
+DumpChar:
+       push ebx                ; Save EBX on the stack so we don't trash
+       push edi
+; First we insert the input char into the ASCII portion of the dump line
+       mov bl,byte [DotXlat+eax]       ; Translate nonprintables to '.'
+       mov byte [ASCLin+edx+1],bl      ; Write to ASCII portion
+; Next we insert the hex equivalent of the input char in the hex portion
+; of the hex dump line:
+       mov ebx,eax             ; Save a second copy of the input char
+       lea edi,[edx*2+edx]     ; Calc offset into line string (ECX X 3)
+; Look up low nybble character and insert it into the string:
+       and eax,0000000Fh          ; Mask out all but the low nybble
+       mov al,byte [HexDigits+eax]   ; Look up the char equivalent of nybble
+       mov byte [DumpLin+edi+2],al ; Write the char equivalent to line string
+; Look up high nybble character and insert it into the string:
+       and ebx,000000F0h       ; Mask out all the but second-lowest nybble
+       shr ebx,4               ; Shift high 4 bits of char into low 4 bits
+       mov bl,byte [HexDigits+ebx] ; Look up char equivalent of nybble
+       mov byte [DumpLin+edi+1],bl ; Write the char equiv. to line string
+;Done! Let's go home:
+       pop ebx                 ; Restore caller's EBX register value
+       pop edi                 ; Restore caller's EDI register value
+       ret                     ; Return to caller
+
+;-------------------------------------------------------------------------
+; PrintLine:   Displays the hex dump line string via INT 80h sys_write
+; IN:          Nothing
+; RETURNS:     Nothing
+; TRASHES:     Nothing
+; DESCRIPTION: The hex dump line string is displayed to stdout using 
+;              INT 80h sys_write.
+
+PrintLine:
+       pushad                  ; Push all GP registers
+       mov eax,4               ; Specify sys_write call
+       mov ebx,1               ; Specify File Descriptor 1: Standard output
+       mov ecx,DumpLin         ; Pass offset of line string
+       mov edx,FULLLEN         ; Pass size of the line string
+       int 80h                 ; Make kernel call to display line string
+       popad                   ; Pop all GP registers
+       ret
diff --git a/asm-7-procedures/exercises/exercises-procedures.pdf b/asm-7-procedures/exercises/exercises-procedures.pdf
new file mode 100644 (file)
index 0000000..2281831
Binary files /dev/null and b/asm-7-procedures/exercises/exercises-procedures.pdf differ
diff --git a/asm-7-procedures/slides/slides-procedures-2x2.pdf b/asm-7-procedures/slides/slides-procedures-2x2.pdf
new file mode 100644 (file)
index 0000000..f9f4450
Binary files /dev/null and b/asm-7-procedures/slides/slides-procedures-2x2.pdf differ
diff --git a/asm-7-procedures/slides/slides-procedures.pdf b/asm-7-procedures/slides/slides-procedures.pdf
new file mode 100644 (file)
index 0000000..81b3f35
Binary files /dev/null and b/asm-7-procedures/slides/slides-procedures.pdf differ
diff --git a/asm-8-strings/.gitignore b/asm-8-strings/.gitignore
new file mode 100644 (file)
index 0000000..aec20dc
--- /dev/null
@@ -0,0 +1,8 @@
+*~
+*.aux
+*.log
+*.nav
+*.out
+*.snm
+*.toc
+
diff --git a/asm-8-strings/examples/clib/eatclib b/asm-8-strings/examples/clib/eatclib
new file mode 100644 (file)
index 0000000..de3206b
Binary files /dev/null and b/asm-8-strings/examples/clib/eatclib differ
diff --git a/asm-8-strings/examples/clib/eatclib.asm b/asm-8-strings/examples/clib/eatclib.asm
new file mode 100644 (file)
index 0000000..1b4bc9d
--- /dev/null
@@ -0,0 +1,46 @@
+extern printf
+                               extern scanf
+                               section .data
+
+                                 a db "set: ", 0
+                                 b db "not set: ", 0
+                                 reading db "Please enter a number: ", 0
+                                 message db "\n", 0
+                                 printsent db "%s", 10, 0
+                                 printint db "%d", 10, 0
+                                 printchar db "%c", 10, 0
+
+                                 readInt db "%d", 0
+                                 input db "%d", 0
+
+                               section .text
+                                   global main
+
+main:
+
+hatta:
+                               push rbp,
+                               mov  rbp, rsp,
+                               push rbx,
+                               xor  rax, rax,
+                               mov  rdi, printsent,
+                               mov  rsi, reading
+                               call  printf,
+                               pop  rbx,
+
+                               xor  rax, rax,
+                               mov  rdi, readInt,
+                               call  scanf,
+                               mov  rbx, rdi
+
+                               push rbx,
+                               xor  rax, rax,
+                               mov  rdi, printint,
+
+                               mov  rsi, rbx,
+                               call  printf,
+                               pop  rbx,
+
+                               pop  rbp,
+                               ret
+                               
diff --git a/asm-8-strings/examples/clib/eatclib2 b/asm-8-strings/examples/clib/eatclib2
new file mode 100644 (file)
index 0000000..f9e99f8
Binary files /dev/null and b/asm-8-strings/examples/clib/eatclib2 differ
diff --git a/asm-8-strings/examples/clib/eatclib2.asm b/asm-8-strings/examples/clib/eatclib2.asm
new file mode 100644 (file)
index 0000000..e0eac10
--- /dev/null
@@ -0,0 +1,43 @@
+;  Source name     : EATCLIB.ASM
+;  Executable name : EATCLIB
+;  Version         : 2.0
+;  Created date    : 10/1/1999
+;  Last update     : 11/16/2015
+;  Author          : Jeff Duntemann
+;;; Modifications: E. Benoist
+;  Description     : Demonstrates calls made into clib, using NASM 2.05 
+;      to send a short text string to stdout with puts().
+;
+;  Build using these commands:
+;    nasm -f elf64 -g -F stabs eatclib.asm
+;    gcc eatclib.o -o boiler
+
+[SECTION .data]                ; Section containing initialised data
+       
+EatMsg: db "Eat at Joe's!",10,0        ; We do not need the length because of c library
+
+[SECTION .bss]         ; Section containing uninitialized data
+               
+[SECTION .text]                ; Section containing code
+       
+extern puts            ; Simple "put string" routine from clib
+global main            ; Required so linker can find entry point
+       
+main:
+        push rbp       ; Set up stack frame for debugger
+       mov rbp,rsp
+       push rbx        ; Must preserve ebp, ebx, esi, & edi
+       push rsi
+       push rdi
+;;; Everything before this is boilerplate; use it for all ordinary apps!
+       mov rdi, EatMsg         ; Write address of message in RDI
+       call puts       ; Call clib function for displaying strings
+       
+
+;;; Everything after this is boilerplate; use it for all ordinary apps!
+       pop rdi         ; Restore saved registers
+       pop rsi
+       pop rbx
+       mov rsp,rbp     ; Destroy stack frame before returning
+       pop rbp
+       ret             ; Return control to Linux
diff --git a/asm-8-strings/examples/clib/eatclib3 b/asm-8-strings/examples/clib/eatclib3
new file mode 100644 (file)
index 0000000..fbdb765
Binary files /dev/null and b/asm-8-strings/examples/clib/eatclib3 differ
diff --git a/asm-8-strings/examples/clib/eatclib3.asm b/asm-8-strings/examples/clib/eatclib3.asm
new file mode 100644 (file)
index 0000000..324f3b0
--- /dev/null
@@ -0,0 +1,45 @@
+;  Source name     : EATCLIB.ASM
+;  Executable name : EATCLIB
+;  Version         : 2.0
+;  Created date    : 2/11/2014
+;  Last update     : 2/11/2014
+;  Author          : Emmanuel Benoist
+;  Description     : Demonstrates calls made into clib, using NASM 2.05 
+;      to send a short text string to stdout with puts().
+;
+;  Build using these commands:
+;    nasm -f elf64 -g -F stabs eatclib3.asm
+;    gcc eatclib3.o -o eatclib3
+
+[SECTION .data]                ; Section containing initialised data
+       
+MathMsg: db "%d +%d =%d ",10, 0        ; We do not need the length because of c library
+
+[SECTION .bss]         ; Section containing uninitialized data
+               
+[SECTION .text]                ; Section containing code
+       
+extern printf          ; Simple "put string" routine from clib
+global main            ; Required so linker can find entry point
+       
+main:
+        push rbp       ; Set up stack frame for debugger
+       mov rbp,rsp
+       push rbx        ; Must preserve ebp, ebx, esi, & edi
+       push rsi
+       push rdi
+;;; Everything before this is boilerplate; use it for all ordinary apps!
+       mov rdi, MathMsg        ; Write address of message in RDI
+       mov rsi, 10
+       mov rdx, 20
+       mov rcx, 30
+       xor rax,rax
+       call printf     ; Call clib function for displaying strings
+
+;;; Everything after this is boilerplate; use it for all ordinary apps!
+       pop rdi         ; Restore saved registers
+       pop rsi
+       pop rbx
+       mov rsp,rbp     ; Destroy stack frame before returning
+       pop rbp
+       ret             ; Return control to Linux
\ No newline at end of file
diff --git a/asm-8-strings/examples/clib/makefile b/asm-8-strings/examples/clib/makefile
new file mode 100644 (file)
index 0000000..b611138
--- /dev/null
@@ -0,0 +1,16 @@
+all: eatclib eatclib2 eatclib3
+
+eatclib: eatclib.o
+       gcc eatclib.o -o eatclib
+eatclib.o: eatclib.asm
+       nasm -f elf64 -g -F stabs eatclib.asm
+
+eatclib2: eatclib2.o
+       gcc eatclib2.o -o eatclib2
+eatclib2.o: eatclib2.asm
+       nasm -f elf64 -g -F stabs eatclib2.asm
+
+eatclib3: eatclib3.o
+       gcc eatclib3.o -o eatclib3
+eatclib3.o: eatclib3.asm
+       nasm -f elf64 -g -F stabs eatclib3.asm
diff --git a/asm-8-strings/examples/movestring/makefile b/asm-8-strings/examples/movestring/makefile
new file mode 100644 (file)
index 0000000..5a0ea5b
--- /dev/null
@@ -0,0 +1,37 @@
+all: movestring1mov movestring2stosbreset movestring3stosb movestring4movsb movestring5rep movestring6repmovsb
+clean:
+       rm *.o *.lst *~
+
+movestring1mov: movestring1mov.o
+       ld -o movestring1mov movestring1mov.o
+movestring1mov.o: movestring1mov.asm
+       nasm -f elf64 -g -F stabs movestring1mov.asm -l movestring1mov.lst
+
+
+movestring2stosbreset: movestring2stosbreset.o
+       ld -o movestring2stosbreset movestring2stosbreset.o
+movestring2stosbreset.o: movestring2stosbreset.asm
+       nasm -f elf64 -g -F stabs movestring2stosbreset.asm -l movestring2stosbreset.lst
+
+
+movestring3stosb: movestring3stosb.o
+       ld -o movestring3stosb movestring3stosb.o
+movestring3stosb.o: movestring3stosb.asm
+       nasm -f elf64 -g -F stabs movestring3stosb.asm -l movestring3stosb.lst
+
+movestring4movsb: movestring4movsb.o
+       ld -o movestring4movsb movestring4movsb.o
+movestring4movsb.o: movestring4movsb.asm
+       nasm -f elf64 -g -F stabs movestring4movsb.asm -l movestring4movsb.lst
+
+
+movestring5rep: movestring5rep.o
+       ld -o movestring5rep movestring5rep.o
+movestring5rep.o: movestring5rep.asm
+       nasm -f elf64 -g -F stabs movestring5rep.asm -l movestring5rep.lst
+
+
+movestring6repmovsb: movestring6repmovsb.o
+       ld -o movestring6repmovsb movestring6repmovsb.o
+movestring6repmovsb.o: movestring6repmovsb.asm
+       nasm -f elf64 -g -F stabs movestring6repmovsb.asm -l movestring6repmovsb.lst
diff --git a/asm-8-strings/examples/movestring/movestring1mov b/asm-8-strings/examples/movestring/movestring1mov
new file mode 100644 (file)
index 0000000..a19ba5f
Binary files /dev/null and b/asm-8-strings/examples/movestring/movestring1mov differ
diff --git a/asm-8-strings/examples/movestring/movestring1mov.asm b/asm-8-strings/examples/movestring/movestring1mov.asm
new file mode 100644 (file)
index 0000000..e5fef0e
--- /dev/null
@@ -0,0 +1,58 @@
+;  Executable name : movestring1mov
+;  Version         : 1.0
+;  Created date    : 3/11/2014
+;  Last update     : 3/11/2014
+;  Author          : Emmanuel Benoist
+;  Description     : A simple program in assembly for Linux, using NASM 2.05,
+;    demonstrating the way to copy a string using MOV instructions
+;
+;  Build using these commands:
+;    nasm -f elf64 -g -F stabs movestring1mov.asm
+;    ld -o movestring1mov movestring1mov.o
+;
+
+SECTION .data                  ; Section containing initialised data
+
+       InitString db "Hello World",10
+       INITLEN equ $-InitString
+       
+       TargetString db "                      ",10
+       TARGETLEN equ $-TargetString
+       
+SECTION .bss                   ; Section containing uninitialized data 
+
+
+SECTION .text                  ; Section containing code
+
+global         _start                  ; Linker needs this to find the entry point!
+       
+_start:
+       nop                     ; This no-op keeps gdb happy...
+
+       ;; Init registers to start the copy
+       mov rcx, INITLEN        ; The counter receives the length of the string
+       mov rsi, InitString     ; The source index receives Initial String
+                               
+       mov rdi, TargetString   ; The destination index receives the address of Target String
+       
+       
+.loopcopystring:       
+       mov al, byte [rsi]              ; The element at rsi is copied into Register A
+       mov byte [rdi], al              ; The element in A is copied into RDI
+       inc rsi
+       inc rdi                 ; We go forward in both strings
+       dec rcx                 ; The counter is decremented
+       jnz .loopcopystring     ; Loop as long as RCS is not 0
+
+       ;;  In the end TargetStings points to a copy of
+       ;;  InitString
+       nop                ;To keep gdb happy
+Output: mov eax,4              ; Specify sys_write call
+       mov ebx,1               ; Specify File Descriptor 2: Standard Error
+       mov ecx,TargetString            ; Pass offset of the error message
+       mov edx,TARGETLEN               ; Pass the length of the message
+       int 80H                 ; Make kernel call
+
+Exit:  mov eax,1               ; Code for Exit Syscall
+       mov ebx,0               ; Return a code of zero 
+       int 80H                 ; Make kernel call
\ No newline at end of file
diff --git a/asm-8-strings/examples/movestring/movestring2stosbreset b/asm-8-strings/examples/movestring/movestring2stosbreset
new file mode 100644 (file)
index 0000000..3899370
Binary files /dev/null and b/asm-8-strings/examples/movestring/movestring2stosbreset differ
diff --git a/asm-8-strings/examples/movestring/movestring2stosbreset.asm b/asm-8-strings/examples/movestring/movestring2stosbreset.asm
new file mode 100644 (file)
index 0000000..3c0708a
--- /dev/null
@@ -0,0 +1,57 @@
+;  Executable name : movestring2stosbreset
+;  Version         : 1.0
+;  Created date    : 3/11/2014
+;  Last update     : 3/11/2014
+;  Author          : Emmanuel Benoist
+;  Description     : A simple program in assembly for Linux, using NASM 2.05,
+;    demonstrating the way to errase a string using STOSB instruction 
+;
+;  Build using these commands:
+;    nasm -f elf64 -g -F stabs movestring2stosbreset.asm
+;    ld -o movestring2stosbreset movestring2stosbreset.o
+;
+
+SECTION .data                  ; Section containing initialised data
+
+       InitString db "Hello World",10
+       INITLEN equ $-InitString
+       
+       TargetString db "------------------------",10
+       TARGETLEN equ $-TargetString
+       
+SECTION .bss                   ; Section containing uninitialized data 
+
+
+SECTION .text                  ; Section containing code
+
+global         _start                  ; Linker needs this to find the entry point!
+       
+_start:
+       nop                     ; This no-op keeps gdb happy...
+
+       ;; Init registers to start the copy
+       mov rcx, TARGETLEN      ; The counter receives the length of the string
+       mov rsi, InitString     ; The source index receives Initial String
+                               
+       mov rdi, TargetString   ; The destination index receives the address of Target String
+       
+       dec rcx                 ; We will not errase the last char, which is a \n
+.loopcopystring:
+       mov bl,'m'              ; Move a char containing "space" into BL
+       mov byte [rdi], bl      ; The element in BL is copied into memory at RDI
+       inc rdi                 ; We go forward in strings
+       dec rcx                 ; The counter is decremented
+       jnz .loopcopystring     ; Loop as long as RCS is not 0
+
+       ;;  In the end TargetStings points to a copy of
+       ;;  InitString
+       nop                ;To keep gdb happy
+Output: mov eax,4              ; Specify sys_write call
+       mov ebx,1               ; Specify File Descriptor 2: Standard Error
+       mov ecx,TargetString            ; Pass offset of the error message
+       mov edx,TARGETLEN               ; Pass the length of the message
+       int 80H                 ; Make kernel call
+
+Exit:  mov eax,1               ; Code for Exit Syscall
+       mov ebx,0               ; Return a code of zero 
+       int 80H                 ; Make kernel call
\ No newline at end of file
diff --git a/asm-8-strings/examples/movestring/movestring3stosb b/asm-8-strings/examples/movestring/movestring3stosb
new file mode 100644 (file)
index 0000000..29de0bf
Binary files /dev/null and b/asm-8-strings/examples/movestring/movestring3stosb differ
diff --git a/asm-8-strings/examples/movestring/movestring3stosb.asm b/asm-8-strings/examples/movestring/movestring3stosb.asm
new file mode 100644 (file)
index 0000000..53af64e
--- /dev/null
@@ -0,0 +1,58 @@
+;  Executable name : movestring3stosb
+;  Version         : 1.0
+;  Created date    : 3/11/2014
+;  Last update     : 3/11/2014
+;  Author          : Emmanuel Benoist
+;  Description     : A simple program in assembly for Linux, using NASM 2.05,
+;    demonstrating the way to copy a string using STOSB instruction 
+;
+;  Build using these commands:
+;    nasm -f elf64 -g -F stabs movestring3stosb.asm
+;    ld -o movestring2stosbreset movestring3stosb.o
+;
+
+SECTION .data                  ; Section containing initialised data
+
+       InitString db "Hello World",10
+       INITLEN equ $-InitString
+       
+       TargetString db "------------------------",10
+       TARGETLEN equ $-TargetString
+       
+SECTION .bss                   ; Section containing uninitialized data 
+
+
+SECTION .text                  ; Section containing code
+
+global         _start                  ; Linker needs this to find the entry point!
+       
+_start:
+       nop                     ; This no-op keeps gdb happy...
+
+       ;; Init registers to start the copy
+       mov rcx, INITLEN        ; The counter receives the length of the string
+       mov rsi, InitString     ; The source index receives Initial String
+                               
+       mov rdi, TargetString   ; The destination index receives the address of Target String
+       
+
+.loopcopystring:
+       mov al, byte[rsi]       ; From source in memory to AL
+       stosb                   ; From AL to [RDI] (and increment RDI)
+       inc rsi                 ; We need to take care of RSI
+       dec rcx                 ; The counter is decremented
+       jnz .loopcopystring     ; Loop as long as RCS is not 0
+
+       ;;  In the end TargetStings points to a copy of
+       ;;  InitString
+       nop                ;To keep gdb happy
+Output: mov eax,4              ; Specify sys_write call
+       mov ebx,1               ; Specify File Descriptor 2: Standard Error
+       mov ecx,TargetString            ; Pass offset of the error message
+       mov edx,INITLEN         ; Pass the length of the message
+       ;;(we only copied initlen chars)
+       int 80H                 ; Make kernel call
+
+Exit:  mov eax,1               ; Code for Exit Syscall
+       mov ebx,0               ; Return a code of zero 
+       int 80H                 ; Make kernel call
\ No newline at end of file
diff --git a/asm-8-strings/examples/movestring/movestring4movsb b/asm-8-strings/examples/movestring/movestring4movsb
new file mode 100644 (file)
index 0000000..91627d6
Binary files /dev/null and b/asm-8-strings/examples/movestring/movestring4movsb differ
diff --git a/asm-8-strings/examples/movestring/movestring4movsb.asm b/asm-8-strings/examples/movestring/movestring4movsb.asm
new file mode 100644 (file)
index 0000000..421d62b
--- /dev/null
@@ -0,0 +1,57 @@
+;  Executable name : movestring4movsb
+;  Version         : 1.0
+;  Created date    : 3/11/2014
+;  Last update     : 3/11/2014
+;  Author          : Emmanuel Benoist
+;  Description     : A simple program in assembly for Linux, using NASM 2.05,
+;    demonstrating the way to copy a string using MOVSB instruction 
+;
+;  Build using these commands:
+;    nasm -f elf64 -g -F stabs movestring4movsb.asm
+;    ld -o movestring2stosbreset movestring4movsb.o
+;
+
+SECTION .data                  ; Section containing initialised data
+
+       InitString db "Hello World",10
+       INITLEN equ $-InitString
+       
+       TargetString db "------------------------",10
+       TARGETLEN equ $-TargetString
+       
+SECTION .bss                   ; Section containing uninitialized data 
+
+
+SECTION .text                  ; Section containing code
+
+global         _start                  ; Linker needs this to find the entry point!
+       
+_start:
+       nop                     ; This no-op keeps gdb happy...
+
+       ;; Init registers to start the copy
+       mov rcx, INITLEN        ; The counter receives the length of the string
+       mov rsi, InitString     ; The source index receives Initial String
+                               
+       mov rdi, TargetString   ; The destination index receives the address of Target String
+       
+
+.loopcopystring:
+       movsb                   ; From [RSI] to [RDI] (and increment RDI and RSI)
+
+       dec rcx                 ; The counter is decremented
+       jnz .loopcopystring     ; Loop as long as RCS is not 0
+
+       ;;  In the end TargetStings points to a copy of
+       ;;  InitString
+       nop                ;To keep gdb happy
+Output: mov eax,4              ; Specify sys_write call
+       mov ebx,1               ; Specify File Descriptor 2: Standard Error
+       mov ecx,TargetString            ; Pass offset of the error message
+       mov edx,INITLEN         ; Pass the length of the message
+       ;;(we only copied initlen chars)
+       int 80H                 ; Make kernel call
+
+Exit:  mov eax,1               ; Code for Exit Syscall
+       mov ebx,0               ; Return a code of zero 
+       int 80H                 ; Make kernel call
\ No newline at end of file
diff --git a/asm-8-strings/examples/movestring/movestring5rep b/asm-8-strings/examples/movestring/movestring5rep
new file mode 100644 (file)
index 0000000..1adb8d7
Binary files /dev/null and b/asm-8-strings/examples/movestring/movestring5rep differ
diff --git a/asm-8-strings/examples/movestring/movestring5rep.asm b/asm-8-strings/examples/movestring/movestring5rep.asm
new file mode 100644 (file)
index 0000000..545bbeb
--- /dev/null
@@ -0,0 +1,54 @@
+;  Executable name : movestring4movsb
+;  Version         : 1.0
+;  Created date    : 3/11/2014
+;  Last update     : 3/11/2014
+;  Author          : Emmanuel Benoist
+;  Description     : A simple program in assembly for Linux, using NASM 2.05,
+;    demonstrating the way to copy a string using MOVSB instruction 
+;
+;  Build using these commands:
+;    nasm -f elf64 -g -F stabs movestring4movsb.asm
+;    ld -o movestring2stosbreset movestring4movsb.o
+;
+
+SECTION .data                  ; Section containing initialised data
+
+       InitString db "Hello World",10
+       INITLEN equ $-InitString
+       
+       TargetString db "------------------------",10
+       TARGETLEN equ $-TargetString
+       
+SECTION .bss                   ; Section containing uninitialized data 
+
+
+SECTION .text                  ; Section containing code
+
+global         _start                  ; Linker needs this to find the entry point!
+       
+_start:
+       nop                     ; This no-op keeps gdb happy...
+
+       ;; Init registers to start the copy
+       mov rcx, INITLEN        ; The counter receives the length of the string
+       mov rdi, TargetString   ; The destination index receives the address of Target String   
+       mov al, 'm'             ; Move a marker in AL
+
+       
+       rep stosb               ; Loop From al to [RDI] (and increment RDI and RSI)
+
+       mov byte[TargetString+INITLEN-1],0Ah ; insert \n in the end of the copied string
+
+       ;;  In the end TargetStings points to a copy of
+       ;;  InitString
+       nop                ;To keep gdb happy
+Output: mov eax,4              ; Specify sys_write call
+       mov ebx,1               ; Specify File Descriptor 2: Standard Error
+       mov ecx,TargetString            ; Pass offset of the error message
+       mov edx,INITLEN         ; Pass the length of the message
+       ;;(we only copied initlen chars)
+       int 80H                 ; Make kernel call
+
+Exit:  mov eax,1               ; Code for Exit Syscall
+       mov ebx,0               ; Return a code of zero 
+       int 80H                 ; Make kernel call
\ No newline at end of file
diff --git a/asm-8-strings/examples/movestring/movestring6repmovsb b/asm-8-strings/examples/movestring/movestring6repmovsb
new file mode 100644 (file)
index 0000000..1ca5526
Binary files /dev/null and b/asm-8-strings/examples/movestring/movestring6repmovsb differ
diff --git a/asm-8-strings/examples/movestring/movestring6repmovsb.asm b/asm-8-strings/examples/movestring/movestring6repmovsb.asm
new file mode 100644 (file)
index 0000000..5de0684
--- /dev/null
@@ -0,0 +1,51 @@
+;  Executable name : movestring4movsb
+;  Version         : 1.0
+;  Created date    : 3/11/2014
+;  Last update     : 3/11/2014
+;  Author          : Emmanuel Benoist
+;  Description     : A simple program in assembly for Linux, using NASM 2.05,
+;    demonstrating the way to copy a string using MOVSB instruction 
+;
+;  Build using these commands:
+;    nasm -f elf64 -g -F stabs movestring4movsb.asm
+;    ld -o movestring2stosbreset movestring4movsb.o
+;
+
+SECTION .data                  ; Section containing initialised data
+
+       InitString db "Hello World",10
+       INITLEN equ $-InitString
+       
+       TargetString db "------------------------",10
+       TARGETLEN equ $-TargetString
+       
+SECTION .bss                   ; Section containing uninitialized data 
+
+
+SECTION .text                  ; Section containing code
+
+global         _start                  ; Linker needs this to find the entry point!
+       
+_start:
+       nop                     ; This no-op keeps gdb happy...
+
+       ;; Init registers to start the copy
+       mov rcx, INITLEN        ; The counter receives the length of the string
+       mov rsi, InitString     ; The source index points to the address of InitString
+       mov rdi, TargetString   ; The destination index receives the address of Target String   
+       
+       rep movsb               ; Loop move data from [RSI] into [RDI] INITLEN times
+
+       ;;  In the end TargetStings points to a copy of
+       ;;  InitString
+       nop                ;To keep gdb happy
+Output: mov eax,4              ; Specify sys_write call
+       mov ebx,1               ; Specify File Descriptor 2: Standard Error
+       mov ecx,TargetString            ; Pass offset of the error message
+       mov edx,INITLEN         ; Pass the length of the message
+       ;;(we only copied initlen chars)
+       int 80H                 ; Make kernel call
+
+Exit:  mov eax,1               ; Code for Exit Syscall
+       mov ebx,0               ; Return a code of zero 
+       int 80H                 ; Make kernel call
\ No newline at end of file
diff --git a/asm-8-strings/examples/showargs/makefile b/asm-8-strings/examples/showargs/makefile
new file mode 100644 (file)
index 0000000..9a928ca
--- /dev/null
@@ -0,0 +1,13 @@
+all: showargs1 showargs64
+
+clean:
+       rm *.o *~
+
+showargs1: showargs1.o
+       ld -o showargs1 showargs1.o -melf_i386
+showargs1.o: showargs1.asm
+       nasm -f elf -g -F stabs showargs1.asm -l showargs1.lst
+showargs64: showargs64.o
+       ld -o showargs64 showargs64.o 
+showargs64.o: showargs64.asm
+       nasm -f elf64 -g -F stabs showargs64.asm
diff --git a/asm-8-strings/examples/showargs/showargs1 b/asm-8-strings/examples/showargs/showargs1
new file mode 100644 (file)
index 0000000..9ece5e8
Binary files /dev/null and b/asm-8-strings/examples/showargs/showargs1 differ
diff --git a/asm-8-strings/examples/showargs/showargs1.asm b/asm-8-strings/examples/showargs/showargs1.asm
new file mode 100644 (file)
index 0000000..1ec22b4
--- /dev/null
@@ -0,0 +1,98 @@
+;  Executable name : SHOWARGS1\r
+;  Version         : 1.0\r
+;  Created date    : 4/17/2009\r
+;  Last update     : 5/19/2009\r
+;  Author          : Jeff Duntemann\r
+;  Description     : A simple program in assembly for Linux, using NASM 2.05,\r
+;    demonstrating the way to access command line arguments on the stack.\r
+;\r
+;  Build using these commands:\r
+;    nasm -f elf -g -F stabs showargs1.asm\r
+;    ld -o showargs1 showargs1.o\r
+;\r
+\r
+SECTION .data                  ; Section containing initialised data\r
+\r
+       ErrMsg db "Terminated with error.",10\r
+       ERRLEN equ $-ErrMsg\r
+       \r
+SECTION .bss                   ; Section containing uninitialized data \r
+\r
+; This program handles up to MAXARGS command-line arguments. Change the\r
+; value of MAXARGS if you need to handle more arguments than the default 10.\r
+; In essence we store pointers to the arguments in a 0-based array, with the\r
+; first arg pointer at array element 0, the second at array element 1, etc.\r
+; Ditto the arg lengths. Access the args and their lengths this way:\r
+;      Arg strings:            [ArgPtrs + <index reg>*4]\r
+;      Arg string lengths:     [ArgLens + <index reg>*4]\r
+; Note that when the argument lengths are calculated, an EOL char (10h) is\r
+; stored into each string where the terminating null was originally. This\r
+; makes it easy to print out an argument using sys_write. This is not\r
+; essential, and if you prefer to retain the 0-termination in the arguments, \r
+; you can comment out those lines as indicated.\r
+\r
+       MAXARGS   equ  10       ; Maximum # of args we support\r
+       ArgCount: resd 1        ; # of arguments passed to program\r
+       ArgPtrs:  resd MAXARGS  ; Table of pointers to arguments\r
+       ArgLens:  resd MAXARGS  ; Table of argument lengths\r
+\r
+SECTION .text                  ; Section containing code\r
+\r
+global         _start                  ; Linker needs this to find the entry point!\r
+       \r
+_start:\r
+       nop                     ; This no-op keeps gdb happy...\r
+\r
+; Get the command line argument count off the stack and validate it:\r
+       pop ecx                 ; TOS contains the argument count\r
+       cmp ecx,MAXARGS         ; See if the arg count exceeds MAXARGS\r
+       ja Error                ; If so, exit with an error message\r
+       mov dword [ArgCount],ecx ; Save arg count in memory variable\r
+\r
+; Once we know how many args we have, a loop will pop them into ArgPtrs:\r
+       xor edx,edx             ; Zero a loop counter\r
+SaveArgs:\r
+       pop dword [ArgPtrs + edx*4]  ; Pop an arg into the memory table\r
+       inc edx                 ; Bump the counter to the next argument\r
+       cmp edx,ecx             ; Is the counter = the argumemt count?\r
+       jb SaveArgs             ; If not, loop back and do another\r
+\r
+; With the argument pointers stored in ArgPtrs, we calculate their lengths:\r
+       xor eax,eax             ; Searching for 0, so clear AL to 0\r
+       xor ebx,ebx             ; Pointer table offset starts at 0\r
+ScanOne:\r
+       mov ecx,0000ffffh       ; Limit search to 65535 bytes max\r
+       mov edi,dword [ArgPtrs+ebx*4] ; Put address of string to search in EDI\r
+       mov edx,edi             ; Copy starting address into EDX                                                                                                                                                                                                                                                                                                             \r
+       cld                     ; Set search direction to up-memory\r
+       repne scasb             ; Search for null (0 char) in string at edi\r
+; Comment out the following line if you need mull-terminated arguments:\r
+       mov byte [edi-1],10     ; Store an EOL where the null used to be\r
+       sub edi,edx             ; Subtract position of 0 from start address\r
+       mov dword [ArgLens+ebx*4],edi   ; Put length of arg into table\r
+       inc ebx                 ; Add 1 to argument counter\r
+       cmp ebx,[ArgCount]      ; See if arg counter exceeds argument count\r
+       jb ScanOne              ; If not, loop back and do another one\r
+\r
+; Display all arguments to stdout:\r
+       xor esi,esi             ; Start (for table addressing reasons) at 0\r
+Showem:\r
+       mov ecx,[ArgPtrs+esi*4] ; Pass offset of the message\r
+       mov eax,4               ; Specify sys_write call\r
+       mov ebx,1               ; Specify File Descriptor 1: Standard Output\r
+       mov edx,[ArgLens+esi*4] ; Pass the length of the message\r
+       int 80H                 ; Make kernel call\r
+       inc esi                 ; Increment the argument counter\r
+       cmp esi,[ArgCount]      ; See if we've displayed all the arguments\r
+       jb Showem               ; If not, loop back and do another\r
+       jmp Exit                ; We're done! Let's pack it in!\r
+\r
+Error:         mov eax,4               ; Specify sys_write call\r
+       mov ebx,1               ; Specify File Descriptor 2: Standard Error\r
+       mov ecx,ErrMsg          ; Pass offset of the error message\r
+       mov edx,ERRLEN          ; Pass the length of the message\r
+       int 80H                 ; Make kernel call\r
+\r
+Exit:  mov eax,1               ; Code for Exit Syscall\r
+       mov ebx,0               ; Return a code of zero \r
+       int 80H                 ; Make kernel call
\ No newline at end of file
diff --git a/asm-8-strings/examples/showargs/showargs64 b/asm-8-strings/examples/showargs/showargs64
new file mode 100644 (file)
index 0000000..243a397
Binary files /dev/null and b/asm-8-strings/examples/showargs/showargs64 differ
diff --git a/asm-8-strings/examples/showargs/showargs64.asm b/asm-8-strings/examples/showargs/showargs64.asm
new file mode 100644 (file)
index 0000000..dbabdaf
--- /dev/null
@@ -0,0 +1,100 @@
+;  Executable name : showargs64
+;  Version         : 1.0
+;  Created date    : 10/11/2014
+;  Last update     : 10/11/2014
+;  Author          : Emmanuel Benoist
+;  Description     : A program for showing command line arguments
+;                   on 64-bit
+;;; 
+;;; MAJOR Change with the original program 
+;;; The args are not in stack, but refered to in stack once
+;;; 
+;  Build using these commands:
+;    nasm -f elf64 -g -F stabs showargs64.asm
+;    ld -o showargs showargs64.o
+;
+
+SECTION .data                  ; Section containing initialised data
+
+       ErrMsg db "Terminated with error.",10
+       ERRLEN equ $-ErrMsg
+
+SECTION .bss                   ; Section containing uninitialized data 
+
+; This program handles up to MAXARGS command-line arguments. Change the
+; value of MAXARGS if you need to handle more arguments than the default 10.
+; In essence we store pointers to the arguments in a 0-based array, with the
+; first arg pointer at array element 0, the second at array element 1, etc.
+; Ditto the arg lengths. Access the args and their lengths this way:
+;      Arg strings:            [ArgPtrs + <index reg>*8]
+;      Arg string lengths:     [ArgLens + <index reg>*8]
+; Note that when the argument lengths are calculated, an EOL char (10h) is
+; stored into each string where the terminating null was originally. This
+; makes it easy to print out an argument using sys_write. This is not
+; essential, and if you prefer to retain the 0-termination in the arguments, 
+; you can comment out those lines as indicated.
+
+       MAXARGS   equ  10       ; Maximum # of args we support
+       ArgCount: resq 1        ; # of arguments passed to program
+       ArgPtrs:  resq MAXARGS  ; Table of pointers to arguments
+       ArgLens:  resq MAXARGS  ; Table of argument lengths
+
+SECTION .text                  ; Section containing code
+
+global         _start                  ; Linker needs this to find the entry point!
+       
+_start:
+       nop                     ; This no-op keeps gdb happy...
+
+       
+; Get the command line argument count off the stack and validate it:
+       pop r12                 ; TOS contains the argument count
+       cmp r12,MAXARGS         ; See if the arg count exceeds MAXARGS
+       ja Error                ; If so, exit with an error message
+       mov qword [ArgCount],r12 ; Save arg count in memory variable
+
+       pop rdi                 ; Read the start of all strings
+       xor rbx,rbx             ; Counts the number of strings (<=[ArgCount])
+
+
+ScanOne:
+       mov [ArgPtrs + rbx*8],rdi       ; Save the pointer into Array
+       mov rcx,0000ffffh       ; Limit search to 65535 bytes max
+       mov rdx,rdi             ; Copy starting address into EDX        
+       cld                     ; Set search direction to up-memory
+       repne scasb             ; Search for null (0 char) in string at edi
+       mov byte [rdi-1],10     ; Store an EOL where the null used to be
+       mov r8,rdi
+       sub r8,rdx              ; Subtract position of 0 from start address
+       mov qword [ArgLens+rbx*8],r8    ; Put length of arg into table
+       inc rbx                 ; Add 1 to argument counter
+       cmp rbx,[ArgCount]      ; See if arg counter exceeds argument count
+       jb ScanOne              ; If not, loop back and do another one
+
+       
+
+       
+; Display all arguments to stdout:
+       xor r13,r13             ; Start (for table addressing reasons) at 0
+
+Showem:
+       mov rax,1               ; Specify sys_write call
+       mov rdi,1
+       mov rsi,[ArgPtrs+r13*8] ; Pass offset of the message
+       mov rdx,[ArgLens+r13*8] ; Pass the length of the message
+       syscall         ; Make kernel call
+       inc r13                 ; Increment the argument counter
+       cmp r13,[ArgCount]      ; See if we've displayed all the arguments
+       jb Showem               ; If not, loop back and do another
+       jmp Exit                ; We're done! Let's pack it in!
+
+
+Error:         mov eax,4               ; Specify sys_write call
+       mov ebx,1               ; Specify File Descriptor 2: Standard Error
+       mov ecx,ErrMsg          ; Pass offset of the error message
+       mov edx,ERRLEN          ; Pass the length of the message
+       int 80H                 ; Make kernel call
+
+Exit:  mov rax,1               ; Code for Exit Syscall
+       mov rbx,0               ; Return a code of zero 
+       int 80H                 ; Make kernel call
\ No newline at end of file
diff --git a/asm-8-strings/exercises/exercises-strings.pdf b/asm-8-strings/exercises/exercises-strings.pdf
new file mode 100644 (file)
index 0000000..98b5bca
Binary files /dev/null and b/asm-8-strings/exercises/exercises-strings.pdf differ
diff --git a/asm-8-strings/slides/slides-strings-2x2.pdf b/asm-8-strings/slides/slides-strings-2x2.pdf
new file mode 100644 (file)
index 0000000..c651c3b
Binary files /dev/null and b/asm-8-strings/slides/slides-strings-2x2.pdf differ
diff --git a/asm-8-strings/slides/slides-strings.pdf b/asm-8-strings/slides/slides-strings.pdf
new file mode 100644 (file)
index 0000000..91b6368
Binary files /dev/null and b/asm-8-strings/slides/slides-strings.pdf differ
diff --git a/asm-project/homework-asm-HS1819.pdf b/asm-project/homework-asm-HS1819.pdf
new file mode 100644 (file)
index 0000000..c861612
Binary files /dev/null and b/asm-project/homework-asm-HS1819.pdf differ
diff --git a/c-1-basics/.gitignore b/c-1-basics/.gitignore
new file mode 100644 (file)
index 0000000..63dc4ab
--- /dev/null
@@ -0,0 +1,7 @@
+*.aux
+*.log
+*.nav
+*.out
+*.snm
+*.toc
+
diff --git a/c-1-basics/examples/fundamentalsC/constants.c b/c-1-basics/examples/fundamentalsC/constants.c
new file mode 100644 (file)
index 0000000..5faded2
--- /dev/null
@@ -0,0 +1,52 @@
+#include <stdio.h>
+
+main(){
+
+  int i1 = 12345;
+  int i2 = 0;
+  int i3 = -145;
+  int i4 = 234;
+  puts("Integer values");
+  printf("i1 = %d, i2=%d, i3=%d, i4=%d\n",i1,i2,i3,i4);
+
+  int j1 = 0;
+  int j2 = 017;
+  int j3 = 07777;
+  printf("j1 = %d, j2=%d, j3=%d\n",j1,j2,j3);
+  /* Output: j1 = 0, j2=15, j3=4095  */
+
+  int k1 = 0xA;
+  int k2 = 0x10;
+  int k3 = -0xFFFF;
+  int k4 = 0x10000;
+
+  printf("k1 = %d, k2=%d, k3=%d, k4=%d\n",k1,k2,k3,k4);
+  /* Output: k1 = 10, k2=16, k3=-65535, k4=65536 */
+
+  puts("(or written in hexadecimal):");
+  printf("k1 = %x, k2=%x, k3=%x, k4=%x\n",k1,k2,k3,k4);
+  /* Output: k1 = a, k2=10, k3=ffff0001, k4=10000 */
+
+  /* Largest integer */
+  int k5 = 0x7FFFFFFF;
+  /* Smallest integer */
+  int k6 = 0x80000000;
+  printf("MAXINT= %x, (%d),MININT=%x,(%d) \n",k5,k5,k6,k6);
+
+  long l1 = 10;
+  long l2 = -20;
+  long l3 = 0xFFFFFFFFFFF;
+  printf("l1 = %ld, l2=%ld, l3=%ld\n",l1,l2,l3);
+
+  unsigned long ul1 = 0xFFFFFFFFFFFFFFFF;
+  long l4=-1;
+  printf("ul1 = %ld, l4=%ld\n",ul1,l4);
+  printf("ul1 = %lu, l4=%lu\n",ul1,l4);
+  printf("ul1 = %lx, l4=%lx\n",ul1,l4);
+  /* Output : ul1 = -1, l4=-1  */
+
+
+
+
+
+}
diff --git a/c-1-basics/examples/fundamentalsC/constants2.c b/c-1-basics/examples/fundamentalsC/constants2.c
new file mode 100644 (file)
index 0000000..bf798b7
--- /dev/null
@@ -0,0 +1,54 @@
+#include <stdio.h>
+
+main(){
+
+
+  char c1 = 'A';
+  char c2 = 'c';
+  char c3 = '0';
+  char c4 = '?';
+  char c5 = '\n';
+
+  printf("c1 as char = %c, as digital =%d, as hexa=%x\n",c1,c1,c1);
+  printf("c2 as char = %c, as digital =%d, as hexa=%x\n",c2,c2,c2);
+  printf("c3 as char = %c, as digital =%d, as hexa=%x\n",c3,c3,c3);
+  printf("c4 as char = %c, as digital =%d, as hexa=%x\n",c4,c4,c4);
+  printf("c5 as char = %c, as digital =%d, as hexa=%x\n",c5,c5,c5);
+
+  // Examples for variables declaration and initializations
+  // Integers and double precition floating numbers
+  int a, b, c;
+  double d1, d2, d3;
+  a=100;
+  b=0;
+  c=0x100;
+  d1=5.0;
+  d2=4E3;
+  d3=d1+d2*c;
+  printf("d3 = %f\n",d3);
+
+  a=200;
+  a=2*a+b*c;
+
+  // Examples of chars 
+  char ch1, ch2;
+  ch1='4';
+  ch2='A';
+  char ch3 = '\n';
+
+  // And strings (arrays of chars)
+  char str1[80];
+  char str2[]="Biel / Bienne";
+
+  char str3[10]="Ville de Bienne";
+  char str4[]="Tooto\n";
+
+  printf("Hello %s%c",str2,ch3); // Inserts a \n after the city name
+  printf("Hello %s",str3); // 
+
+
+  // Be carreful to reserve enough space
+
+
+
+}
diff --git a/c-1-basics/examples/fundamentalsC/makefile b/c-1-basics/examples/fundamentalsC/makefile
new file mode 100644 (file)
index 0000000..71fd2fb
--- /dev/null
@@ -0,0 +1,9 @@
+all: constants constants2
+
+clean:
+       rm -f *.o *~ constants constants2
+
+constants: constants.c
+       gcc constants.c -g -F dwarf -o constants
+constants2: constants2.c
+       gcc constants2.c -g -F dwarf -o constants2
diff --git a/c-1-basics/examples/helloC/helloWorld.c b/c-1-basics/examples/helloC/helloWorld.c
new file mode 100644 (file)
index 0000000..21f88bb
--- /dev/null
@@ -0,0 +1,5 @@
+#include <stdio.h>
+
+main(){
+  printf("Hello World Gruessech mitenandt\n");
+}
diff --git a/c-1-basics/examples/helloC/helloWorld2.c b/c-1-basics/examples/helloC/helloWorld2.c
new file mode 100644 (file)
index 0000000..33acf42
--- /dev/null
@@ -0,0 +1,12 @@
+#include <stdio.h>
+
+main(){
+  
+  printf("Hello, compute the square of a number\n");
+  printf("What number?\n");
+  int number; /* We reserve memory */
+  int number2; /* We reserve memory */
+  scanf("%d", &number); /* We set the value inside memory */
+  printf("The square of %d is %d\n",number,number*number);
+
+}
diff --git a/c-1-basics/examples/helloC/helloWorld3.c b/c-1-basics/examples/helloC/helloWorld3.c
new file mode 100644 (file)
index 0000000..0d90bd5
--- /dev/null
@@ -0,0 +1,10 @@
+#include <stdio.h>
+
+main(){
+  char str1[25]; // We reserve place in memory
+  
+  printf("Hello, what is your name?\n");
+  scanf("%s", &str1); // We change the value in the memory
+  printf("Hello %s\n", str1);
+
+}
diff --git a/c-1-basics/examples/helloC/makefile b/c-1-basics/examples/helloC/makefile
new file mode 100644 (file)
index 0000000..c802fa3
--- /dev/null
@@ -0,0 +1,15 @@
+all: helloWorld helloWorld2 helloWorld3
+
+clean:
+       rm -f *.o *~ helloWorld helloWorld2 helloWorld3
+
+helloWorld: helloWorld.c
+       gcc helloWorld.c -g -F dwarf -o helloWorld
+
+helloWorld2: helloWorld2.c
+       gcc helloWorld2.c -g -F dwarf -o helloWorld2
+
+helloWorld3: helloWorld3.c
+       gcc helloWorld3.c -g -F dwarf -o helloWorld3
+
diff --git a/c-1-basics/examples/operatorsC/library.c b/c-1-basics/examples/operatorsC/library.c
new file mode 100644 (file)
index 0000000..1c48c0a
--- /dev/null
@@ -0,0 +1,12 @@
+#include <stdio.h>
+
+main(){
+  char name [26];
+  // stdio.h
+  puts("What is your name?");
+  scanf("%s",name);
+  printf("Hello %s \n",name);
+
+
+
+}
diff --git a/c-1-basics/examples/operatorsC/library2.c b/c-1-basics/examples/operatorsC/library2.c
new file mode 100644 (file)
index 0000000..bb4f70e
--- /dev/null
@@ -0,0 +1,23 @@
+#include <stdio.h>
+#include <math.h>
+
+main(){
+  float x, y;
+  double logX;
+  double xPowerY;
+  int iX,iY;
+  // stdio.h
+  puts("Type an integer x?");
+  char xsadfsda = scanf("%f",&x); // argument is address of x
+  puts("Type an integer y?");
+  char yasfsadf = scanf("%f",&y); // address of y
+  
+  logX = log(x)/log(2); // since log(x) is the natural logarithm
+
+  printf("Log of %f = %lf \n",x,logX);
+
+  xPowerY = pow(x,y);
+  printf("%f power %f = %lf \n",x,y,xPowerY);
+
+
+}
diff --git a/c-1-basics/examples/operatorsC/makefile b/c-1-basics/examples/operatorsC/makefile
new file mode 100644 (file)
index 0000000..a4281df
--- /dev/null
@@ -0,0 +1,22 @@
+PROGS=operators operators2 library library2
+all: $(PROGS)
+
+clean:
+       rm -f *.o *~ $(PROGS)
+
+operators: operators.c
+       gcc operators.c -g -F dwarf -o operators
+
+operators2: operators2.c
+       gcc operators2.c -F dwarf -o operators2
+
+library: library.c
+       gcc library.c -F dwarf -o library
+
+library2: library2.o
+       gcc library2.o -lm -o library2
+
+library2.o: library2.c
+       gcc -c library2.c -F dwarf -O
+
+
diff --git a/c-1-basics/examples/operatorsC/operators.c b/c-1-basics/examples/operatorsC/operators.c
new file mode 100644 (file)
index 0000000..14ad5f7
--- /dev/null
@@ -0,0 +1,44 @@
+#include <stdio.h>
+
+main(){
+  int i1=0;
+  int i2=5;
+  i1 = i1+2;
+  i2 = i2++;
+
+
+  // incrementation operator
+  i1 = 35;
+  printf("Value of i1=%d\n",i1);
+  printf("Value of ++i1=%d\n",++i1);
+  printf("Value of i1++=%d\n",i1++);
+  printf("Value of i1=%d\n",i1);
+
+
+  // Operator sizeof
+  int j1;
+  long l1;
+  float f1;
+  double d1;
+  char str1[10]="Bienne";
+    printf("size of j1 (int)=%ld\n",sizeof j1);
+  printf("size of l1 (long)=%ld\n",sizeof l1);
+  printf("size of f1 (float)=%ld\n",sizeof f1);
+  printf("size of d1 (double)=%ld\n",sizeof d1);
+  printf("size of str1 (String 10chars)=%ld\n",sizeof str1);
+
+  char text[]="Canton of Bern";
+  printf("size of text=%ld\n",sizeof text);
+
+  i1=20;
+  i2=22;
+
+  if(i1<30 || i1>i2){
+    puts("condition is true");
+  }
+  else{  // should not arrive, since i1<30
+    puts("condition is false");
+  }
+
+
+}
diff --git a/c-1-basics/examples/operatorsC/operators2.c b/c-1-basics/examples/operatorsC/operators2.c
new file mode 100644 (file)
index 0000000..7d5301b
--- /dev/null
@@ -0,0 +1,33 @@
+#include <stdio.h>
+
+main(){
+
+  int i1;
+  int i2 = 4;
+  i1 = 3;
+  i1 = i2;
+  i1 = i2 * 4;
+  i1 = i2 + i1 + 5;
+  
+  int i, j;
+  i = j = 5;
+  printf("i=%d, j=%d\n",i,j);
+  // Output : i=5, j=5
+
+  int i3=0;
+  i3 += 5; // i3 is 5
+  i3 *= 2; // i3 is 10
+  printf("i3=%d\n",i3);
+
+
+  int i4 = (i3<0) ? 0 : 100;
+  printf("i4=%d\n",i4);
+
+  float f1 = 1.5;
+  float f2 = 2.3;
+
+  float fmin = (f1<f2) ? f1 : f2;
+  printf("fmin=%f\n",fmin);
+
+
+}
diff --git a/c-1-basics/exercises/exercises-basics.pdf b/c-1-basics/exercises/exercises-basics.pdf
new file mode 100644 (file)
index 0000000..45cf94e
Binary files /dev/null and b/c-1-basics/exercises/exercises-basics.pdf differ
diff --git a/c-1-basics/slides/slides-basics-2x2.pdf b/c-1-basics/slides/slides-basics-2x2.pdf
new file mode 100644 (file)
index 0000000..3018817
Binary files /dev/null and b/c-1-basics/slides/slides-basics-2x2.pdf differ
diff --git a/c-1-basics/slides/slides-basics.pdf b/c-1-basics/slides/slides-basics.pdf
new file mode 100644 (file)
index 0000000..1bee64b
Binary files /dev/null and b/c-1-basics/slides/slides-basics.pdf differ
diff --git a/c-2-controlStructures/.gitignore b/c-2-controlStructures/.gitignore
new file mode 100644 (file)
index 0000000..63dc4ab
--- /dev/null
@@ -0,0 +1,7 @@
+*.aux
+*.log
+*.nav
+*.out
+*.snm
+*.toc
+
diff --git a/c-2-controlStructures/examples/controlStatements/average.c b/c-2-controlStructures/examples/controlStatements/average.c
new file mode 100644 (file)
index 0000000..31662c5
--- /dev/null
@@ -0,0 +1,23 @@
+#include <stdio.h>
+
+main(){
+
+  char name[80];
+  int nbMarks,i=0;
+  float mark, sum, avg;
+  puts("Hello, what is your name?");
+  /* scan a line : everything not \n */
+  scanf(" %[^\n]",name);
+  printf("Number of marks?");
+  scanf(" %d",&nbMarks);
+  while (i<nbMarks){
+    i++;
+    printf("Enter Mark %d:",(i));
+    scanf(" %f",&mark);
+    sum += mark;
+  }
+  avg = sum / nbMarks;
+
+  printf("%s, your average mark is: %.1f \n",name,avg);
+  
+}
diff --git a/c-2-controlStructures/examples/controlStatements/breaks.c b/c-2-controlStructures/examples/controlStatements/breaks.c
new file mode 100644 (file)
index 0000000..f75ab76
--- /dev/null
@@ -0,0 +1,24 @@
+#include <stdio.h>
+
+main(){
+  puts("--------------------------");
+  puts("Examples with BREAK");
+
+  int val, exponent;
+
+  int i=0;
+  int res = 1;
+
+  puts("type value and exponent:");
+  scanf(" %d %d",&val,&exponent);
+
+  while(1){
+    if(i++ == exponent){
+      break;
+    }
+    res *= val;
+    
+  }
+  printf("%d power %d = %d\n",val,exponent,res);
+
+}
diff --git a/c-2-controlStructures/examples/controlStatements/continue.c b/c-2-controlStructures/examples/controlStatements/continue.c
new file mode 100644 (file)
index 0000000..f416b4d
--- /dev/null
@@ -0,0 +1,22 @@
+#include <stdio.h>
+#include <math.h>
+main(){
+  puts("--------------------------");
+  puts("Examples with CONTINUE");
+
+  long int i,val;
+
+  for(i=0; i< 10; i++){
+    puts("Type a number:");
+    scanf("%ld",&val);
+    if(val<0){ /* A negative number does not have a sqrt*/
+      printf("Negative number do not have any real square root\n");
+      continue;
+    }
+    double res = sqrt(val*1.0);
+    printf("Square root of %ld is %lg\n",val,res);
+
+  }
+
+
+}
diff --git a/c-2-controlStructures/examples/controlStatements/goto.c b/c-2-controlStructures/examples/controlStatements/goto.c
new file mode 100644 (file)
index 0000000..2b337be
--- /dev/null
@@ -0,0 +1,26 @@
+#include <stdio.h>
+#include <math.h>
+main(){
+  puts("--------------------------");
+  puts("Examples with CONTINUE");
+
+  int i,val;
+
+  for(i=0; i< 10; i++){
+    puts("Type a number:");
+    scanf("%d",&val);
+    if(val<0){ /* A negative number does not have a sqrt*/
+      goto errorNegativeNumber;
+    }
+    double res = sqrt(val*1.0);
+    printf("Square root of %d is %lg\n",val,res);
+
+  }
+
+  return;
+
+ errorNegativeNumber:
+  printf("Negative number do not have any square root\n");
+  return;
+
+}
diff --git a/c-2-controlStructures/examples/controlStatements/ifthenelse.c b/c-2-controlStructures/examples/controlStatements/ifthenelse.c
new file mode 100644 (file)
index 0000000..72237fc
--- /dev/null
@@ -0,0 +1,45 @@
+#include <stdio.h>
+#define PI 3.14159
+
+
+main(){
+
+  puts("Examples for If / Then /Else");
+
+  puts("-------------------------");
+  puts("Example 1");
+
+  char status = 'S';
+  double pay = 7000, tax;
+  
+  if (status == 'S')
+    tax = 0.20 * pay;
+  else
+    tax = 0.14 * pay;
+
+  printf("Pay=%lf and tax=%lf",pay,tax);
+
+
+
+
+  puts("-------------------------");
+  puts("Example 2");
+  char circle;
+  double radius, area,length, width;
+
+  circle = 1;
+
+if(circle){
+   scanf("%lf",&radius);
+   area = PI * radius * radius;
+   printf("Area of the circle = %lf \n",area);
+}
+else {
+   scanf("%lf %lf", &length, &width);
+   area = length * width;
+   printf("Area of rectangle = %lf",area);
+}
+
+  
+
+}
diff --git a/c-2-controlStructures/examples/controlStatements/loops.c b/c-2-controlStructures/examples/controlStatements/loops.c
new file mode 100644 (file)
index 0000000..8d9d322
--- /dev/null
@@ -0,0 +1,44 @@
+#include <stdio.h>
+#include <ctype.h>
+
+main(){
+  puts("--------------------------");
+  puts("Examples with DO... WHILE");
+  int digit = 0;
+  do
+    printf("%d\n",digit++);
+  while(digit <= 9);
+
+
+  char line[80];
+  int i = 0, size=0;
+  /* Scan one line (until a \n is read) */
+  puts("Type a line (to be transformed in uppercase):");
+  scanf("%[^\n]",line);
+  do 
+    ++size;
+  while(line[size]!=0);
+
+  do {
+    putchar(toupper(line[i]));
+    i++;
+  } while (i<size);
+  putchar('\n');
+                  
+
+  puts("--------------------------");
+  puts("Examples with FOR");
+
+  for(digit = 0; digit <=9; ++digit){
+    printf("%d\n",digit);
+  }
+    
+  
+  for(i=0;i<size;i++){
+    putchar(toupper(line[i]));
+  }
+  putchar('\n');
+      
+
+}
diff --git a/c-2-controlStructures/examples/controlStatements/makefile b/c-2-controlStructures/examples/controlStatements/makefile
new file mode 100644 (file)
index 0000000..513f0b9
--- /dev/null
@@ -0,0 +1,33 @@
+all: while ifthenelse average loops switches breaks continue goto
+
+clean:
+       rm -f *.o *~ while ifthenelse average loops switches breaks continue goto
+
+
+ifthenelse: ifthenelse.c
+       gcc ifthenelse.c -g -o ifthenelse
+
+
+while: while.c
+       gcc while.c -o while
+
+
+average: average.c
+       gcc average.c -o average
+
+
+loops: loops.c
+       gcc loops.c -o loops
+
+
+switches: switches.c
+       gcc switches.c -o switches
+
+breaks: breaks.c
+       gcc breaks.c -o breaks
+
+continue: continue.c
+       gcc continue.c -lm -o continue
+
+goto: goto.c
+       gcc goto.c -lm -o goto
diff --git a/c-2-controlStructures/examples/controlStatements/switches.c b/c-2-controlStructures/examples/controlStatements/switches.c
new file mode 100644 (file)
index 0000000..b7bdd91
--- /dev/null
@@ -0,0 +1,31 @@
+#include <stdio.h>
+
+main(){
+  puts("--------------------------");
+  puts("Examples with SWITCH");
+
+  puts("Enter one letter for a color (RWB):");
+  char choice;
+  choice = getchar();
+      
+  switch(choice){
+  case 'r':
+  case 'R':
+    printf("Red");
+     break;
+  case 'w':
+  case 'W':
+    printf("White");
+    break;
+  case 'b':
+  case 'B':
+    printf("Blue");
+    break;
+  default:
+    printf("Not a valid color");
+    
+  }
+
+  putchar('\n');
+
+}
diff --git a/c-2-controlStructures/examples/controlStatements/while.c b/c-2-controlStructures/examples/controlStatements/while.c
new file mode 100644 (file)
index 0000000..55a7635
--- /dev/null
@@ -0,0 +1,23 @@
+#include <stdio.h>
+
+main(){
+
+  puts("Examples for while");
+
+  puts("-------------------------");
+  puts("Example 1");
+
+  int digit = 0;
+  while(digit <= 9){
+    printf("%d\n",digit);
+    ++digit;
+  }
+
+  puts("-------------------------");
+  puts("Example 2");
+
+
+}
diff --git a/c-2-controlStructures/examples/inputsoutputs/getsputs.c b/c-2-controlStructures/examples/inputsoutputs/getsputs.c
new file mode 100644 (file)
index 0000000..6290d37
--- /dev/null
@@ -0,0 +1,11 @@
+#include <stdio.h>
+
+main(){
+
+  char line[80];
+  puts("Hello, what is your name:");
+  gets(line);
+  printf("Hello ");
+  puts(line);
+
+}
diff --git a/c-2-controlStructures/examples/inputsoutputs/input.txt b/c-2-controlStructures/examples/inputsoutputs/input.txt
new file mode 100644 (file)
index 0000000..61d2720
--- /dev/null
@@ -0,0 +1,4 @@
+10 45 80 98
+3 4 5 6
+9 9 9 9
+100 1000 10000 100000
diff --git a/c-2-controlStructures/examples/inputsoutputs/inputs.c b/c-2-controlStructures/examples/inputsoutputs/inputs.c
new file mode 100644 (file)
index 0000000..c8c2719
--- /dev/null
@@ -0,0 +1,36 @@
+#include <stdio.h>
+
+main(){
+
+  puts("Tests of inputs of strings (scanf)");
+
+  /* Example 1 Scanf */
+  int i1;
+  double d1;
+  char c1;
+  puts("type an integer, a float and a char");
+  int res= scanf(" %d %lf %c",&i1,&d1,&c1);
+  
+  printf(" i1=%d, d1=%lf c1=%c\n",i1,d1,c1);
+  printf("res=%d\n",res);
+
+  /* if input is : 1234 10.5 T
+     Output is i1=1234, d1=10.500000 c1=T
+  */
+
+  /* Example 2 Scanf */
+  int i2;
+  double d2;
+  char c2;
+  puts("type an integer (3 digits), a float (5 chars) and a char");
+  scanf(" %3d %5lf %c",&i2,&d2,&c2);
+  printf(" i2=%d, d2=%lf c2=%c\n",i2,d2,c2);
+  /* if input is : 1234 10.5 T
+ Output is: i2=123, d2=4.000000 c2=1
+
+  */
+  
+
+  
+
+}
diff --git a/c-2-controlStructures/examples/inputsoutputs/interactive.c b/c-2-controlStructures/examples/inputsoutputs/interactive.c
new file mode 100644 (file)
index 0000000..1c04bd0
--- /dev/null
@@ -0,0 +1,22 @@
+#include <stdio.h>
+
+main(){
+
+  char name[80];
+  int nbMarks,i;
+  double mark, sum, avg;
+  puts("Hello, what is your name?");
+  /* scan a line : everything not \n */
+  scanf(" %[^\n]",name);
+  printf("Number of marks?");
+  scanf(" %d",&nbMarks);
+  for(i=0;i<nbMarks;i++){
+    printf("Enter Mark %d:",(i+1));
+    scanf(" %lf",&mark);
+    sum += mark;
+  }
+  avg = sum / nbMarks;
+
+  printf("%s, your average mark is: %.1lf \n",name,avg);
+  
+}
diff --git a/c-2-controlStructures/examples/inputsoutputs/makefile b/c-2-controlStructures/examples/inputsoutputs/makefile
new file mode 100644 (file)
index 0000000..0bbb7e0
--- /dev/null
@@ -0,0 +1,23 @@
+all: inputs outputs getsputs interactive sscanf
+
+clean:
+       rm -f *.o *~  inputs outputs getsputs interactive sscanf
+
+inputs: inputs.c
+       gcc inputs.c -o inputs
+
+
+outputs: outputs.c
+       gcc outputs.c -o outputs
+
+
+getsputs: getsputs.c
+       gcc getsputs.c -o getsputs
+
+
+interactive: interactive.c
+       gcc interactive.c -o interactive
+
+sscanf: sscanf.c
+       gcc sscanf.c -o sscanf
+
diff --git a/c-2-controlStructures/examples/inputsoutputs/outputs.c b/c-2-controlStructures/examples/inputsoutputs/outputs.c
new file mode 100644 (file)
index 0000000..020e7c1
--- /dev/null
@@ -0,0 +1,46 @@
+#include <stdio.h>
+
+main(){
+
+  puts("Tests of output of strings (printf)");
+
+  /* Example 1 Printf */
+  double d1 = 101.593039;
+  puts("Example 1 : printf()");
+
+  printf("%f %.2f %.0f %2.2f \n",d1,d1,d1,d1);
+  
+  /* Output: 101.593039 101.59 102 101.59
+   */
+
+
+  /* Example 2 Printf */
+  char line[]="ABCDEFGHIJKLMNOP";
+  puts("Example 2 : printf()");
+  
+  printf("%10s %15s %15.5s %.10s\n",line,line,line,line);
+  /* Output:
+     ABCDEFGHIJKLMNOP ABCDEFGHIJKLMNOP           ABCDE ABCDEFGHIJ
+  */
+
+
+  /* Example 3 Printf */
+  puts("Example 3 : printf()");
+  int i1 = 1234;
+  double x = 12.0, y = -3.3;
+
+  printf(":%6d %7.0f %10.1e:\n",i1,x,y);
+  printf(":%-6d %-7.0f %-10.1e:\n",i1,x,y);
+  printf(":%+6d %+7.0f %+10.1e:\n",i1,x,y);
+  printf(":%-+6d %-+7.0f %-+10.1e:\n",i1,x,y);
+  printf(":%7.0f %#7.0f %7g %#7g:\n",x,x,y,y);
+  /* Output:
+     :  1234      12   -3.3e+00:
+     :1234   12      -3.3e+00  :
+     : +1234     +12   -3.3e+00:
+     :+1234  +12     -3.3e+00  :
+     :     12     12.    -3.3 -3.30000:
+  */
+
+
+}
diff --git a/c-2-controlStructures/examples/inputsoutputs/sscanf.c b/c-2-controlStructures/examples/inputsoutputs/sscanf.c
new file mode 100644 (file)
index 0000000..a4e6d21
--- /dev/null
@@ -0,0 +1,20 @@
+#include <stdio.h>
+/* Usage:
+./sscanf < input.txt 
+*/
+main(){
+
+  char line[256];
+  int i=0;
+  int a,b,c,d;
+  while(gets(line)){
+    int i = sscanf(line,"%d %d %d %d",&a,&b,&c,&d);
+    printf("%d + %d + %d + %d = %d\n",a,b,c,d,(a+b+c+d));
+
+    printf("(nb of match %d)\n",i);
+  }
+
+
+  
+
+}
diff --git a/c-2-controlStructures/exercises/exercises-cControlStructures.pdf b/c-2-controlStructures/exercises/exercises-cControlStructures.pdf
new file mode 100644 (file)
index 0000000..ce43969
Binary files /dev/null and b/c-2-controlStructures/exercises/exercises-cControlStructures.pdf differ
diff --git a/c-2-controlStructures/exercises/resources/result.txt b/c-2-controlStructures/exercises/resources/result.txt
new file mode 100644 (file)
index 0000000..1a550be
--- /dev/null
@@ -0,0 +1,3 @@
+Benoist                Emmanuel        2014 
+Fuhrer         Claude          2013
+Biberstein     Olivier         2016
diff --git a/c-2-controlStructures/exercises/resources/test.txt b/c-2-controlStructures/exercises/resources/test.txt
new file mode 100644 (file)
index 0000000..524eea0
--- /dev/null
@@ -0,0 +1,3 @@
+Emmanuel; Benoist; 24/11/2014 
+Claude; Fuhrer; 30/12/2013
+Olivier; Biberstein; 09/09/2016
diff --git a/c-2-controlStructures/slides/slides-cControlStructures-2x2.pdf b/c-2-controlStructures/slides/slides-cControlStructures-2x2.pdf
new file mode 100644 (file)
index 0000000..75053f4
Binary files /dev/null and b/c-2-controlStructures/slides/slides-cControlStructures-2x2.pdf differ
diff --git a/c-2-controlStructures/slides/slides-cControlStructures.pdf b/c-2-controlStructures/slides/slides-cControlStructures.pdf
new file mode 100644 (file)
index 0000000..b63c1f1
Binary files /dev/null and b/c-2-controlStructures/slides/slides-cControlStructures.pdf differ
diff --git a/c-3-libraries/.gitignore b/c-3-libraries/.gitignore
new file mode 100644 (file)
index 0000000..63dc4ab
--- /dev/null
@@ -0,0 +1,7 @@
+*.aux
+*.log
+*.nav
+*.out
+*.snm
+*.toc
+
diff --git a/c-3-libraries/examples/c-arrays/array1 b/c-3-libraries/examples/c-arrays/array1
new file mode 100644 (file)
index 0000000..3a01f94
Binary files /dev/null and b/c-3-libraries/examples/c-arrays/array1 differ
diff --git a/c-3-libraries/examples/c-arrays/array1.c b/c-3-libraries/examples/c-arrays/array1.c
new file mode 100644 (file)
index 0000000..a40bd8c
--- /dev/null
@@ -0,0 +1,15 @@
+#include <stdio.h>
+#define SIZEARRAY1 5
+
+main(){
+  double array1[SIZEARRAY1]={1.3, 4.5, 8.9,-1.0,3};
+
+  int i;
+  for(i=0; i < SIZEARRAY1 ; i++){
+    printf("array[%d]=%lf\n",i,array1[i]);
+  }
+  
+
+
+
+}
diff --git a/c-3-libraries/examples/c-arrays/array2 b/c-3-libraries/examples/c-arrays/array2
new file mode 100644 (file)
index 0000000..a1bc4eb
Binary files /dev/null and b/c-3-libraries/examples/c-arrays/array2 differ
diff --git a/c-3-libraries/examples/c-arrays/array2.c b/c-3-libraries/examples/c-arrays/array2.c
new file mode 100644 (file)
index 0000000..2c32ff1
--- /dev/null
@@ -0,0 +1,30 @@
+#include <stdio.h>
+int main (){
+   /* an array with 5 rows and 2 columns*/
+   int a[5][2] = { {0,0}, {1,2}, {2,4}, {3,6},{4,8}};
+   int i, j;
+   /* output each array element's value */
+   for ( i = 0; i < 5; i++ )
+   {
+      for ( j = 0; j < 2; j++ )
+      {
+         printf("a[%d][%d] = %d\n", i,j, a[i][j] );
+      }
+   }
+   return 0;
+}  
+
+/* Output:
+a[0][0] = 0
+a[0][1] = 0
+a[1][0] = 1
+a[1][1] = 2
+a[2][0] = 2
+a[2][1] = 4
+a[3][0] = 3
+a[3][1] = 6
+a[4][0] = 4
+a[4][1] = 8
+ */
diff --git a/c-3-libraries/examples/c-arrays/array3 b/c-3-libraries/examples/c-arrays/array3
new file mode 100644 (file)
index 0000000..2bd7dd6
Binary files /dev/null and b/c-3-libraries/examples/c-arrays/array3 differ
diff --git a/c-3-libraries/examples/c-arrays/array3.c b/c-3-libraries/examples/c-arrays/array3.c
new file mode 100644 (file)
index 0000000..2c95c81
--- /dev/null
@@ -0,0 +1,26 @@
+#include <stdio.h>
+/* function declaration */
+double getAverage(int arr[], int size);
+
+int main ()
+{
+   /* an int array with 5 elements */
+   int balance[5] = {1000, 2, 3, 17, 50};
+   double avg;
+   /* pass pointer to the array as an argument */
+   avg = getAverage( balance, 5 ) ;
+   /* output the returned value */
+   printf( "Average value is: %f \n", avg );
+   return 0;
+}
+
+double getAverage(int arr[], int size){
+  int    i;
+  double avg, sum;
+  for (i = 0; i < size; ++i){
+    sum += arr[i];
+  }
+  avg = sum / size;
+  return avg;
+}
diff --git a/c-3-libraries/examples/c-arrays/array4 b/c-3-libraries/examples/c-arrays/array4
new file mode 100644 (file)
index 0000000..e275152
Binary files /dev/null and b/c-3-libraries/examples/c-arrays/array4 differ
diff --git a/c-3-libraries/examples/c-arrays/array4.c b/c-3-libraries/examples/c-arrays/array4.c
new file mode 100644 (file)
index 0000000..839c75f
--- /dev/null
@@ -0,0 +1,35 @@
+#include <stdio.h>
+
+/* function to generate and return random numbers */
+int * getRandom( )
+{
+  static int  r[10];
+  int i;
+
+  /* set the seed */
+  srand( (unsigned)time( NULL ) );
+  for ( i = 0; i < 10; ++i)
+  {
+     r[i] = rand();
+     printf( "r[%d] = %d\n", i, r[i]);
+
+  }
+
+  return r;
+}
+
+/* main function to call above defined function */
+int main ()
+{
+   /* a pointer to an int */
+   int *p;
+   int i;
+
+   p = getRandom();
+   for ( i = 0; i < 10; i++ )
+   {
+       printf( "*(p + %d) : %d\n", i, *(p + i));
+   }
+
+   return 0;
+}
diff --git a/c-3-libraries/examples/c-arrays/makefile b/c-3-libraries/examples/c-arrays/makefile
new file mode 100644 (file)
index 0000000..b40f0ff
--- /dev/null
@@ -0,0 +1,17 @@
+all: array1 array2 array3 array4
+
+clean:
+       rm *.o *~
+
+array1: array1.c
+       gcc array1.c  -g -F dwarf -o array1
+
+
+array2: array2.c
+       gcc array2.c  -g -F dwarf -o array2
+
+array3: array3.c
+       gcc array3.c -g -F dwarf -o array3
+
+array4: array4.c
+       gcc array4.c -g -F dwarf -o array4
diff --git a/c-3-libraries/examples/c-functions/function1 b/c-3-libraries/examples/c-functions/function1
new file mode 100644 (file)
index 0000000..6bdacc9
Binary files /dev/null and b/c-3-libraries/examples/c-functions/function1 differ
diff --git a/c-3-libraries/examples/c-functions/function1.c b/c-3-libraries/examples/c-functions/function1.c
new file mode 100644 (file)
index 0000000..824e825
--- /dev/null
@@ -0,0 +1,23 @@
+#include <stdio.h>
+#include <math.h>
+
+char lower2upper(char c){
+  int delta = 'A'-'a';
+  char res=c;
+  if((c>='a') && (c<='z')){
+    res += delta; 
+  }
+  return res;
+}
+
+main(){
+  char c1;
+
+  while(scanf("%c",&c1)!=EOF){
+    c1 = lower2upper(c1);
+    printf("%c",c1);
+  }
+}
+
+
+
diff --git a/c-3-libraries/examples/c-functions/helloWorld b/c-3-libraries/examples/c-functions/helloWorld
new file mode 100644 (file)
index 0000000..d6951a0
Binary files /dev/null and b/c-3-libraries/examples/c-functions/helloWorld differ
diff --git a/c-3-libraries/examples/c-functions/helloWorld.c b/c-3-libraries/examples/c-functions/helloWorld.c
new file mode 100644 (file)
index 0000000..b5d875c
--- /dev/null
@@ -0,0 +1,11 @@
+/* we do not need stdio.h */
+int printf(const char*, ...);
+int scanf(const char*, ...);
+
+
+main(){
+  char name[80];
+  printf("Hello what is your name\n");
+  scanf("%s",name);
+  printf("Hello %s!\n",name);
+}
diff --git a/c-3-libraries/examples/c-functions/makefile b/c-3-libraries/examples/c-functions/makefile
new file mode 100644 (file)
index 0000000..0a30a3b
--- /dev/null
@@ -0,0 +1,21 @@
+all: function1 helloWorld useLibrary
+
+clean:
+       rm *.o *~
+
+function1: function1.c
+       gcc function1.c -g -F dwarf -lm -o function1
+
+helloWorld: helloWorld.c
+       gcc helloWorld.c -g -F dwarf -lm -o helloWorld
+
+# Generate the library file myFIrstLibrary.o that must be linked with the
+# File containing a main
+myFirstLibrary.o: myFirstLibrary.c myFirstLibrary.h
+       gcc myFirstLibrary.c  -g -F dwarf -c
+
+useLibrary.o: useLibrary.c myFirstLibrary.h
+       gcc useLibrary.c  -g -F dwarf -c 
+
+useLibrary: useLibrary.o myFirstLibrary.o
+       gcc useLibrary.o myFirstLibrary.o -o useLibrary
diff --git a/c-3-libraries/examples/c-functions/myFirstLibrary.c b/c-3-libraries/examples/c-functions/myFirstLibrary.c
new file mode 100644 (file)
index 0000000..8ccbe89
--- /dev/null
@@ -0,0 +1,31 @@
+#include "myFirstLibrary.h"
+
+/* Compute the factorial of a value 
+Input : val a long integer
+Return : val! (i.e. 1*2*3* ...* val)
+*/
+long factorial(long val){
+  long res= 1;
+  long i;
+  for(i=1; i <= val;i++){
+    res *= i;
+  }
+  return res;
+}
+
+/* Compute the protected integer binary logarithm of val
+Input: val a long integer
+Return : an integer for binary logarithm of val 
+or 0 if val is 0 
+*/
+long logarithm(long val){
+  long res=0;
+  if(val<=1){
+    return 0;
+  }
+  while(val>1){
+    val /=2;
+    res++;
+  }
+  return res;
+}
diff --git a/c-3-libraries/examples/c-functions/myFirstLibrary.h b/c-3-libraries/examples/c-functions/myFirstLibrary.h
new file mode 100644 (file)
index 0000000..e2834db
--- /dev/null
@@ -0,0 +1,5 @@
+
+long factorial(long);
+long logarithm(long);
+
+
diff --git a/c-3-libraries/examples/c-functions/useLibrary b/c-3-libraries/examples/c-functions/useLibrary
new file mode 100644 (file)
index 0000000..3cca2e0
Binary files /dev/null and b/c-3-libraries/examples/c-functions/useLibrary differ
diff --git a/c-3-libraries/examples/c-functions/useLibrary.c b/c-3-libraries/examples/c-functions/useLibrary.c
new file mode 100644 (file)
index 0000000..2d00130
--- /dev/null
@@ -0,0 +1,13 @@
+#include <stdio.h>
+#include "myFirstLibrary.h"
+
+main(){
+  long i;
+  puts("Please type a number:");
+  scanf(" %ld",&i);
+  long logi = logarithm(i);
+  long factoriali = factorial(logi);
+  printf("log(%ld)=%ld and %ld! = %ld\n",i,logi,logi,factoriali);
+
+
+}
diff --git a/c-3-libraries/examples/c-lowlevel/bitwiseoperations b/c-3-libraries/examples/c-lowlevel/bitwiseoperations
new file mode 100644 (file)
index 0000000..111a27b
Binary files /dev/null and b/c-3-libraries/examples/c-lowlevel/bitwiseoperations differ
diff --git a/c-3-libraries/examples/c-lowlevel/bitwiseoperations.c b/c-3-libraries/examples/c-lowlevel/bitwiseoperations.c
new file mode 100644 (file)
index 0000000..62903e1
--- /dev/null
@@ -0,0 +1,53 @@
+#include <stdio.h>
+
+int main(){
+  puts("One's complement (negate each bit)");
+
+  int number1 = 0x1;
+  int number2 = ~number1; // One's complement to number1
+
+  printf("n1= %X and n2=%X \n",number1,number2);
+
+  number1 = 0xF0FF00;
+  number2 = ~number1; // One's complement to number1
+
+  printf("n1= %X and n2=%X \n",number1,number2);
+
+  puts("AND (= &) operator");
+
+  int n1 = 0xFF11;
+  int n2 = 0x5599;
+
+  int n3 = n1 & n2;
+
+  printf("%X AND %X = %X \n",n1,n2,n3);
+
+  puts("OR (= |) operator");
+
+  int n4 = n1 | n2;
+
+  printf("%X OR %X = %X \n",n1,n2,n4);
+
+
+  puts("XOR (= ^) operator");
+
+
+  int n5 = n1 ^ n2;
+
+  printf("%X XOR %X = %X \n",n1,n2,n5);
+
+
+  /* Output:
+     One's complement (negate each bit)
+     n1= 1 and n2=FFFFFFFE 
+     n1= F0FF00 and n2=FF0F00FF 
+     AND (= &) operator
+     FF11 AND 5599 = 5511 
+     OR (= |) operator
+     FF11 OR 5599 = FF99 
+     XOR (= ^) operator
+     FF11 XOR 5599 = AA88 
+   */
+
+
+}
diff --git a/c-3-libraries/examples/c-lowlevel/makefile b/c-3-libraries/examples/c-lowlevel/makefile
new file mode 100644 (file)
index 0000000..7e93385
--- /dev/null
@@ -0,0 +1,13 @@
+all: bitwiseoperations shift
+
+clean:
+       rm *.o *~
+
+
+bitwiseoperations: bitwiseoperations.c
+       gcc bitwiseoperations.c -g -lm -o bitwiseoperations
+
+
+shift: shift.c
+       gcc shift.c -g -lm -o shift
+
diff --git a/c-3-libraries/examples/c-lowlevel/shift b/c-3-libraries/examples/c-lowlevel/shift
new file mode 100644 (file)
index 0000000..fd4867d
Binary files /dev/null and b/c-3-libraries/examples/c-lowlevel/shift differ
diff --git a/c-3-libraries/examples/c-lowlevel/shift.c b/c-3-libraries/examples/c-lowlevel/shift.c
new file mode 100644 (file)
index 0000000..125369a
--- /dev/null
@@ -0,0 +1,27 @@
+#include <stdio.h>
+
+
+int main(){
+  puts("Shift to the left 3 bits");
+  unsigned int a = 0xFF00;
+  unsigned int b = a << 3;
+  printf("a=%X; b=%X\n",a,b);
+
+  puts("Shift to the right 3 bits");
+  unsigned int a2 = 0xFF00;
+  unsigned int b2 = a >> 3;
+  printf("a2=%X; b2=%X\n",a2,b2);
+
+  putchar('\n');
+  puts("Shift to the left 4 bits");
+  a = 0xFF00;
+  b = a << 4;
+  printf("a=%X; b=%X\n",a,b);
+
+  puts("Shift to the right 4 bits");
+  a2 = 0xFF00;
+  b2 = a >> 4;
+  printf("a2=%X; b2=%X\n",a2,b2);
+
+
+}
diff --git a/c-3-libraries/examples/c-variables/automatic1 b/c-3-libraries/examples/c-variables/automatic1
new file mode 100644 (file)
index 0000000..6466ae0
Binary files /dev/null and b/c-3-libraries/examples/c-variables/automatic1 differ
diff --git a/c-3-libraries/examples/c-variables/automatic1.c b/c-3-libraries/examples/c-variables/automatic1.c
new file mode 100644 (file)
index 0000000..bbd58a8
--- /dev/null
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <math.h>
+#define MAX 10
+
+void print_n_stars(int nbStars){
+  int i;
+  printf("%d)",i); 
+  for(i=0;i<nbStars;i++){
+    printf("*");
+  }
+  printf("\n");
+}
+
+
+int main(){
+  int i =0;
+  for(i=0;i<MAX;i++){
+    print_n_stars(i);
+  }
+
+}
diff --git a/c-3-libraries/examples/c-variables/automatic2 b/c-3-libraries/examples/c-variables/automatic2
new file mode 100644 (file)
index 0000000..b3c9216
Binary files /dev/null and b/c-3-libraries/examples/c-variables/automatic2 differ
diff --git a/c-3-libraries/examples/c-variables/automatic2.c b/c-3-libraries/examples/c-variables/automatic2.c
new file mode 100644 (file)
index 0000000..e126640
--- /dev/null
@@ -0,0 +1,20 @@
+#include <stdio.h>
+#define MAX 8
+
+
+int main(){
+  int i;
+  for(i=0; i<MAX; i++){
+    if(i<3){
+      int i=9; 
+      printf("i=%d ;",i);
+    }
+    else{
+      printf("i=%d ;",i);
+    }
+  }
+  putchar('\n');
+}
+/* Output:
+i=9 ;i=9 ;i=9 ;i=3 ;i=4 ;i=5 ;i=6 ;i=7 ;
+*/
diff --git a/c-3-libraries/examples/c-variables/external.c b/c-3-libraries/examples/c-variables/external.c
new file mode 100644 (file)
index 0000000..134597d
--- /dev/null
@@ -0,0 +1,13 @@
+#include <stdio.h>
+
+/* This is the declaration of an external variable that will be linked later. 
+   The variable is defined in the file global2.c, where the function
+   printVar is actually used. */
+
+extern int myVar1;
+
+void printVar(void){
+  extern int myVar2;
+  printf("myVar1 =%d\n",myVar1);
+  printf("myVar2 =%d\n",myVar2);
+}
diff --git a/c-3-libraries/examples/c-variables/global1 b/c-3-libraries/examples/c-variables/global1
new file mode 100644 (file)
index 0000000..84156f4
Binary files /dev/null and b/c-3-libraries/examples/c-variables/global1 differ
diff --git a/c-3-libraries/examples/c-variables/global1.c b/c-3-libraries/examples/c-variables/global1.c
new file mode 100644 (file)
index 0000000..2769c85
--- /dev/null
@@ -0,0 +1,22 @@
+#include <stdio.h>
+
+
+int myVar;
+
+void printVar(void){
+  printf("myVar =%d\n",myVar);
+}
+
+int main(){
+  myVar = 10;
+  printVar();
+
+  myVar /=2;
+
+  printVar();
+  /* Output:
+     myVar =10
+     myVar =5
+  */
+
+}
diff --git a/c-3-libraries/examples/c-variables/global2 b/c-3-libraries/examples/c-variables/global2
new file mode 100644 (file)
index 0000000..1686452
Binary files /dev/null and b/c-3-libraries/examples/c-variables/global2 differ
diff --git a/c-3-libraries/examples/c-variables/global2.c b/c-3-libraries/examples/c-variables/global2.c
new file mode 100644 (file)
index 0000000..20d9dd9
--- /dev/null
@@ -0,0 +1,21 @@
+#include <stdio.h>
+/* This function is extern and defined in file "external.c"
+   where the value myVar1 is also used as external variable.*/
+void printVar(void);
+int myVar1;
+int myVar2;
+int main(){
+  myVar1 = 10;
+  myVar2 = -1;
+  printVar();
+  myVar1 /=2;
+  myVar2 *=2;
+  printVar();
+  /* Output:
+    myVar1 =10
+    myVar2 =-1
+    myVar1 =5
+    myVar2 =-2
+  */
+
+}
diff --git a/c-3-libraries/examples/c-variables/makefile b/c-3-libraries/examples/c-variables/makefile
new file mode 100644 (file)
index 0000000..1aa9e50
--- /dev/null
@@ -0,0 +1,26 @@
+all: automatic1 automatic2 static1 global1 global2
+
+clean:
+       rm *.o *~
+
+automatic1: automatic1.c
+       gcc automatic1.c -g -F dwarf -lm -o automatic1
+
+automatic2: automatic2.c
+       gcc automatic2.c -g -F dwarf -o automatic2
+
+
+static1: static1.c
+       gcc static1.c -g -F dwarf -o static1
+
+global1: global1.c
+       gcc global1.c -g -F dwarf -o global1
+
+global2.o: global2.c
+       gcc global2.c -g -F dwarf -c
+
+external.o: external.c
+       gcc external.c -g -F dwarf -c
+
+global2: global2.o external.o
+       gcc global2.o external.o -o global2
diff --git a/c-3-libraries/examples/c-variables/static1 b/c-3-libraries/examples/c-variables/static1
new file mode 100644 (file)
index 0000000..fe726c9
Binary files /dev/null and b/c-3-libraries/examples/c-variables/static1 differ
diff --git a/c-3-libraries/examples/c-variables/static1.c b/c-3-libraries/examples/c-variables/static1.c
new file mode 100644 (file)
index 0000000..a8677f2
--- /dev/null
@@ -0,0 +1,24 @@
+#include <stdio.h>
+
+int counter(void); /* Prototype of the function */
+
+
+main(){
+  counter();
+  counter();
+  counter();
+  counter();
+  counter();
+  printf("Counter = %d\n",counter());
+  /* Output 
+     Counter = 6
+  */
+}
+
+int counter(void){
+  static int i=0;
+  i++;
+  return i;
+
+}
+
diff --git a/c-3-libraries/exercises/exercises-libraries.pdf b/c-3-libraries/exercises/exercises-libraries.pdf
new file mode 100644 (file)
index 0000000..5ba21eb
Binary files /dev/null and b/c-3-libraries/exercises/exercises-libraries.pdf differ
diff --git a/c-3-libraries/slides/slides-libraries-2x2.pdf b/c-3-libraries/slides/slides-libraries-2x2.pdf
new file mode 100644 (file)
index 0000000..4e21fe5
Binary files /dev/null and b/c-3-libraries/slides/slides-libraries-2x2.pdf differ
diff --git a/c-3-libraries/slides/slides-libraries.pdf b/c-3-libraries/slides/slides-libraries.pdf
new file mode 100644 (file)
index 0000000..b1d7727
Binary files /dev/null and b/c-3-libraries/slides/slides-libraries.pdf differ
diff --git a/c-4-pointers/.gitignore b/c-4-pointers/.gitignore
new file mode 100644 (file)
index 0000000..63dc4ab
--- /dev/null
@@ -0,0 +1,7 @@
+*.aux
+*.log
+*.nav
+*.out
+*.snm
+*.toc
+
diff --git a/c-4-pointers/examples/c-pointers/dynamic1.c b/c-4-pointers/examples/c-pointers/dynamic1.c
new file mode 100644 (file)
index 0000000..9185deb
--- /dev/null
@@ -0,0 +1,41 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+
+double avrge(double* marks, int size);
+
+main(){
+  int i, n;
+  double* marks;
+  /* read in a value for n */
+
+  puts("Number of marks:");
+  scanf(" %d", &n);
+  
+  if(n>0){
+
+    marks = (double *) malloc(n*sizeof(double));
+  
+    for(i=0;i<n;i++){
+      printf("%d) Enter Mark:",(i+1));
+      // equivalent to scanf(" %lf",&marks[i]);
+      scanf(" %lf",marks+i);
+
+    }
+    double average = avrge(marks,n);
+    printf("Average is:%lf\n",average);
+    return 0;
+  }
+  printf("Need at least one number to make a mean!\n");
+}
+
+
+double avrge(double* marks, int size){
+  double sum=0;
+  int i;
+  for(i=0;i<size;i++){
+    sum += *(marks+i); // equivalent to marks[i]
+  }
+  return sum/size;
+
+}
diff --git a/c-4-pointers/examples/c-pointers/functions.c b/c-4-pointers/examples/c-pointers/functions.c
new file mode 100644 (file)
index 0000000..7ce5f44
--- /dev/null
@@ -0,0 +1,26 @@
+#include <stdio.h>
+
+void printA(int i){
+  printf("AAAA %i\n",i);
+}
+void printB(int i){
+  printf("BBBB %i\n",i);
+}
+
+void printSquare(int i, void (*pf)(int a)){
+  int square = i*i;
+  (*pf)(square);
+
+}
+
+int main(){
+  int val;
+  puts("type a number");
+  scanf(" %d",&val);
+  if((val%2)==0){
+    printSquare(val,printA);
+  }
+  else{
+    printSquare(val,printB);
+  }
+}
diff --git a/c-4-pointers/examples/c-pointers/makefile b/c-4-pointers/examples/c-pointers/makefile
new file mode 100644 (file)
index 0000000..fa7539f
--- /dev/null
@@ -0,0 +1,51 @@
+PROGS=pointers1 pointers2 pointers3 pointers4 pointers5  pointers6 pointers7 dynamic1 pointerArithmetic1 pointerArithmetic2 multidimentionarray1 multidimentionarray2 functions
+all: $(PROGS)
+
+clean:
+       rm -f *.o *~ $(PROGS)
+
+pointers1: pointers1.c
+       gcc pointers1.c -g -F dwarf -lm -o pointers1
+
+pointers2: pointers2.c
+       gcc pointers2.c -g -F dwarf -lm -o pointers2
+
+
+pointers3: pointers3.c
+       gcc pointers3.c -g -F dwarf -lm -o pointers3
+
+pointers4: pointers4.c
+       gcc pointers4.c -g -F dwarf -lm -o pointers4
+
+
+pointers5: pointers5.c
+       gcc pointers5.c -g -F dwarf -lm -o pointers5
+
+pointers6: pointers6.c
+       gcc pointers6.c -g -F dwarf -lm -o pointers6
+
+pointers7: pointers7.c
+       gcc pointers7.c -g -F dwarf -lm -o pointers7
+
+
+dynamic1: dynamic1.c
+       gcc dynamic1.c -g -F dwarf -lm -o dynamic1
+
+pointerArithmetic1: pointerArithmetic1.c
+       gcc pointerArithmetic1.c -g  -F dwarf -lm -o pointerArithmetic1
+
+pointerArithmetic2: pointerArithmetic2.c
+       gcc pointerArithmetic2.c -g -F dwarf -lm -o pointerArithmetic2
+
+multidimentionarray1: multidimentionarray1.c
+       gcc multidimentionarray1.c -g -F dwarf -lm -o multidimentionarray1
+
+
+
+multidimentionarray2: multidimentionarray2.c
+       gcc multidimentionarray2.c -g -F dwarf -lm -o multidimentionarray2
+
+
+functions: functions.c
+       gcc functions.c -g -F dwarf -lm -o functions
+
diff --git a/c-4-pointers/examples/c-pointers/multidimentionarray1.c b/c-4-pointers/examples/c-pointers/multidimentionarray1.c
new file mode 100644 (file)
index 0000000..8a5be9a
--- /dev/null
@@ -0,0 +1,65 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#define MAXROWS 4
+
+int main(){
+  int cols, rows;
+  int *a[MAXROWS];
+
+  puts("Number of cols:");
+  scanf(" %d",&cols);
+  puts("Number of rows:");
+  scanf(" %d", &rows);
+
+  int row;
+  for(row = 0; row < rows ; row++){
+    a[row]= (int *) malloc (cols* sizeof(int));
+  }
+  printf("Enter table");
+
+  int r,c;
+  for(r=0;r<rows;r++){
+    for(c=0;c<cols;c++){
+      printf("val (%d,%d)=",r,c);
+      scanf(" %d",(*(a+r)+c));
+    }
+  }
+  
+  for(r=0;r<rows;r++){
+    for(c=0;c<cols;c++){
+      printf(" val a[%d][%d]=%d",r,c,a[r][c]);
+
+    }
+    putchar('\n');
+  }
+  puts("other view of the same array");
+  for(r=0;r<rows;r++){
+    for(c=0;c<cols;c++){
+      printf(" val *(*(a+%d)+%d)=%d",r,c,*(*(a+r)+c));
+
+    }
+    putchar('\n');
+  }
+
+
+  /* Output
+     Number of cols:
+     2
+     Number of rows:
+     3
+     Enter tableval (0,0)=1
+     val (0,1)=2
+     val (1,0)=3
+     val (1,1)=4
+     val (2,0)=5
+     val (2,1)=6
+     val a[0][0]=1 val a[0][1]=2
+     val a[1][0]=3 val a[1][1]=4
+     val a[2][0]=5 val a[2][1]=6
+     other view of the same array
+     val *(*(a+0)+0)=1 val *(*(a+0)+1)=2
+     val *(*(a+1)+0)=3 val *(*(a+1)+1)=4
+     val *(*(a+2)+0)=5 val *(*(a+2)+1)=6
+  */
+}
diff --git a/c-4-pointers/examples/c-pointers/multidimentionarray2.c b/c-4-pointers/examples/c-pointers/multidimentionarray2.c
new file mode 100644 (file)
index 0000000..4cdd399
--- /dev/null
@@ -0,0 +1,36 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define MAXSIZE 12
+
+void sort(int size, char* x[]);
+
+int main(){
+  int i,n=0;
+  char *arrayOfStrings[10];
+  
+  puts("Enter each string on a separate line");
+  puts("Type control D to finished");
+  int max=10;
+  int size;
+  do{
+    
+    arrayOfStrings[n]=(char*) malloc(MAXSIZE * sizeof(char));
+    scanf("%s",arrayOfStrings[n]);
+    size = strlen(arrayOfStrings[n]);
+    n++;
+  }while(size > 0);
+  
+  sort(--n,arrayOfStrings);
+  
+  printf("List of strings (after sort)\n");
+  for(i=0;i<n;i++){
+    printf("%d) %s\n",(i+1),arrayOfStrings[i]);
+  }
+  
+}
+/* Should sort, function to be written in exercise */
+void sort(int size, char* x[]){
+  return;
+}
diff --git a/c-4-pointers/examples/c-pointers/pointerArithmetic1.c b/c-4-pointers/examples/c-pointers/pointerArithmetic1.c
new file mode 100644 (file)
index 0000000..8eb684f
--- /dev/null
@@ -0,0 +1,27 @@
+#include <stdio.h>
+
+int main(){
+  int* px;
+  int i = 1;
+  float f= 0.3;
+  double d=0.005;
+  char c = '*';
+   
+  px=&i;
+  printf("Values: i=%i f=%f d=%f c=%c\n",i,f,d,c);
+
+  printf("Addresses: i=%lX f=%lX d=%lX c=%lX\n",&i,&f,&d,&c);
+
+  printf("Pointer Values (size of int = %d):\n px=%lX; px+1=%lX;  px+2=%lX;  px+3=%lX\n",sizeof(int),px,px+1,px+2,px+3);
+
+  printf("Dereference: at px+1=%lX, value is:%f \n",px+1,*(px+1));
+
+  /* Output :
+Values: i=1 f=0.300000 d=0.005000 c=*
+Addresses: i=7FFF13C9C164 f=7FFF13C9C168 d=7FFF13C9C150 c=7FFF13C9C16F
+Pointer Values (size of int = 4):
+ px=7FFF13C9C164; px+1=7FFF13C9C168;  px+2=7FFF13C9C16C;  px+3=7FFF13C9C170
+Dereference: at px+1=7FFF13C9C168, value is:0.300000 
+   */
+
+}
diff --git a/c-4-pointers/examples/c-pointers/pointerArithmetic2.c b/c-4-pointers/examples/c-pointers/pointerArithmetic2.c
new file mode 100644 (file)
index 0000000..8b0eef3
--- /dev/null
@@ -0,0 +1,15 @@
+#include <stdio.h>
+
+int main(){
+  int* px, * py;
+  static int a[6] = {1,2,3,4,5,6};
+
+  px = &a[0];
+  py = &a[5];
+  printf("px=%X;  py=%X  \n",px,py);
+  printf("py - px = %X \n", py-px);
+  /* Output
+     px=601020;  py=601034  
+     py - px = 5
+  */
+}
diff --git a/c-4-pointers/examples/c-pointers/pointers1.c b/c-4-pointers/examples/c-pointers/pointers1.c
new file mode 100644 (file)
index 0000000..822a267
--- /dev/null
@@ -0,0 +1,24 @@
+#include <stdio.h>
+
+main(){
+  int w;
+  int u = 3;
+  int v;
+  int *pu; /* pointer to an integer */
+  int *pv; /* pointer to an integer */
+  int *pw; /* pointer to an integer */
+  pu = &u;  /* assign address of u to pu */
+  v = *pu; /* assign value of u to v */
+  pv = &v; /* assign addresse of v to pv */
+  pw= &w;
+
+  printf("u = %d   &u=%lX  pu=%lX   *pu=%d\n",u,&u,pu,*pu);
+  printf("v = %d   &v=%lX  pv=%lX   *pv=%d\n",v,&v,pv,*pv);
+  printf("w = %d   &v=%lX  pv=%lX   *pv=%d\n",w,&w,pw,*pw);
+  return 0;
+}
+/* Output:
+u = 3   &u=6e3b6f18  pu=6e3b6f18   *pu=3
+v = 3   &v=6e3b6f1c  pv=6e3b6f1c   *pv=3
+ */
diff --git a/c-4-pointers/examples/c-pointers/pointers2.c b/c-4-pointers/examples/c-pointers/pointers2.c
new file mode 100644 (file)
index 0000000..6c5e78e
--- /dev/null
@@ -0,0 +1,17 @@
+#include <stdio.h>
+
+main(){
+  int u1, u2;
+  int v = 3;
+  int *pv; /* pv is a pointer to v */
+  u1 = 2 * (v + 5);
+  pv = &v;
+  u2 = 2 *(*pv + 5);
+
+  printf("u1 = %d;  u2 = %d \n",u1,u2);
+  /* Output:
+     u1 = 16;  u2 = 16
+   */
+  
+
+}
diff --git a/c-4-pointers/examples/c-pointers/pointers3.c b/c-4-pointers/examples/c-pointers/pointers3.c
new file mode 100644 (file)
index 0000000..64a98f2
--- /dev/null
@@ -0,0 +1,19 @@
+#include <stdio.h>
+
+main(){
+  int v = 3;
+  int *pv; /* pv is a pointer to v */
+  pv = &v;
+  printf("*pv = %d;  v = %d \n",*pv,v);
+
+  *pv = 0;
+  printf("*pv = %d;  v = %d \n",*pv,v);
+
+
+  /* Output:
+   *pv = 3;  v = 3 
+   *pv = 0;  v = 0
+   */
+  
+
+}
diff --git a/c-4-pointers/examples/c-pointers/pointers4.c b/c-4-pointers/examples/c-pointers/pointers4.c
new file mode 100644 (file)
index 0000000..e1074e3
--- /dev/null
@@ -0,0 +1,37 @@
+#include <stdio.h>
+
+void funct1(int u, int v);
+void funct2(int *pu, int *pv);
+
+main(){
+  int u = 1;
+  int v = 3;
+  puts("before calling functions");
+  printf("u = %d; v = %d \n",u,v);
+  funct1(u,v);
+  puts("After funct1(u,v);");
+  printf("u = %d; v = %d \n",u,v);
+  funct2(&u,&v);
+    puts("After funct2(&u,&v);");
+  printf("u = %d; v = %d \n",u,v);
+}
+
+void funct1(int u, int v){
+  u = 0;
+  v = 0;
+  return;
+}
+void funct2(int *pu, int *pv){
+
+  *pu = 0;
+  *pv = 0;
+  return;
+}
+  /* Output:
+     before calling functions
+     u = 1; v = 3 
+     After funct1(u,v);
+     u = 1; v = 3 
+     After funct2(&u,&v);
+     u = 0; v = 0 
+  */
diff --git a/c-4-pointers/examples/c-pointers/pointers5.c b/c-4-pointers/examples/c-pointers/pointers5.c
new file mode 100644 (file)
index 0000000..3899cc5
--- /dev/null
@@ -0,0 +1,20 @@
+#include <stdio.h>
+
+void multiply(int* pi1,int* pi2);
+int main(){
+  int i1;
+  int i2;
+  puts("Enter two numbers");
+  scanf(" %d %d",&i1,&i2);
+  multiply(&i1, &i2);
+  printf("i1=%d and i2=%d \n",i1, i2);
+}
+void multiply(int* pi1,int* pi2){
+  *pi1 *= *pi2;
+}
+  /* Output:
+     Enter two numbers
+     45 65
+     i1=2925 and i2=65 
+   */
+
diff --git a/c-4-pointers/examples/c-pointers/pointers6.c b/c-4-pointers/examples/c-pointers/pointers6.c
new file mode 100644 (file)
index 0000000..667cffe
--- /dev/null
@@ -0,0 +1,22 @@
+#include <stdio.h>
+
+main(){
+  static int x[10] = {10,11,12,13,14,15,16,17,18,19};
+
+  int i;
+  for( i = 0; i <= 9; ++i){
+    printf("i = %d; x[%d] = %d; *(x+%d)=%d \n",i,i,x[i],i,*(x+i));
+    printf("       &x[%d] = %X; x+%d=%X \n",i,&x[i],i,x+i);
+  }
+  /* Output:
+     i = 0; x[i] = 10; *(x+i)=10 
+           &x[i] = 601040; x+i=601040 
+     i = 1; x[i] = 11; *(x+i)=11 
+           &x[i] = 601044; x+i=601044 
+     i = 2; x[i] = 12; *(x+i)=12 
+           &x[i] = 601048; x+i=601048
+     ...
+   */
+
+
+}
diff --git a/c-4-pointers/examples/c-pointers/pointers7.c b/c-4-pointers/examples/c-pointers/pointers7.c
new file mode 100644 (file)
index 0000000..6a64fc4
--- /dev/null
@@ -0,0 +1,67 @@
+#include <stdio.h>
+#include <string.h>
+
+main(){
+  char line[80];
+  char copy1[80];
+  char copy2[80];
+  char copy3[80];
+  char copy4[80];
+  char copy5[80];
+
+  puts("Enter line");
+  scanf(" %[^\n]",line);
+
+  /* Function for reading the length of a string */
+  int length = strlen(line); 
+  
+  int i;
+  /* We add one to copy the '\0' */
+  for(i=0;i<length+1 ; i++){
+    copy1[i]=line[i];
+    
+  }
+
+  for(i=0;i<length+1 ; i++){
+    copy2[i]=*(line+i);
+    
+  }
+
+
+  for(i=0;i<length+1 ; i++){
+    *(copy3 + i)=*(line + i);
+    
+  }
+
+
+  for(i=0;i<length+1 ; i++){
+    *(copy4 + i)=line[i];
+    
+  }
+
+  /* substring, without copy, same memory part */
+  char* p1 = &line[2]; 
+  char* p2 = line+2;
+  
+  printf("line = %s\n",line);
+  printf("Copy1 = %s\n",copy1);
+  printf("Copy2 = %s\n",copy2);
+  printf("Copy3 = %s\n",copy3);
+  printf("Copy4 = %s\n",copy4);
+  printf("p1 = %s\n",p1);
+  printf("p2 = %s\n",p2);
+
+}
+/* Ouptput
+bie1@VirtualBox:~/pointers$ ./pointers7
+Enter line
+Emmanuel Benoist
+line = Emmanuel Benoist
+Copy1 = Emmanuel Benoist
+Copy2 = Emmanuel Benoist
+Copy3 = Emmanuel Benoist
+Copy4 = Emmanuel Benoist
+p1 = manuel Benoist
+p2 = manuel Benoist
+
+ */
diff --git a/c-4-pointers/exercises/exercises-pointers.pdf b/c-4-pointers/exercises/exercises-pointers.pdf
new file mode 100644 (file)
index 0000000..cb4a09a
Binary files /dev/null and b/c-4-pointers/exercises/exercises-pointers.pdf differ
diff --git a/c-4-pointers/slides/slides-pointers-2x2.pdf b/c-4-pointers/slides/slides-pointers-2x2.pdf
new file mode 100644 (file)
index 0000000..5efcc0f
Binary files /dev/null and b/c-4-pointers/slides/slides-pointers-2x2.pdf differ
diff --git a/c-4-pointers/slides/slides-pointers.pdf b/c-4-pointers/slides/slides-pointers.pdf
new file mode 100644 (file)
index 0000000..3d8fd02
Binary files /dev/null and b/c-4-pointers/slides/slides-pointers.pdf differ
diff --git a/c-5-structuresFiles/.gitignore b/c-5-structuresFiles/.gitignore
new file mode 100644 (file)
index 0000000..63dc4ab
--- /dev/null
@@ -0,0 +1,7 @@
+*.aux
+*.log
+*.nav
+*.out
+*.snm
+*.toc
+
diff --git a/c-5-structuresFiles/examples/c-files/makefile b/c-5-structuresFiles/examples/c-files/makefile
new file mode 100644 (file)
index 0000000..e0febd2
--- /dev/null
@@ -0,0 +1,20 @@
+all: writeFile writeBinary writeFile2 readFile
+
+clean:
+       rm *.o *~
+
+
+writeFile: writeFile.c
+       gcc writeFile.c -g -lm -o writeFile
+
+
+
+
+writeFile2: writeFile2.c
+       gcc writeFile2.c -g -lm -o writeFile2
+
+writeBinary: writeBinary.c
+       gcc writeBinary.c -g -lm -o writeBinary
+
+readFile: readFile.c
+       gcc readFile.c -g -lm -o readFile
diff --git a/c-5-structuresFiles/examples/c-files/output.bin b/c-5-structuresFiles/examples/c-files/output.bin
new file mode 100644 (file)
index 0000000..a4b7b3a
Binary files /dev/null and b/c-5-structuresFiles/examples/c-files/output.bin differ
diff --git a/c-5-structuresFiles/examples/c-files/output.txt b/c-5-structuresFiles/examples/c-files/output.txt
new file mode 100644 (file)
index 0000000..21fd7dc
--- /dev/null
@@ -0,0 +1,2 @@
+Hello world
+012345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
\ No newline at end of file
diff --git a/c-5-structuresFiles/examples/c-files/output2.txt b/c-5-structuresFiles/examples/c-files/output2.txt
new file mode 100644 (file)
index 0000000..75fa843
--- /dev/null
@@ -0,0 +1,5 @@
+Toto
+Titi
+Tutu
+Foo
+Bar
diff --git a/c-5-structuresFiles/examples/c-files/readFile b/c-5-structuresFiles/examples/c-files/readFile
new file mode 100644 (file)
index 0000000..f338aef
Binary files /dev/null and b/c-5-structuresFiles/examples/c-files/readFile differ
diff --git a/c-5-structuresFiles/examples/c-files/readFile.c b/c-5-structuresFiles/examples/c-files/readFile.c
new file mode 100644 (file)
index 0000000..296e359
--- /dev/null
@@ -0,0 +1,37 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define MAXSIZE 16
+
+int main(){
+  FILE *file_pointer;
+  file_pointer = fopen("output2.txt","r");
+  
+
+  int i,n=0;
+  char *arrayOfStrings[10];
+  
+  puts("Reading strings from the file: output2.txt");
+  int max=10;
+  int size;
+  do{
+    
+    arrayOfStrings[n]=(char*) malloc(MAXSIZE * sizeof(char));
+    fscanf(file_pointer,"%s",arrayOfStrings[n]);
+    size = strlen(arrayOfStrings[n]);
+    n++;
+  }while(size > 0);
+  n--;
+  printf("List of strings\n");
+  for(i=0;i<n;i++){
+    printf("%d) %s\n",(i+1),arrayOfStrings[i]);
+  }
+    
+  fclose(file_pointer);
+
+
+  
+
+
+}
diff --git a/c-5-structuresFiles/examples/c-files/writeBinary b/c-5-structuresFiles/examples/c-files/writeBinary
new file mode 100644 (file)
index 0000000..d6b32a4
Binary files /dev/null and b/c-5-structuresFiles/examples/c-files/writeBinary differ
diff --git a/c-5-structuresFiles/examples/c-files/writeBinary.c b/c-5-structuresFiles/examples/c-files/writeBinary.c
new file mode 100644 (file)
index 0000000..97a0539
--- /dev/null
@@ -0,0 +1,23 @@
+#include <stdio.h>
+
+int main(){
+  FILE *file_pointer;
+  file_pointer = fopen("output.bin","w");
+  puts("Type a number");
+  int nb;
+  scanf(" %d",&nb);
+  
+  int data[nb];
+  int data_size = nb;
+  int i;
+  for(i=0;i<data_size;i++){
+    data[i]=i*2;
+  }
+  char* data_char = (char*)data;
+  for(i=0;i<sizeof(data);i++){
+    putc(data_char[i],file_pointer);
+    printf(" %d",i);
+  }
+    
+  fclose(file_pointer);
+}
diff --git a/c-5-structuresFiles/examples/c-files/writeFile b/c-5-structuresFiles/examples/c-files/writeFile
new file mode 100644 (file)
index 0000000..759dcad
Binary files /dev/null and b/c-5-structuresFiles/examples/c-files/writeFile differ
diff --git a/c-5-structuresFiles/examples/c-files/writeFile.c b/c-5-structuresFiles/examples/c-files/writeFile.c
new file mode 100644 (file)
index 0000000..de0f617
--- /dev/null
@@ -0,0 +1,22 @@
+#include <stdio.h>
+
+int main(){
+  FILE *file_pointer;
+  file_pointer = fopen("output.txt","w");
+  puts("Type a number");
+  int nb;
+  scanf(" %d",&nb);
+  
+  fprintf(file_pointer,"Hello world\n");
+  int i;
+  for(i=0;i<nb;i++){
+    fprintf(file_pointer,"%d",i);
+  }
+    
+  fclose(file_pointer);
+
+
+  
+
+
+}
diff --git a/c-5-structuresFiles/examples/c-files/writeFile2 b/c-5-structuresFiles/examples/c-files/writeFile2
new file mode 100644 (file)
index 0000000..dc9a07e
Binary files /dev/null and b/c-5-structuresFiles/examples/c-files/writeFile2 differ
diff --git a/c-5-structuresFiles/examples/c-files/writeFile2.c b/c-5-structuresFiles/examples/c-files/writeFile2.c
new file mode 100644 (file)
index 0000000..3f34717
--- /dev/null
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define MAXSIZE 16
+
+int main(){
+  FILE *file_pointer;
+  file_pointer = fopen("output2.txt","w");
+  
+
+  int i,n=0;
+  char *arrayOfStrings[10];
+  
+  puts("Enter each string on a separate line");
+  puts("Type control D to finished");
+  int max=10;
+  int size;
+  do{
+    
+    arrayOfStrings[n]=(char*) malloc(MAXSIZE * sizeof(char));
+    scanf("%s",arrayOfStrings[n]);
+    size = strlen(arrayOfStrings[n]);
+    n++;
+  }while(size > 0);
+  n--;
+  printf("List of strings (after sort)\n");
+  for(i=0;i<n;i++){
+    printf("%d) %s\n",(i+1),arrayOfStrings[i]);
+    fprintf(file_pointer,"%s\n",arrayOfStrings[i]);
+  }
+    
+  fclose(file_pointer);
+
+
+  
+
+
+}
diff --git a/c-5-structuresFiles/examples/c-structures/makefile b/c-5-structuresFiles/examples/c-structures/makefile
new file mode 100644 (file)
index 0000000..67a4b6f
--- /dev/null
@@ -0,0 +1,23 @@
+all: structures1 structures2 structures3 structures4 unions
+
+clean:
+       rm *.o *~
+
+structures1: structures1.c
+       gcc structures1.c -g -lm -o structures1
+
+
+structures2: structures2.c
+       gcc structures2.c -g -lm -o structures2
+
+
+structures3: structures3.c
+       gcc structures3.c -g -lm -o structures3
+
+
+structures4: structures4.c
+       gcc structures4.c -g -lm -o structures4
+
+
+unions: unions.c
+       gcc unions.c -g -lm -o unions
diff --git a/c-5-structuresFiles/examples/c-structures/structures1 b/c-5-structuresFiles/examples/c-structures/structures1
new file mode 100644 (file)
index 0000000..194942f
Binary files /dev/null and b/c-5-structuresFiles/examples/c-structures/structures1 differ
diff --git a/c-5-structuresFiles/examples/c-structures/structures1.c b/c-5-structuresFiles/examples/c-structures/structures1.c
new file mode 100644 (file)
index 0000000..1b9d4f7
--- /dev/null
@@ -0,0 +1,27 @@
+#include <stdio.h>
+
+struct account {
+   int acct_no;
+  char acct_type;
+  char name[80];
+  float balance;
+} myAccount1; /* define a variable myAccount1 from type struct account */
+
+int main(){
+  printf("Structures, example1\n");
+
+  /* define a variable myAccount2 of type struct account */
+  struct account myAccount2;
+
+  /* Define an array containing 100 struct accounts */
+  struct account myAccountArray[100];
+
+  myAccount1.acct_no = 10;
+
+  myAccount2.acct_type ='a';
+
+  myAccountArray[0].acct_no = 9;
+
+  struct account myAccount3 = {100,'R',"Hans Muster", 1023.9};
+
+}
diff --git a/c-5-structuresFiles/examples/c-structures/structures2 b/c-5-structuresFiles/examples/c-structures/structures2
new file mode 100644 (file)
index 0000000..519cd25
Binary files /dev/null and b/c-5-structuresFiles/examples/c-structures/structures2 differ
diff --git a/c-5-structuresFiles/examples/c-structures/structures2.c b/c-5-structuresFiles/examples/c-structures/structures2.c
new file mode 100644 (file)
index 0000000..1cbe36c
--- /dev/null
@@ -0,0 +1,59 @@
+#include <stdio.h>
+
+struct date{
+  int year;
+  int month;
+  int day;
+};
+
+struct birthdate{
+  char name[80];
+  struct date birth;
+};
+
+    
+
+struct account {
+  int acct_no;
+  char acct_type;
+  char name[80];
+  float balance;
+  struct date lastpayment;
+} myAccount1; /* define a variable myAccount1 from type struct account */
+
+int main(){
+  printf("Structures, example2\n");
+
+  /* define a variable myAccount2 of type struct account */
+  struct account myAccount2;
+
+  /* Define an array containing 100 struct accounts */
+  struct account myAccountArray[100];
+
+  myAccount1.acct_no = 10;
+
+  myAccount2.acct_type ='a';
+
+  myAccountArray[0].acct_no = 9;
+
+  printf("My Account1 number=%d; type=%c; ", myAccount1.acct_no,myAccount2.acct_type);
+
+
+  static struct birthdate birthdays[]={
+    {"Emmanuel",{1960,10,24}},
+    {"Jean",{1940,1,30}},
+    {"Paul",{1930,5,10}}
+  };
+  int size_birthdays = 3;
+
+  printf("Birthdays list:\n");
+  int i;
+  for(i=0;i< size_birthdays ;i++){
+    printf("Birth of %s was on %d.%d.%d \n",
+          birthdays[i].name,
+          birthdays[i].birth.day,
+          birthdays[i].birth.month,
+          birthdays[i].birth.year);
+  }
+
+}
diff --git a/c-5-structuresFiles/examples/c-structures/structures3 b/c-5-structuresFiles/examples/c-structures/structures3
new file mode 100644 (file)
index 0000000..6e26d28
Binary files /dev/null and b/c-5-structuresFiles/examples/c-structures/structures3 differ
diff --git a/c-5-structuresFiles/examples/c-structures/structures3.c b/c-5-structuresFiles/examples/c-structures/structures3.c
new file mode 100644 (file)
index 0000000..4b465e6
--- /dev/null
@@ -0,0 +1,55 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+struct user_structure{
+  int user_id;
+  char* username;
+  char* password;
+};
+
+typedef  struct user_structure user;
+
+int main(){
+  user u0 = {0,"abc","def"};
+
+  printf("u0: Userid= %d, username=%s and password =%s\n",u0.user_id,u0.username, u0.password);
+
+
+
+  user u1;
+  
+  u1.user_id=1;
+  u1.username="bie1";
+  u1.password="foo";
+
+  printf("u1: Userid= %d, username=%s and password =%s\n",u1.user_id,u1.username, u1.password);
+
+
+  user* pu1 = &u1;
+
+  printf("pu1: Userid= %d, username=%s and password =%s\n",(*pu1).user_id,pu1->username, pu1->password);
+
+  user* list_of_users[80];
+
+  
+  list_of_users[0]=&u1;
+
+
+  printf("lou[0]: Userid= %d, username=%s and password =%s\n",(*list_of_users[0]).user_id,list_of_users[0]->username, list_of_users[0]->password);
+  
+  u1.user_id=2;
+
+  printf("lou[0]: Userid= %d, username=%s and password =%s\n",list_of_users[0]->user_id,list_of_users[0]->username, list_of_users[0]->password);
+
+
+  list_of_users[1]=(user*)malloc(sizeof(user));
+
+  list_of_users[1]->user_id=3;
+  list_of_users[1]->username="beo1";
+  list_of_users[1]->password="bar";
+
+  printf("lou[1]: Userid= %d, username=%s and password =%s\n",list_of_users[1]->user_id,list_of_users[1]->username, list_of_users[1]->password);
+  
+  printf("%lu\n",sizeof(user));// 24
+
+}
diff --git a/c-5-structuresFiles/examples/c-structures/structures4 b/c-5-structuresFiles/examples/c-structures/structures4
new file mode 100644 (file)
index 0000000..fb2764e
Binary files /dev/null and b/c-5-structuresFiles/examples/c-structures/structures4 differ
diff --git a/c-5-structuresFiles/examples/c-structures/structures4.c b/c-5-structuresFiles/examples/c-structures/structures4.c
new file mode 100644 (file)
index 0000000..2f8f40d
--- /dev/null
@@ -0,0 +1,58 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+typedef struct{
+  int year;
+  int month;
+  int day;
+} date;
+
+typedef struct{
+  char* name;
+  char* firstname;
+  date birth;
+  date death;
+  
+} person;
+
+
+int main(){
+  person* emmanuel = (person*) malloc(sizeof(person)); 
+
+
+  emmanuel->name="Benoist";
+  emmanuel->firstname="Emmanuel";
+  emmanuel->birth=(date){1960,10,29};
+  emmanuel->death=(date){0,0,0};
+
+  person* p2 = (person*) malloc(sizeof(person));
+  p2->name = "Muster";
+  p2->firstname = "Hans";
+  p2->birth=(date){1890,1,1};
+  p2->death=(date){1918,11,11};
+  
+  person* list_of_persons[20];
+  list_of_persons[0]=emmanuel;
+  list_of_persons[1]=p2;
+  
+  int nb_of_persons = 2;
+  int i;
+  for(i=0;i < nb_of_persons; i++){
+    person* person = list_of_persons[i];
+    printf("*** Person %d ***\n",i);
+    printf("%s %s \n",person->firstname,person->name);
+    printf("Birth date :%d.%d.%d\n",person->birth.day,person->birth.month,person->birth.year);
+    if(person->death.year !=0){
+    printf("Death date :%d.%d.%d\n",person->death.day,person->death.month,person->death.year);      
+    }
+  }
+}
+/* Output:
+   *** Person 0 ***
+   Emmanuel Benoist 
+   Birth date :29.10.1960
+   *** Person 1 ***
+   Hans Muster 
+   Birth date :1.1.1890
+   Death date :11.11.1918
+ */
diff --git a/c-5-structuresFiles/examples/c-structures/unions b/c-5-structuresFiles/examples/c-structures/unions
new file mode 100644 (file)
index 0000000..291730a
Binary files /dev/null and b/c-5-structuresFiles/examples/c-structures/unions differ
diff --git a/c-5-structuresFiles/examples/c-structures/unions.c b/c-5-structuresFiles/examples/c-structures/unions.c
new file mode 100644 (file)
index 0000000..9c83965
--- /dev/null
@@ -0,0 +1,55 @@
+#include <stdio.h>
+#include <string.h>
+
+typedef struct
+{int r; int g; int b;} color;
+
+union val{
+  color col;
+  int size;
+};
+
+
+int main(){
+
+  union val array[10];
+  array[0].col=(color){255,0,0};
+  array[1].size=41;
+  array[2].col=(color){255,255,255};
+  array[3].size=39;
+  array[4].col=(color){0,255,55};
+  array[5].size=44;
+  array[6].col=(color){255,200,200};
+  array[7].size=42;
+  printf("Size of color :%lu\n",sizeof(color));
+  printf("Size of val :%lu\n",sizeof(union val));
+  printf("Size of int :%lu\n",sizeof(int));
+  
+  int nb_items=4;
+  int i;
+  for(i=0;i<nb_items;i++){
+    printf("Color:(%d, %d, %d), size: %d \n",array[2*i].col.r,array[2*i].col.g,array[2*i].col.b,array[2*i+1].size);
+  }
+  puts("And if we mix inputs");
+  for(i=0;i<nb_items;i++){
+    printf(" Color:(%d, %d, %d), size: %d \n",array[2*i+1].col.r,array[2*i+1].col.g,array[2*i+1].col.b,array[2*i].size);
+  }
+
+}
+/* Output
+   Size of color :12
+   Size of val :12
+   Size of int :4
+
+   Color:(255, 0, 0), size: 41 
+   Color:(255, 255, 255), size: 39 
+   Color:(0, 255, 55), size: 44 
+   Color:(255, 200, 200), size: 42 
+
+   And if we mix inputs
+   Color:(41, 6, 0), size: 255 
+   Color:(39, 4196224, 0), size: 255 
+   Color:(44, 349646710, 32767), size: 0 
+   Color:(42, 4196224, 0), size: 255 
+ */
diff --git a/c-5-structuresFiles/examples/enum1.c b/c-5-structuresFiles/examples/enum1.c
new file mode 100644 (file)
index 0000000..6a7a244
--- /dev/null
@@ -0,0 +1,39 @@
+#include <stdio.h>
+
+int main(){
+  enum color {black, white, red, green, blue, yellow};
+
+  enum color col1 = black;
+  enum color col2 = white;
+
+  enum color col3 = red;
+
+  printf("Print colors col1=%d, col2=%d, col3=%d\n", col1,col2,col3);
+
+  enum color2 {b=-1, w, r, g, bl, y};
+
+  enum color2 col4 = b;
+  enum color2 col5 = w;
+
+  enum color2 col6 = r;
+
+  printf("Print colors col4=%d, col5=%d, col6=%d\n", col4,col5,col6);
+
+  enum color2 background=w,foreground;
+  
+  switch(background){
+  b:
+  g:
+  bl:
+    foreground=w;
+    break;
+  w:
+  y:
+    foreground=b;
+  default:
+    foreground=bl;
+  }
+  printf("Background:%d , Foreground: %d\n",background,foreground);
+
+}
diff --git a/c-5-structuresFiles/examples/makefile b/c-5-structuresFiles/examples/makefile
new file mode 100644 (file)
index 0000000..cb1b680
--- /dev/null
@@ -0,0 +1,7 @@
+all: enum1
+
+clean:
+       rm -f *.o *~ enum1
+
+enum1: enum1.c
+       gcc enum1.c -g -lm -o enum1
diff --git a/c-5-structuresFiles/exercises/exercises-structuresFiles.pdf b/c-5-structuresFiles/exercises/exercises-structuresFiles.pdf
new file mode 100644 (file)
index 0000000..e2fa2d2
Binary files /dev/null and b/c-5-structuresFiles/exercises/exercises-structuresFiles.pdf differ
diff --git a/c-5-structuresFiles/slides/slides-structuresFiles-2x2.pdf b/c-5-structuresFiles/slides/slides-structuresFiles-2x2.pdf
new file mode 100644 (file)
index 0000000..2cfba93
Binary files /dev/null and b/c-5-structuresFiles/slides/slides-structuresFiles-2x2.pdf differ
diff --git a/c-5-structuresFiles/slides/slides-structuresFiles.pdf b/c-5-structuresFiles/slides/slides-structuresFiles.pdf
new file mode 100644 (file)
index 0000000..47d344b
Binary files /dev/null and b/c-5-structuresFiles/slides/slides-structuresFiles.pdf differ
diff --git a/c-6-additional/.gitignore b/c-6-additional/.gitignore
new file mode 100644 (file)
index 0000000..63dc4ab
--- /dev/null
@@ -0,0 +1,7 @@
+*.aux
+*.log
+*.nav
+*.out
+*.snm
+*.toc
+
diff --git a/c-6-additional/examples/c-paralelism/fork1.c b/c-6-additional/examples/c-paralelism/fork1.c
new file mode 100644 (file)
index 0000000..fa541b9
--- /dev/null
@@ -0,0 +1,54 @@
+/* Source 
+http://www.thegeekstuff.com/2012/05/c-fork-function/
+*/
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <stdio.h>
+#include <sys/wait.h>
+#include <stdlib.h>
+
+
+int var_glb; /* A global variable*/
+
+int main(void)
+{
+    pid_t childPID;
+    int var_lcl = 0;
+    
+    int i,j,k;
+
+    childPID = fork();
+
+    if(childPID >= 0) // fork was successful
+    {
+        if(childPID == 0) // child process
+        {
+            var_lcl++;
+            var_glb++;
+            printf("\n Child Process :: var_lcl = [%d], var_glb[%d]\n", var_lcl, var_glb);
+        }
+        else //Parent process
+        {
+            var_lcl = 10;
+            var_glb = 20;
+            printf("\n Parent process :: var_lcl = [%d], var_glb[%d]\n", var_lcl, var_glb);
+
+        }
+    }
+    else // fork failed
+    {
+        printf("\n Fork failed, quitting!!!!!!\n");
+        return 1;
+    }
+
+    return 0;
+}
+/* Output:
+bie1@bie1-VirtualBox:~/svn/examples/cAdditional/parallelism$ ./fork1 
+
+ Parent process :: var_lcl = [10], var_glb[20]
+
+ Child Process :: var_lcl = [1], var_glb[1]
+*/
diff --git a/c-6-additional/examples/c-paralelism/fork2.c b/c-6-additional/examples/c-paralelism/fork2.c
new file mode 100644 (file)
index 0000000..fa47068
--- /dev/null
@@ -0,0 +1,82 @@
+/* Source 
+http://www.thegeekstuff.com/2012/05/c-fork-function/
+*/
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <stdio.h>
+#include <sys/wait.h>
+#include <stdlib.h>
+
+#define MAXLOOP 10
+#define LOOP 100000000
+
+int var_glb; /* A global variable*/
+
+int main(void)
+{
+    pid_t childPID;
+    
+    int i,j,k;
+
+    childPID = fork();
+
+    if(childPID >= 0) // fork was successful
+    {
+        if(childPID == 0) // child process
+        {
+
+           for(i=0;i<MAXLOOP;i++){
+             for(j=0;j<LOOP;j++){
+               k+=1;
+             }
+             printf("Child Process : %d \n",i);
+           }
+
+        }
+        else //Parent process
+        {
+
+           for(i=0;i<MAXLOOP;i++){
+             for(j=0;j<LOOP;j++){
+               k+=1;
+               
+             }
+             printf("Parent Process : %d\n",i);
+           }
+
+        }
+    }
+    else // fork failed
+    {
+        printf("\n Fork failed, quitting!!!!!!\n");
+        return 1;
+    }
+
+    return 0;
+}
+/* Output:
+bie1@bie1-VirtualBox:~/svn/examples/cAdditional/parallelism$ ./fork1 
+
+Child Process : 0 
+Parent Process : 0
+Parent Process : 1
+Child Process : 1 
+Child Process : 2 
+Child Process : 3 
+Parent Process : 2
+Parent Process : 3
+Child Process : 4 
+Parent Process : 4
+Parent Process : 5
+Parent Process : 6
+Child Process : 5 
+Child Process : 6 
+Child Process : 7 
+Parent Process : 7
+Parent Process : 8
+Child Process : 8 
+Parent Process : 9
+Child Process : 9
+*/
diff --git a/c-6-additional/examples/c-paralelism/makefile b/c-6-additional/examples/c-paralelism/makefile
new file mode 100644 (file)
index 0000000..e485ccb
--- /dev/null
@@ -0,0 +1,16 @@
+all: fork1 fork2 thread1 thread0
+
+clean:
+       rm *.o *~
+
+fork1: fork1.c
+       gcc fork1.c -g -lm -o fork1
+fork2: fork2.c
+       gcc fork2.c -g -lm -o fork2
+
+thread1: thread1.c
+       gcc thread1.c -g -lm -lpthread -o thread1
+
+
+thread0: thread0.c
+       gcc thread0.c -g -lm -lpthread -o thread0
diff --git a/c-6-additional/examples/c-paralelism/thread0.c b/c-6-additional/examples/c-paralelism/thread0.c
new file mode 100644 (file)
index 0000000..07e3dec
--- /dev/null
@@ -0,0 +1,29 @@
+#include <pthread.h>
+#include <stdio.h>
+/* Source 
+http://timmurphy.org/2010/05/04/pthreads-in-c-a-minimal-working-example/ 
+*/
+
+void *inc_x(void *x_void_ptr){
+  int *x_ptr = (int *)x_void_ptr;
+  while(++(*x_ptr) < 100);
+  printf("x increment finished\n");
+  return NULL;
+}
+int main(){
+  int x = 0, y = 0;
+  printf("x: %d, y: %d\n", x, y);
+  pthread_t inc_x_thread;
+  if(pthread_create(&inc_x_thread, NULL, inc_x, &x)) {
+    fprintf(stderr, "Error creating thread\n");
+    return 1;
+  } 
+  while(++y < 100);
+  printf("y increment finished\n");
+  if(pthread_join(inc_x_thread, NULL)) {
+    fprintf(stderr, "Error joining thread\n");
+    return 2;
+  }
+  printf("x: %d, y: %d\n", x, y);
+  return 0;
+}
diff --git a/c-6-additional/examples/c-paralelism/thread1.c b/c-6-additional/examples/c-paralelism/thread1.c
new file mode 100644 (file)
index 0000000..a566006
--- /dev/null
@@ -0,0 +1,47 @@
+/* http://www.thegeekstuff.com/2012/04/create-threads-in-linux/ */
+#include<stdio.h>
+#include<string.h>
+#include<pthread.h>
+#include<stdlib.h>
+#include<unistd.h>
+
+pthread_t tid[2];
+
+void* doSomeThing(void *arg)
+{
+    unsigned long i = 0;
+    pthread_t id = pthread_self();
+
+    if(pthread_equal(id,tid[0]))
+    {
+        printf("\n First thread processing\n");
+    }
+    else
+    {
+        printf("\n Second thread processing\n");
+    }
+
+    for(i=0; i<(0xFFFFFFFF);i++);
+
+    return NULL;
+}
+
+int main(void)
+{
+    int i = 0;
+    int err;
+
+    while(i < 2)
+    {
+        err = pthread_create(&(tid[i]), NULL, &doSomeThing, NULL);
+        if (err != 0)
+            printf("\ncan't create thread :[%s]", strerror(err));
+        else
+            printf("\n Thread created successfully\n");
+
+        i++;
+    }
+
+    sleep(5);
+    return 0;
+}
diff --git a/c-6-additional/examples/c-variousexamples/cars.h b/c-6-additional/examples/c-variousexamples/cars.h
new file mode 100644 (file)
index 0000000..c533d5c
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef STRUCT_CAR
+#define STRUCT_CAR
+
+typedef struct{
+  char id_number[30];
+  char brand[80];
+  char type[80];
+  double price;
+} car;
+#endif
diff --git a/c-6-additional/examples/c-variousexamples/cars.txt b/c-6-additional/examples/c-variousexamples/cars.txt
new file mode 100644 (file)
index 0000000..8cda16c
--- /dev/null
@@ -0,0 +1,5 @@
+C4 Citroen BE234 1000.000000
+Megan Renault SO3454 5000.000000
+CLK Mercedes ZH7899 100000.000000
+A80 Audi BE3939 1000.000000
+asldfkj asdfkjk RRR 1000.000000
diff --git a/c-6-additional/examples/c-variousexamples/commandline b/c-6-additional/examples/c-variousexamples/commandline
new file mode 100644 (file)
index 0000000..12e4613
Binary files /dev/null and b/c-6-additional/examples/c-variousexamples/commandline differ
diff --git a/c-6-additional/examples/c-variousexamples/commandline.c b/c-6-additional/examples/c-variousexamples/commandline.c
new file mode 100644 (file)
index 0000000..a7fb2dd
--- /dev/null
@@ -0,0 +1,22 @@
+#include <stdio.h>
+
+int main(int argc,char* argv[]){
+  int i;
+  printf("Print command line parameters\n");
+  for(i=0; i<argc; i++){
+    printf("argv[%d] %s\n",i,argv[i]);
+  }
+
+}
+
+/* Output:
+bie1@machine $ ./commandline 1 2 3 4 Hello World
+Print command line parameters
+argv[0] ./commandline
+argv[1] 1
+argv[2] 2
+argv[3] 3
+argv[4] 4
+argv[5] Hello
+argv[6] World
+ */
diff --git a/c-6-additional/examples/c-variousexamples/commandlinemultiply b/c-6-additional/examples/c-variousexamples/commandlinemultiply
new file mode 100644 (file)
index 0000000..669100f
Binary files /dev/null and b/c-6-additional/examples/c-variousexamples/commandlinemultiply differ
diff --git a/c-6-additional/examples/c-variousexamples/commandlinemultiply.c b/c-6-additional/examples/c-variousexamples/commandlinemultiply.c
new file mode 100644 (file)
index 0000000..f35c2ef
--- /dev/null
@@ -0,0 +1,22 @@
+#include <stdio.h>
+
+int main(int argc,char* argv[]){
+
+  if(argc!=3)
+    goto error;
+  int val1,val2; 
+
+  int res1=sscanf(argv[1]," %d",&val1);
+  int res2=sscanf(argv[2]," %d",&val2);
+
+  if(res1!=1 || res2!=1)
+    goto error;
+
+  printf("%d x %d = %d\n",val1,val2,val1*val2);
+
+  return 0;
+ error:
+  printf("Usage:\n commandlinemultiply <num1> <num2>\n");
+  return 1;
+
+}
diff --git a/c-6-additional/examples/c-variousexamples/exercise2writecars b/c-6-additional/examples/c-variousexamples/exercise2writecars
new file mode 100644 (file)
index 0000000..f131b6f
Binary files /dev/null and b/c-6-additional/examples/c-variousexamples/exercise2writecars differ
diff --git a/c-6-additional/examples/c-variousexamples/exercise2writecars.c b/c-6-additional/examples/c-variousexamples/exercise2writecars.c
new file mode 100644 (file)
index 0000000..23fee2a
--- /dev/null
@@ -0,0 +1,75 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "cars.h"
+
+#define DEBUG 0
+
+#define MAXCARS 255
+
+int main(){
+
+  car** list_of_cars;
+
+  list_of_cars = (car**) malloc(MAXCARS * sizeof(car*));
+  int nb_cars=0;
+
+  printf("*********************************\n");
+  printf("******* CAR LIST*****************\n");
+  printf("**********************************\n");
+  printf("**Type Control D to end the list**\n");
+  printf("**********************************\n");
+  
+  while(1){
+    car* p_car = (car*) malloc(sizeof(car));
+    printf("*** Car number : %d ***\n",nb_cars+1);
+    printf("Enter the identification number: ");
+    scanf(" %s",p_car->id_number);
+    if(strlen(p_car->id_number) ==0){
+      goto endloop;
+    }
+    printf("Enter the brand:");
+    scanf(" %s",p_car->brand);
+    if(strlen(p_car->brand) ==0){
+      goto endloop;
+    }
+    printf("Enter the type:");
+    scanf(" %s",p_car->type);
+    if(strlen(p_car->type) == 0){
+      goto endloop;
+    }
+    printf("Enter the price:");
+    int matches;
+    matches=scanf(" %lf",&(p_car->price));
+    if(matches==0){
+      goto endloop;
+    }
+
+    #if DEBUG 
+    printf("new car\n");
+    printf("Address in memory %lX",p_car);
+    printf("Size in memory %lu\n",sizeof(*p_car));
+    #endif
+
+    list_of_cars[nb_cars++]=p_car;
+    
+    continue;
+  endloop:
+    puts("*********************");
+    free(p_car);
+    break;
+
+  }
+  int i;
+  printf("*****\nList of cars\n");
+  FILE *fp;
+  fp = fopen("cars.txt","a");
+  for(i=0;i<nb_cars;++i){
+    car* p_car2 = list_of_cars[i];
+    
+    fprintf(fp,"%s %s %s %lf\n",p_car2->type,p_car2->brand,p_car2->id_number, p_car2->price);
+  }
+
+
+}
diff --git a/c-6-additional/examples/c-variousexamples/macro.c b/c-6-additional/examples/c-variousexamples/macro.c
new file mode 100644 (file)
index 0000000..ab341fb
--- /dev/null
@@ -0,0 +1,22 @@
+#include <stdio.h>
+
+#define area length * width
+
+int main(int argc, char* argv[]){
+  
+  int length, width;
+
+  printf("length : ");
+  scanf(" %d",&length);
+  printf("width : ");
+  scanf(" %d",&width);
+  // The constant area is replaced by value length * width
+  printf("Area = %d \n",area);
+
+}
+/* Output:
+bie1@VirtualBox:~/variousExamples$ ./macro 
+length : 10
+width : 10
+Area = 100 
+*/
diff --git a/c-6-additional/examples/c-variousexamples/macro2.c b/c-6-additional/examples/c-variousexamples/macro2.c
new file mode 100644 (file)
index 0000000..cade87c
--- /dev/null
@@ -0,0 +1,26 @@
+#include <stdio.h>
+
+#define area(x,y) x * y
+
+#define print(n) int i; for(i=0;i<n;i++){      \
+  printf("%d x %d = %d\n",i,i,i*i);\
+    }
+
+int main(int argc, char* argv[]){
+  
+  int length, width;
+
+  printf("length : ");
+  scanf(" %d",&length);
+  printf("width : ");
+  scanf(" %d",&width);
+  // The constant area is replaced by value length * width
+  printf("Area = %d \n",area(length,width));
+  print(width);
+ }
+/* Output:
+bie1@VirtualBox:~/variousExamples$ ./macro2 
+length : 10
+width : 10
+Area = 100 
+*/
diff --git a/c-6-additional/examples/c-variousexamples/makefile b/c-6-additional/examples/c-variousexamples/makefile
new file mode 100644 (file)
index 0000000..3e7fce2
--- /dev/null
@@ -0,0 +1,19 @@
+all: commandline commandlinemultiply macro macro2 exercise2writecars
+
+clean:
+       rm -f *.o *~ macro macro2 exercise2writecars
+
+commandline: commandline.c
+       gcc commandline.c -g -lm -o commandline
+
+commandlinemultiply: commandlinemultiply.c
+       gcc commandlinemultiply.c -g -lm -o commandlinemultiply
+
+
+macro: macro.c
+       gcc macro.c -g -lm -o macro
+macro2: macro2.c
+       gcc macro2.c -g -lm -o macro2
+
+exercise2writecars: exercise2writecars.c cars.h
+       gcc exercise2writecars.c -g -lm -o exercise2writecars
diff --git a/c-6-additional/exercises/exercises-additional.pdf b/c-6-additional/exercises/exercises-additional.pdf
new file mode 100644 (file)
index 0000000..1176020
Binary files /dev/null and b/c-6-additional/exercises/exercises-additional.pdf differ
diff --git a/c-6-additional/slides/slides-cAdditional-2x2.pdf b/c-6-additional/slides/slides-cAdditional-2x2.pdf
new file mode 100644 (file)
index 0000000..05324fe
Binary files /dev/null and b/c-6-additional/slides/slides-cAdditional-2x2.pdf differ
diff --git a/c-6-additional/slides/slides-cAdditional.pdf b/c-6-additional/slides/slides-cAdditional.pdf
new file mode 100644 (file)
index 0000000..f161c26
Binary files /dev/null and b/c-6-additional/slides/slides-cAdditional.pdf differ
diff --git a/c-7-compilation/.gitignore b/c-7-compilation/.gitignore
new file mode 100644 (file)
index 0000000..63dc4ab
--- /dev/null
@@ -0,0 +1,7 @@
+*.aux
+*.log
+*.nav
+*.out
+*.snm
+*.toc
+
diff --git a/c-7-compilation/examples/autotools/Makefile.am b/c-7-compilation/examples/autotools/Makefile.am
new file mode 100644 (file)
index 0000000..ba5f504
--- /dev/null
@@ -0,0 +1,10 @@
+bin_PROGRAMS = \
+  exercise1logarithm exercise2toupercase exercise3threads
+exercise1logarithm_SOURCES = \
+  exercise1logarithm.c myLib.c
+exercise2toupercase_SOURCES = \
+  exercise2toupercase.c
+exercise3threads_SOURCES = \
+  exercise3threads.c myLib.c
+exercise3threads_LDADD = \
+  -lpthread
diff --git a/c-7-compilation/examples/autotools/configure.ac b/c-7-compilation/examples/autotools/configure.ac
new file mode 100644 (file)
index 0000000..98a4408
--- /dev/null
@@ -0,0 +1,24 @@
+#                                               -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ([2.69])
+AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])
+AC_CONFIG_SRCDIR([myLib.c])
+AC_CONFIG_HEADERS([config.h])
+
+# Checks for programs.
+AC_PROG_CC
+AM_INIT_AUTOMAKE
+
+# Checks for libraries.
+AC_CHECK_LIB([adns], [adns_init], [pthread])
+
+# Checks for header files.
+AC_CHECK_HEADERS([arpa/inet.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+
+# Checks for library functions.
+
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
diff --git a/c-7-compilation/examples/autotools/exercise1logarithm.c b/c-7-compilation/examples/autotools/exercise1logarithm.c
new file mode 100644 (file)
index 0000000..a159253
--- /dev/null
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include "myLib.h"
+
+int main(int argc, char* argv[]){
+  if(argc !=2) goto error;
+
+  long int arg1;
+  int scan_res = sscanf(argv[1]," %ld", &arg1); 
+  if(scan_res != 1) goto error;
+  
+  long result = logarithm(arg1);
+
+  printf("Decimal log(%ld)=%ld\n",arg1,result);
+  
+  return 0;
+
+
+ error:
+  printf("Usage \n exercise1logarithm <number>\n");
+
+}
diff --git a/c-7-compilation/examples/autotools/exercise2toupercase.c b/c-7-compilation/examples/autotools/exercise2toupercase.c
new file mode 100644 (file)
index 0000000..38f2a46
--- /dev/null
@@ -0,0 +1,27 @@
+#include <stdio.h>
+
+int main(int argc, char* argv[]){
+  if(argc !=2) goto error;
+
+  char* file_name=argv[1];
+
+  FILE *file_pointer;
+  file_pointer = fopen(file_name,"r");
+
+  if(file_pointer == NULL) goto error;
+  char c;
+  while((c=getc(file_pointer)) != EOF){
+    if(c>='a' && c<='z'){
+      c += 'A'-'a';
+    }
+    putchar(c);
+  }
+  
+  
+  return 0;
+
+
+ error:
+  printf("Usage \n exercise2toupercase <file name>\n");
+
+}
diff --git a/c-7-compilation/examples/autotools/exercise3threads.c b/c-7-compilation/examples/autotools/exercise3threads.c
new file mode 100644 (file)
index 0000000..aaa3adc
--- /dev/null
@@ -0,0 +1,52 @@
+#include <stdio.h>
+#include <pthread.h>
+#include "myLib.h"
+
+#define MAX_LOOP 1000000000
+pthread_t tid[2];
+
+double expo;
+long facto;
+
+void* starterExponential(void* args){
+  long i = (long)args;
+  
+   expo = exponential(i);
+   long j;
+   for(j=0;j<MAX_LOOP;j++){
+     if(j%(MAX_LOOP/10)==0){
+       printf("Exponential (loop %ld)\n",j);
+       }
+   }
+}
+
+void* starterFactorial(void* args){
+  long i= (long)args;
+  facto =  factorial(i);
+   long j;
+   for(j=0;j<MAX_LOOP;j++){
+     if(j%(MAX_LOOP/10)==0){
+       printf("factorial (loop %ld)\n",j);
+       }
+   }
+}
+
+int main(int argc, char* argv[]){
+  
+  long number;
+
+  printf("Enter a number\n");
+  int res = scanf(" %ld",&number);
+  if(res !=1) goto error;
+  pthread_create(&tid[0], NULL, starterExponential,(void*)number);
+
+  pthread_create(&tid[1], NULL, starterFactorial, (void*)number);
+  pthread_join(tid[0],NULL);
+  pthread_join(tid[1],NULL);
+  printf("exponential(%ld)=%lf and %ld! =%ld  \n",number,expo,number,facto);
+
+  return 0;
+ error:
+  printf("The number is not valid\n");
+  return 1;
+}
diff --git a/c-7-compilation/examples/autotools/myLib.c b/c-7-compilation/examples/autotools/myLib.c
new file mode 100644 (file)
index 0000000..8f4685c
--- /dev/null
@@ -0,0 +1,102 @@
+#include <stdio.h>
+
+#include "myLib.h"
+
+/* Compute the exponential of a value 
+Input : val a long integer
+Return : exponential(x) (i.e. e^x)
+*/
+double exponential(long val){
+  double res= 1;
+  long i;
+  for(i=1; i <= val;i++){
+    res *= EULER;
+  }
+  return res;
+}
+
+/* Compute the factorial of a value 
+Input : val a long integer
+Return : factorial(x) (i.e. x!)
+*/
+long factorial(long val){
+  long res= 1;
+  long i;
+  for(i=1; i <= val;i++){
+    res *= i;
+  }
+  return res;
+}
+
+
+/* Compute the protected integer decimal logarithm of val
+Input: val a long integer
+Return : an integer for decimal logarithm of val 
+or 0 if val is 0 
+*/
+long logarithm(long val){
+  long res=0;
+  if(val<10){
+    return 0;
+  }
+  while(val>=10){
+    val /=10;
+    res++;
+  }
+  return res;
+}
+
+
+/* Function square that returns x^2 
+Input: a long integer x
+Ouput: a long integer x*x
+*/
+long square(long x){
+  return x*x;
+}
+
+
+/* Function gcd computes the greater common divisor of two numbers
+Input: two long integers numbers x and y
+Output: the greatest common divisor of x and y
+*/
+long gcd(long number1, long number2){
+
+  long divisor,gcd;
+
+  if(number1 == 0 || number2 == 0){
+    return 0;
+  }
+
+  if(number1 < 0 || number2<0){
+      printf("GCD formula only for positive numbers\n");
+      return;
+    }
+
+    divisor = 2;
+    gcd = 1;
+    //printf("1");
+    while(number1!=1 || number2!=1){
+      /* Case where divisor devises number */
+      if(((number1 % divisor) == 0) && ((number2 % divisor)==0)){
+       number1 /= divisor;
+       number2 /= divisor;
+       gcd *= divisor;
+       
+       //printf(" * %ld",divisor);
+      }
+      else{
+       if((number1 % divisor)==0){
+         number1 /= divisor;
+       }
+       else if((number2 % divisor) == 0){
+         number2 /= divisor;
+       }
+       else
+         divisor++;
+      }
+      
+    }
+    return gcd;
+
+}
diff --git a/c-7-compilation/examples/autotools/myLib.h b/c-7-compilation/examples/autotools/myLib.h
new file mode 100644 (file)
index 0000000..a2cfa13
--- /dev/null
@@ -0,0 +1,8 @@
+#define EULER 2.71828
+double exponential(long);
+long factorial(long);
+long logarithm(long);
+
+long square(long);
+long gcd(long, long);
+
diff --git a/c-7-compilation/exercises/exercises-compilation.pdf b/c-7-compilation/exercises/exercises-compilation.pdf
new file mode 100644 (file)
index 0000000..0a810d6
Binary files /dev/null and b/c-7-compilation/exercises/exercises-compilation.pdf differ
diff --git a/c-7-compilation/slides/slides-cCompilation-2x2.pdf b/c-7-compilation/slides/slides-cCompilation-2x2.pdf
new file mode 100644 (file)
index 0000000..9e2b77a
Binary files /dev/null and b/c-7-compilation/slides/slides-cCompilation-2x2.pdf differ
diff --git a/c-7-compilation/slides/slides-cCompilation.pdf b/c-7-compilation/slides/slides-cCompilation.pdf
new file mode 100644 (file)
index 0000000..3b95727
Binary files /dev/null and b/c-7-compilation/slides/slides-cCompilation.pdf differ
diff --git a/c-project/.gitignore b/c-project/.gitignore
new file mode 100644 (file)
index 0000000..44eebb9
--- /dev/null
@@ -0,0 +1,6 @@
+ps
+raw.out
+raw2.out
+delta.txt
+have.out
+want.out
diff --git a/c-project/INSTRUCTIONS.txt b/c-project/INSTRUCTIONS.txt
new file mode 100644 (file)
index 0000000..34b5d20
--- /dev/null
@@ -0,0 +1,16 @@
+You are to implement a C tool similar to "ps x -o pid,comm,rss"
+that will show for each process that shares your user ID the amount of
+memory it is using. Scan the /proc directory to find all active
+processes by their process ID (PID). You can find all of the
+information you need for each process under /proc/$PID/status, in
+particular the lines "Name", "Uid" and "VmRSS".
+
+Your output should list on seperate lines the PID, binary name of the
+process and the resident set size (RSS), separated by spaces.
+Your process must return 0 upon successful completion.
+
+Your C program must be called "ps.c".  You will be graded for style
+(compiler warnings (-Wall), memory leaks, etc.) as well as for correct
+output.
+
+Test your program using the "test.sh".
diff --git a/c-project/test.sh b/c-project/test.sh
new file mode 100755 (executable)
index 0000000..709be02
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+gcc ps.c -o ps || { echo "C code failed to compile"; exit 1; }
+timeout -s SIGKILL 1s ./ps > raw.out || { echo "Your 'ps' command failed to run" ; exit 1 ; }
+cat raw.out | grep -v ps | grep -v timeout | sort -n > have.out
+/bin/ps x -o pid,comm,rss > raw2.out || { echo "System 'ps' failed to run"; exit 2; }
+cat raw2.out | grep -v "COMMAND" | grep -v ps | sort -n > want.out
+diff -w want.out have.out > delta.txt || { echo "Fail, delta is:" ; cat delta.txt ; exit 1; }
+echo "Test passed"
diff --git a/makefile b/makefile
new file mode 100644 (file)
index 0000000..58594eb
--- /dev/null
+++ b/makefile
@@ -0,0 +1,691 @@
+# MAKEFILE for the BTI7061 course of the BFH
+all: asm1 asm2 asm3 asm4 asm5 asm6 asm7 asm8 c1 c2 c3 c4 c5 c6 c7 c8 c9
+
+clean: cleanAsm1 cleanAsm2 cleanAsm3 cleanAsm4 cleanAsm5 cleanAsm6 cleanAsm7 cleanAsm8\
+cleanC1 cleanC2 cleanC3 cleanC4 cleanC5 cleanC6 cleanC7 cleanC8 cleanC9
+
+reset: resetAsm1  resetAsm2 resetAsm3 resetAsm4 resetAsm5 resetAsm6 resetAsm7 resetAsm8\
+resetC1 resetC2 resetC3 resetC4 resetC5 resetC6 resetC7 resetC8 resetC9
+
+DESTINATION=../BTI7061classI1P2017
+
+deploy: copy_slides copy_examples copy_exercise_dirs
+
+deploy_W2: deploy copy_solution_asm1
+
+deploy_W3: deploy_W2 copy_solution_asm2
+
+deploy_W4: deploy_W3 copy_solution_asm3
+
+deploy_W5: deploy_W4 copy_solution_asm4
+
+deploy_W6: deploy_W5 copy_solution_asm5
+
+deploy_W7: deploy_W6 copy_solution_asm6
+
+deploy_W8: deploy_W7 copy_solution_asm7
+
+deploy_W9: deploy_W8 copy_solution_asm8
+
+deploy_W10: deploy_W9 copy_solution_c1
+
+deploy_W11: deploy_W10 copy_solution_c2
+
+deploy_W12: deploy_W11 copy_solution_c3
+
+deploy_W13: deploy_W12 copy_solution_c4
+
+deploy_W14: deploy_W13 copy_solution_c5
+
+deploy_W15: deploy_W14 copy_solution_c6
+
+deploy_W16: deploy_W15 copy_solution_c7
+
+deploy_Final: deploy_W16 copy_solution_c8
+
+
+
+
+
+
+
+
+
+
+
+SUFFIXES=*.toc *.nav *.aux *.log *.out *.snm
+
+# CHAPTER 1 : BASES
+
+asm1 : asm1slides asm1exercises
+
+asm1slides: asm-1-bases/slides/slides-bases.pdf asm-1-bases/slides-unicode/slides-unicode.pdf
+
+asm1exercises: asm-1-bases/exercises/exercises-bases.pdf asm-1-bases/exercises/exercises-bases.sol.pdf
+
+cleanAsm1:
+       cd asm-1-bases/slides;\
+       rm $(SUFFIXES);\
+       cd ../exercises;\
+       rm $(SUFFIXES)
+
+asm-1-bases/slides/slides-bases.pdf: asm-1-bases/slides/slides-bases.tex
+       ./compile-latex-plus.sh asm-1-bases/slides slides-bases
+asm-1-bases/slides-unicode/slides-unicode.pdf: asm-1-bases/slides-unicode/slides-unicode.tex
+       ./compile-latex-plus.sh asm-1-bases/slides-unicode slides-unicode
+
+asm-1-bases/exercises/exercises-bases.pdf: asm-1-bases/exercises/exercises-bases.tex
+       ./compile-latex.sh asm-1-bases/exercises exercises-bases
+
+asm-1-bases/exercises/exercises-bases.sol.pdf: asm-1-bases/exercises/exercises-bases.sol.tex
+       ./compile-latex.sh asm-1-bases/exercises exercises-bases.sol
+
+resetAsm1:
+       touch asm-1-bases/slides/slides-bases.tex
+       touch asm-1-bases/exercises/exercises-bases.tex
+       touch asm-1-bases/exercises/exercises-bases.sol.tex
+
+# CHAPTER 2 : ARCHITECTURE
+
+asm2 : asm2slides asm2exercises
+
+asm2slides: asm-2-architecture/slides/slides-architecture.pdf
+
+asm2exercises: asm-2-architecture/exercises/exercises-architecture.pdf asm-2-architecture/exercises/exercises-architecture.sol.pdf
+
+cleanAsm2:
+       cd asm-2-bases/slides;\
+       rm $(SUFFIXES);\
+       cd ../exercises;\
+       rm $(SUFFIXES)
+
+asm-2-architecture/slides/slides-architecture.pdf: asm-2-architecture/slides/slides-architecture.tex
+       ./compile-latex-plus.sh asm-2-architecture/slides slides-architecture
+
+asm-2-architecture/exercises/exercises-architecture.pdf: asm-2-architecture/exercises/exercises-architecture.tex
+       ./compile-latex.sh asm-2-architecture/exercises exercises-architecture
+
+asm-2-architecture/exercises/exercises-architecture.sol.pdf: asm-2-architecture/exercises/exercises-architecture.sol.tex
+       ./compile-latex.sh asm-2-architecture/exercises exercises-architecture.sol
+
+resetAsm2:
+       touch asm-2-architecture/slides/slides-architecture.tex
+       touch asm-2-architecture/exercises/exercises-architecture.tex
+       touch asm-2-architecture/exercises/exercises-architecture.sol.tex
+
+
+# CHAPTER 3 : MEMORY
+
+asm3 : asm3slides asm3exercises
+
+asm3slides: asm-3-memory/slides/slides-linux.pdf asm-3-memory/slides/slides-memory.pdf
+
+asm3exercises: asm-3-memory/exercises/exercises-memory.pdf asm-3-memory/exercises/exercises-memory.sol.pdf
+
+cleanAsm3:
+       cd asm-3-memory/slides;\
+       rm $(SUFFIXES);\
+       cd ../exercises;\
+       rm $(SUFFIXES)
+
+asm-3-memory/slides/slides-memory.pdf: asm-3-memory/slides/slides-memory.tex
+       ./compile-latex-plus.sh asm-3-memory/slides slides-memory
+
+asm-3-memory/slides/slides-linux.pdf: asm-3-memory/slides/slides-linux.tex
+       ./compile-latex-plus.sh asm-3-memory/slides slides-linux
+
+asm-3-memory/exercises/exercises-memory.pdf: asm-3-memory/exercises/exercises-memory.tex
+       ./compile-latex.sh asm-3-memory/exercises exercises-memory
+
+asm-3-memory/exercises/exercises-memory.sol.pdf: asm-3-memory/exercises/exercises-memory.sol.tex
+       ./compile-latex.sh asm-3-memory/exercises exercises-memory.sol
+
+resetAsm3:
+       touch asm-3-memory/slides/slides-memory.tex
+       touch asm-3-memory/slides/slides-linux.tex
+       touch asm-3-memory/exercises/exercises-memory.tex
+       touch asm-3-memory/exercises/exercises-memory.sol.tex
+
+
+# CHAPTER 4 : CODIFICATION
+asm4 : asm4slides asm4exercises
+
+asm4slides: asm-4-codification/slides/slides-developmentProcess.pdf
+
+asm4exercises: asm-4-codification/exercises/exercises-codification.pdf asm-4-codification/exercises/exercises-codification.sol.pdf
+
+cleanAsm4:
+       cd asm-4-codification/slides;\
+       rm $(SUFFIXES);\
+       cd ../exercises;\
+       rm $(SUFFIXES)
+
+asm-4-codification/slides/slides-developmentProcess.pdf: asm-4-codification/slides/slides-developmentProcess.tex
+       ./compile-latex-plus.sh asm-4-codification/slides slides-developmentProcess
+
+asm-4-codification/exercises/exercises-codification.pdf: asm-4-codification/exercises/exercises-codification.tex asm-4-codification/exercises/data-codification.tex
+       ./compile-latex.sh asm-4-codification/exercises exercises-codification
+
+asm-4-codification/exercises/exercises-codification.sol.pdf: asm-4-codification/exercises/exercises-codification.sol.tex asm-4-codification/exercises/data-codification.tex
+       ./compile-latex.sh asm-4-codification/exercises exercises-codification.sol
+
+resetAsm4:
+       touch asm-4-codification/slides/slides-developmentProcess.tex
+       touch asm-4-codification/exercises/exercises-codification.tex
+       touch asm-4-codification/exercises/exercises-codification.sol.tex
+
+
+# CHAPTER 5 : PROGRAMMING
+
+asm5 : asm5slides asm5exercises
+
+asm5slides: asm-5-programming/slides/slides-assemblerProgramming.pdf
+
+asm5exercises: asm-5-programming/exercises/exercises-programming.pdf asm-5-programming/exercises/exercise-programming2.pdf
+
+cleanAsm5:
+       cd asm-5-programming/slides;\
+       rm $(SUFFIXES);\
+       cd ../exercises;\
+       rm $(SUFFIXES)
+
+asm-5-programming/slides/slides-assemblerProgramming.pdf: asm-5-programming/slides/slides-assemblerProgramming.tex
+       ./compile-latex-plus.sh asm-5-programming/slides slides-assemblerProgramming
+
+
+asm-5-programming/exercises/exercises-programming.pdf: asm-5-programming/exercises/exercises-programming.tex
+       ./compile-latex.sh asm-5-programming/exercises exercises-programming
+
+asm-5-programming/exercises/exercise-programming2.pdf: asm-5-programming/exercises/exercise-programming2.tex
+       ./compile-latex.sh asm-5-programming/exercises exercise-programming2
+
+
+resetAsm5:
+       touch asm-5-programming/slides/slides-assemblerProgramming.tex
+       touch asm-5-programming/exercises/exercises-programming.tex
+       touch asm-5-programming/exercises/exercises-programming.sol.tex
+
+# CHAPTER 6 : BITS AND BRANCHINGS
+
+asm6 : asm6slides asm6exercises
+
+asm6slides: asm-6-bits-branching/slides/slides-bits-branching.pdf
+
+asm6exercises: asm-6-bits-branching/exercises/exercises-bits-branching.pdf asm-6-bits-branching/exercises/exercises-bits-branching.sol.pdf
+
+cleanAsm6:
+       cd asm-6-bits-branching/slides;\
+       rm $(SUFFIXES);\
+       cd ../exercises;\
+       rm $(SUFFIXES)
+
+asm-6-bits-branching/slides/slides-bits-branching.pdf: asm-6-bits-branching/slides/slides-bits-branching.tex
+       ./compile-latex-plus.sh asm-6-bits-branching/slides slides-bits-branching
+
+asm-6-bits-branching/exercises/exercises-bits-branching.pdf: asm-6-bits-branching/exercises/exercises-bits-branching.tex
+       ./compile-latex.sh asm-6-bits-branching/exercises exercises-bits-branching
+
+asm-6-bits-branching/exercises/exercises-bits-branching.sol.pdf: asm-6-bits-branching/exercises/exercises-bits-branching.sol.tex
+       ./compile-latex.sh asm-6-bits-branching/exercises exercises-bits-branching.sol
+
+
+resetAsm6:
+       touch asm-6-bits-branching/slides/slides-bits-branching.tex
+       touch asm-6-bits-branching/exercises/exercises-bits-branching.tex
+       touch asm-6-bits-branching/exercises/exercises-bits-branching.sol.tex
+
+
+
+# CHAPTER 7 : PROCEDURES
+
+asm7: asm7slides asm7exercises
+
+asm7slides: asm-7-procedures/slides/slides-procedures.pdf
+
+asm7exercises: asm-7-procedures/exercises/exercises-procedures.pdf
+
+cleanAsm7:
+       cd asm-7-procedures/slides;\
+       rm $(SUFFIXES);\
+       cd ../exercises;\
+       rm $(SUFFIXES)
+
+asm-7-procedures/slides/slides-procedures.pdf: asm-7-procedures/slides/slides-procedures.tex
+       ./compile-latex-plus.sh asm-7-procedures/slides slides-procedures
+
+asm-7-procedures/exercises/exercises-procedures.pdf: asm-7-procedures/exercises/exercises-procedures.tex
+       ./compile-latex.sh asm-7-procedures/exercises exercises-procedures
+
+
+
+resetAsm7:
+       touch asm-7-procedures/slides/slides-procedures.tex
+       touch asm-7-procedures/exercises/exercises-procedures.tex
+
+# CHAPTER 8 : STRINGS
+
+asm8: asm8slides asm8exercises
+
+asm8slides: asm-8-strings/slides/slides-strings.pdf
+
+asm8exercises: asm-8-strings/exercises/exercises-strings.pdf asm-8-strings/exercises/exercises-strings.sol.pdf
+
+cleanAsm8:
+       cd asm-8-strings/slides;\
+       rm $(SUFFIXES);\
+       cd ../exercises;\
+       rm $(SUFFIXES)
+
+asm-8-strings/slides/slides-strings.pdf: asm-8-strings/slides/slides-strings.tex
+       ./compile-latex-plus.sh asm-8-strings/slides slides-strings
+
+asm-8-strings/exercises/exercises-strings.pdf: asm-8-strings/exercises/exercises-strings.tex
+       ./compile-latex.sh asm-8-strings/exercises exercises-strings
+
+asm-8-strings/exercises/exercises-strings.sol.pdf: asm-8-strings/exercises/exercises-strings.sol.tex
+       ./compile-latex.sh asm-8-strings/exercises exercises-strings.sol
+
+
+resetAsm8:
+       touch asm-8-strings/slides/slides-strings.tex
+       touch asm-8-strings/exercises/exercises-strings.tex
+       touch asm-8-strings/exercises/exercises-strings.sol.tex
+
+# CHAPTER C-1 : BASICS
+
+c1: c1slides c1exercises
+
+c1slides: c-1-basics/slides/slides-basics.pdf
+
+c1exercises: c-1-basics/exercises/exercises-basics.pdf
+
+cleanC1:
+       cd c-1-basics/slides;\
+       rm *.toc *.nav *.aux *.log *.out *.snm *~;\
+       cd ../exercises;\
+       rm *.toc *.nav *.aux *.log *.out *.snm *~
+
+c-1-basics/slides/slides-basics.pdf: c-1-basics/slides/slides-basics.tex
+       ./compile-latex-plus.sh c-1-basics/slides slides-basics
+
+c-1-basics/exercises/exercises-basics.pdf: c-1-basics/exercises/exercises-basics.tex
+       ./compile-latex.sh c-1-basics/exercises exercises-basics
+
+resetC1:
+       touch c-1-basics/slides/slides-basics.tex
+       touch c-1-basics/exercises/exercises-basics.tex
+
+
+# CHAPTER C-2 : CONTROL STRUCTURES in C
+
+c2: c2slides c2exercises
+
+c2slides: c-2-controlStructures/slides/slides-cControlStructures.pdf
+
+c2exercises: c-2-controlStructures/exercises/exercises-cControlStructures.pdf
+
+cleanC2:
+       cd c-2-controlStructures/slides;\
+       rm *.toc *.nav *.aux *.log *.out *.snm *~;\
+       cd ../exercises;\
+       rm *.toc *.nav *.aux *.log *.out *.snm *~
+
+c-2-controlStructures/slides/slides-cControlStructures.pdf: c-2-controlStructures/slides/slides-cControlStructures.tex
+       ./compile-latex-plus.sh c-2-controlStructures/slides slides-cControlStructures
+
+c-2-controlStructures/exercises/exercises-cControlStructures.pdf: c-2-controlStructures/exercises/exercises-cControlStructures.tex
+       ./compile-latex.sh c-2-controlStructures/exercises exercises-cControlStructures
+
+resetC2:
+       touch c-2-controlStructures/slides/slides-cControlStructures.tex
+       touch c-2-controlStructures/exercises/exercises-cControlStructures.tex
+
+
+# CHAPTER C-3 : LIBRARIES in C
+
+c3: c3slides c3exercises
+
+c3slides: c-3-libraries/slides/slides-libraries.pdf
+
+c3exercises: c-3-libraries/exercises/exercises-libraries.pdf
+
+cleanC3:
+       cd c-3-libraries/slides;\
+       rm *.toc *.nav *.aux *.log *.out *.snm *~;\
+       cd ../exercises;\
+       rm *.toc *.nav *.aux *.log *.out *.snm *~
+
+c-3-libraries/slides/slides-libraries.pdf: c-3-libraries/slides/slides-libraries.tex
+       ./compile-latex-plus.sh c-3-libraries/slides slides-libraries
+
+c-3-libraries/exercises/exercises-libraries.pdf: c-3-libraries/exercises/exercises-libraries.tex
+       ./compile-latex.sh c-3-libraries/exercises exercises-libraries
+
+resetC3:
+       touch c-3-libraries/slides/slides-libraries.tex
+       touch c-3-libraries/exercises/exercises-libraries.tex
+
+# CHAPTER C-4 : POINTERS
+
+c4: c4slides c4exercises
+
+c4slides: c-4-pointers/slides/slides-pointers.pdf
+
+c4exercises: c-4-pointers/exercises/exercises-pointers.pdf
+
+cleanC4:
+       cd c-4-pointers/slides;\
+       rm *.toc *.nav *.aux *.log *.out *.snm *~;\
+       cd ../exercises;\
+       rm *.toc *.nav *.aux *.log *.out *.snm *~
+
+c-4-pointers/slides/slides-pointers.pdf: c-4-pointers/slides/slides-pointers.tex
+       ./compile-latex-plus.sh c-4-pointers/slides slides-pointers
+
+c-4-pointers/exercises/exercises-pointers.pdf: c-4-pointers/exercises/exercises-pointers.tex
+       ./compile-latex.sh c-4-pointers/exercises exercises-pointers
+
+resetC4:
+       touch c-4-pointers/slides/slides-pointers.tex
+       touch c-4-pointers/exercises/exercises-pointers.tex
+
+
+# CHAPTER C-5 : POINTERS
+
+c5: c5slides c5exercises
+
+c5slides: c-5-structuresFiles/slides/slides-structuresFiles.pdf
+
+c5exercises: c-5-structuresFiles/exercises/exercises-structuresFiles.pdf
+
+cleanC5:
+       cd c-5-structuresFiles/slides;\
+       rm *.toc *.nav *.aux *.log *.out *.snm *~;\
+       cd ../exercises;\
+       rm *.toc *.nav *.aux *.log *.out *.snm *~
+
+c-5-structuresFiles/slides/slides-structuresFiles.pdf: c-5-structuresFiles/slides/slides-structuresFiles.tex
+       ./compile-latex-plus.sh c-5-structuresFiles/slides slides-structuresFiles
+
+c-5-structuresFiles/exercises/exercises-structuresFiles.pdf: c-5-structuresFiles/exercises/exercises-structuresFiles.tex
+       ./compile-latex.sh c-5-structuresFiles/exercises exercises-structuresFiles
+
+resetC5:
+       touch c-5-structuresFiles/slides/slides-structuresFiles.tex
+       touch c-5-structuresFiles/exercises/exercises-structuresFiles.tex
+
+# CHAPTER C-6 : ADDITIONAL
+
+c6: c6slides c6exercises
+
+c6slides: c-6-additional/slides/slides-cAdditional.pdf
+
+c6exercises: c-6-additional/exercises/exercises-additional.pdf
+
+cleanC6:
+       cd c-6-additional/slides;\
+       rm *.toc *.nav *.aux *.log *.out *.snm *~;\
+       cd ../exercises;\
+       rm *.toc *.nav *.aux *.log *.out *.snm *~
+
+c-6-additional/slides/slides-cAdditional.pdf: c-6-additional/slides/slides-cAdditional.tex
+       ./compile-latex-plus.sh c-6-additional/slides slides-cAdditional
+
+c-6-additional/exercises/exercises-additional.pdf: c-6-additional/exercises/exercises-additional.tex
+       ./compile-latex.sh c-6-additional/exercises exercises-additional
+
+resetC6:
+       touch c-6-additional/slides/slides-cAdditional.tex
+       touch c-6-additional/exercises/exercises-additional.tex
+
+
+# CHAPTER C-7 : COMPILATION
+
+c7: c7slides c7exercises
+
+c7slides: c-7-compilation/slides/slides-cCompilation.pdf
+
+c7exercises: c-7-compilation/exercises/exercises-compilation.pdf
+
+cleanC7:
+       cd c-7-compilation/slides;\
+       rm *.toc *.nav *.aux *.log *.out *.snm *~;\
+       cd ../exercises;\
+       rm *.toc *.nav *.aux *.log *.out *.snm *~
+
+c-7-compilation/slides/slides-cCompilation.pdf: c-7-compilation/slides/slides-cCompilation.tex
+       ./compile-latex-plus.sh c-7-compilation/slides slides-cCompilation
+
+c-7-compilation/exercises/exercises-compilation.pdf: c-7-compilation/exercises/exercises-compilation.tex
+       ./compile-latex.sh c-7-compilation/exercises exercises-compilation
+
+resetC7:
+       touch c-7-compilation/slides/slides-cCompilation.tex
+       touch c-7-compilation/exercises/exercises-compilation.tex
+
+
+# CHAPTER C-8 : API
+
+c8: c8slides
+
+c8slides: c-8-api/slides/slides-cAPI.pdf
+
+cleanC8:
+       cd c-8-compilation/slides;\
+       rm *.toc *.nav *.aux *.log *.out *.snm *~;\
+
+c-8-api/slides/slides-cAPI.pdf: c-8-api/slides/slides-cAPI.tex
+       ./compile-latex-plus.sh c-8-api/slides slides-cAPI
+
+resetC8:
+       touch c-8-compilation/slides/slides-cAPI.tex
+
+
+# CHAPTER C-9 : Tools
+
+c9: c9slides
+
+c9slides: c-9-tools/slides/slides-cTools.pdf
+
+cleanC9:
+       cd c-9-compilation/slides;\
+       rm *.toc *.nav *.aux *.log *.out *.snm *~;\
+
+c-9-tools/slides/slides-cTools.pdf: c-9-tools/slides/slides-cTools.tex
+       ./compile-latex-plus.sh c-9-tools/slides slides-cTools
+
+resetC9:
+       touch c-9-compilation/slides/slides-cTools.tex
+
+# Transfert PDF's
+# I was just trying, it still does not work properly
+# DESTDIR := ../BTI7061intern/
+# FILES := asm-1-bases/slides/slides-bases.pdf
+# DST_FILES := $(addprefix $(DESTDIR)/,$(FILES))
+
+# SLIDES=$(wildcard */slides/slides*.pdf)
+# DEST:=$(addprefix '../BTI7061intern/', $(SLIDES))
+# transfert_master : $(DST_FILES)
+
+# deploy_master: $(DEST)
+
+# $(DEST):     $(SLIDES)
+#      @echo copying $< to $@
+
+# $(DST_FILES) : ${DESTDIR}/% : %
+#    @echo "$< ==> $@"
+#    @[[ -e $< ]] || (echo "some error for $<" && false)
+#    @mkdir -p $(dir $@)
+#    @cp  $< $@
+
+
+
+ASM_DIRS = asm-1-bases asm-2-architecture asm-3-memory asm-4-codification\
+       asm-5-programming asm-6-bits-branching asm-7-procedures asm-8-strings
+C_DIRS = c-1-basics c-2-controlStructures c-3-libraries c-4-pointers\
+       c-5-structuresFiles c-6-additional c-7-compilation
+
+DIRS = $(ASM_DIRS) $(C_DIRS)
+
+# Names without suffixes of LaTeX files (and also pdf)
+ASM_BASES = asm-1-bases/slides/slides-bases\
+       asm-2-architecture/slides/slides-architecture\
+       asm-3-memory/slides/slides-memory\
+       asm-3-memory/slides/slides-linux\
+       asm-4-codification/slides/slides-developmentProcess\
+       asm-5-programming/slides/slides-assemblerProgramming\
+       asm-6-bits-branching/slides/slides-bits-branching\
+       asm-7-procedures/slides/slides-procedures\
+       asm-8-strings/slides/slides-strings
+
+C_BASES = c-1-basics/slides/slides-basics\
+       c-2-controlStructures/slides/slides-cControlStructures\
+       c-3-libraries/slides/slides-libraries\
+       c-4-pointers/slides/slides-pointers\
+       c-5-structuresFiles/slides/slides-structuresFiles\
+       c-6-additional/slides/slides-cAdditional\
+       c-7-compilation/slides/slides-cCompilation\
+       c-8-compilation/slides/slides-cAPI\
+        c-9-compilation/slides/slides-cTools
+
+
+ASM_EXERCISES = asm-1-bases/exercises/exercises-bases.pdf\
+       asm-2-architecture/exercises/exercises-architecture.pdf \
+       asm-3-memory/exercises/exercises-memory.pdf\
+       asm-4-codification/exercises/exercises-codification.pdf\
+       asm-5-programming/exercises/exercises-programming.pdf \
+       asm-5-programming/exercises/exercise-programming2.pdf \
+       asm-6-bits-branching/exercises/exercises-bits-branching.pdf\
+       asm-7-procedures/exercises/exercises-procedures.pdf\
+       asm-8-strings/exercises/exercises-strings.pdf
+
+C_EXERCISES = c-1-basics/exercises/exercises-basics.pdf\
+       c-2-controlStructures/exercises/exercises-cControlStructures.pdf\
+       c-3-libraries/exercises/exercises-libraries.pdf\
+       c-4-pointers/exercises/exercises-pointers.pdf\
+       c-5-structuresFiles/exercises/exercises-structuresFiles.pdf\
+       c-6-additional/exercises/exercises-additional.pdf\
+       c-7-compilation/exercises/exercises-compilation.pdf
+
+# Directories contining Data for the exercises.
+ASM_EXO_DIRS = asm-2-architecture/exercises/images/\
+       asm-3-memory/exercises/resources/\
+       asm-5-memory/exercises/helloWorld/\
+       asm-5-memory/exercises/eatsyscall/\
+       asm-6-bits-branching/exercises/hexdump1/
+
+
+ASM_EXAMPLES = asm-4-codification/examples/\
+       asm-5-programming/examples/\
+       asm-6-bits-branching/examples/\
+       asm-7-procedures/examples/\
+       asm-8-strings/examples/
+
+ASM_SLIDES :=$(addsuffix '.pdf', $(ASM_BASES))
+ASM_SLIDES_2x2 := $(addsuffix '-2x2.pdf', $(ASM_BASES))
+C_SLIDES :=$(addsuffix '.pdf', $(C_BASES))
+C_SLIDES_2x2 := $(addsuffix '-2x2.pdf', $(C_BASES))
+C_EXAMPLES := $(addsuffix '/examples/',  $(C_DIRS))
+
+
+ASM_DOCS = $(ASM_SLIDES) $(ASM_SLIDES_2x2) $(C_SLIDES) $(C_SLIDES_2x2)\
+       $(ASM_EXERCISES) $(C_EXERCISES)
+
+EXAMPLES = $(ASM_EXAMPLES) $(C_EXAMPLES)
+
+
+# Should be used only to initialize the directory structure if the repository is empty
+init_dirs:
+       for directory in $(DIRS); do\
+               echo mkdir $(DESTINATION)/$$directory;\
+               mkdir $(DESTINATION)/$$directory;\
+               mkdir $(DESTINATION)/$$directory/slides;\
+               mkdir $(DESTINATION)/$$directory/exercises;\
+               mkdir $(DESTINATION)/$$directory/examples;\
+       done
+
+copy_slides:
+       for file in $(ASM_DOCS); do\
+               echo cp $$file $(DESTINATION)/$$file;\
+               cp $$file $(DESTINATION)/$$file;\
+       done
+
+copy_examples:
+       for directory in $(EXAMPLES); do\
+               echo cp -r $$directory $(DESTINATION)/$$directory;\
+               cp -r $$directory $(DESTINATION)/$$directory;\
+       done
+
+copy_exercise_dirs:
+       for directory in $(ASM_EXO_DIRS); do\
+               echo cp -r $$directory $(DESTINATION)/$$directory;\
+               cp -r $$directory $(DESTINATION)/$$directory;\
+       done
+
+
+SOLUTION_ASM1=asm-1-bases/exercises/exercises-bases.sol.pdf
+copy_solution_asm1:
+       echo "copy solution ASM 1";
+       for directory in $(SOLUTION_ASM1); do\
+               echo cp -r $$directory $(DESTINATION)/$$directory;\
+               cp -r $$directory $(DESTINATION)/$$directory;\
+       done
+
+SOLUTION_ASM2=asm-2-architecture/exercises/exercises-architecture.sol.pdf
+copy_solution_asm2:
+       echo "copy solution ASM 2";
+       for directory in $(SOLUTION_ASM2); do\
+               echo cp -r $$directory $(DESTINATION)/$$directory;\
+               cp -r $$directory $(DESTINATION)/$$directory;\
+       done
+
+SOLUTION_ASM3=asm-3-memory/exercises/exercises-memory.sol.pdf
+copy_solution_asm3:
+       echo "copy solution ASM 3";
+       for directory in $(SOLUTION_ASM3); do\
+               echo cp -r $$directory $(DESTINATION)/$$directory;\
+               cp -r $$directory $(DESTINATION)/$$directory;\
+       done
+
+SOLUTION_ASM4=asm-4-codification/exercises/exercises-codification.sol.pdf
+copy_solution_asm4:
+       echo "copy solution ASM 4";
+       for directory in $(SOLUTION_ASM4); do\
+               echo cp -r $$directory $(DESTINATION)/$$directory;\
+               cp -r $$directory $(DESTINATION)/$$directory;\
+       done
+
+
+SOLUTION_ASM5=asm-5-programming/exercises/exercise1/ asm-5-programming/exercises/exercise2/
+copy_solution_asm5:
+       echo "copy solution ASM 5";
+       for directory in $(SOLUTION_ASM5); do\
+               echo cp -r $$directory $(DESTINATION)/$$directory;\
+               cp -r $$directory $(DESTINATION)/$$directory;\
+       done
+
+SOLUTION_ASM6=asm-6-bits-branching/exercises/logarithm/
+copy_solution_asm6:
+       echo "copy solution ASM 6";
+       for directory in $(SOLUTION_ASM6); do\
+               echo cp -r $$directory $(DESTINATION)/$$directory;\
+               cp -r $$directory $(DESTINATION)/$$directory;\
+       done
+
+
+SOLUTION_ASM7=asm-7-procedures/exercises/exercise-procedures/
+copy_solution_asm7:
+       echo "copy solution ASM 7";
+       for directory in $(SOLUTION_ASM7); do\
+               echo cp -r $$directory $(DESTINATION)/$$directory;\
+               cp -r $$directory $(DESTINATION)/$$directory;\
+       done
+
+
+SOLUTION_ASM8=asm-8-strings/exercises/exercise-strings/
+copy_solution_asm8:
+       echo "copy solution ASM 8";
+       for directory in $(SOLUTION_ASM8); do\
+               echo cp -r $$directory $(DESTINATION)/$$directory;\
+               cp -r $$directory $(DESTINATION)/$$directory;\
+       done