diff --git a/20230316/add-01-O0.s b/20230316/add-01-O0.s new file mode 100644 index 0000000000000000000000000000000000000000..a96d1b4ea5434b12a65cdbb1e9328fe3721b0195 --- /dev/null +++ b/20230316/add-01-O0.s @@ -0,0 +1,40 @@ + .file "add-01.c" + .text + .section .rodata +.LC0: + .string "%llu\n" + .text + .globl main + .type main, @function +main: +.LFB0: + .cfi_startproc + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + movq %rsp, %rbp + .cfi_def_cfa_register 6 + subq $32, %rsp + movabsq $5000000000, %rax + movq %rax, -8(%rbp) + movabsq $6000000000, %rax + movq %rax, -16(%rbp) + movq -8(%rbp), %rdx + movq -16(%rbp), %rax + addq %rdx, %rax + movq %rax, -24(%rbp) + movq -24(%rbp), %rax + movq %rax, %rsi + leaq .LC0(%rip), %rax + movq %rax, %rdi + movl $0, %eax + call printf@PLT + movl $0, %eax + leave + .cfi_def_cfa 7, 8 + ret + .cfi_endproc +.LFE0: + .size main, .-main + .ident "GCC: (Debian 12.2.0-14) 12.2.0" + .section .note.GNU-stack,"",@progbits diff --git a/20230316/add-01-O1.s b/20230316/add-01-O1.s new file mode 100644 index 0000000000000000000000000000000000000000..d868f60dbe099ec66b60e9e256af951f87b9ab92 --- /dev/null +++ b/20230316/add-01-O1.s @@ -0,0 +1,26 @@ + .file "add-01.c" + .text + .section .rodata.str1.1,"aMS",@progbits,1 +.LC0: + .string "%llu\n" + .text + .globl main + .type main, @function +main: +.LFB11: + .cfi_startproc + subq $8, %rsp + .cfi_def_cfa_offset 16 + movabsq $11000000000, %rsi + leaq .LC0(%rip), %rdi + movl $0, %eax + call printf@PLT + movl $0, %eax + addq $8, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_endproc +.LFE11: + .size main, .-main + .ident "GCC: (Debian 12.2.0-14) 12.2.0" + .section .note.GNU-stack,"",@progbits diff --git a/20230316/add-01-m32-O0.s b/20230316/add-01-m32-O0.s new file mode 100644 index 0000000000000000000000000000000000000000..395a89b382648e79a47934101adc9913b2eab0df --- /dev/null +++ b/20230316/add-01-m32-O0.s @@ -0,0 +1,77 @@ + .file "add-01.c" + .text + .section .rodata +.LC0: + .string "%llu\n" + .text + .globl main + .type main, @function +main: +.LFB0: + .cfi_startproc + leal 4(%esp), %ecx + .cfi_def_cfa 1, 0 + andl $-16, %esp + pushl -4(%ecx) + pushl %ebp + movl %esp, %ebp + .cfi_escape 0x10,0x5,0x2,0x75,0 + pushl %esi + pushl %ebx + pushl %ecx + .cfi_escape 0xf,0x3,0x75,0x74,0x6 + .cfi_escape 0x10,0x6,0x2,0x75,0x7c + .cfi_escape 0x10,0x3,0x2,0x75,0x78 + subl $44, %esp + call __x86.get_pc_thunk.si + addl $_GLOBAL_OFFSET_TABLE_, %esi + movl $705032704, -32(%ebp) + movl $1, -28(%ebp) + movl $1705032704, -40(%ebp) + movl $1, -36(%ebp) + movl -32(%ebp), %ecx + movl -28(%ebp), %ebx + movl -40(%ebp), %eax + movl -36(%ebp), %edx + addl %ecx, %eax + adcl %ebx, %edx + movl %eax, -48(%ebp) + movl %edx, -44(%ebp) + subl $4, %esp + pushl -44(%ebp) + pushl -48(%ebp) + leal .LC0@GOTOFF(%esi), %eax + pushl %eax + movl %esi, %ebx + call printf@PLT + addl $16, %esp + movl $0, %eax + leal -12(%ebp), %esp + popl %ecx + .cfi_restore 1 + .cfi_def_cfa 1, 0 + popl %ebx + .cfi_restore 3 + popl %esi + .cfi_restore 6 + popl %ebp + .cfi_restore 5 + leal -4(%ecx), %esp + .cfi_def_cfa 4, 4 + ret + .cfi_endproc +.LFE0: + .size main, .-main + .section .text.__x86.get_pc_thunk.si,"axG",@progbits,__x86.get_pc_thunk.si,comdat + .globl __x86.get_pc_thunk.si + .hidden __x86.get_pc_thunk.si + .type __x86.get_pc_thunk.si, @function +__x86.get_pc_thunk.si: +.LFB1: + .cfi_startproc + movl (%esp), %esi + ret + .cfi_endproc +.LFE1: + .ident "GCC: (Debian 12.2.0-14) 12.2.0" + .section .note.GNU-stack,"",@progbits diff --git a/20230316/add-01-m32-O1.s b/20230316/add-01-m32-O1.s new file mode 100644 index 0000000000000000000000000000000000000000..c74bb19957acd0865836ded2ebbd3e07022a999e --- /dev/null +++ b/20230316/add-01-m32-O1.s @@ -0,0 +1,59 @@ + .file "add-01.c" + .text + .section .rodata.str1.1,"aMS",@progbits,1 +.LC0: + .string "%llu\n" + .text + .globl main + .type main, @function +main: +.LFB11: + .cfi_startproc + leal 4(%esp), %ecx + .cfi_def_cfa 1, 0 + andl $-16, %esp + pushl -4(%ecx) + pushl %ebp + movl %esp, %ebp + .cfi_escape 0x10,0x5,0x2,0x75,0 + pushl %ebx + pushl %ecx + .cfi_escape 0xf,0x3,0x75,0x78,0x6 + .cfi_escape 0x10,0x3,0x2,0x75,0x7c + call __x86.get_pc_thunk.bx + addl $_GLOBAL_OFFSET_TABLE_, %ebx + subl $4, %esp + pushl $2 + pushl $-1884901888 + leal .LC0@GOTOFF(%ebx), %eax + pushl %eax + call printf@PLT + addl $16, %esp + movl $0, %eax + leal -8(%ebp), %esp + popl %ecx + .cfi_restore 1 + .cfi_def_cfa 1, 0 + popl %ebx + .cfi_restore 3 + popl %ebp + .cfi_restore 5 + leal -4(%ecx), %esp + .cfi_def_cfa 4, 4 + ret + .cfi_endproc +.LFE11: + .size main, .-main + .section .text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat + .globl __x86.get_pc_thunk.bx + .hidden __x86.get_pc_thunk.bx + .type __x86.get_pc_thunk.bx, @function +__x86.get_pc_thunk.bx: +.LFB12: + .cfi_startproc + movl (%esp), %ebx + ret + .cfi_endproc +.LFE12: + .ident "GCC: (Debian 12.2.0-14) 12.2.0" + .section .note.GNU-stack,"",@progbits diff --git a/20230316/add-01.c b/20230316/add-01.c new file mode 100644 index 0000000000000000000000000000000000000000..611c63a0f30b78167731e06150475d38b568b887 --- /dev/null +++ b/20230316/add-01.c @@ -0,0 +1,11 @@ +#include <stdio.h> +#include <stdint.h> + +int main (void) +{ + uint64_t x = 5000000000; + uint64_t y = 6000000000; + uint64_t z = x + y; + printf ("%llu\n", z); + return 0; +} diff --git a/20230316/add-02.c b/20230316/add-02.c new file mode 100644 index 0000000000000000000000000000000000000000..bf5ddb39a176ba47cc390d1fbdd9cb831f0aa18e --- /dev/null +++ b/20230316/add-02.c @@ -0,0 +1,12 @@ +#include <stdio.h> +#include <stdint.h> +#include <inttypes.h> + +int main (void) +{ + uint64_t x = 5000000000; + uint64_t y = 6000000000; + uint64_t z = x + y; + printf ("%" PRIu64 "\n", z); + return 0; +} diff --git a/20230316/arrays-and-pointers-01.c b/20230316/arrays-and-pointers-01.c new file mode 100644 index 0000000000000000000000000000000000000000..0deb38558e6e21d723fa06124efd6ec4af2b2962 --- /dev/null +++ b/20230316/arrays-and-pointers-01.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char a[] = "Test"; + char *p = "Test"; + printf ("a = %s, p = %s\n", a, p); + return 0; +} diff --git a/20230316/arrays-and-pointers-02.c b/20230316/arrays-and-pointers-02.c new file mode 100644 index 0000000000000000000000000000000000000000..e5d4dce6587109634a57a0f17ac8f2b2792473a9 --- /dev/null +++ b/20230316/arrays-and-pointers-02.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char a[] = { 84, 101, 115, 116, 0 }; + char *p = "Test"; + printf ("a = %s, p = %s\n", a, p); + return 0; +} diff --git a/20230316/arrays-and-pointers-03.c b/20230316/arrays-and-pointers-03.c new file mode 100644 index 0000000000000000000000000000000000000000..7f5ee33157bd67d49ca96909decd3eb2c8edb0d4 --- /dev/null +++ b/20230316/arrays-and-pointers-03.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char a[] = { 84, 101, 115, 116, 0 }; + char *p = "Test"; + printf ("a = %s, p = %s\n", &a, &p); + return 0; +} diff --git a/20230316/arrays-and-pointers-04.c b/20230316/arrays-and-pointers-04.c new file mode 100644 index 0000000000000000000000000000000000000000..c61505046122fe08188e21a50c7510042bdf8b89 --- /dev/null +++ b/20230316/arrays-and-pointers-04.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +int main (void) +{ + char *a[] = { "Dies", "ist", "ein", "Test" }; + char **p = a; + for (int i = 0; i < 4; i++) + printf ("%s\n", p[i]); + return 0; +} diff --git a/20230316/arrays-and-pointers-05.c b/20230316/arrays-and-pointers-05.c new file mode 100644 index 0000000000000000000000000000000000000000..aa6e043074e94ef5986cbdedfab92c3d7801a3b8 --- /dev/null +++ b/20230316/arrays-and-pointers-05.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +int main (void) +{ + char *a[] = { "Dies", "ist", "ein", "Test" }; + char **p = a; + for (int i = 0; i < 4; i++) + printf ("%s\n", *p++); + return 0; +} diff --git a/20230316/arrays-and-pointers-06.c b/20230316/arrays-and-pointers-06.c new file mode 100644 index 0000000000000000000000000000000000000000..a4e2a9e0c3732e605d6a7d1f9a408c58eda8a1c7 --- /dev/null +++ b/20230316/arrays-and-pointers-06.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +int main (void) +{ + char *a[] = { "Dies", "ist", "ein", "Test" }; + char **p = a; + for (int i = 0; i < 4; i++) + printf ("%s\n", p[i]++); + return 0; +} diff --git a/20230316/arrays-and-pointers-07.c b/20230316/arrays-and-pointers-07.c new file mode 100644 index 0000000000000000000000000000000000000000..36feacff45be695197e067097c252733c078bd75 --- /dev/null +++ b/20230316/arrays-and-pointers-07.c @@ -0,0 +1,14 @@ +#include <stdio.h> + +int main (void) +{ + char *a[] = { "Dies", "ist", "ein", "Test" }; + char **p = a; + for (int i = 0; i < 4; i++) + { + char *q; + printf ("%s ", q = p[i]++); + printf ("%s\n", q); + } + return 0; +} diff --git a/20230316/arrays-and-pointers-08.c b/20230316/arrays-and-pointers-08.c new file mode 100644 index 0000000000000000000000000000000000000000..85f21b81efe29d7c91735f218c8b2499b80fab2d --- /dev/null +++ b/20230316/arrays-and-pointers-08.c @@ -0,0 +1,13 @@ +#include <stdio.h> + +int main (void) +{ + char *a[] = { "Dies", "ist", "ein", "Test" }; + char **p = a; + for (int i = 0; i < 4; i++) + { + printf ("%s ", p[i]++); + printf ("%s\n", p[i]); + } + return 0; +} diff --git a/20230316/arrays-and-pointers-09.c b/20230316/arrays-and-pointers-09.c new file mode 100644 index 0000000000000000000000000000000000000000..4ce256e0c45fa8bc79b3b838a1cbe8f9f7eadac2 --- /dev/null +++ b/20230316/arrays-and-pointers-09.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char *a[] = { "Dies", "ist", "ein", "Test" }; + for (char **p = a; p < a + 4; p++) + printf ("%s\n", *p); + return 0; +} diff --git a/20230316/arrays-and-pointers-10.c b/20230316/arrays-and-pointers-10.c new file mode 100644 index 0000000000000000000000000000000000000000..b5671bf2fe82a36aaf77a112df0227b523da8a66 --- /dev/null +++ b/20230316/arrays-and-pointers-10.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char *a[] = { "Dies", "ist", "ein", "Test", NULL }; + for (char **p = a; *p; p++) + printf ("%s\n", *p); + return 0; +} diff --git a/20230316/arrays-and-pointers-11.c b/20230316/arrays-and-pointers-11.c new file mode 100644 index 0000000000000000000000000000000000000000..6e47dd62f7d2cd7fe6468b7593aa6e02ab928118 --- /dev/null +++ b/20230316/arrays-and-pointers-11.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char a[][5] = { "Dies", "ist", "ein", "Test" }; + for (int i = 0; i < 4; i++) + printf ("%s\n", a[i]); + return 0; +} diff --git a/20230316/arrays-and-pointers-12.c b/20230316/arrays-and-pointers-12.c new file mode 100644 index 0000000000000000000000000000000000000000..2760d299577771d1201c6d2590c5fa3efda84622 --- /dev/null +++ b/20230316/arrays-and-pointers-12.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char a[][] = { "Dies", "ist", "ein", "Test" }; + for (int i = 0; i < 4; i++) + printf ("%s\n", a[i]); + return 0; +} diff --git a/20230316/arrays-and-pointers-13.c b/20230316/arrays-and-pointers-13.c new file mode 100644 index 0000000000000000000000000000000000000000..4e10b970c678531f0abe616192ea5d2a93d222ab --- /dev/null +++ b/20230316/arrays-and-pointers-13.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char a[][5] = { "Dies", "ist", "ein", "Test", "" }; + for (char *p = a; *p; p++) + printf ("%s\n", *p); + return 0; +} diff --git a/20230316/arrays-and-pointers-14.c b/20230316/arrays-and-pointers-14.c new file mode 100644 index 0000000000000000000000000000000000000000..ea91f13c60c2a086db47fee8edb52e100fe6e4a7 --- /dev/null +++ b/20230316/arrays-and-pointers-14.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char a[][5] = { "Dies", "ist", "ein", "Test", "" }; + for (char **p = a; **p; p++) + printf ("%s\n", *p); + return 0; +} diff --git a/20230316/arrays-and-pointers-15.c b/20230316/arrays-and-pointers-15.c new file mode 100644 index 0000000000000000000000000000000000000000..2ed2c866113d76ea26418f1bc0fba0cda0a264e7 --- /dev/null +++ b/20230316/arrays-and-pointers-15.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char a[][5] = { "Dies", "ist", "ein", "Test", "" }; + for (char **p = a; **p; p++) + printf ("%s\n", p); + return 0; +} diff --git a/20230316/arrays-and-pointers-16.c b/20230316/arrays-and-pointers-16.c new file mode 100644 index 0000000000000000000000000000000000000000..7863b369bc9803c4b6f316b507adc70c48fcad27 --- /dev/null +++ b/20230316/arrays-and-pointers-16.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char a[][5] = { "Dies", "ist", "ein", "Test", "" }; + for (char *p = a; *p; p++) + printf ("%s\n", p); + return 0; +} diff --git a/20230316/arrays-and-pointers-17.c b/20230316/arrays-and-pointers-17.c new file mode 100644 index 0000000000000000000000000000000000000000..4896be8a3b956944117219d213718cc5784b14b8 --- /dev/null +++ b/20230316/arrays-and-pointers-17.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int main (void) +{ + char a[][5] = { "Dies", "ist", "ein", "Test", "" }; + for (char *p = a; *p; p += 5) + printf ("%s\n", p); + return 0; +} diff --git a/20230316/arrays-and-pointers-18.c b/20230316/arrays-and-pointers-18.c new file mode 100644 index 0000000000000000000000000000000000000000..ad7c609775c791f8220da81f880500370ef6633c --- /dev/null +++ b/20230316/arrays-and-pointers-18.c @@ -0,0 +1,11 @@ +#include <stdio.h> + +typedef char string5[5]; + +int main (void) +{ + string5 a[] = { "Dies", "ist", "ein", "Test", "" }; + for (string5 *p = a; *p; p++) + printf ("%s\n", *p); + return 0; +} diff --git a/20230316/arrays-and-pointers-19.c b/20230316/arrays-and-pointers-19.c new file mode 100644 index 0000000000000000000000000000000000000000..bb4d0640f435114d07ba3a825a44228f89c07858 --- /dev/null +++ b/20230316/arrays-and-pointers-19.c @@ -0,0 +1,11 @@ +#include <stdio.h> + +typedef char string5[5]; + +int main (void) +{ + string5 a[] = { "Dies", "ist", "ein", "Test", "" }; + for (string5 *p = a; *p; p++) + printf ("%s\n", p); + return 0; +} diff --git a/20230316/arrays-and-pointers-20.c b/20230316/arrays-and-pointers-20.c new file mode 100644 index 0000000000000000000000000000000000000000..3ad7b011872d5bd2840aaa8416777fad68d11ed3 --- /dev/null +++ b/20230316/arrays-and-pointers-20.c @@ -0,0 +1,11 @@ +#include <stdio.h> + +typedef char string5[5]; + +int main (void) +{ + string5 a[] = { "Dies", "ist", "ein", "Test", "" }; + for (string5 *p = a; **p; p++) + printf ("%s\n", *p); + return 0; +} diff --git a/20230316/arrays-and-pointers-21.c b/20230316/arrays-and-pointers-21.c new file mode 100644 index 0000000000000000000000000000000000000000..b193a2f9a52e42249de9775c69c1d6d0b0c5dbd8 --- /dev/null +++ b/20230316/arrays-and-pointers-21.c @@ -0,0 +1,11 @@ +#include <stdio.h> + +typedef char string5[5]; + +int main (void) +{ + string5 *p = { "Dies", "ist", "ein", "Test", "" }; + while (**p) + printf ("%s\n", *p++); + return 0; +} diff --git a/20230316/arrays-and-pointers-21.s b/20230316/arrays-and-pointers-21.s new file mode 100644 index 0000000000000000000000000000000000000000..860def8eee6fe7b56979a8a5de831a5c3d74eb32 --- /dev/null +++ b/20230316/arrays-and-pointers-21.s @@ -0,0 +1,43 @@ + .file "arrays-and-pointers-21.c" + .text + .section .rodata +.LC0: + .string "Dies" + .string "ist" # manuell eingefügt + .string "ein" # manuell eingefügt + .string "Test" # manuell eingefügt + .text + .globl main + .type main, @function +main: +.LFB0: + .cfi_startproc + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + movq %rsp, %rbp + .cfi_def_cfa_register 6 + subq $16, %rsp + leaq .LC0(%rip), %rax + movq %rax, -8(%rbp) + jmp .L2 +.L3: + movq -8(%rbp), %rax + leaq 5(%rax), %rdx + movq %rdx, -8(%rbp) + movq %rax, %rdi + call puts@PLT +.L2: + movq -8(%rbp), %rax + movzbl (%rax), %eax + testb %al, %al + jne .L3 + movl $0, %eax + leave + .cfi_def_cfa 7, 8 + ret + .cfi_endproc +.LFE0: + .size main, .-main + .ident "GCC: (Debian 12.2.0-14) 12.2.0" + .section .note.GNU-stack,"",@progbits diff --git a/20230316/arrays-and-pointers-22.s b/20230316/arrays-and-pointers-22.s new file mode 100644 index 0000000000000000000000000000000000000000..359421ae96d84d4e7778244ac7384f46e9e8d68a --- /dev/null +++ b/20230316/arrays-and-pointers-22.s @@ -0,0 +1,44 @@ + .file "arrays-and-pointers-21.c" + .text + .section .rodata +.LC0: + .string "Dies" + .string "ist\000" # manuell eingefügt + .string "ein\000" # manuell eingefügt + .string "Test" # manuell eingefügt + .string "" # manuell eingefügt + .text + .globl main + .type main, @function +main: +.LFB0: + .cfi_startproc + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + movq %rsp, %rbp + .cfi_def_cfa_register 6 + subq $16, %rsp + leaq .LC0(%rip), %rax + movq %rax, -8(%rbp) + jmp .L2 +.L3: + movq -8(%rbp), %rax + leaq 5(%rax), %rdx + movq %rdx, -8(%rbp) + movq %rax, %rdi + call puts@PLT +.L2: + movq -8(%rbp), %rax + movzbl (%rax), %eax + testb %al, %al + jne .L3 + movl $0, %eax + leave + .cfi_def_cfa 7, 8 + ret + .cfi_endproc +.LFE0: + .size main, .-main + .ident "GCC: (Debian 12.2.0-14) 12.2.0" + .section .note.GNU-stack,"",@progbits