diff --git a/20220607/calls-01.c b/20220607/calls-01.c new file mode 100644 index 0000000000000000000000000000000000000000..c585c1f89ddadd3a8ee28d10f73177b81cec8f3e --- /dev/null +++ b/20220607/calls-01.c @@ -0,0 +1,19 @@ +#include <stdio.h> + +void setup (void) +{ + printf ("Hello, world!\n"); +} + +void loop (void) +{ + printf (":-) "); +} + +int main (void) +{ + setup (); + while (1) + loop (); + return 0; +} diff --git a/20220607/calls-01.s b/20220607/calls-01.s new file mode 100644 index 0000000000000000000000000000000000000000..3f3bd2ead4aea915b1f90de9ed28346eff2e7d87 --- /dev/null +++ b/20220607/calls-01.s @@ -0,0 +1,57 @@ + .file "calls-01.c" + .text + .section .rodata.str1.1,"aMS",@progbits,1 +.LC0: + .string "Hello, world!" + .text + .globl setup + .type setup, @function +setup: +.LFB11: + .cfi_startproc + subq $8, %rsp + .cfi_def_cfa_offset 16 + leaq .LC0(%rip), %rdi + call puts@PLT + addq $8, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_endproc +.LFE11: + .size setup, .-setup + .section .rodata.str1.1 +.LC1: + .string ":-) " + .text + .globl loop + .type loop, @function +loop: +.LFB12: + .cfi_startproc + subq $8, %rsp + .cfi_def_cfa_offset 16 + leaq .LC1(%rip), %rdi + movl $0, %eax + call printf@PLT + addq $8, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_endproc +.LFE12: + .size loop, .-loop + .globl main + .type main, @function +main: +.LFB13: + .cfi_startproc + subq $8, %rsp + .cfi_def_cfa_offset 16 + call setup +.L6: + call loop + jmp .L6 + .cfi_endproc +.LFE13: + .size main, .-main + .ident "GCC: (Debian 8.3.0-6) 8.3.0" + .section .note.GNU-stack,"",@progbits diff --git a/20220607/calls-02.c b/20220607/calls-02.c new file mode 100644 index 0000000000000000000000000000000000000000..e8a3f3d3b9b854e5061c912dc3fefac6878c27a4 --- /dev/null +++ b/20220607/calls-02.c @@ -0,0 +1,13 @@ +#include <stdio.h> + +void hello (void) +{ + for (int i = 0; i < 10; i++) + puts ("Hello, world!"); +} + +int main (void) +{ + hello (); + return 0; +} diff --git a/20220607/calls-02.s b/20220607/calls-02.s new file mode 100644 index 0000000000000000000000000000000000000000..dcecbd04f7b2fcba94dcbade4cfbb4a0ae424471 --- /dev/null +++ b/20220607/calls-02.s @@ -0,0 +1,53 @@ + .file "calls-02.c" + .text + .section .rodata.str1.1,"aMS",@progbits,1 +.LC0: + .string "Hello, world!" + .text + .globl hello + .type hello, @function +hello: +.LFB11: + .cfi_startproc + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + pushq %rbx + .cfi_def_cfa_offset 24 + .cfi_offset 3, -24 + subq $8, %rsp + .cfi_def_cfa_offset 32 + movl $10, %ebx + leaq .LC0(%rip), %rbp +.L2: + movq %rbp, %rdi + call puts@PLT + subl $1, %ebx + jne .L2 + addq $8, %rsp + .cfi_def_cfa_offset 24 + popq %rbx + .cfi_def_cfa_offset 16 + popq %rbp + .cfi_def_cfa_offset 8 + ret + .cfi_endproc +.LFE11: + .size hello, .-hello + .globl main + .type main, @function +main: +.LFB12: + .cfi_startproc + subq $8, %rsp + .cfi_def_cfa_offset 16 + call hello + movl $0, %eax + addq $8, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_endproc +.LFE12: + .size main, .-main + .ident "GCC: (Debian 8.3.0-6) 8.3.0" + .section .note.GNU-stack,"",@progbits diff --git a/20220607/calls-03.c b/20220607/calls-03.c new file mode 100644 index 0000000000000000000000000000000000000000..dd84b2a3e2ad0a8c59d50adb897363c24e7492cf --- /dev/null +++ b/20220607/calls-03.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +int main (void) +{ + char name[10]; + printf ("Ihr Name: "); + gets (name); + printf ("Hallo, %s! :-)\n", name); + return 0; +} diff --git a/20220607/calls-04.c b/20220607/calls-04.c new file mode 100644 index 0000000000000000000000000000000000000000..10f8b3c218e43cbc1d2ec329e0629c6346197ab5 --- /dev/null +++ b/20220607/calls-04.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +int main (void) +{ + char name[10]; + printf ("Ihr Name: "); + fgets (name, 9, stdin); + printf ("Hallo, %s! :-)\n", name); + return 0; +}