From c5fcf7179a83ef65c86c6a4a390029149e518649 Mon Sep 17 00:00:00 2001 From: Franciszek Malinka Date: Tue, 5 Oct 2021 21:49:54 +0200 Subject: Duzy commit ze smieciami --- Semestr 4/ask/lista0/Lista 0.pdf | Bin 362255 -> 0 bytes Semestr 4/ask/lista0/ask21_lista_0.pdf | Bin 94705 -> 0 bytes Semestr 4/ask/lista0/rozw.c | 78 ---- Semestr 4/ask/lista1/ask21_lista_1.pdf | Bin 118889 -> 0 bytes Semestr 4/ask/lista1/rozw.c | 217 --------- Semestr 4/ask/lista1/test.c | 11 - Semestr 4/ask/lista1/zad7.txt | 21 - Semestr 4/ask/lista11/gen.py | 65 --- Semestr 4/ask/lista11/zad8.c | 23 - Semestr 4/ask/lista2/ask21_lista_2.pdf | Bin 137597 -> 0 bytes Semestr 4/ask/lista2/pom.c | 38 -- Semestr 4/ask/lista3/ask21_lista_3.pdf | Bin 152374 -> 0 bytes Semestr 4/ask/lista4/ask21_lista_4.pdf | Bin 149361 -> 0 bytes Semestr 4/ask/lista5/ask21_lista_5.pdf | Bin 91135 -> 0 bytes Semestr 4/ask/lista5/puzzle3.s | 19 - Semestr 4/ask/lista5/puzzle4.s | 24 - Semestr 4/ask/lista5/puzzle5.s | 24 - Semestr 4/ask/lista5/zad1.asm | 15 - Semestr 4/ask/lista5/zad1.c | 25 - Semestr 4/ask/lista5/zad1.s | 98 ---- Semestr 4/ask/lista5/zad2.asm | 15 - Semestr 4/ask/lista5/zad2.c | 44 -- Semestr 4/ask/lista5/zad3.c | 60 --- Semestr 4/ask/lista5/zad4.c | 66 --- Semestr 4/ask/lista5/zad5.c | 54 --- Semestr 4/ask/lista6/puzzle.c | 28 -- Semestr 4/ask/lista6/puzzle.s | 22 - Semestr 4/ask/lista6/puzzle7.s | 29 -- Semestr 4/ask/lista6/puzzle8.c | 25 - Semestr 4/ask/lista6/puzzle8.s | 30 -- Semestr 4/ask/lista6/test.c | 9 - Semestr 4/ask/lista6/zad7.c | 18 - Semestr 4/ask/lista7/eval.s | 18 - Semestr 4/ask/lista7/wrap.s | 18 - Semestr 4/ask/lista7/zad5.c | 38 -- Semestr 4/ask/lista7/zad5.s | 0 Semestr 4/ask/lista7/zad7.cpp | 19 - Semestr 4/ask/lista7/zad7.ll | 174 ------- Semestr 4/ask/lista8/._lista_8 | Bin 212 -> 0 bytes Semestr 4/ask/lista8/ask21_lista_8.tgz | Bin 2136 -> 0 bytes Semestr 4/ask/lista8/bar.c | 5 - Semestr 4/ask/lista8/even.c | 8 - Semestr 4/ask/lista8/foo.c | 5 - Semestr 4/ask/lista8/lazy.c | 7 - Semestr 4/ask/lista8/main.lds | 39 -- Semestr 4/ask/lista8/merge-1.map | 300 ------------ Semestr 4/ask/lista8/merge-2.map | 301 ------------ Semestr 4/ask/lista8/mismatch-a.c | 7 - Semestr 4/ask/lista8/mismatch-b.c | 8 - Semestr 4/ask/lista8/odd.c | 8 - Semestr 4/ask/lista8/relo3.c | 15 - Semestr 4/ask/lista8/start.c | 8 - Semestr 4/ask/lista8/str-a.c | 10 - Semestr 4/ask/lista8/str-b.c | 9 - Semestr 4/ask/lista8/swap.c | 18 - Semestr 4/ask/lista9/gadget.s | 16 - Semestr 4/ask/lista9/lazy.c | 7 - Semestr 4/ask/lista9/lista_9.tgz | Bin 1278 -> 0 bytes Semestr 4/ask/lista9/relo3.c | 15 - Semestr 4/ask/lista9/ropex.c | 31 -- Semestr 4/ask/lista9/ropex.in (1).txt | 7 - Semestr 4/ask/lista9/ropex.in.txt | 7 - Semestr 4/ask/lista9/ropex.map | 511 --------------------- Semestr 4/ask/lista9/test.c | 7 - Semestr 4/ask/lista9/test.s | 50 -- .../materia\305\202y/ask21-05-machine-basics.pdf" | Bin 930028 -> 0 bytes .../materia\305\202y/ask21-06-machine-control.pdf" | Bin 1673505 -> 0 bytes .../ask21-07-machine-procedures.pdf" | Bin 1096679 -> 0 bytes .../ask/materia\305\202y/hackersdelight.pdf" | Bin 25678006 -> 0 bytes .../ask/materia\305\202y/x64_cheatsheet.pdf" | Bin 192472 -> 0 bytes .../ask/materia\305\202y/x86-64-psABI-1.0.pdf" | Bin 496280 -> 0 bytes Semestr 4/ask/zadanie1/rozw.c | 21 - 72 files changed, 2745 deletions(-) delete mode 100644 Semestr 4/ask/lista0/Lista 0.pdf delete mode 100644 Semestr 4/ask/lista0/ask21_lista_0.pdf delete mode 100644 Semestr 4/ask/lista0/rozw.c delete mode 100644 Semestr 4/ask/lista1/ask21_lista_1.pdf delete mode 100644 Semestr 4/ask/lista1/rozw.c delete mode 100644 Semestr 4/ask/lista1/test.c delete mode 100644 Semestr 4/ask/lista1/zad7.txt delete mode 100644 Semestr 4/ask/lista11/gen.py delete mode 100644 Semestr 4/ask/lista11/zad8.c delete mode 100644 Semestr 4/ask/lista2/ask21_lista_2.pdf delete mode 100644 Semestr 4/ask/lista2/pom.c delete mode 100644 Semestr 4/ask/lista3/ask21_lista_3.pdf delete mode 100644 Semestr 4/ask/lista4/ask21_lista_4.pdf delete mode 100644 Semestr 4/ask/lista5/ask21_lista_5.pdf delete mode 100644 Semestr 4/ask/lista5/puzzle3.s delete mode 100644 Semestr 4/ask/lista5/puzzle4.s delete mode 100644 Semestr 4/ask/lista5/puzzle5.s delete mode 100644 Semestr 4/ask/lista5/zad1.asm delete mode 100644 Semestr 4/ask/lista5/zad1.c delete mode 100644 Semestr 4/ask/lista5/zad1.s delete mode 100644 Semestr 4/ask/lista5/zad2.asm delete mode 100644 Semestr 4/ask/lista5/zad2.c delete mode 100644 Semestr 4/ask/lista5/zad3.c delete mode 100644 Semestr 4/ask/lista5/zad4.c delete mode 100644 Semestr 4/ask/lista5/zad5.c delete mode 100644 Semestr 4/ask/lista6/puzzle.c delete mode 100644 Semestr 4/ask/lista6/puzzle.s delete mode 100644 Semestr 4/ask/lista6/puzzle7.s delete mode 100644 Semestr 4/ask/lista6/puzzle8.c delete mode 100644 Semestr 4/ask/lista6/puzzle8.s delete mode 100644 Semestr 4/ask/lista6/test.c delete mode 100644 Semestr 4/ask/lista6/zad7.c delete mode 100644 Semestr 4/ask/lista7/eval.s delete mode 100644 Semestr 4/ask/lista7/wrap.s delete mode 100644 Semestr 4/ask/lista7/zad5.c delete mode 100644 Semestr 4/ask/lista7/zad5.s delete mode 100644 Semestr 4/ask/lista7/zad7.cpp delete mode 100644 Semestr 4/ask/lista7/zad7.ll delete mode 100755 Semestr 4/ask/lista8/._lista_8 delete mode 100644 Semestr 4/ask/lista8/ask21_lista_8.tgz delete mode 100644 Semestr 4/ask/lista8/bar.c delete mode 100644 Semestr 4/ask/lista8/even.c delete mode 100644 Semestr 4/ask/lista8/foo.c delete mode 100644 Semestr 4/ask/lista8/lazy.c delete mode 100644 Semestr 4/ask/lista8/main.lds delete mode 100644 Semestr 4/ask/lista8/merge-1.map delete mode 100644 Semestr 4/ask/lista8/merge-2.map delete mode 100644 Semestr 4/ask/lista8/mismatch-a.c delete mode 100644 Semestr 4/ask/lista8/mismatch-b.c delete mode 100644 Semestr 4/ask/lista8/odd.c delete mode 100644 Semestr 4/ask/lista8/relo3.c delete mode 100644 Semestr 4/ask/lista8/start.c delete mode 100644 Semestr 4/ask/lista8/str-a.c delete mode 100644 Semestr 4/ask/lista8/str-b.c delete mode 100644 Semestr 4/ask/lista8/swap.c delete mode 100644 Semestr 4/ask/lista9/gadget.s delete mode 100644 Semestr 4/ask/lista9/lazy.c delete mode 100644 Semestr 4/ask/lista9/lista_9.tgz delete mode 100644 Semestr 4/ask/lista9/relo3.c delete mode 100644 Semestr 4/ask/lista9/ropex.c delete mode 100644 Semestr 4/ask/lista9/ropex.in (1).txt delete mode 100644 Semestr 4/ask/lista9/ropex.in.txt delete mode 100644 Semestr 4/ask/lista9/ropex.map delete mode 100644 Semestr 4/ask/lista9/test.c delete mode 100644 Semestr 4/ask/lista9/test.s delete mode 100644 "Semestr 4/ask/materia\305\202y/ask21-05-machine-basics.pdf" delete mode 100644 "Semestr 4/ask/materia\305\202y/ask21-06-machine-control.pdf" delete mode 100644 "Semestr 4/ask/materia\305\202y/ask21-07-machine-procedures.pdf" delete mode 100644 "Semestr 4/ask/materia\305\202y/hackersdelight.pdf" delete mode 100644 "Semestr 4/ask/materia\305\202y/x64_cheatsheet.pdf" delete mode 100644 "Semestr 4/ask/materia\305\202y/x86-64-psABI-1.0.pdf" delete mode 100644 Semestr 4/ask/zadanie1/rozw.c (limited to 'Semestr 4/ask') diff --git a/Semestr 4/ask/lista0/Lista 0.pdf b/Semestr 4/ask/lista0/Lista 0.pdf deleted file mode 100644 index bffa5cb..0000000 Binary files a/Semestr 4/ask/lista0/Lista 0.pdf and /dev/null differ diff --git a/Semestr 4/ask/lista0/ask21_lista_0.pdf b/Semestr 4/ask/lista0/ask21_lista_0.pdf deleted file mode 100644 index cc9b182..0000000 Binary files a/Semestr 4/ask/lista0/ask21_lista_0.pdf and /dev/null differ diff --git a/Semestr 4/ask/lista0/rozw.c b/Semestr 4/ask/lista0/rozw.c deleted file mode 100644 index c71940a..0000000 --- a/Semestr 4/ask/lista0/rozw.c +++ /dev/null @@ -1,78 +0,0 @@ -#include -#include - - -int main() { - /* Zad. 3 */ - - uint32_t x, k; - scanf("%d%d", &x, &k); - - x &= ~(1<>= y; // floor(x / 2^y) - x &= (1<> y; // ceil(x/2^y) = floor((x + 2^y - 1)/2^y) - - /* Zad. 5 */ - - scanf("%d", &x); - /* jesli x = 2^k, to x = 1000...0. Wtedy x - 1 = 0111...1, zatem x & (x - 1) == 0 - * gdy x jest potęgą dwójki. Łatwo widać, że jeśli x nie jest potęgą dwójki, - * to wiodący bit będzie ten sam, więc koniunkcja bitowa będzie niezerowa */ - printf("%d", (x & (x - 1))); - - /* Zad. 6 */ - - int rev = ((0xff000000 & x) >> 24u) | // można pominąć tę koniunkcję. - ((0xff0000 & x) >> 8u) | - ((0xff00 & x) << 8u) | - ((0xff & x) << 24u); - - /* Zad. 7 */ - - /* Kod sterujący - kod, który nie niesie informacji o znaku, ale niesie jakąś - * instrukcję sterującą dla urządzenia, np. do terminala. - * ASCII (American Standard Code for Information Interchange) - zestaw znaków, - * który stał się standardem w komunikacji elektronicznej. - * 0, NUL - znak nie niosący żadnej informacji. Może informować np. o końcu danych tekstowych - * 4, EOT (end of thread/end of transmission), ^D - informuje o końcu transmisji danych, - * które mogły zawierać więcej niż jeden tekst. - * 7, BEL (bell), ^G - instruuje urządzenie do wysłania dźwięku. - * 10, LF (line feed), \n - instruuje urządzenie do przejścia do nowej linii, - * ale nie do jej początku. Z tego względu jest często wiązany z CR (carriage return), - * który instruuje urządzenie do powrotu do początku wiersza. W systemach UNIX sam \n - * wystarczy. - * 12, FF (Form feed) - instruuje np. drukarki do przejścia do pierwszego wiersza - * następnej kartkii. - */ - - /* Zad. 8 */ - - /* UTF-8 (8-bit Unicode Transformation Format) - alternatywny zestaw znaków, - * w pełni kompatybilny z ASCII. Wykorzystuje od 1 do 4 bajtów do zakodowania - * pojedyńczego znaku. ASCII ma do dyspozycji jedynie 128 możliwych znaków, co - * zdecydowanie jest mniejsze niż potrzebna liczba znaków do zakodowania. - * Wykorzystanie 4 bajtów pozwala na gwałtowne zwiększenie tej liczby. - * - * Proszę zapłacić 5€! ę - U+0119 (0000 0001 0001 1001), spacja - U+0020, - * ł - U+0142 (0000 0001 0100 0010), € - U+20AC (0010 0000 1010 1100) - * 01010000 01110010 01101111 01110011 01111010 [1100 0100 1001 1001] - * 00100000 - * 01111010 01010001 01110000 [1100 0101 1000 0010] 01010001 01010011 01011001 [1100 0100 1000 0111] - * 00100000 - * 00110101 [1110 0010 1000 0010 1010 1100] 00100001 - */ - - return 0; -} \ No newline at end of file diff --git a/Semestr 4/ask/lista1/ask21_lista_1.pdf b/Semestr 4/ask/lista1/ask21_lista_1.pdf deleted file mode 100644 index 9afcd65..0000000 Binary files a/Semestr 4/ask/lista1/ask21_lista_1.pdf and /dev/null differ diff --git a/Semestr 4/ask/lista1/rozw.c b/Semestr 4/ask/lista1/rozw.c deleted file mode 100644 index 0b4c208..0000000 --- a/Semestr 4/ask/lista1/rozw.c +++ /dev/null @@ -1,217 +0,0 @@ -#include -#include - - -static const int S[] = {1, 2, 4, 8, 16}; // Magic Binary Numbers -static const int B[] = {0x55555555, 0x33333333, 0x0F0F0F0F, 0x00FF00FF, 0x0000FFFF}; - -char* utb(uint32_t x) { - static char rep[36]; - int cnt = 34; - for (int i = 0; i < 32; i += 1) { - if (i > 0 && i % 8 == 0) { - rep[cnt] = ' '; - cnt -= 1; - } - rep[cnt] = (x & 1) + '0'; - cnt -= 1; - x >>= 1; - } - rep[35] = '\0'; - return rep; -} - -void pb(uint32_t x) { - printf("%s : %d\n", utb(x), x); -} - -struct A { - int8_t a; - void *b; - int8_t c; - int16_t d; -}; - -struct B { - void *c; - double b; - int16_t a; -}; - -struct C { - int8_t a; - int8_t c; - int16_t d; - void *b; -}; - -// zaklada count > 0 -void secret(uint8_t *to, uint8_t *from, size_t count) { - size_t n = (count + 7) / 8; - switch (count % 8) { - case 0: do { *to++ = *from++; - case 7: *to++ = *from++; - case 6: *to++ = *from++; - case 5: *to++ = *from++; - case 4: *to++ = *from++; - case 3: *to++ = *from++; - case 2: *to++ = *from++; - case 1: *to++ = *from++; - } while (--n > 0); - } -} - -// zaklada count > 0 -void goto_secret(uint8_t *to, uint8_t *from, size_t count) { - size_t n = (count + 7) / 8; - static void *array[] = { &&finito, &&c0, &&c1, &&c2, &&c3, &&c4, &&c5, &&c6, &&c7 }; - goto *array[count % 8 + 1]; - c0: *to++ = *from++; - c7: *to++ = *from++; - c6: *to++ = *from++; - c5: *to++ = *from++; - c4: *to++ = *from++; - c3: *to++ = *from++; - c2: *to++ = *from++; - c1: *to++ = *from++; - goto *array[(--n > 0)]; - finito: return; -} - -int main() { - /* Zadanie 1 */ - printf("Zadanie 1:\n"); - - uint32_t i = 7, k = 15, x = 15689126; - - pb(x); - uint32_t c = (((1<> i) << k; // 0010 0000 - x = (x & ~(1<> 1) & B[0]); pb(c); - c = ((c >> S[1]) & B[1]) + (c & B[1]); pb(c); - c = ((c >> S[2]) + c) & B[2]; pb(c); - c = ((c >> S[3]) + c) & B[3]; pb(c); - c = ((c >> S[4]) + c) & B[4]; pb(c); - printf("-----------------\n"); - // wersja dla koksow - v = v - ((v >> 1) & 0x55555555); pb(v);// reuse input as temporary - v = ((v >> 2) & 0x33333333) + (v & 0x33333333); pb(v); // temp - c = ((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; pb(c); // count - - - /* Zadanie 3 */ - printf("Zadanie 3:\n"); - - struct A a; - struct B b; - struct C d; - int8_t x1; - void *x2; - int16_t x3; - printf("%lu %lu %lu\n", sizeof x1, sizeof x2, sizeof x3); - printf("%lu %lu %lu\n", sizeof a, sizeof b, sizeof d); - - - /* Zadanie 4 */ - - - /* Zadanie 5 */ - - /* s += b[j + 1] + b[--j]; - * - * t1 := j + 1 - * t2 := t1 * 4 - * t3 := b[t2] - * j := j - 1 - * t4 := j * 4 - * t5 := b[t4] - * t6 := t4 + t5 // Czy na pewno tak? - * s := s + t6 - * - * a[i++] -= *b * (c[j*2] + 1); - * - * t1 := *b - * t2 := j * 2 - * t3 := t2 * 4 - * t4 := c[t3] - * t5 := t4 + 1 - * t6 := t1 * t5 - * a := a - t6 - * i := i + 1 - */ - - /* Zadanie 6 */ - /* vs->d = us[1].a + us[j].c; - * t1 := 1 * 12 - * t2 := us + t1 - * t2' := us + 0 // chcemy dostać się do a, ale jest na poczatku, wiec nic dodawac nie trzeba - * t3 := *t2 - * t4 := j * 12 - * t5 := us + t4 - * t6 := t5 + 8 - * t7 := *t6 - * t8 := t3 + t7 - * t9 := vs + 9 - * *t9 := t8 - */ - - /* Zadanie 7 */ - - /* I := 0 ; <> - goto ITest - ILoop: J := I ; <> - goto WTest - WLoop: t1 := 4 * J ; <> - Temp := arr[t1] ; arr[J] - t2 := J - 1 - t3 := 4 * t2 - t4 := arr[t3] ; arr[J - 1] - arr[t1] := t4 ; arr[J] := arr[J - 1] - arr[t3] := Temp ; arr[J - 1] := Temp - J := J - 1 - WTest: if J <= 0 goto IPlus ; <> - t4 := 4 * J ; <> - t5 := arr[t4] - t6 := J - 1 - t7 = 4 * t6 - t8 := arr[t7] - if t5 >= t8 goto IPlus - goto WLoop ; <> - IPlus: I := I + 1 ; <> - ITest: if I < length goto ILoop ; <> - */ - - - /* Zadanie 8 */ - printf("Zadanie 8:\n"); - - // secret kopiuje wartości na które wskazuje from do miejsca w które wskazuje to, - // przesuwa oba wskaźniki i powtarza tak count razy (czyli efektywnie kopiuje np. tablice) - - uint8_t t1[10] = {1,2,3,0,5,100,7,8,9,10}, t2[10]; - uint8_t* to = t2 + 2, *from = t1 + 3; - size_t count = 4; - - goto_secret(to, from, count); - - for (int i = 0; i < 10; i++) - printf("%hhd ", t1[i]); - printf("\n"); - for (int i = 0; i < 10; i++) - printf("%hhd ", t2[i]); - printf("\n"); - - i = 3; - t1[i++] = i; - printf("%hhd\n", t1[i-1]); -} \ No newline at end of file diff --git a/Semestr 4/ask/lista1/test.c b/Semestr 4/ask/lista1/test.c deleted file mode 100644 index 0f3c11e..0000000 --- a/Semestr 4/ask/lista1/test.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include - -int main() -{ - int x; - short y; - x = -10; - y = (short)x; - printf("%d %hd", x, y); -} \ No newline at end of file diff --git a/Semestr 4/ask/lista1/zad7.txt b/Semestr 4/ask/lista1/zad7.txt deleted file mode 100644 index 1e9c4b3..0000000 --- a/Semestr 4/ask/lista1/zad7.txt +++ /dev/null @@ -1,21 +0,0 @@ - I := 0 - goto ITest -ILoop: J := I - goto WTest -WLoop: t1 := 4 * J - Temp := arr[t1] - t2 := J - 1 - t3 := 4 * t2 - arr[t1] := arr[t3] - arr[t3] := Temp - J := J - 1 -WTest: if J <= 0 goto IPlus - t4 := 4 * J - t5 := arr[t4] - t6 := J - 1 - t7 = 4 * t6 - t8 := arr[t7] - if t5 >= t8 goto IPlus - goto WLoop -IPlus: I := I + 1 -ITest: if I < length goto ILoop \ No newline at end of file diff --git a/Semestr 4/ask/lista11/gen.py b/Semestr 4/ask/lista11/gen.py deleted file mode 100644 index d4de762..0000000 --- a/Semestr 4/ask/lista11/gen.py +++ /dev/null @@ -1,65 +0,0 @@ -def next_permutation(a): - """Generate the lexicographically next permutation inplace. - - https://en.wikipedia.org/wiki/Permutation#Generation_in_lexicographic_order - Return false if there is no next permutation. - """ - # Find the largest index i such that a[i] < a[i + 1]. If no such - # index exists, the permutation is the last permutation - for i in reversed(range(len(a) - 1)): - if a[i] < a[i + 1]: - break # found - else: # no break: not found - return False # no next permutation - - # Find the largest index j greater than i such that a[i] < a[j] - j = next(j for j in reversed(range(i + 1, len(a))) if a[i] < a[j]) - - # Swap the value of a[i] with that of a[j] - a[i], a[j] = a[j], a[i] - - # Reverse sequence from a[i + 1] up to and including the final element a[n] - a[i + 1:] = reversed(a[i + 1:]) - return True - -def perm_to_str(a): - return ''.join(map(str, a)) - -def str_to_perm(s): - return [int(c) for c in s] - -t = [0,1,2,3] -perm_to_idx = dict() - -def bbin(x): - return bin(x)[2:] - -cnt = 23 -while True: - perm_to_idx[perm_to_str(t)] = cnt - cnt -= 1 - if not next_permutation(t): - break - -for p in perm_to_idx.keys(): - for i in range(4): - t = str_to_perm(p) - for j in range(4): - if t[j] > t[i]: - t[j] -= 1 - t[i] = 3 - print(p, 'x', i, '->', perm_to_str(t), ':\t', bbin(perm_to_idx[p]), '\t', bbin(i), '\t', bbin(perm_to_idx[perm_to_str(t)]), end='\t') - print(perm_to_idx[p], '\t', i, '\t', perm_to_idx[perm_to_str(t)]) - -print('\n-----\n') - - -for p in perm_to_idx.keys(): - for i in range(4): - t = str_to_perm(p) - for j in range(4): - if t[j] > t[i]: - t[j] -= 1 - t[i] = 3 - print(p, 'x', i, '->', perm_to_str(t), ':\t', bbin(perm_to_idx[p]), '\t', bbin(i), '\t', bbin(perm_to_idx[perm_to_str(t)]), end='\t') - print(perm_to_idx[p], '\t', i, '\t', perm_to_idx[perm_to_str(t)]) diff --git a/Semestr 4/ask/lista11/zad8.c b/Semestr 4/ask/lista11/zad8.c deleted file mode 100644 index cd8c2bf..0000000 --- a/Semestr 4/ask/lista11/zad8.c +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -uint8_t victim(uint8_t s) { - s |= ((s & 0x55) << 1) | (s & 0xaa >> 1); - return ((s >> 2) && 1) | ((s >> 4) && 2) | ((s >> 6) && 3); -} - -uint8_t update(uint8_t s, uint8_t v) { - int8_t p0 = victim(s); - int8_t p1 = victim(s ^ 0b01010101); - int8_t p2 = victim(s ^ 0b10101010); - int8_t p3 = victim(s ^ 0b11111111); - uint8_t age = (3 << (v << 1)) & s; - - s -= (~((char)(age - 1) >> 7)) & (1 << (p1 << 1)); - s -= (~((char)(age - 2) >> 7)) & (1 << (p2 << 1)); - s -= (~((char)(age - 3) >> 7)) & (1 << (p3 << 1)); - s |= (3 << (v << 1)); - return s; -} - -int main() {} \ No newline at end of file diff --git a/Semestr 4/ask/lista2/ask21_lista_2.pdf b/Semestr 4/ask/lista2/ask21_lista_2.pdf deleted file mode 100644 index e6df9d7..0000000 Binary files a/Semestr 4/ask/lista2/ask21_lista_2.pdf and /dev/null differ diff --git a/Semestr 4/ask/lista2/pom.c b/Semestr 4/ask/lista2/pom.c deleted file mode 100644 index 87d542d..0000000 --- a/Semestr 4/ask/lista2/pom.c +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include -#include - -char* utb(uint32_t x) { - static char rep[36]; - int cnt = 34; - for (int i = 0; i < 32; i += 1) { - if (i > 0 && i % 8 == 0) { - rep[cnt] = ' '; - cnt -= 1; - } - rep[cnt] = (x & 1) + '0'; - cnt -= 1; - x >>= 1; - } - rep[35] = '\0'; - return rep; -} - -void pb(uint32_t x) { - printf("%s : %d\n", utb(x), x); -} - -// int main() { -// /* Zadanie 1 */ - -// int32_t x; -// x = (1<<31); -// printf("%d, %d, %d %d\n", x, (x > 0), x-1, (x - 1 < 0)); -// } - -int main() { - /* Zadanie 1 */ - int32_t x; - scanf("%d", &x); - printf("%d %d\n", x*x, INT_MIN); -} \ No newline at end of file diff --git a/Semestr 4/ask/lista3/ask21_lista_3.pdf b/Semestr 4/ask/lista3/ask21_lista_3.pdf deleted file mode 100644 index d83e9f8..0000000 Binary files a/Semestr 4/ask/lista3/ask21_lista_3.pdf and /dev/null differ diff --git a/Semestr 4/ask/lista4/ask21_lista_4.pdf b/Semestr 4/ask/lista4/ask21_lista_4.pdf deleted file mode 100644 index 87e0e4a..0000000 Binary files a/Semestr 4/ask/lista4/ask21_lista_4.pdf and /dev/null differ diff --git a/Semestr 4/ask/lista5/ask21_lista_5.pdf b/Semestr 4/ask/lista5/ask21_lista_5.pdf deleted file mode 100644 index b8c1977..0000000 Binary files a/Semestr 4/ask/lista5/ask21_lista_5.pdf and /dev/null differ diff --git a/Semestr 4/ask/lista5/puzzle3.s b/Semestr 4/ask/lista5/puzzle3.s deleted file mode 100644 index f625752..0000000 --- a/Semestr 4/ask/lista5/puzzle3.s +++ /dev/null @@ -1,19 +0,0 @@ - .global puzzle3 - - .text -puzzle3: # rdi: n; rsi: d - movl %edi, %edi # zeruje 32 starsze bity rdi - salq $32, %rsi # rsi <<= 32 - movl $32, %edx # edx := 32 - movl $0x80000000, %ecx # ecx := MIN_INT - xorl %eax, %eax # eax := 0 -.L3: addq %rdi, %rdi # rdi *= 2 - movq %rdi, %r8 # r8 := rdi - subq %rsi, %r8 # r8 -= rsi - js .L2 # if r8 < 0 then jump to L2 - orl %ecx, %eax # eax |= ecx - movq %r8, %rdi # rdi := r8 -.L2: shrl %ecx # ecx >>= 1 - decl %edx # edx-- - jne .L3 # if (edx != 0) then jump to L3 - ret diff --git a/Semestr 4/ask/lista5/puzzle4.s b/Semestr 4/ask/lista5/puzzle4.s deleted file mode 100644 index 16ca386..0000000 --- a/Semestr 4/ask/lista5/puzzle4.s +++ /dev/null @@ -1,24 +0,0 @@ -.global puzzle4 - -.text -puzzle4: # argumenty: rdi - long*, rsi - long, rdx - uint64, rcx - uint64 - movq %rcx, %rax # rax := rcx - subq %rdx, %rax # rax -= rdx - shrq %rax # rax >>= 1; // ale logiczne! - addq %rdx, %rax # rax += rdx; - cmpq %rdx, %rcx # if rcx < rdx - jb .L5 # then jump to L5 - movq (%rdi,%rax,8), %r8 # r8 = *(rdi + 8*rax) - cmpq %rsi, %r8 # if rsi == r8 - je .L10 # then jump to L10 - cmpq %rsi, %r8 # if (r8 - rsi < 0) <=> r8 < rsi - jg .L11 # then jump to L11 - leaq 1(%rax), %rdx # rdx := rax + 1 - call puzzle4 # call recursively puzzle4 -.L10: ret # return rax -.L11: leaq -1(%rax), %rcx # rcx := rax - 1 - call puzzle4 # call recursively puzzle4 - ret # return rax -.L5: movl $-1, %eax # eax := -1 - ret # return rax - diff --git a/Semestr 4/ask/lista5/puzzle5.s b/Semestr 4/ask/lista5/puzzle5.s deleted file mode 100644 index 02c3aea..0000000 --- a/Semestr 4/ask/lista5/puzzle5.s +++ /dev/null @@ -1,24 +0,0 @@ -400590 : -400590: 48 83 subq $0x3c, %rsi # rsi -= 0x3c -400594: 48 83 fe 0 cmpq $0x5, %rsi # if rsi > 0x5 -400598: 77 29 ja *0x4005c3 # then jump to line 16 -40059a: ff 24 f5 f8 06 40 00 jmpq *0x4006f8(,%rsi,8) # jump to 19 + rsi -4005a1: 48 8d 04 fd 00 00 00 00 lea 0x0(,%rdi,8),%rax # rax := rdi * 8 -4005a9: c3 retq # return rax -4005aa: 48 89 f8 movq %rdi,%rax # rax := rdi -4005ad: 48 c1 f8 03 sarq $0x3,%rax # rax >>= 3 (arithmetic) -4005b1: c3 retq # return rax -4005b2: 48 89 f8 movq %rdi,%rax # rax := rdi -4005b5: 48 c1 e0 04 shlq $0x4,%rax # rax <<= 4 (logic) -4005b9: 48 29 f8 subq %rdi,%rax # rax -= rdi -4005bc: 48 89 c7 movq %rax,%rdi # rdi := rax -4005bf: 48 0f af ff imulq %rdi,%rdi # rdi *= rdi -4005c3: 48 8d 47 4b leaq 0x4b(%rdi),%rax # rax := 0x4b + rdi -4005c7: c3 retq # return rax - -0x4006f8: 0x4005a1 # line 6 -0x400700: 0x4005a1 # line 6 -0x400708: 0x4005b2 # line 11 -0x400710: 0x4005c3 # line 16 -0x400718: 0x4005aa # line 8 -0x400720: 0x4005bf # line 15 diff --git a/Semestr 4/ask/lista5/zad1.asm b/Semestr 4/ask/lista5/zad1.asm deleted file mode 100644 index 22aef29..0000000 --- a/Semestr 4/ask/lista5/zad1.asm +++ /dev/null @@ -1,15 +0,0 @@ -puzzle: testl %esi, %esi - je .L4 ; jesli esi == 0, skocz do L4 - xorl %edx, %edx ; edx := 0 - xorl %eax, %eax ; eax := 0 -.L3: movl %edi, %ecx ; ecx := edi - andl $1, %ecx ; ecx &= 1 - addl %ecx, %eax ; eax += eax - sarq %rdi ; rdi >>= 1 - incl %edx, ; edx++ - cmpl %edx, %esi ; edx - esi != 0? <=> edx != esi - jne .L3 ; jesli tak, skocz do L3 - ret -.L4 movl %esi, %eax ; return esi - ret - diff --git a/Semestr 4/ask/lista5/zad1.c b/Semestr 4/ask/lista5/zad1.c deleted file mode 100644 index 9379bb2..0000000 --- a/Semestr 4/ask/lista5/zad1.c +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include - -int puzzle(long x /* rdi */ , unsigned n /* rsi */) { - if (n == 0) { - return n; - } - int t = 0; // edx := 0 - int result = 0; // eax := 0 - do { - int m = x & 0xffffffff; // ecx := edi - m &= 1; - result += m; - x >>= 1; - t++; - } while (t != n); - return result; // ???? -} - -int main() { - long x; - unsigned n; - scanf("%ld%u", &x, &n); - return puzzle(x, n); -} \ No newline at end of file diff --git a/Semestr 4/ask/lista5/zad1.s b/Semestr 4/ask/lista5/zad1.s deleted file mode 100644 index b935b9e..0000000 --- a/Semestr 4/ask/lista5/zad1.s +++ /dev/null @@ -1,98 +0,0 @@ - .file "zad1.c" - .text - .p2align 4 - .globl puzzle - .type puzzle, @function -puzzle: -.LFB23: - .cfi_startproc - endbr64 - xorl %r8d, %r8d - testl %esi, %esi - je .L1 - xorl %eax, %eax - .p2align 4,,10 - .p2align 3 -.L3: - movl %edi, %edx - addl $1, %eax - sarq %rdi - andl $1, %edx - addl %edx, %r8d - cmpl %esi, %eax - jne .L3 -.L1: - movl %r8d, %eax - ret - .cfi_endproc -.LFE23: - .size puzzle, .-puzzle - .section .rodata.str1.1,"aMS",@progbits,1 -.LC0: - .string "%ld%u" - .section .text.startup,"ax",@progbits - .p2align 4 - .globl main - .type main, @function -main: -.LFB24: - .cfi_startproc - endbr64 - subq $40, %rsp - .cfi_def_cfa_offset 48 - leaq .LC0(%rip), %rdi - movq %fs:40, %rax - movq %rax, 24(%rsp) - xorl %eax, %eax - leaq 12(%rsp), %rdx - leaq 16(%rsp), %rsi - call __isoc99_scanf@PLT - movl 12(%rsp), %ecx - movq 16(%rsp), %rax - xorl %r8d, %r8d - testl %ecx, %ecx - je .L8 - xorl %edx, %edx - .p2align 4,,10 - .p2align 3 -.L10: - movl %eax, %esi - addl $1, %edx - sarq %rax - andl $1, %esi - addl %esi, %r8d - cmpl %ecx, %edx - jne .L10 -.L8: - movq 24(%rsp), %rax - xorq %fs:40, %rax - jne .L16 - movl %r8d, %eax - addq $40, %rsp - .cfi_remember_state - .cfi_def_cfa_offset 8 - ret -.L16: - .cfi_restore_state - call __stack_chk_fail@PLT - .cfi_endproc -.LFE24: - .size main, .-main - .ident "GCC: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0" - .section .note.GNU-stack,"",@progbits - .section .note.gnu.property,"a" - .align 8 - .long 1f - 0f - .long 4f - 1f - .long 5 -0: - .string "GNU" -1: - .align 8 - .long 0xc0000002 - .long 3f - 2f -2: - .long 0x3 -3: - .align 8 -4: diff --git a/Semestr 4/ask/lista5/zad2.asm b/Semestr 4/ask/lista5/zad2.asm deleted file mode 100644 index 7fe4364..0000000 --- a/Semestr 4/ask/lista5/zad2.asm +++ /dev/null @@ -1,15 +0,0 @@ -puzzle2: - movq %rdi, %rax ; rax := rdi -.L3: movb (%rax), %r9b ; r9b := *rax - leaq 1(%rax), %r8 ; r8 := rax + 1 - movq %rsi, %rdx ; rdx := *rsi -.L2: movb (%rdx), %cl ; cl := *rdx - incq %rdx ; rdx++ - testb %cl, %cl ; if (cl == 0) - je .L4 ; then jump to L4 - cmpb %cl, %r9b ; if (cl != r9b) - jne .L2 ; then jump to L2 - movq %r8, %rax ; rax := r8 - jmp .L3 ; jump to L3 -.L4 subq %rdi, %rax ; rax -= rdi - ret \ No newline at end of file diff --git a/Semestr 4/ask/lista5/zad2.c b/Semestr 4/ask/lista5/zad2.c deleted file mode 100644 index ab9cb54..0000000 --- a/Semestr 4/ask/lista5/zad2.c +++ /dev/null @@ -1,44 +0,0 @@ -#include -#include - -long puzzle2(char *rdi /* rdi */, char *rsi /* rsi */) { - char *rax = rdi; -L3: - char r9b = *rax; - char *r8 = rax + 1; - char *rdx = rsi; -L2: - char cl = *rdx; - rdx++; - if (cl == 0) { - goto L4; - } - if (cl != r9b) { - goto L2; - } - rax = r8; - goto L3; -L4: - return rax - rdi; -} - - -// funkcja sprawdza jaka jest pierwsza litera z s która nie występuje w d -// jesli wszystkie występują, to zwróci długość s. -long puzzle2_decoded(char *s /* rdi */, char *d /* rsi */) { - for (char *result = s ; ; result++) { - char first = *result; - char *crawl = d; - for (char *crawl = d; *crawl != first; crawl++) { - if (*crawl == 0) { - return result - s; - } - } - } -} - - - -int main() { - -} \ No newline at end of file diff --git a/Semestr 4/ask/lista5/zad3.c b/Semestr 4/ask/lista5/zad3.c deleted file mode 100644 index 1ce9067..0000000 --- a/Semestr 4/ask/lista5/zad3.c +++ /dev/null @@ -1,60 +0,0 @@ -#include -#include -#include - -uint32_t puzzle3(uint32_t n, uint32_t d); - -// uint32_t divv(uint32_t edi, uint32_t esi) { -// uint64_t rdi = edi; -// uint64_t rsi = esi; -// rsi <<= 32; -// uint8_t edx = 32; -// uint32_t ecx = 0x80000000; -// uint32_t eax = 0; -// L3: -// rdi += rdi; -// int64_t r8 = rdi; -// r8 -= rsi; -// if (r8 < 0) { -// goto L2; -// } -// eax |= ecx; -// rdi = r8; -// L2: -// ecx >>= 1; -// edx--; -// if (edx != 0) { -// goto L3; -// } -// return eax; -// } - -uint32_t decoded(uint32_t n, uint32_t d) { - uint64_t N = n; - uint64_t D = (uint64_t)d << 32; - - uint32_t bit = 0x80000000; - uint32_t result = 0; - for (uint32_t edx = 32; edx > 0; edx--) { - N += N; - if ((int64_t)(N - D) >= 0) { - result |= bit; - N -= D; - } - bit >>= 1; - } - return result; -} - -int main() { - for (uint32_t n=0; n <= 1000; ++n) { - for (uint32_t d=1; d <= 1000; ++d) { - if (puzzle3(n,d) != decoded(n, d)) { - printf("%d %d\n", n, d); - printf("%u %u\n", puzzle3(n, d), decoded(n, d)); - return 0; - } - } - } - printf("%d\n", puzzle3(1000000000, 2)); -} \ No newline at end of file diff --git a/Semestr 4/ask/lista5/zad4.c b/Semestr 4/ask/lista5/zad4.c deleted file mode 100644 index a6927fb..0000000 --- a/Semestr 4/ask/lista5/zad4.c +++ /dev/null @@ -1,66 +0,0 @@ -#include -#include -#include - -int puzzle4(long *a, long v, uint64_t s, uint64_t e); - -long tab[100]; - -int assembly_like(long *rdi, long rsi, uint64_t rdx, uint64_t rcx) { - uint64_t rax = rcx; - rax -= rdx; - rax >>= 1; - rax += rdx; - if (rcx < rdx) { - goto L5; - } - long r8 = *(rdi + rax*8); - if (rsi == r8) { - goto L10; - } - if (rsi > r8) { - goto L11; - } - rdx = rax + 1; - assembly_like(rdi, rsi, rdx, rcx); -L10: - return (int)rax; -L11: - rcx = rax - 1; - assembly_like(rdi, rsi, rdx, rcx); - return (int)rax; -L5: - return -1; -} - - -// binsearch :) -int decode(long *a, long v, uint64_t s, uint64_t e) { - int result = (e + s) / 2; - if (e < s) { - return -1; - } - long val = a[result]; - if (v == val) { - return result; - } - if (v < val) { - e = result - 1; - } - else { - s = result + 1; - } - return decode(a, v, s, e); -} - -int main() { - uint64_t n; - long v; - scanf("%ld %ld", &n, &v); - for (int i = 0; i < n; i++) { - scanf("%ld", &tab[i]); - } - printf("%d\n", puzzle4(tab, v, 0, n-1)); - printf("%d\n", decode(tab, v, 0, n-1)); - -} \ No newline at end of file diff --git a/Semestr 4/ask/lista5/zad5.c b/Semestr 4/ask/lista5/zad5.c deleted file mode 100644 index c1fe957..0000000 --- a/Semestr 4/ask/lista5/zad5.c +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include - -long switch_prob(long rdi, long rsi) { - static void *array[] = { &&L1, &&L1, &&L2, &&L3, &&L4, &&L5 }; - long rax; - rsi -= 0x3c; - if (rsi > 0x5) { - goto L3; - } - goto *array[rsi]; -L1: - rax = rdi * 8; - return rax; -L4: - rax = rdi; - rax >>= 3; - retun rax; -L2: - rax = rdi; - rax <<= 4; - rax -= rdi; - rdi = rax; -L5: - rdi *= rdi; -L3: - rax = 0x4b + rdi; - return rax; -} - -long decode(long x, long n) { - long result; - n -= 0x3c; - switch (n) - { - case 0: - case 1: - return x + 8; - case 4: - return x >> 3; - case 2: - result = (x << 4) - x; - x = result; - case 5: - x *= x; - case 3: - default: - return 0x4b + x; - } -} - -int main() { - -} \ No newline at end of file diff --git a/Semestr 4/ask/lista6/puzzle.c b/Semestr 4/ask/lista6/puzzle.c deleted file mode 100644 index 6a18d20..0000000 --- a/Semestr 4/ask/lista6/puzzle.c +++ /dev/null @@ -1,28 +0,0 @@ -```c= - 0: 55 pushq %rbp - 1: 48 89 e5 movq %rsp, %rbp - 4: 48 83 ec 10 subq $16, %rsp - 8: 48 89 e0 movq %rsp, %rax #wsk stosu to rax - b: 48 8d 0c fd 0f 00 00 00 leaq 15(,%rdi,8), %rcx #n * rozmiar longa + 15 do rcx (+15 to kwestia wyrównania/sufit) - 13: 48 83 e1 f0 andq $-16, %rcx #zerujemy ostatnie 4 bity - 17: 48 29 c8 subq %rcx, %rax #oblicz nowy wskaźnik stosu - 1a: 48 89 c4 movq %rax, %rsp #nowy wskaźnik wrzuć do rsp - 1d: 48 8d 4d f8 leaq -8(%rbp), %rcx - 21: 48 89 4c f8 f8 movq %rcx, -8(%rax,%rdi,8) - 26: 48 c7 45 f8 00 00 00 00 movq $0, -8(%rbp) - 2e: 48 85 ff testq %rdi, %rdi - 31: 7e 1d jle 29 <_aframe+0x50> - 33: 31 c9 xorl %ecx, %ecx - 35: 66 2e 0f 1f 84 00 00 00 00 00 nopw %cs:(%rax,%rax) - 3f: 90 nop - 40: 48 89 14 c8 movq %rdx, (%rax,%rcx,8) - 44: 48 ff c1 incq %rcx - 47: 48 39 cf cmpq %rcx, %rdi - 4a: 75 f4 jne -12 <_aframe+0x40> - 4c: 48 89 7d f8 movq %rdi, -8(%rbp) - 50: 48 8b 04 f0 movq (%rax,%rsi,8), %rax - 54: 48 8b 00 movq (%rax), %rax - 57: 48 89 ec movq %rbp, %rsp #powrót do poprzedniej ramki - 5a: 5d popq %rbp #wrzucenie do rbp poprzedniego adresu - 5b: c3 retq -``` \ No newline at end of file diff --git a/Semestr 4/ask/lista6/puzzle.s b/Semestr 4/ask/lista6/puzzle.s deleted file mode 100644 index 3a39398..0000000 --- a/Semestr 4/ask/lista6/puzzle.s +++ /dev/null @@ -1,22 +0,0 @@ - .globl puzzle - - .text -puzzle: - push %rbp # adres koncu ramki, callee-saved - xorl %eax, %eax # zeruje %rax - mov %rsi, %rbp # rbp := rsi, czyli rbp := p - push %rbx # rbx na stos, callee-saved - mov %rdi, %rbx # rbx := rdi, czyli rbx := n - sub $24, %rsp # rsp -= 24, czyli przesun rsp o 3 bajty w dół - test %rdi, %rdi # rdi == 0?, czyli n == 0? - jle .L1 # jesli tak, skocz do L1 - lea 8(%rsp), %rsi # w p.w. rsi := rsp + 8 - lea (%rdi,%rdi), %rdi # rdi := 2*rdi - call puzzle # wywolanie rekurencyjne puzzle - add 8(%rsp), %rax # rax := rax + *(rsp + 8) - add %rax, %rbx # rbx := rbx + rax -.L1: mov %rbx, (%rbp) # *rbp := rbx, czyli *p := rbx - add $24, %rsp # rsp := rsp + 24 (przesun adres stacka o 3 bajty) - pop %rbx # przywracamy rbx - pop %rbp # przywracamy rbp - ret diff --git a/Semestr 4/ask/lista6/puzzle7.s b/Semestr 4/ask/lista6/puzzle7.s deleted file mode 100644 index 6d26961..0000000 --- a/Semestr 4/ask/lista6/puzzle7.s +++ /dev/null @@ -1,29 +0,0 @@ - .global puzzle7 - - .text -puzzle7: - movq %rsi, -40(%rsp) - movq %rdx, -32(%rsp) - movq %rcx, -24(%rsp) - movq %r8, -16(%rsp) - movq %r9, -8(%rsp) - movl $8, -72(%rsp) - leaq 8(%rsp), %rax - movq %rax, -64(%rsp) - leaq -48(%rsp), %rax - movq %rax, -56(%rsp) - movl $0, %eax - jmp .L2 -.L3: movq -64(%rsp), %rdx - leaq 8(%rdx), %rcx - movq %rcx, -64(%rsp) -.L4: addq (%rdx), %rax -.L2: subq $1, %rdi - js .L6 - cmpl $47, -72(%rsp) - ja .L3 - movl -72(%rsp), %edx - addq -56(%rsp), %rdx - addl $8, -72(%rsp) - jmp .L4 -.L6: ret diff --git a/Semestr 4/ask/lista6/puzzle8.c b/Semestr 4/ask/lista6/puzzle8.c deleted file mode 100644 index 4d65f9d..0000000 --- a/Semestr 4/ask/lista6/puzzle8.c +++ /dev/null @@ -1,25 +0,0 @@ -#include - -struct T { - long min; - long max; - long mean; -}; - -struct T puzzle8(long *a, long n); - -struct T decode(long *a, long n) { - long maks = LONG_MIN; - long mini = LONG_MAX; - long sum = 0; - for (int i = 0; i < n; i++) { - if (maks < a[i]) maks = a[i]; - if (mini > a[i]) mini = a[i]; - sum += a[i]; - } - struct T ret; - ret.min = mini; - ret.max = maks; - ret.mean = sum / n; - return ret; -} \ No newline at end of file diff --git a/Semestr 4/ask/lista6/puzzle8.s b/Semestr 4/ask/lista6/puzzle8.s deleted file mode 100644 index cc3805d..0000000 --- a/Semestr 4/ask/lista6/puzzle8.s +++ /dev/null @@ -1,30 +0,0 @@ -# rdi - adres zwracanej struktury (niejawnie) -# rsi - *a -# rdx - n - - .global puzzle8 - - .text -puzzle8: - movq %rdx, %r11 # r11 := n - xorl %r10d, %r10d # r10 := 0 - xorl %eax, %eax # rax := 0 - movq $LONG_MIN, %r8 # r8 := 0x800... - movq $LONG_MAX, %r9 # r9 := 0x7ff... -.L2: cmpq %r11, %r10 # if n <= r10 - jge .L5 # then jump to L5, else - movq (%rsi,%r10,8), %rcx # rcx := a[r10] - cmpq %rcx, %r9 # if a[r10] < r9 - cmovg %rcx, %r9 # then r9 = a[r10] - cmpq %rcx, %r8 # if a[r10] > r8 - cmovl %rcx, %r8 # then r8 = a[r10] - addq %rcx, %rax # rax += a[r10] - incq %r10 # r10++ - jmp .L2 -.L5: cqto # jeśli rax < 0 to niech rdx zaplonie - movq %r9, (%rdi) # rdi->0 := r9 - idivq %r11 # podziel rax przez r11, efektywnie rax /= r11 - movq %r8, 8(%rdi) # rdi->8 := r8 - movq %rax, 16(%rdi) # rdi->16 := rax - movq %rdi, %rax # rax := rdi - ret \ No newline at end of file diff --git a/Semestr 4/ask/lista6/test.c b/Semestr 4/ask/lista6/test.c deleted file mode 100644 index 8a84ac2..0000000 --- a/Semestr 4/ask/lista6/test.c +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include - -int main() { - int32_t x = 0xc0000000; - int32_t y = x + x; - - printf("%d, %d\n", x, y); -} \ No newline at end of file diff --git a/Semestr 4/ask/lista6/zad7.c b/Semestr 4/ask/lista6/zad7.c deleted file mode 100644 index 9072504..0000000 --- a/Semestr 4/ask/lista6/zad7.c +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include - -int wypisuj(int cnt, ...) { - va_list v; - va_start(v, cnt); - int sum = 0; - for (int i = 0; i < cnt; i++) { - sum += va_arg(v, int); - } - return sum; -} - -int puzzle7(int cnt, ...); - -int main() { - printf("%d\n", puzzle7(10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); -} \ No newline at end of file diff --git a/Semestr 4/ask/lista7/eval.s b/Semestr 4/ask/lista7/eval.s deleted file mode 100644 index f7340a0..0000000 --- a/Semestr 4/ask/lista7/eval.s +++ /dev/null @@ -1,18 +0,0 @@ - .global eval - - .text -eval: - movq %rdi, %rax - movq 16(%rsp), %rcx - movq 24(%rsp), %rdx - movq (%rdx), %rsi - movq %rcx, %rdx - imulq %rsi, %rdx - movq %rdx, (%rdi) - movq 8(%rsp), %rdx - movq %rdx, %rdi - subq %rsi, %rdi - movq %rdi, 8(%rax) - subq %rcx, %rdx - movq %rdx, 16(%rax) - ret \ No newline at end of file diff --git a/Semestr 4/ask/lista7/wrap.s b/Semestr 4/ask/lista7/wrap.s deleted file mode 100644 index 6f01dfc..0000000 --- a/Semestr 4/ask/lista7/wrap.s +++ /dev/null @@ -1,18 +0,0 @@ - .global wrap - - .text -wrap: - subq $72, %rsp - movq %rdx, (%rsp) - movq %rsp, %rdx - leaq 8(%rsp), %rax - pushq %rdx - pushq %rsi - pushq %rdi - movq %rax, %rdi - call eval - movq 40(%rsp), %rax - addq 32(%rsp), %rax - imulq 48(%rsp), %rax - addq $96, %rsp - ret \ No newline at end of file diff --git a/Semestr 4/ask/lista7/zad5.c b/Semestr 4/ask/lista7/zad5.c deleted file mode 100644 index d65cb4f..0000000 --- a/Semestr 4/ask/lista7/zad5.c +++ /dev/null @@ -1,38 +0,0 @@ -#include - -typedef struct A { - long u[2]; - long *v; -} SA; - -typedef struct B { - long p[2]; - long q; -} SB; - -SB eval(SA s); -long wrap(long x, long y, long z); - -SB eval_decoded(SA a) { - SB ret; - ret.p[0] = a.u[1] * (*a.v); - ret.p[1] = a.u[0] - (*a.v); - ret.q = a.u[0] - a.u[1]; - return ret; -} - -long wrap_decoded(long x, long y, long z) { - SA a; - a.v = &z; - a.u[0] = x; - a.u[1] = y; - SB b = eval_decoded(a); - long result = (b.p[1] + b.p[0]) * b.q; - return result; -} - -int main() { - printf("%ld\n", wrap(15, 16, 17)); - printf("%ld\n", wrap_decoded(15, 16, 17)); - return 0; -} \ No newline at end of file diff --git a/Semestr 4/ask/lista7/zad5.s b/Semestr 4/ask/lista7/zad5.s deleted file mode 100644 index e69de29..0000000 diff --git a/Semestr 4/ask/lista7/zad7.cpp b/Semestr 4/ask/lista7/zad7.cpp deleted file mode 100644 index 073224f..0000000 --- a/Semestr 4/ask/lista7/zad7.cpp +++ /dev/null @@ -1,19 +0,0 @@ -struct Base { - Base(int n) : data(n) {} - int data; - virtual int doit(int n) { return n - data; } -}; -struct Derived : Base { - Derived(int n) : Base(n + 1) {} - int doit(int n) { return n * data; } -}; - -int doit(Base *bp) { - return bp->doit(1); -} - -int main(int argc, char *argv[]) { - Base b = Base(10); - Derived d = Derived(20); - return doit(&b) + doit(&d); -} \ No newline at end of file diff --git a/Semestr 4/ask/lista7/zad7.ll b/Semestr 4/ask/lista7/zad7.ll deleted file mode 100644 index a99e8d8..0000000 --- a/Semestr 4/ask/lista7/zad7.ll +++ /dev/null @@ -1,174 +0,0 @@ -; ModuleID = 'zad7.cpp' -source_filename = "zad7.cpp" -target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-pc-linux-gnu" - -%struct.Base = type <{ i32 (...)**, i32, [4 x i8] }> -%struct.Derived = type { %struct.Base.base, [4 x i8] } -%struct.Base.base = type <{ i32 (...)**, i32 }> - -$_ZN4BaseC1Ei = comdat any - -$_ZN7DerivedC1Ei = comdat any - -$_ZN4BaseC2Ei = comdat any - -$_ZN4Base4doitEi = comdat any - -$_ZN7DerivedC2Ei = comdat any - -$_ZN7Derived4doitEi = comdat any - -$_ZTV4Base = comdat any - -$_ZTS4Base = comdat any - -$_ZTI4Base = comdat any - -$_ZTV7Derived = comdat any - -$_ZTS7Derived = comdat any - -$_ZTI7Derived = comdat any - -@_ZTV4Base = linkonce_odr unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI4Base to i8*), i8* bitcast (i32 (%struct.Base*, i32)* @_ZN4Base4doitEi to i8*)] }, comdat, align 8 -@_ZTVN10__cxxabiv117__class_type_infoE = external global i8* -@_ZTS4Base = linkonce_odr constant [6 x i8] c"4Base\00", comdat, align 1 -@_ZTI4Base = linkonce_odr constant { i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv117__class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @_ZTS4Base, i32 0, i32 0) }, comdat, align 8 -@_ZTV7Derived = linkonce_odr unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* bitcast ({ i8*, i8*, i8* }* @_ZTI7Derived to i8*), i8* bitcast (i32 (%struct.Derived*, i32)* @_ZN7Derived4doitEi to i8*)] }, comdat, align 8 -@_ZTVN10__cxxabiv120__si_class_type_infoE = external global i8* -@_ZTS7Derived = linkonce_odr constant [9 x i8] c"7Derived\00", comdat, align 1 -@_ZTI7Derived = linkonce_odr constant { i8*, i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8*, i8** @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @_ZTS7Derived, i32 0, i32 0), i8* bitcast ({ i8*, i8* }* @_ZTI4Base to i8*) }, comdat, align 8 - -; Function Attrs: noinline nounwind optnone -define i32 @_Z4doitP4Base(%struct.Base* %bp) #0 { -entry: - %bp.addr = alloca %struct.Base*, align 8 - store %struct.Base* %bp, %struct.Base** %bp.addr, align 8 - %0 = load %struct.Base*, %struct.Base** %bp.addr, align 8 - %1 = bitcast %struct.Base* %0 to i32 (%struct.Base*, i32)*** - %vtable = load i32 (%struct.Base*, i32)**, i32 (%struct.Base*, i32)*** %1, align 8 - %vfn = getelementptr inbounds i32 (%struct.Base*, i32)*, i32 (%struct.Base*, i32)** %vtable, i64 0 - %2 = load i32 (%struct.Base*, i32)*, i32 (%struct.Base*, i32)** %vfn, align 8 - %call = call i32 %2(%struct.Base* %0, i32 1) - ret i32 %call -} - -; Function Attrs: noinline norecurse nounwind optnone -define i32 @main(i32 %argc, i8** %argv) #1 { -entry: - %retval = alloca i32, align 4 - %argc.addr = alloca i32, align 4 - %argv.addr = alloca i8**, align 8 - %b = alloca %struct.Base, align 8 - %d = alloca %struct.Derived, align 8 - store i32 0, i32* %retval, align 4 - store i32 %argc, i32* %argc.addr, align 4 - store i8** %argv, i8*** %argv.addr, align 8 - call void @_ZN4BaseC1Ei(%struct.Base* %b, i32 10) - call void @_ZN7DerivedC1Ei(%struct.Derived* %d, i32 20) - %call = call i32 @_Z4doitP4Base(%struct.Base* %b) - %0 = bitcast %struct.Derived* %d to %struct.Base* - %call1 = call i32 @_Z4doitP4Base(%struct.Base* %0) - %add = add nsw i32 %call, %call1 - ret i32 %add -} - -; Function Attrs: noinline nounwind optnone -define linkonce_odr void @_ZN4BaseC1Ei(%struct.Base* %this, i32 %n) unnamed_addr #0 comdat align 2 { -entry: - %this.addr = alloca %struct.Base*, align 8 - %n.addr = alloca i32, align 4 - store %struct.Base* %this, %struct.Base** %this.addr, align 8 - store i32 %n, i32* %n.addr, align 4 - %this1 = load %struct.Base*, %struct.Base** %this.addr, align 8 - %0 = load i32, i32* %n.addr, align 4 - call void @_ZN4BaseC2Ei(%struct.Base* %this1, i32 %0) - ret void -} - -; Function Attrs: noinline nounwind optnone -define linkonce_odr void @_ZN7DerivedC1Ei(%struct.Derived* %this, i32 %n) unnamed_addr #0 comdat align 2 { -entry: - %this.addr = alloca %struct.Derived*, align 8 - %n.addr = alloca i32, align 4 - store %struct.Derived* %this, %struct.Derived** %this.addr, align 8 - store i32 %n, i32* %n.addr, align 4 - %this1 = load %struct.Derived*, %struct.Derived** %this.addr, align 8 - %0 = load i32, i32* %n.addr, align 4 - call void @_ZN7DerivedC2Ei(%struct.Derived* %this1, i32 %0) - ret void -} - -; Function Attrs: noinline nounwind optnone -define linkonce_odr void @_ZN4BaseC2Ei(%struct.Base* %this, i32 %n) unnamed_addr #0 comdat align 2 { -entry: - %this.addr = alloca %struct.Base*, align 8 - %n.addr = alloca i32, align 4 - store %struct.Base* %this, %struct.Base** %this.addr, align 8 - store i32 %n, i32* %n.addr, align 4 - %this1 = load %struct.Base*, %struct.Base** %this.addr, align 8 - %0 = bitcast %struct.Base* %this1 to i32 (...)*** - store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV4Base, i32 0, inrange i32 0, i32 2) to i32 (...)**), i32 (...)*** %0, align 8 - %data = getelementptr inbounds %struct.Base, %struct.Base* %this1, i32 0, i32 1 - %1 = load i32, i32* %n.addr, align 4 - store i32 %1, i32* %data, align 8 - ret void -} - -; Function Attrs: noinline nounwind optnone -define linkonce_odr i32 @_ZN4Base4doitEi(%struct.Base* %this, i32 %n) unnamed_addr #0 comdat align 2 { -entry: - %this.addr = alloca %struct.Base*, align 8 - %n.addr = alloca i32, align 4 - store %struct.Base* %this, %struct.Base** %this.addr, align 8 - store i32 %n, i32* %n.addr, align 4 - %this1 = load %struct.Base*, %struct.Base** %this.addr, align 8 - %0 = load i32, i32* %n.addr, align 4 - %data = getelementptr inbounds %struct.Base, %struct.Base* %this1, i32 0, i32 1 - %1 = load i32, i32* %data, align 8 - %sub = sub nsw i32 %0, %1 - ret i32 %sub -} - -; Function Attrs: noinline nounwind optnone -define linkonce_odr void @_ZN7DerivedC2Ei(%struct.Derived* %this, i32 %n) unnamed_addr #0 comdat align 2 { -entry: - %this.addr = alloca %struct.Derived*, align 8 - %n.addr = alloca i32, align 4 - store %struct.Derived* %this, %struct.Derived** %this.addr, align 8 - store i32 %n, i32* %n.addr, align 4 - %this1 = load %struct.Derived*, %struct.Derived** %this.addr, align 8 - %0 = bitcast %struct.Derived* %this1 to %struct.Base* - %1 = load i32, i32* %n.addr, align 4 - %add = add nsw i32 %1, 1 - call void @_ZN4BaseC2Ei(%struct.Base* %0, i32 %add) - %2 = bitcast %struct.Derived* %this1 to i32 (...)*** - store i32 (...)** bitcast (i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTV7Derived, i32 0, inrange i32 0, i32 2) to i32 (...)**), i32 (...)*** %2, align 8 - ret void -} - -; Function Attrs: noinline nounwind optnone -define linkonce_odr i32 @_ZN7Derived4doitEi(%struct.Derived* %this, i32 %n) unnamed_addr #0 comdat align 2 { -entry: - %this.addr = alloca %struct.Derived*, align 8 - %n.addr = alloca i32, align 4 - store %struct.Derived* %this, %struct.Derived** %this.addr, align 8 - store i32 %n, i32* %n.addr, align 4 - %this1 = load %struct.Derived*, %struct.Derived** %this.addr, align 8 - %0 = load i32, i32* %n.addr, align 4 - %1 = bitcast %struct.Derived* %this1 to %struct.Base* - %data = getelementptr inbounds %struct.Base, %struct.Base* %1, i32 0, i32 1 - %2 = load i32, i32* %data, align 8 - %mul = mul nsw i32 %0, %2 - ret i32 %mul -} - -attributes #0 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } -attributes #1 = { noinline norecurse nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } - -!llvm.module.flags = !{!0} -!llvm.ident = !{!1} - -!0 = !{i32 1, !"wchar_size", i32 4} -!1 = !{!"clang version 10.0.0-4ubuntu1 "} diff --git a/Semestr 4/ask/lista8/._lista_8 b/Semestr 4/ask/lista8/._lista_8 deleted file mode 100755 index 893436c..0000000 Binary files a/Semestr 4/ask/lista8/._lista_8 and /dev/null differ diff --git a/Semestr 4/ask/lista8/ask21_lista_8.tgz b/Semestr 4/ask/lista8/ask21_lista_8.tgz deleted file mode 100644 index 789c9af..0000000 Binary files a/Semestr 4/ask/lista8/ask21_lista_8.tgz and /dev/null differ diff --git a/Semestr 4/ask/lista8/bar.c b/Semestr 4/ask/lista8/bar.c deleted file mode 100644 index 97fbd4f..0000000 --- a/Semestr 4/ask/lista8/bar.c +++ /dev/null @@ -1,5 +0,0 @@ -// extern long foo; - -int bar = 42; -// long *foo_p = &foo; -short dead[15]; diff --git a/Semestr 4/ask/lista8/even.c b/Semestr 4/ask/lista8/even.c deleted file mode 100644 index 5bf8606..0000000 --- a/Semestr 4/ask/lista8/even.c +++ /dev/null @@ -1,8 +0,0 @@ -int is_odd(long n); - -int is_even(long n) { - if (n == 0) - return 1; - else - return is_odd(n - 1); -} diff --git a/Semestr 4/ask/lista8/foo.c b/Semestr 4/ask/lista8/foo.c deleted file mode 100644 index 080d831..0000000 --- a/Semestr 4/ask/lista8/foo.c +++ /dev/null @@ -1,5 +0,0 @@ -// extern int bar; - -long foo = 19; -// int *bar_p = &bar; -char code[17]; diff --git a/Semestr 4/ask/lista8/lazy.c b/Semestr 4/ask/lista8/lazy.c deleted file mode 100644 index fb08cf7..0000000 --- a/Semestr 4/ask/lista8/lazy.c +++ /dev/null @@ -1,7 +0,0 @@ -#include - -int main(void) { - puts("first time"); - puts("second time"); - return 0; -} diff --git a/Semestr 4/ask/lista8/main.lds b/Semestr 4/ask/lista8/main.lds deleted file mode 100644 index 25a4ca9..0000000 --- a/Semestr 4/ask/lista8/main.lds +++ /dev/null @@ -1,39 +0,0 @@ -OUTPUT_FORMAT("elf64-x86-64") -OUTPUT_ARCH(i386:x86-64) -ENTRY(_start) -PHDRS -{ - code PT_LOAD FLAGS(5); - rodata PT_LOAD FLAGS(4); - data PT_LOAD FLAGS(6); -} -SECTIONS -{ - . = 0x400000 + SIZEOF_HEADERS; - - .text : - { - *(.text .text.*) - } : code - - .rodata : - { - *(.rodata .rodata.*) - } : rodata - - .data : - { - *(.data .data.*) - } : data - - .bss : - { - *(.bss .bss.*) - *(COMMON) - } : data - - /DISCARD/ : - { - *(.note.gnu.property) - } -} diff --git a/Semestr 4/ask/lista8/merge-1.map b/Semestr 4/ask/lista8/merge-1.map deleted file mode 100644 index 2e93e7c..0000000 --- a/Semestr 4/ask/lista8/merge-1.map +++ /dev/null @@ -1,300 +0,0 @@ - -Merging program properties - - -Discarded input sections - - .note.gnu.property - 0x0000000000000000 0x20 bar.o - -Memory Configuration - -Name Origin Length Attributes -*default* 0x0000000000000000 0xffffffffffffffff - -Linker script and memory map - -LOAD foo.o -LOAD bar.o - -.interp - *(.interp) - -.note.gnu.property - 0x0000000000000000 0x20 - .note.gnu.property - 0x0000000000000000 0x20 foo.o - -.note.gnu.build-id - *(.note.gnu.build-id) - -.hash - *(.hash) - -.gnu.hash - *(.gnu.hash) - -.dynsym - *(.dynsym) - -.dynstr - *(.dynstr) - -.gnu.version - *(.gnu.version) - -.gnu.version_d - *(.gnu.version_d) - -.gnu.version_r - *(.gnu.version_r) - -.rela.init - *(.rela.init) - -.rela.text - *(.rela.text) - -.rela.fini - *(.rela.fini) - -.rela.rodata - *(.rela.rodata) - -.rela.data.rel.ro - *(.rela.data.rel.ro) - -.rela.data - *(.rela.data) - -.rela.tdata - *(.rela.tdata) - -.rela.tbss - *(.rela.tbss) - -.rela.ctors - *(.rela.ctors) - -.rela.dtors - *(.rela.dtors) - -.rela.got - *(.rela.got) - -.rela.bss - *(.rela.bss) - -.rela.ldata - *(.rela.ldata) - -.rela.lbss - *(.rela.lbss) - -.rela.lrodata - *(.rela.lrodata) - -.rela.ifunc - *(.rela.ifunc) - -.rela.plt - *(.rela.plt) - -.init - *(SORT_NONE(.init)) - -.plt - *(.plt) - -.plt.got - *(.plt.got) - -.plt.sec - *(.plt.sec) - -.text 0x0000000000000000 0x0 - *(.text .stub) - .text 0x0000000000000000 0x0 foo.o - .text 0x0000000000000000 0x0 bar.o - *(.gnu.warning) - -.fini - *(SORT_NONE(.fini)) - -.rodata - *(.rodata) - -.rodata1 - *(.rodata1) - -.eh_frame_hdr - *(.eh_frame_hdr) - -.eh_frame - *(.eh_frame) - -.gcc_except_table - *(.gcc_except_table) - -.gnu_extab - *(.gnu_extab*) - -.exception_ranges - *(.exception_ranges) - -.eh_frame - *(.eh_frame) - -.gnu_extab - *(.gnu_extab) - -.gcc_except_table - *(.gcc_except_table) - -.exception_ranges - *(.exception_ranges) - -.tdata - *(.tdata) - -.tbss - *(.tbss) - -.jcr - *(.jcr) - -.dynamic - *(.dynamic) - -.got - *(.got) - -.got.plt - *(.got.plt) - -.data 0x0000000000000000 0xc - *(.data) - .data 0x0000000000000000 0x8 foo.o - 0x0000000000000000 foo - .data 0x0000000000000008 0x4 bar.o - 0x0000000000000008 bar - -.data1 - *(.data1) - -.bss 0x0000000000000000 0x3e - *(.bss) - .bss 0x0000000000000000 0x11 foo.o - 0x0000000000000000 code - *fill* 0x0000000000000011 0xf - .bss 0x0000000000000020 0x1e bar.o - 0x0000000000000020 dead - -.lbss - *(.lbss) - -.lrodata - *(.lrodata) - -.ldata - *(.ldata) - -.stab - *(.stab) - -.stabstr - *(.stabstr) - -.stab.excl - *(.stab.excl) - -.stab.exclstr - *(.stab.exclstr) - -.stab.index - *(.stab.index) - -.stab.indexstr - *(.stab.indexstr) - -.comment 0x0000000000000000 0x56 - *(.comment) - .comment 0x0000000000000000 0x2b foo.o - .comment 0x000000000000002b 0x2b bar.o - -.note.GNU-stack - 0x0000000000000000 0x0 - .note.GNU-stack - 0x0000000000000000 0x0 foo.o - .note.GNU-stack - 0x0000000000000000 0x0 bar.o - -.gnu.build.attributes - *(.gnu.build.attributes) - -.debug - *(.debug) - -.line - *(.line) - -.debug_srcinfo - *(.debug_srcinfo) - -.debug_sfnames - *(.debug_sfnames) - -.debug_aranges - *(.debug_aranges) - -.debug_pubnames - *(.debug_pubnames) - -.debug_info - *(.debug_info) - -.debug_abbrev - *(.debug_abbrev) - -.debug_line - *(.debug_line) - -.debug_frame - *(.debug_frame) - -.debug_str - *(.debug_str) - -.debug_loc - *(.debug_loc) - -.debug_macinfo - *(.debug_macinfo) - -.debug_weaknames - *(.debug_weaknames) - -.debug_funcnames - *(.debug_funcnames) - -.debug_typenames - *(.debug_typenames) - -.debug_varnames - *(.debug_varnames) - -.debug_pubtypes - *(.debug_pubtypes) - -.debug_ranges - *(.debug_ranges) - -.debug_macro - *(.debug_macro) - -.debug_addr - *(.debug_addr) - -.gnu.attributes - *(.gnu.attributes) -OUTPUT(merge-1.o elf64-x86-64) diff --git a/Semestr 4/ask/lista8/merge-2.map b/Semestr 4/ask/lista8/merge-2.map deleted file mode 100644 index 2677803..0000000 --- a/Semestr 4/ask/lista8/merge-2.map +++ /dev/null @@ -1,301 +0,0 @@ - -Merging program properties - - -Discarded input sections - - .note.gnu.property - 0x0000000000000000 0x20 foo.o - -Memory Configuration - -Name Origin Length Attributes -*default* 0x0000000000000000 0xffffffffffffffff - -Linker script and memory map - -LOAD bar.o -LOAD foo.o - -.interp - *(.interp) - -.note.gnu.property - 0x0000000000000000 0x20 - .note.gnu.property - 0x0000000000000000 0x20 bar.o - -.note.gnu.build-id - *(.note.gnu.build-id) - -.hash - *(.hash) - -.gnu.hash - *(.gnu.hash) - -.dynsym - *(.dynsym) - -.dynstr - *(.dynstr) - -.gnu.version - *(.gnu.version) - -.gnu.version_d - *(.gnu.version_d) - -.gnu.version_r - *(.gnu.version_r) - -.rela.init - *(.rela.init) - -.rela.text - *(.rela.text) - -.rela.fini - *(.rela.fini) - -.rela.rodata - *(.rela.rodata) - -.rela.data.rel.ro - *(.rela.data.rel.ro) - -.rela.data - *(.rela.data) - -.rela.tdata - *(.rela.tdata) - -.rela.tbss - *(.rela.tbss) - -.rela.ctors - *(.rela.ctors) - -.rela.dtors - *(.rela.dtors) - -.rela.got - *(.rela.got) - -.rela.bss - *(.rela.bss) - -.rela.ldata - *(.rela.ldata) - -.rela.lbss - *(.rela.lbss) - -.rela.lrodata - *(.rela.lrodata) - -.rela.ifunc - *(.rela.ifunc) - -.rela.plt - *(.rela.plt) - -.init - *(SORT_NONE(.init)) - -.plt - *(.plt) - -.plt.got - *(.plt.got) - -.plt.sec - *(.plt.sec) - -.text 0x0000000000000000 0x0 - *(.text .stub) - .text 0x0000000000000000 0x0 bar.o - .text 0x0000000000000000 0x0 foo.o - *(.gnu.warning) - -.fini - *(SORT_NONE(.fini)) - -.rodata - *(.rodata) - -.rodata1 - *(.rodata1) - -.eh_frame_hdr - *(.eh_frame_hdr) - -.eh_frame - *(.eh_frame) - -.gcc_except_table - *(.gcc_except_table) - -.gnu_extab - *(.gnu_extab*) - -.exception_ranges - *(.exception_ranges) - -.eh_frame - *(.eh_frame) - -.gnu_extab - *(.gnu_extab) - -.gcc_except_table - *(.gcc_except_table) - -.exception_ranges - *(.exception_ranges) - -.tdata - *(.tdata) - -.tbss - *(.tbss) - -.jcr - *(.jcr) - -.dynamic - *(.dynamic) - -.got - *(.got) - -.got.plt - *(.got.plt) - -.data 0x0000000000000000 0x10 - *(.data) - .data 0x0000000000000000 0x4 bar.o - 0x0000000000000000 bar - *fill* 0x0000000000000004 0x4 - .data 0x0000000000000008 0x8 foo.o - 0x0000000000000008 foo - -.data1 - *(.data1) - -.bss 0x0000000000000000 0x31 - *(.bss) - .bss 0x0000000000000000 0x1e bar.o - 0x0000000000000000 dead - *fill* 0x000000000000001e 0x2 - .bss 0x0000000000000020 0x11 foo.o - 0x0000000000000020 code - -.lbss - *(.lbss) - -.lrodata - *(.lrodata) - -.ldata - *(.ldata) - -.stab - *(.stab) - -.stabstr - *(.stabstr) - -.stab.excl - *(.stab.excl) - -.stab.exclstr - *(.stab.exclstr) - -.stab.index - *(.stab.index) - -.stab.indexstr - *(.stab.indexstr) - -.comment 0x0000000000000000 0x56 - *(.comment) - .comment 0x0000000000000000 0x2b bar.o - .comment 0x000000000000002b 0x2b foo.o - -.note.GNU-stack - 0x0000000000000000 0x0 - .note.GNU-stack - 0x0000000000000000 0x0 bar.o - .note.GNU-stack - 0x0000000000000000 0x0 foo.o - -.gnu.build.attributes - *(.gnu.build.attributes) - -.debug - *(.debug) - -.line - *(.line) - -.debug_srcinfo - *(.debug_srcinfo) - -.debug_sfnames - *(.debug_sfnames) - -.debug_aranges - *(.debug_aranges) - -.debug_pubnames - *(.debug_pubnames) - -.debug_info - *(.debug_info) - -.debug_abbrev - *(.debug_abbrev) - -.debug_line - *(.debug_line) - -.debug_frame - *(.debug_frame) - -.debug_str - *(.debug_str) - -.debug_loc - *(.debug_loc) - -.debug_macinfo - *(.debug_macinfo) - -.debug_weaknames - *(.debug_weaknames) - -.debug_funcnames - *(.debug_funcnames) - -.debug_typenames - *(.debug_typenames) - -.debug_varnames - *(.debug_varnames) - -.debug_pubtypes - *(.debug_pubtypes) - -.debug_ranges - *(.debug_ranges) - -.debug_macro - *(.debug_macro) - -.debug_addr - *(.debug_addr) - -.gnu.attributes - *(.gnu.attributes) -OUTPUT(merge-2.o elf64-x86-64) diff --git a/Semestr 4/ask/lista8/mismatch-a.c b/Semestr 4/ask/lista8/mismatch-a.c deleted file mode 100644 index 39436f2..0000000 --- a/Semestr 4/ask/lista8/mismatch-a.c +++ /dev/null @@ -1,7 +0,0 @@ -/* mismatch-a.c */ -void p2(void); - -int main() { - p2(); - return 0; -} diff --git a/Semestr 4/ask/lista8/mismatch-b.c b/Semestr 4/ask/lista8/mismatch-b.c deleted file mode 100644 index 451d5b3..0000000 --- a/Semestr 4/ask/lista8/mismatch-b.c +++ /dev/null @@ -1,8 +0,0 @@ -/* mismatch-b.c */ -#include - -char main; - -void p2() { - printf("0x%x\n", main); -} diff --git a/Semestr 4/ask/lista8/odd.c b/Semestr 4/ask/lista8/odd.c deleted file mode 100644 index c32961e..0000000 --- a/Semestr 4/ask/lista8/odd.c +++ /dev/null @@ -1,8 +0,0 @@ -int is_even(long n); - -int is_odd(long n) { - if (n == 0) - return 0; - else - return is_even(n - 1); -} diff --git a/Semestr 4/ask/lista8/relo3.c b/Semestr 4/ask/lista8/relo3.c deleted file mode 100644 index 6aca7b6..0000000 --- a/Semestr 4/ask/lista8/relo3.c +++ /dev/null @@ -1,15 +0,0 @@ -int relo3(int val) { - switch (val) { - case 100: - return val; - case 101: - return val + 1; - case 103: - case 104: - return val + 3; - case 105: - return val + 5; - default: - return val + 6; - } -} diff --git a/Semestr 4/ask/lista8/start.c b/Semestr 4/ask/lista8/start.c deleted file mode 100644 index a875ace..0000000 --- a/Semestr 4/ask/lista8/start.c +++ /dev/null @@ -1,8 +0,0 @@ -int is_even(long); - -void _start(void) { - asm volatile( - "syscall" - : /* no output */ - : "a" (0x3c), "D" (is_even(42))); -} diff --git a/Semestr 4/ask/lista8/str-a.c b/Semestr 4/ask/lista8/str-a.c deleted file mode 100644 index 3b0fb36..0000000 --- a/Semestr 4/ask/lista8/str-a.c +++ /dev/null @@ -1,10 +0,0 @@ -#include - -char *somestr(void); - -int main(void) { - char *s = somestr(); - s[5] = '\0'; - puts(s); - return 0; -} diff --git a/Semestr 4/ask/lista8/str-b.c b/Semestr 4/ask/lista8/str-b.c deleted file mode 100644 index 50101cb..0000000 --- a/Semestr 4/ask/lista8/str-b.c +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include - -char *somestr(void) { - char *buf = malloc(sizeof("Hello, world!")); - strcpy(buf, "Hello, world!"); - return buf; -} - diff --git a/Semestr 4/ask/lista8/swap.c b/Semestr 4/ask/lista8/swap.c deleted file mode 100644 index e1966fd..0000000 --- a/Semestr 4/ask/lista8/swap.c +++ /dev/null @@ -1,18 +0,0 @@ -extern int buf[]; - -int *bufp0 = &buf[0]; -static int *bufp1; - -static void incr() { - static int count = 0; - count++; -} - -void swap() { - int temp; - incr(); - bufp1 = &buf[1]; - temp = *bufp0; - *bufp0 = *bufp1; - *bufp1 = temp; -} diff --git a/Semestr 4/ask/lista9/gadget.s b/Semestr 4/ask/lista9/gadget.s deleted file mode 100644 index 6d60a63..0000000 --- a/Semestr 4/ask/lista9/gadget.s +++ /dev/null @@ -1,16 +0,0 @@ - .global gadget - - .text - -# rax: 0x3c -# rdi: 0 -# rdx: {NULL, ...} -# rsi: path + '\n' -gadget: - dec %rax # rax: 0x3c -> 0x3b (sys_execve) - mov %rdx, %rsi # rsi: argv = {NULL} - mov %rdi, %rdx # rdx: envp = NULL - lea 16(%rsp),%rdi # rdi: path - ret - -# vim: ft=gas diff --git a/Semestr 4/ask/lista9/lazy.c b/Semestr 4/ask/lista9/lazy.c deleted file mode 100644 index fb08cf7..0000000 --- a/Semestr 4/ask/lista9/lazy.c +++ /dev/null @@ -1,7 +0,0 @@ -#include - -int main(void) { - puts("first time"); - puts("second time"); - return 0; -} diff --git a/Semestr 4/ask/lista9/lista_9.tgz b/Semestr 4/ask/lista9/lista_9.tgz deleted file mode 100644 index 5e5c6f4..0000000 Binary files a/Semestr 4/ask/lista9/lista_9.tgz and /dev/null differ diff --git a/Semestr 4/ask/lista9/relo3.c b/Semestr 4/ask/lista9/relo3.c deleted file mode 100644 index 6aca7b6..0000000 --- a/Semestr 4/ask/lista9/relo3.c +++ /dev/null @@ -1,15 +0,0 @@ -int relo3(int val) { - switch (val) { - case 100: - return val; - case 101: - return val + 1; - case 103: - case 104: - return val + 3; - case 105: - return val + 5; - default: - return val + 6; - } -} diff --git a/Semestr 4/ask/lista9/ropex.c b/Semestr 4/ask/lista9/ropex.c deleted file mode 100644 index dbeae12..0000000 --- a/Semestr 4/ask/lista9/ropex.c +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include -#include - -/* Get string from stdin */ -void readline(FILE *in, char *p) { - int c; - while (true) { - c = fgetc(in); - if (c == EOF || c == '\n') - break; - *p++ = c; - } - *p = '\0'; -} - -void echo(FILE *in) { - char buf[48]; - readline(in, buf); - puts(buf); -} - -int main(int argc, char *argv[]) { - FILE *in = NULL; - if (argc == 2) - in = fopen(argv[1], "rb"); - if (in == NULL) - in = stdin; - echo(in); - return 0; -} diff --git a/Semestr 4/ask/lista9/ropex.in (1).txt b/Semestr 4/ask/lista9/ropex.in (1).txt deleted file mode 100644 index 902773e..0000000 --- a/Semestr 4/ask/lista9/ropex.in (1).txt +++ /dev/null @@ -1,7 +0,0 @@ -00000000: dead c0de dead c0de dead c0de dead c0de ................ -00000010: dead c0de dead c0de dead c0de dead c0de ................ -00000020: dead c0de dead c0de dead c0de dead c0de ................ -00000030: dead c0de dead c0de 731c 4000 0000 0000 ................ -00000040: f422 4000 0000 0000 0000 0000 0000 0000 ................ -00000050: 2f75 7372 2f62 696e 2f70 7974 686f 6e32 /usr/bin/python2 -00000060: 000a ................ diff --git a/Semestr 4/ask/lista9/ropex.in.txt b/Semestr 4/ask/lista9/ropex.in.txt deleted file mode 100644 index 8deabfe..0000000 --- a/Semestr 4/ask/lista9/ropex.in.txt +++ /dev/null @@ -1,7 +0,0 @@ -00000000: dead c0de dead c0de dead c0de dead c0de ................ -00000010: dead c0de dead c0de dead c0de dead c0de ................ -00000020: dead c0de dead c0de dead c0de dead c0de ................ -00000030: dead c0de dead c0de 671d 4000 0000 0000 ................ -00000040: 8e44 4900 0000 0000 0000 0000 0000 0000 ................ -00000050: 2f75 7372 2f62 696e 2f6e 7961 6e63 6174 /usr/bin/nyancat -00000060: 000a ................ \ No newline at end of file diff --git a/Semestr 4/ask/lista9/ropex.map b/Semestr 4/ask/lista9/ropex.map deleted file mode 100644 index 4bd12a5..0000000 --- a/Semestr 4/ask/lista9/ropex.map +++ /dev/null @@ -1,511 +0,0 @@ -Archive member included to satisfy reference by file (symbol) - -/usr/lib/x86_64-linux-gnu/libc_nonshared.a(elf-init.oS) - /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o (__libc_csu_init) - -Merging program properties - -Removed property 0xc0000002 to merge /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o (0x3) and gadget.o (not found) -Removed property 0xc0000002 to merge /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o (not found) and /usr/lib/x86_64-linux-gnu/libc_nonshared.a(elf-init.oS) (0x3) -Removed property 0xc0000002 to merge /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o (not found) and /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o (0x3) -Removed property 0xc0000002 to merge /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o (not found) and /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o (0x3) - -As-needed library included to satisfy reference by file (symbol) - -libc.so.6 ropex.o (fopen@@GLIBC_2.2.5) - -Discarded input sections - - .note.gnu.property - 0x0000000000000000 0x20 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - .note.GNU-stack - 0x0000000000000000 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - .note.gnu.property - 0x0000000000000000 0x20 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o - .note.GNU-stack - 0x0000000000000000 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o - .note.GNU-stack - 0x0000000000000000 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o - .note.gnu.property - 0x0000000000000000 0x20 /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o - .note.GNU-stack - 0x0000000000000000 0x0 ropex.o - .note.gnu.property - 0x0000000000000000 0x20 ropex.o - .note.GNU-stack - 0x0000000000000000 0x0 /usr/lib/x86_64-linux-gnu/libc_nonshared.a(elf-init.oS) - .note.gnu.property - 0x0000000000000000 0x20 /usr/lib/x86_64-linux-gnu/libc_nonshared.a(elf-init.oS) - .note.GNU-stack - 0x0000000000000000 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o - .note.gnu.property - 0x0000000000000000 0x20 /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o - .note.gnu.property - 0x0000000000000000 0x20 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o - .note.GNU-stack - 0x0000000000000000 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o - -Memory Configuration - -Name Origin Length Attributes -*default* 0x0000000000000000 0xffffffffffffffff - -Linker script and memory map - -LOAD /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o -LOAD /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o -LOAD /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o -LOAD ropex.o -LOAD gadget.o -LOAD /usr/lib/gcc/x86_64-linux-gnu/9/libgcc.a -LOAD /usr/lib/gcc/x86_64-linux-gnu/9/libgcc_s.so -START GROUP -LOAD /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libgcc_s.so.1 -LOAD /usr/lib/gcc/x86_64-linux-gnu/9/libgcc.a -END GROUP -LOAD /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libc.so -START GROUP -LOAD /lib/x86_64-linux-gnu/libc.so.6 -LOAD /usr/lib/x86_64-linux-gnu/libc_nonshared.a -LOAD /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 -END GROUP -LOAD /usr/lib/gcc/x86_64-linux-gnu/9/libgcc.a -LOAD /usr/lib/gcc/x86_64-linux-gnu/9/libgcc_s.so -START GROUP -LOAD /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libgcc_s.so.1 -LOAD /usr/lib/gcc/x86_64-linux-gnu/9/libgcc.a -END GROUP -LOAD /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o -LOAD /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o - [!provide] PROVIDE (__executable_start = SEGMENT_START ("text-segment", 0x0)) - 0x00000000000002a8 . = (SEGMENT_START ("text-segment", 0x0) + SIZEOF_HEADERS) - -.interp 0x00000000000002a8 0x1c - *(.interp) - .interp 0x00000000000002a8 0x1c /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - -.note.gnu.build-id - 0x00000000000002c4 0x24 - *(.note.gnu.build-id) - .note.gnu.build-id - 0x00000000000002c4 0x24 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - -.note.ABI-tag 0x00000000000002e8 0x20 - .note.ABI-tag 0x00000000000002e8 0x20 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - -.hash - *(.hash) - -.gnu.hash 0x0000000000000308 0x28 - *(.gnu.hash) - .gnu.hash 0x0000000000000308 0x28 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - -.dynsym 0x0000000000000330 0x108 - *(.dynsym) - .dynsym 0x0000000000000330 0x108 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - -.dynstr 0x0000000000000438 0xaf - *(.dynstr) - .dynstr 0x0000000000000438 0xaf /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - -.gnu.version 0x00000000000004e8 0x16 - *(.gnu.version) - .gnu.version 0x00000000000004e8 0x16 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - -.gnu.version_d 0x0000000000000500 0x0 - *(.gnu.version_d) - .gnu.version_d - 0x0000000000000500 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - -.gnu.version_r 0x0000000000000500 0x30 - *(.gnu.version_r) - .gnu.version_r - 0x0000000000000500 0x30 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - -.rela.dyn 0x0000000000000530 0xd8 - *(.rela.init) - *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) - .rela.text 0x0000000000000530 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - *(.rela.fini) - *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) - *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) - .rela.data.rel.ro - 0x0000000000000530 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - .rela.data.rel.local - 0x0000000000000530 0x18 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) - *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) - *(.rela.ctors) - *(.rela.dtors) - *(.rela.got) - .rela.got 0x0000000000000548 0x78 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) - .rela.bss 0x00000000000005c0 0x18 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - *(.rela.ldata .rela.ldata.* .rela.gnu.linkonce.l.*) - *(.rela.lbss .rela.lbss.* .rela.gnu.linkonce.lb.*) - *(.rela.lrodata .rela.lrodata.* .rela.gnu.linkonce.lr.*) - *(.rela.ifunc) - .rela.ifunc 0x00000000000005d8 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - .rela.fini_array - 0x00000000000005d8 0x18 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - .rela.init_array - 0x00000000000005f0 0x18 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - -.rela.plt 0x0000000000000608 0x60 - *(.rela.plt) - .rela.plt 0x0000000000000608 0x60 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - *(.rela.iplt) - 0x0000000000001000 . = ALIGN (CONSTANT (MAXPAGESIZE)) - -.init 0x0000000000001000 0x1b - *(SORT_NONE(.init)) - .init 0x0000000000001000 0x16 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o - 0x0000000000001000 _init - .init 0x0000000000001016 0x5 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o - -.plt 0x0000000000001020 0x50 - *(.plt) - .plt 0x0000000000001020 0x50 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - 0x0000000000001030 puts@@GLIBC_2.2.5 - 0x0000000000001040 __stack_chk_fail@@GLIBC_2.4 - 0x0000000000001050 fgetc@@GLIBC_2.2.5 - 0x0000000000001060 fopen@@GLIBC_2.2.5 - *(.iplt) - -.plt.got 0x0000000000001070 0x8 - *(.plt.got) - .plt.got 0x0000000000001070 0x8 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - 0x0000000000001070 __cxa_finalize@@GLIBC_2.2.5 - -.plt.sec - *(.plt.sec) - -.text 0x0000000000001080 0x235 - *(.text.unlikely .text.*_unlikely .text.unlikely.*) - *(.text.exit .text.exit.*) - *(.text.startup .text.startup.*) - *(.text.hot .text.hot.*) - *(SORT_BY_NAME(.text.sorted.*)) - *(.text .stub .text.* .gnu.linkonce.t.*) - .text 0x0000000000001080 0x2f /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - 0x0000000000001080 _start - .text 0x00000000000010af 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o - *fill* 0x00000000000010af 0x1 - .text 0x00000000000010b0 0xb9 /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o - .text 0x0000000000001169 0xbb ropex.o - 0x0000000000001169 readline - 0x00000000000011a3 echo - 0x00000000000011e7 main - .text 0x0000000000001224 0xf gadget.o - 0x0000000000001224 gadget - *fill* 0x0000000000001233 0xd - .text 0x0000000000001240 0x75 /usr/lib/x86_64-linux-gnu/libc_nonshared.a(elf-init.oS) - 0x0000000000001240 __libc_csu_init - 0x00000000000012b0 __libc_csu_fini - .text 0x00000000000012b5 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o - .text 0x00000000000012b5 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o - *(.gnu.warning) - -.fini 0x00000000000012b8 0xd - *(SORT_NONE(.fini)) - .fini 0x00000000000012b8 0x8 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o - 0x00000000000012b8 _fini - .fini 0x00000000000012c0 0x5 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o - [!provide] PROVIDE (__etext = .) - [!provide] PROVIDE (_etext = .) - [!provide] PROVIDE (etext = .) - 0x0000000000002000 . = ALIGN (CONSTANT (MAXPAGESIZE)) - 0x0000000000002000 . = SEGMENT_START ("rodata-segment", (ALIGN (CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 0x1)))) - -.rodata 0x0000000000002000 0x7 - *(.rodata .rodata.* .gnu.linkonce.r.*) - .rodata.cst4 0x0000000000002000 0x4 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - 0x0000000000002000 _IO_stdin_used - .rodata.str1.1 - 0x0000000000002004 0x3 ropex.o - -.rodata1 - *(.rodata1) - -.eh_frame_hdr 0x0000000000002008 0x34 - *(.eh_frame_hdr) - .eh_frame_hdr 0x0000000000002008 0x34 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - 0x0000000000002008 __GNU_EH_FRAME_HDR - *(.eh_frame_entry .eh_frame_entry.*) - -.eh_frame 0x0000000000002040 0xd0 - *(.eh_frame) - .eh_frame 0x0000000000002040 0x30 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - 0x2c (size before relaxing) - *fill* 0x0000000000002070 0x0 - .eh_frame 0x0000000000002070 0x28 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - 0x40 (size before relaxing) - .eh_frame 0x0000000000002098 0x18 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - 0x30 (size before relaxing) - .eh_frame 0x00000000000020b0 0x5c /usr/lib/x86_64-linux-gnu/libc_nonshared.a(elf-init.oS) - 0x78 (size before relaxing) - .eh_frame 0x000000000000210c 0x4 /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o - *(.eh_frame.*) - -.gcc_except_table - *(.gcc_except_table .gcc_except_table.*) - -.gnu_extab - *(.gnu_extab*) - -.exception_ranges - *(.exception_ranges*) - 0x0000000000003da0 . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE)) - -.eh_frame - *(.eh_frame) - *(.eh_frame.*) - -.gnu_extab - *(.gnu_extab) - -.gcc_except_table - *(.gcc_except_table .gcc_except_table.*) - -.exception_ranges - *(.exception_ranges*) - -.tdata 0x0000000000003da0 0x0 - [!provide] PROVIDE (__tdata_start = .) - *(.tdata .tdata.* .gnu.linkonce.td.*) - -.tbss - *(.tbss .tbss.* .gnu.linkonce.tb.*) - *(.tcommon) - -.preinit_array 0x0000000000003da0 0x0 - [!provide] PROVIDE (__preinit_array_start = .) - *(.preinit_array) - [!provide] PROVIDE (__preinit_array_end = .) - -.init_array 0x0000000000003da0 0x8 - 0x0000000000003da0 PROVIDE (__init_array_start = .) - *(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)) - *(.init_array EXCLUDE_FILE(*crtend?.o *crtend.o *crtbegin?.o *crtbegin.o) .ctors) - .init_array 0x0000000000003da0 0x8 /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o - 0x0000000000003da8 PROVIDE (__init_array_end = .) - -.fini_array 0x0000000000003da8 0x8 - [!provide] PROVIDE (__fini_array_start = .) - *(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)) - *(.fini_array EXCLUDE_FILE(*crtend?.o *crtend.o *crtbegin?.o *crtbegin.o) .dtors) - .fini_array 0x0000000000003da8 0x8 /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o - [!provide] PROVIDE (__fini_array_end = .) - -.ctors - *crtbegin.o(.ctors) - *crtbegin?.o(.ctors) - *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) - *(SORT_BY_NAME(.ctors.*)) - *(.ctors) - -.dtors - *crtbegin.o(.dtors) - *crtbegin?.o(.dtors) - *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) - *(SORT_BY_NAME(.dtors.*)) - *(.dtors) - -.jcr - *(.jcr) - -.data.rel.ro 0x0000000000003db0 0x0 - *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) - *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) - .data.rel.ro 0x0000000000003db0 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - -.dynamic 0x0000000000003db0 0x1f0 - *(.dynamic) - .dynamic 0x0000000000003db0 0x1f0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - 0x0000000000003db0 _DYNAMIC - -.got 0x0000000000003fa0 0x60 - *(.got.plt) - .got.plt 0x0000000000003fa0 0x38 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - 0x0000000000003fa0 _GLOBAL_OFFSET_TABLE_ - *(.igot.plt) - *(.got) - .got 0x0000000000003fd8 0x28 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - *(.igot) - 0x0000000000004000 . = DATA_SEGMENT_RELRO_END (., 0x0) - -.data 0x0000000000004000 0x10 - *(.data .data.* .gnu.linkonce.d.*) - .data 0x0000000000004000 0x4 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - 0x0000000000004000 data_start - 0x0000000000004000 __data_start - .data 0x0000000000004004 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o - .data 0x0000000000004004 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o - *fill* 0x0000000000004004 0x4 - .data.rel.local - 0x0000000000004008 0x8 /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o - 0x0000000000004008 __dso_handle - .data 0x0000000000004010 0x0 ropex.o - .data 0x0000000000004010 0x0 gadget.o - .data 0x0000000000004010 0x0 /usr/lib/x86_64-linux-gnu/libc_nonshared.a(elf-init.oS) - .data 0x0000000000004010 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o - .data 0x0000000000004010 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o - -.tm_clone_table - 0x0000000000004010 0x0 - .tm_clone_table - 0x0000000000004010 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o - .tm_clone_table - 0x0000000000004010 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o - -.data1 - *(.data1) - 0x0000000000004010 _edata = . - [!provide] PROVIDE (edata = .) - 0x0000000000004010 . = . - 0x0000000000004010 __bss_start = . - -.bss 0x0000000000004010 0x10 - *(.dynbss) - *fill* 0x0000000000004010 0x0 - .dynbss 0x0000000000004010 0x8 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - 0x0000000000004010 stdin@@GLIBC_2.2.5 - *(.bss .bss.* .gnu.linkonce.b.*) - .bss 0x0000000000004018 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o - .bss 0x0000000000004018 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o - .bss 0x0000000000004018 0x1 /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o - .bss 0x0000000000004019 0x0 ropex.o - .bss 0x0000000000004019 0x0 gadget.o - .bss 0x0000000000004019 0x0 /usr/lib/x86_64-linux-gnu/libc_nonshared.a(elf-init.oS) - .bss 0x0000000000004019 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o - .bss 0x0000000000004019 0x0 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o - *(COMMON) - 0x0000000000004020 . = ALIGN ((. != 0x0)?0x8:0x1) - *fill* 0x0000000000004019 0x7 - -.lbss - *(.dynlbss) - *(.lbss .lbss.* .gnu.linkonce.lb.*) - *(LARGE_COMMON) - 0x0000000000004020 . = ALIGN (0x8) - 0x0000000000004020 . = SEGMENT_START ("ldata-segment", .) - -.lrodata - *(.lrodata .lrodata.* .gnu.linkonce.lr.*) - -.ldata 0x0000000000006020 0x0 - *(.ldata .ldata.* .gnu.linkonce.l.*) - 0x0000000000006020 . = ALIGN ((. != 0x0)?0x8:0x1) - 0x0000000000006020 . = ALIGN (0x8) - 0x0000000000004020 _end = . - [!provide] PROVIDE (end = .) - 0x0000000000006020 . = DATA_SEGMENT_END (.) - -.stab - *(.stab) - -.stabstr - *(.stabstr) - -.stab.excl - *(.stab.excl) - -.stab.exclstr - *(.stab.exclstr) - -.stab.index - *(.stab.index) - -.stab.indexstr - *(.stab.indexstr) - -.comment 0x0000000000000000 0x2a - *(.comment) - .comment 0x0000000000000000 0x2a /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o - 0x2b (size before relaxing) - .comment 0x000000000000002a 0x2b ropex.o - .comment 0x000000000000002a 0x2b /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o - -.gnu.build.attributes - *(.gnu.build.attributes .gnu.build.attributes.*) - -.debug - *(.debug) - -.line - *(.line) - -.debug_srcinfo - *(.debug_srcinfo) - -.debug_sfnames - *(.debug_sfnames) - -.debug_aranges 0x0000000000000000 0x30 - *(.debug_aranges) - .debug_aranges - 0x0000000000000000 0x30 ropex.o - -.debug_pubnames - *(.debug_pubnames) - -.debug_info 0x0000000000000000 0x49e - *(.debug_info .gnu.linkonce.wi.*) - .debug_info 0x0000000000000000 0x49e ropex.o - -.debug_abbrev 0x0000000000000000 0x19b - *(.debug_abbrev) - .debug_abbrev 0x0000000000000000 0x19b ropex.o - -.debug_line 0x0000000000000000 0x188 - *(.debug_line .debug_line.* .debug_line_end) - .debug_line 0x0000000000000000 0x188 ropex.o - -.debug_frame 0x0000000000000000 0xa8 - *(.debug_frame) - .debug_frame 0x0000000000000000 0xa8 ropex.o - -.debug_str 0x0000000000000000 0x2f4 - *(.debug_str) - .debug_str 0x0000000000000000 0x2f4 ropex.o - 0x333 (size before relaxing) - -.debug_loc 0x0000000000000000 0x254 - *(.debug_loc) - .debug_loc 0x0000000000000000 0x254 ropex.o - -.debug_macinfo - *(.debug_macinfo) - -.debug_weaknames - *(.debug_weaknames) - -.debug_funcnames - *(.debug_funcnames) - -.debug_typenames - *(.debug_typenames) - -.debug_varnames - *(.debug_varnames) - -.debug_pubtypes - *(.debug_pubtypes) - -.debug_ranges - *(.debug_ranges) - -.debug_macro - *(.debug_macro) - -.debug_addr - *(.debug_addr) - -.gnu.attributes - *(.gnu.attributes) - -/DISCARD/ - *(.note.GNU-stack) - *(.gnu_debuglink) - *(.gnu.lto_*) -OUTPUT(ropex elf64-x86-64) diff --git a/Semestr 4/ask/lista9/test.c b/Semestr 4/ask/lista9/test.c deleted file mode 100644 index 1dae111..0000000 --- a/Semestr 4/ask/lista9/test.c +++ /dev/null @@ -1,7 +0,0 @@ -void foobar() {} - -static const struct { - char a[3]; int b; long c; float pi; -} baz = { "abc", 42, -3, 1.4142 }; - -long array[100]; \ No newline at end of file diff --git a/Semestr 4/ask/lista9/test.s b/Semestr 4/ask/lista9/test.s deleted file mode 100644 index 5e60585..0000000 --- a/Semestr 4/ask/lista9/test.s +++ /dev/null @@ -1,50 +0,0 @@ - .file "test.c" - .text - .globl foobar - .type foobar, @function -foobar: -.LFB0: - .cfi_startproc - endbr64 - pushq %rbp - .cfi_def_cfa_offset 16 - .cfi_offset 6, -16 - movq %rsp, %rbp - .cfi_def_cfa_register 6 - nop - popq %rbp - .cfi_def_cfa 7, 8 - ret - .cfi_endproc -.LFE0: - .size foobar, .-foobar - .section .rodata - .align 16 - .type baz, @object - .size baz, 24 -baz: - .ascii "abc" - .zero 1 - .long 42 - .quad -3 - .long 1068827777 - .zero 4 - .comm array,800,32 - .ident "GCC: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0" - .section .note.GNU-stack,"",@progbits - .section .note.gnu.property,"a" - .align 8 - .long 1f - 0f - .long 4f - 1f - .long 5 -0: - .string "GNU" -1: - .align 8 - .long 0xc0000002 - .long 3f - 2f -2: - .long 0x3 -3: - .align 8 -4: diff --git "a/Semestr 4/ask/materia\305\202y/ask21-05-machine-basics.pdf" "b/Semestr 4/ask/materia\305\202y/ask21-05-machine-basics.pdf" deleted file mode 100644 index ee8e221..0000000 Binary files "a/Semestr 4/ask/materia\305\202y/ask21-05-machine-basics.pdf" and /dev/null differ diff --git "a/Semestr 4/ask/materia\305\202y/ask21-06-machine-control.pdf" "b/Semestr 4/ask/materia\305\202y/ask21-06-machine-control.pdf" deleted file mode 100644 index b847b14..0000000 Binary files "a/Semestr 4/ask/materia\305\202y/ask21-06-machine-control.pdf" and /dev/null differ diff --git "a/Semestr 4/ask/materia\305\202y/ask21-07-machine-procedures.pdf" "b/Semestr 4/ask/materia\305\202y/ask21-07-machine-procedures.pdf" deleted file mode 100644 index 61cb028..0000000 Binary files "a/Semestr 4/ask/materia\305\202y/ask21-07-machine-procedures.pdf" and /dev/null differ diff --git "a/Semestr 4/ask/materia\305\202y/hackersdelight.pdf" "b/Semestr 4/ask/materia\305\202y/hackersdelight.pdf" deleted file mode 100644 index 9f0003f..0000000 Binary files "a/Semestr 4/ask/materia\305\202y/hackersdelight.pdf" and /dev/null differ diff --git "a/Semestr 4/ask/materia\305\202y/x64_cheatsheet.pdf" "b/Semestr 4/ask/materia\305\202y/x64_cheatsheet.pdf" deleted file mode 100644 index 3133054..0000000 Binary files "a/Semestr 4/ask/materia\305\202y/x64_cheatsheet.pdf" and /dev/null differ diff --git "a/Semestr 4/ask/materia\305\202y/x86-64-psABI-1.0.pdf" "b/Semestr 4/ask/materia\305\202y/x86-64-psABI-1.0.pdf" deleted file mode 100644 index 2a5a923..0000000 Binary files "a/Semestr 4/ask/materia\305\202y/x86-64-psABI-1.0.pdf" and /dev/null differ diff --git a/Semestr 4/ask/zadanie1/rozw.c b/Semestr 4/ask/zadanie1/rozw.c deleted file mode 100644 index 068a268..0000000 --- a/Semestr 4/ask/zadanie1/rozw.c +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -const uint64_t C[] = { - 0x5555555555555555LL, - 0x3333333333333333LL, - 0x0f0f0f0f0f0f0f0fLL, - 0x00ff00ff00ff00ffLL, - 0x0000ffff0000ffffLL, - 0x00000000ffffffffLL -}; - -uint64_t revbits(uint64_t x) { - x = ((x & C[0]) << 1) | ((x >> 1) & C[0]); - x = ((x & C[1]) << 2) | ((x >> 2) & C[1]); - x = ((x & C[2]) << 4) | ((x >> 4) & C[2]); - x = ((x & C[3]) << 8) | ((x >> 8) & C[3]); - x = ((x & C[4]) << 16) | ((x >> 16) & C[4]); - x = ((x & C[5]) << 32) | ((x >> 32) & C[5]); - return x; -} \ No newline at end of file -- cgit v1.2.3