Skip to content
Snippets Groups Projects
Commit 8e60d9ec authored by Peter Gerwinski's avatar Peter Gerwinski
Browse files

Beispiel-Programme 7.6.2022

parent ab3c5fe0
Branches
Tags
No related merge requests found
#include <stdio.h>
void setup (void)
{
printf ("Hello, world!\n");
}
void loop (void)
{
printf (":-) ");
}
int main (void)
{
setup ();
while (1)
loop ();
return 0;
}
.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
#include <stdio.h>
void hello (void)
{
for (int i = 0; i < 10; i++)
puts ("Hello, world!");
}
int main (void)
{
hello ();
return 0;
}
.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
#include <stdio.h>
int main (void)
{
char name[10];
printf ("Ihr Name: ");
gets (name);
printf ("Hallo, %s! :-)\n", name);
return 0;
}
#include <stdio.h>
int main (void)
{
char name[10];
printf ("Ihr Name: ");
fgets (name, 9, stdin);
printf ("Hallo, %s! :-)\n", name);
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment