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

Beispiele und Screenshot 14.11.2024

parent c5c04b61
No related branches found
No related tags found
No related merge requests found
Showing
with 284 additions and 0 deletions
#include <stdio.h>
int main (void)
{
int prime[15] = { 2, 3, 5, 7, 11, 0 };
for (int *p = prime; *p; p++)
printf ("%d\n", *p);
return 0;
}
#include <stdio.h>
int main (void)
{
int prime[5] = { 2, 3, 5, 7, 11, 0 };
for (int *p = prime; *p; p++)
printf ("%d\n", *p);
return 0;
}
#include <stdio.h>
int main (void)
{
int prime[15] = { 2, 3, 5, 7, 11, 0, [14] 13 };
for (int *p = prime; p < prime + 15; p++)
printf ("%d\n", *p);
return 0;
}
#include <stdio.h>
int main (void)
{
int prime[15] = {};
for (int *p = prime; p < prime + 15; p++)
printf ("%d\n", *p);
return 0;
}
.file "arrays-04.c"
.text
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "%d\n"
.section .text.startup,"ax",@progbits
.p2align 4
.globl main
.type main, @function
main:
.LFB11:
.cfi_startproc
pushq %r12
.cfi_def_cfa_offset 16
.cfi_offset 12, -16
pxor %xmm0, %xmm0
leaq .LC0(%rip), %r12
pushq %rbp
.cfi_def_cfa_offset 24
.cfi_offset 6, -24
pushq %rbx
.cfi_def_cfa_offset 32
.cfi_offset 3, -32
subq $64, %rsp
.cfi_def_cfa_offset 96 ; #include <stdio.h>
movaps %xmm0, 32(%rsp) ;
movq %rsp, %rbx ; int main (void)
leaq 60(%rsp), %rbp ; {
movaps %xmm0, (%rsp) ; int prime[15] = {};
movaps %xmm0, 16(%rsp) ; for (int *p = prime; p < prime + 15; p++)
movups %xmm0, 44(%rsp) ; printf ("%d\n", *p);
.p2align 4,,10 ; return 0;
.p2align 3 ; }
.L2:
movl (%rbx), %esi
movq %r12, %rdi
xorl %eax, %eax
addq $4, %rbx
call printf@PLT
cmpq %rbp, %rbx
jne .L2
addq $64, %rsp
.cfi_def_cfa_offset 32
xorl %eax, %eax
popq %rbx
.cfi_def_cfa_offset 24
popq %rbp
.cfi_def_cfa_offset 16
popq %r12
.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
#include <stdio.h>
int main (void)
{
int prime[15]; /* FALSCH: Array wird nicht initalisiert, aber ausgegeben! */
for (int *p = prime; p < prime + 15; p++)
printf ("%d\n", *p);
return 0;
}
.file "arrays-05.c"
.text
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "%d\n"
.section .text.startup,"ax",@progbits
.p2align 4
.globl main
.type main, @function
main:
.LFB11:
.cfi_startproc
pushq %r12
.cfi_def_cfa_offset 16
.cfi_offset 12, -16
leaq .LC0(%rip), %r12
pushq %rbp
.cfi_def_cfa_offset 24
.cfi_offset 6, -24
pushq %rbx
.cfi_def_cfa_offset 32
.cfi_offset 3, -32
subq $64, %rsp
.cfi_def_cfa_offset 96
movq %rsp, %rbx ; #include <stdio.h>
leaq 60(%rsp), %rbp ;
.p2align 4,,10 ; int main (void)
.p2align 3 ; {
.L2: ; int prime[15];
movl (%rbx), %esi ; for (int *p = prime; p < prime + 15; p++)
movq %r12, %rdi ; printf ("%d\n", *p);
xorl %eax, %eax ; return 0;
addq $4, %rbx ; }
call printf@PLT
cmpq %rbp, %rbx
jne .L2
addq $64, %rsp
.cfi_def_cfa_offset 32
xorl %eax, %eax
popq %rbx
.cfi_def_cfa_offset 24
popq %rbp
.cfi_def_cfa_offset 16
popq %r12
.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
#include <stdio.h>
int main (void)
{
int prime;
printf ("%d\n", prime);
return 0;
}
#include <stdio.h>
int main (void)
{
int prime[15] = {1};
for (int *p = prime; p < prime + 15; p++)
printf ("%d\n", *p);
return 0;
}
#include <stdio.h>
int main (void)
{
char hello[] = "Hello, world!\n";
for (char *p = hello; *p; p++)
printf ("%d", *p);
return 0;
}
#include <stdio.h>
int main (void)
{
char hello[] = "Hello, world!\n";
for (char *p = hello; *p; p++)
printf ("%c", *p);
return 0;
}
#include <stdio.h>
int main (void)
{
char hello[] = { 72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33, 10, 0 };
for (char *p = hello; *p; p++)
printf ("%c", *p);
return 0;
}
#include <stdio.h>
int main (void)
{
char *hello = { 72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33, 10, 0 };
for (char *p = hello; *p; p++)
printf ("%c", *p);
return 0;
}
#include <stdio.h>
int main (void)
{
char x[] = { 72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33, 10, 0 };
char *hello = x;
for (char *p = hello; *p; p++)
printf ("%c", *p);
return 0;
}
#include <stdio.h>
int main (void)
{
char hello[] = { 72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33, 10, 0 };
printf ("%s", hello);
return 0;
}
#include <stdio.h>
int main (void)
{
char hello[] = "Hello, world!\n";
printf ("%s", hello);
return 0;
}
#include <stdio.h>
int main (void)
{
char *hello = "Hello, world!\n";
printf ("%s", hello);
return 0;
}
cassini/home/peter/bo/2024ws/hp/20241114> cat strings-09.c
#include <stdio.h>
int main (void)
{
char hello[] = "Hello!\n";
hello[1] = 'a';
printf ("%s", hello);
return 0;
}
cassini/home/peter/bo/2024ws/hp/20241114> gcc -Wall -O strings-09.c -o strings-09
cassini/home/peter/bo/2024ws/hp/20241114> ./strings-09
Hallo!
cassini/home/peter/bo/2024ws/hp/20241114> cat strings-10.c
#include <stdio.h>
int main (void)
{
char *hello = "Hello!\n";
hello[1] = 'a';
printf ("%s", hello);
return 0;
}
cassini/home/peter/bo/2024ws/hp/20241114> gcc -Wall -O strings-10.c -o strings-10
cassini/home/peter/bo/2024ws/hp/20241114> ./strings-10
Speicherzugriffsfehler
cassini/home/peter/bo/2024ws/hp/20241114>
#include <stdio.h>
int main (void)
{
char hello[] = "Hello!\n";
hello[1] = 'a';
printf ("%s", hello);
return 0;
}
#include <stdio.h>
int main (void)
{
char *hello = "Hello!\n";
hello[1] = 'a';
printf ("%s", hello);
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment