diff --git a/lab03/aaa b/lab03/aaa new file mode 100644 index 0000000000000000000000000000000000000000..b4de3947675361a7770d29b8982c407b0ec6b2a0 --- /dev/null +++ b/lab03/aaa @@ -0,0 +1 @@ +11 diff --git a/lab03/add b/lab03/add deleted file mode 100755 index f2d0aaaba1eee7fbf1ed109b172305b70a5d8784..0000000000000000000000000000000000000000 Binary files a/lab03/add and /dev/null differ diff --git a/lab03/add.c b/lab03/add.c index 7c112f6e523b810a96bc8c247e4722d97af6e706..74c4639dbdb2c137800bae6f13b6ec4b5881e4b7 100644 --- a/lab03/add.c +++ b/lab03/add.c @@ -1,4 +1,5 @@ #include <stdio.h> +/* 이환용 이 짰어요 */ int main() { diff --git a/lab03/add.o b/lab03/add.o new file mode 100644 index 0000000000000000000000000000000000000000..c150cb7fcb215dea0cc34fdcc630e5d0cfa5981a Binary files /dev/null and b/lab03/add.o differ diff --git a/lab03/add.s b/lab03/add.s new file mode 100644 index 0000000000000000000000000000000000000000..b0c75b5f884d3fed5176b6053009a3313f804737 --- /dev/null +++ b/lab03/add.s @@ -0,0 +1,95 @@ + .file "add.c" + .text + .section .rodata +.LC0: + .string "%d %d" +.LC1: + .string "Input Two Numbers\n" +.LC2: + .string "%d \n" + .text + .globl main + .type main, @function +main: +.LFB0: + .cfi_startproc + endbr64 + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + movq %rsp, %rbp + .cfi_def_cfa_register 6 + subq $32, %rsp + movq %fs:40, %rax + movq %rax, -8(%rbp) + xorl %eax, %eax + movl $0, -12(%rbp) +.L7: + leaq -16(%rbp), %rdx + leaq -20(%rbp), %rax + movq %rax, %rsi + leaq .LC0(%rip), %rdi + movl $0, %eax + call __isoc99_scanf@PLT + movl %eax, -12(%rbp) + cmpl $-1, -12(%rbp) + je .L10 + movl -20(%rbp), %eax + cmpl $9999, %eax + je .L11 + cmpl $2, -12(%rbp) + je .L5 + movq stderr(%rip), %rax + movq %rax, %rcx + movl $18, %edx + movl $1, %esi + leaq .LC1(%rip), %rdi + call fwrite@PLT + jmp .L6 +.L5: + movl -20(%rbp), %edx + movl -16(%rbp), %eax + addl %edx, %eax + movl %eax, %esi + leaq .LC2(%rip), %rdi + movl $0, %eax + call printf@PLT +.L6: + jmp .L7 +.L10: + nop + jmp .L3 +.L11: + nop +.L3: + movl -12(%rbp), %eax + subl $2, %eax + movq -8(%rbp), %rcx + xorq %fs:40, %rcx + je .L9 + call __stack_chk_fail@PLT +.L9: + leave + .cfi_def_cfa 7, 8 + ret + .cfi_endproc +.LFE0: + .size main, .-main + .ident "GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.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/lab03/all b/lab03/all deleted file mode 100644 index 6f27d2dd34238294954c9be3ff09b43313c009d7..0000000000000000000000000000000000000000 --- a/lab03/all +++ /dev/null @@ -1,2 +0,0 @@ -STDOUT: 100 -STDERR: 100 diff --git a/lab03/errfile b/lab03/errfile deleted file mode 100644 index b22717bfa9ce890d8f5e2f9094f98499db48c1f0..0000000000000000000000000000000000000000 --- a/lab03/errfile +++ /dev/null @@ -1 +0,0 @@ -STDERR: 666 diff --git a/lab03/fadd.c b/lab03/fadd.c new file mode 100644 index 0000000000000000000000000000000000000000..db726c4a8dd26efa2ecfebcd8dd1dd7f2eaf759a --- /dev/null +++ b/lab03/fadd.c @@ -0,0 +1,4 @@ +int fadd(int a, int b) +{ + return a+b; +} diff --git a/lab03/fadd.o b/lab03/fadd.o new file mode 100644 index 0000000000000000000000000000000000000000..b9c87826c2f72e1c767bc5771a5fdfacbdb6b268 Binary files /dev/null and b/lab03/fadd.o differ diff --git a/lab03/gen b/lab03/gen deleted file mode 100755 index 814d2160f3e3e5eb848bac0ed720ebe432ac627d..0000000000000000000000000000000000000000 Binary files a/lab03/gen and /dev/null differ diff --git a/lab03/gen.c b/lab03/gen.c index 82d7d3747b80054acc435213529fe3ebdcdd7cb5..d8d28949a2662cb8099448e161050fa2fe3ece08 100644 --- a/lab03/gen.c +++ b/lab03/gen.c @@ -1,4 +1,5 @@ #include <stdio.h> +#define AA 9999 int main() { @@ -8,7 +9,7 @@ int main() while(1) { scret = scanf("%d %d", &a, &b); - if (scret == EOF || a== 9999) + if (scret == EOF || a== AA) break; printf("%d %d ", a, b); } diff --git a/lab03/gen.i b/lab03/gen.i new file mode 100644 index 0000000000000000000000000000000000000000..c2ee1cfd5c29ad18de80e1b04feaedc3d2125b13 --- /dev/null +++ b/lab03/gen.i @@ -0,0 +1,759 @@ +# 1 "gen.c" +# 1 "<built-in>" +# 1 "<command-line>" +# 31 "<command-line>" +# 1 "/usr/include/stdc-predef.h" 1 3 4 +# 32 "<command-line>" 2 +# 1 "gen.c" +# 1 "/usr/include/stdio.h" 1 3 4 +# 27 "/usr/include/stdio.h" 3 4 +# 1 "/usr/include/x86_64-linux-gnu/bits/libc-header-start.h" 1 3 4 +# 33 "/usr/include/x86_64-linux-gnu/bits/libc-header-start.h" 3 4 +# 1 "/usr/include/features.h" 1 3 4 +# 461 "/usr/include/features.h" 3 4 +# 1 "/usr/include/x86_64-linux-gnu/sys/cdefs.h" 1 3 4 +# 452 "/usr/include/x86_64-linux-gnu/sys/cdefs.h" 3 4 +# 1 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 1 3 4 +# 453 "/usr/include/x86_64-linux-gnu/sys/cdefs.h" 2 3 4 +# 1 "/usr/include/x86_64-linux-gnu/bits/long-double.h" 1 3 4 +# 454 "/usr/include/x86_64-linux-gnu/sys/cdefs.h" 2 3 4 +# 462 "/usr/include/features.h" 2 3 4 +# 485 "/usr/include/features.h" 3 4 +# 1 "/usr/include/x86_64-linux-gnu/gnu/stubs.h" 1 3 4 +# 10 "/usr/include/x86_64-linux-gnu/gnu/stubs.h" 3 4 +# 1 "/usr/include/x86_64-linux-gnu/gnu/stubs-64.h" 1 3 4 +# 11 "/usr/include/x86_64-linux-gnu/gnu/stubs.h" 2 3 4 +# 486 "/usr/include/features.h" 2 3 4 +# 34 "/usr/include/x86_64-linux-gnu/bits/libc-header-start.h" 2 3 4 +# 28 "/usr/include/stdio.h" 2 3 4 + + + + + +# 1 "/usr/lib/gcc/x86_64-linux-gnu/9/include/stddef.h" 1 3 4 +# 209 "/usr/lib/gcc/x86_64-linux-gnu/9/include/stddef.h" 3 4 + +# 209 "/usr/lib/gcc/x86_64-linux-gnu/9/include/stddef.h" 3 4 +typedef long unsigned int size_t; +# 34 "/usr/include/stdio.h" 2 3 4 + + +# 1 "/usr/lib/gcc/x86_64-linux-gnu/9/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/x86_64-linux-gnu/9/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 37 "/usr/include/stdio.h" 2 3 4 + +# 1 "/usr/include/x86_64-linux-gnu/bits/types.h" 1 3 4 +# 27 "/usr/include/x86_64-linux-gnu/bits/types.h" 3 4 +# 1 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 1 3 4 +# 28 "/usr/include/x86_64-linux-gnu/bits/types.h" 2 3 4 +# 1 "/usr/include/x86_64-linux-gnu/bits/timesize.h" 1 3 4 +# 29 "/usr/include/x86_64-linux-gnu/bits/types.h" 2 3 4 + + +typedef unsigned char __u_char; +typedef unsigned short int __u_short; +typedef unsigned int __u_int; +typedef unsigned long int __u_long; + + +typedef signed char __int8_t; +typedef unsigned char __uint8_t; +typedef signed short int __int16_t; +typedef unsigned short int __uint16_t; +typedef signed int __int32_t; +typedef unsigned int __uint32_t; + +typedef signed long int __int64_t; +typedef unsigned long int __uint64_t; + + + + + + +typedef __int8_t __int_least8_t; +typedef __uint8_t __uint_least8_t; +typedef __int16_t __int_least16_t; +typedef __uint16_t __uint_least16_t; +typedef __int32_t __int_least32_t; +typedef __uint32_t __uint_least32_t; +typedef __int64_t __int_least64_t; +typedef __uint64_t __uint_least64_t; + + + +typedef long int __quad_t; +typedef unsigned long int __u_quad_t; + + + + + + + +typedef long int __intmax_t; +typedef unsigned long int __uintmax_t; +# 141 "/usr/include/x86_64-linux-gnu/bits/types.h" 3 4 +# 1 "/usr/include/x86_64-linux-gnu/bits/typesizes.h" 1 3 4 +# 142 "/usr/include/x86_64-linux-gnu/bits/types.h" 2 3 4 +# 1 "/usr/include/x86_64-linux-gnu/bits/time64.h" 1 3 4 +# 143 "/usr/include/x86_64-linux-gnu/bits/types.h" 2 3 4 + + +typedef unsigned long int __dev_t; +typedef unsigned int __uid_t; +typedef unsigned int __gid_t; +typedef unsigned long int __ino_t; +typedef unsigned long int __ino64_t; +typedef unsigned int __mode_t; +typedef unsigned long int __nlink_t; +typedef long int __off_t; +typedef long int __off64_t; +typedef int __pid_t; +typedef struct { int __val[2]; } __fsid_t; +typedef long int __clock_t; +typedef unsigned long int __rlim_t; +typedef unsigned long int __rlim64_t; +typedef unsigned int __id_t; +typedef long int __time_t; +typedef unsigned int __useconds_t; +typedef long int __suseconds_t; + +typedef int __daddr_t; +typedef int __key_t; + + +typedef int __clockid_t; + + +typedef void * __timer_t; + + +typedef long int __blksize_t; + + + + +typedef long int __blkcnt_t; +typedef long int __blkcnt64_t; + + +typedef unsigned long int __fsblkcnt_t; +typedef unsigned long int __fsblkcnt64_t; + + +typedef unsigned long int __fsfilcnt_t; +typedef unsigned long int __fsfilcnt64_t; + + +typedef long int __fsword_t; + +typedef long int __ssize_t; + + +typedef long int __syscall_slong_t; + +typedef unsigned long int __syscall_ulong_t; + + + +typedef __off64_t __loff_t; +typedef char *__caddr_t; + + +typedef long int __intptr_t; + + +typedef unsigned int __socklen_t; + + + + +typedef int __sig_atomic_t; +# 39 "/usr/include/stdio.h" 2 3 4 +# 1 "/usr/include/x86_64-linux-gnu/bits/types/__fpos_t.h" 1 3 4 + + + + +# 1 "/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h" 1 3 4 +# 13 "/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h" 3 4 +typedef struct +{ + int __count; + union + { + unsigned int __wch; + char __wchb[4]; + } __value; +} __mbstate_t; +# 6 "/usr/include/x86_64-linux-gnu/bits/types/__fpos_t.h" 2 3 4 + + + + +typedef struct _G_fpos_t +{ + __off_t __pos; + __mbstate_t __state; +} __fpos_t; +# 40 "/usr/include/stdio.h" 2 3 4 +# 1 "/usr/include/x86_64-linux-gnu/bits/types/__fpos64_t.h" 1 3 4 +# 10 "/usr/include/x86_64-linux-gnu/bits/types/__fpos64_t.h" 3 4 +typedef struct _G_fpos64_t +{ + __off64_t __pos; + __mbstate_t __state; +} __fpos64_t; +# 41 "/usr/include/stdio.h" 2 3 4 +# 1 "/usr/include/x86_64-linux-gnu/bits/types/__FILE.h" 1 3 4 + + + +struct _IO_FILE; +typedef struct _IO_FILE __FILE; +# 42 "/usr/include/stdio.h" 2 3 4 +# 1 "/usr/include/x86_64-linux-gnu/bits/types/FILE.h" 1 3 4 + + + +struct _IO_FILE; + + +typedef struct _IO_FILE FILE; +# 43 "/usr/include/stdio.h" 2 3 4 +# 1 "/usr/include/x86_64-linux-gnu/bits/types/struct_FILE.h" 1 3 4 +# 35 "/usr/include/x86_64-linux-gnu/bits/types/struct_FILE.h" 3 4 +struct _IO_FILE; +struct _IO_marker; +struct _IO_codecvt; +struct _IO_wide_data; + + + + +typedef void _IO_lock_t; + + + + + +struct _IO_FILE +{ + int _flags; + + + char *_IO_read_ptr; + char *_IO_read_end; + char *_IO_read_base; + char *_IO_write_base; + char *_IO_write_ptr; + char *_IO_write_end; + char *_IO_buf_base; + char *_IO_buf_end; + + + char *_IO_save_base; + char *_IO_backup_base; + char *_IO_save_end; + + struct _IO_marker *_markers; + + struct _IO_FILE *_chain; + + int _fileno; + int _flags2; + __off_t _old_offset; + + + unsigned short _cur_column; + signed char _vtable_offset; + char _shortbuf[1]; + + _IO_lock_t *_lock; + + + + + + + + __off64_t _offset; + + struct _IO_codecvt *_codecvt; + struct _IO_wide_data *_wide_data; + struct _IO_FILE *_freeres_list; + void *_freeres_buf; + size_t __pad5; + int _mode; + + char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)]; +}; +# 44 "/usr/include/stdio.h" 2 3 4 +# 52 "/usr/include/stdio.h" 3 4 +typedef __gnuc_va_list va_list; +# 63 "/usr/include/stdio.h" 3 4 +typedef __off_t off_t; +# 77 "/usr/include/stdio.h" 3 4 +typedef __ssize_t ssize_t; + + + + + + +typedef __fpos_t fpos_t; +# 133 "/usr/include/stdio.h" 3 4 +# 1 "/usr/include/x86_64-linux-gnu/bits/stdio_lim.h" 1 3 4 +# 134 "/usr/include/stdio.h" 2 3 4 + + + +extern FILE *stdin; +extern FILE *stdout; +extern FILE *stderr; + + + + + + +extern int remove (const char *__filename) __attribute__ ((__nothrow__ , __leaf__)); + +extern int rename (const char *__old, const char *__new) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern int renameat (int __oldfd, const char *__old, int __newfd, + const char *__new) __attribute__ ((__nothrow__ , __leaf__)); +# 173 "/usr/include/stdio.h" 3 4 +extern FILE *tmpfile (void) ; +# 187 "/usr/include/stdio.h" 3 4 +extern char *tmpnam (char *__s) __attribute__ ((__nothrow__ , __leaf__)) ; + + + + +extern char *tmpnam_r (char *__s) __attribute__ ((__nothrow__ , __leaf__)) ; +# 204 "/usr/include/stdio.h" 3 4 +extern char *tempnam (const char *__dir, const char *__pfx) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) ; + + + + + + + +extern int fclose (FILE *__stream); + + + + +extern int fflush (FILE *__stream); +# 227 "/usr/include/stdio.h" 3 4 +extern int fflush_unlocked (FILE *__stream); +# 246 "/usr/include/stdio.h" 3 4 +extern FILE *fopen (const char *__restrict __filename, + const char *__restrict __modes) ; + + + + +extern FILE *freopen (const char *__restrict __filename, + const char *__restrict __modes, + FILE *__restrict __stream) ; +# 279 "/usr/include/stdio.h" 3 4 +extern FILE *fdopen (int __fd, const char *__modes) __attribute__ ((__nothrow__ , __leaf__)) ; +# 292 "/usr/include/stdio.h" 3 4 +extern FILE *fmemopen (void *__s, size_t __len, const char *__modes) + __attribute__ ((__nothrow__ , __leaf__)) ; + + + + +extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __attribute__ ((__nothrow__ , __leaf__)) ; + + + + + +extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf, + int __modes, size_t __n) __attribute__ ((__nothrow__ , __leaf__)); + + + + +extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf, + size_t __size) __attribute__ ((__nothrow__ , __leaf__)); + + +extern void setlinebuf (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)); + + + + + + + +extern int fprintf (FILE *__restrict __stream, + const char *__restrict __format, ...); + + + + +extern int printf (const char *__restrict __format, ...); + +extern int sprintf (char *__restrict __s, + const char *__restrict __format, ...) __attribute__ ((__nothrow__)); + + + + + +extern int vfprintf (FILE *__restrict __s, const char *__restrict __format, + __gnuc_va_list __arg); + + + + +extern int vprintf (const char *__restrict __format, __gnuc_va_list __arg); + +extern int vsprintf (char *__restrict __s, const char *__restrict __format, + __gnuc_va_list __arg) __attribute__ ((__nothrow__)); + + + +extern int snprintf (char *__restrict __s, size_t __maxlen, + const char *__restrict __format, ...) + __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 3, 4))); + +extern int vsnprintf (char *__restrict __s, size_t __maxlen, + const char *__restrict __format, __gnuc_va_list __arg) + __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 3, 0))); +# 379 "/usr/include/stdio.h" 3 4 +extern int vdprintf (int __fd, const char *__restrict __fmt, + __gnuc_va_list __arg) + __attribute__ ((__format__ (__printf__, 2, 0))); +extern int dprintf (int __fd, const char *__restrict __fmt, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); + + + + + + + +extern int fscanf (FILE *__restrict __stream, + const char *__restrict __format, ...) ; + + + + +extern int scanf (const char *__restrict __format, ...) ; + +extern int sscanf (const char *__restrict __s, + const char *__restrict __format, ...) __attribute__ ((__nothrow__ , __leaf__)); + + + + + + +extern int fscanf (FILE *__restrict __stream, const char *__restrict __format, ...) __asm__ ("" "__isoc99_fscanf") + + ; +extern int scanf (const char *__restrict __format, ...) __asm__ ("" "__isoc99_scanf") + ; +extern int sscanf (const char *__restrict __s, const char *__restrict __format, ...) __asm__ ("" "__isoc99_sscanf") __attribute__ ((__nothrow__ , __leaf__)) + + ; +# 432 "/usr/include/stdio.h" 3 4 +extern int vfscanf (FILE *__restrict __s, const char *__restrict __format, + __gnuc_va_list __arg) + __attribute__ ((__format__ (__scanf__, 2, 0))) ; + + + + + +extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg) + __attribute__ ((__format__ (__scanf__, 1, 0))) ; + + +extern int vsscanf (const char *__restrict __s, + const char *__restrict __format, __gnuc_va_list __arg) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__format__ (__scanf__, 2, 0))); + + + + +extern int vfscanf (FILE *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) __asm__ ("" "__isoc99_vfscanf") + + + + __attribute__ ((__format__ (__scanf__, 2, 0))) ; +extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg) __asm__ ("" "__isoc99_vscanf") + + __attribute__ ((__format__ (__scanf__, 1, 0))) ; +extern int vsscanf (const char *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) __asm__ ("" "__isoc99_vsscanf") __attribute__ ((__nothrow__ , __leaf__)) + + + + __attribute__ ((__format__ (__scanf__, 2, 0))); +# 485 "/usr/include/stdio.h" 3 4 +extern int fgetc (FILE *__stream); +extern int getc (FILE *__stream); + + + + + +extern int getchar (void); + + + + + + +extern int getc_unlocked (FILE *__stream); +extern int getchar_unlocked (void); +# 510 "/usr/include/stdio.h" 3 4 +extern int fgetc_unlocked (FILE *__stream); +# 521 "/usr/include/stdio.h" 3 4 +extern int fputc (int __c, FILE *__stream); +extern int putc (int __c, FILE *__stream); + + + + + +extern int putchar (int __c); +# 537 "/usr/include/stdio.h" 3 4 +extern int fputc_unlocked (int __c, FILE *__stream); + + + + + + + +extern int putc_unlocked (int __c, FILE *__stream); +extern int putchar_unlocked (int __c); + + + + + + +extern int getw (FILE *__stream); + + +extern int putw (int __w, FILE *__stream); + + + + + + + +extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream) + ; +# 603 "/usr/include/stdio.h" 3 4 +extern __ssize_t __getdelim (char **__restrict __lineptr, + size_t *__restrict __n, int __delimiter, + FILE *__restrict __stream) ; +extern __ssize_t getdelim (char **__restrict __lineptr, + size_t *__restrict __n, int __delimiter, + FILE *__restrict __stream) ; + + + + + + + +extern __ssize_t getline (char **__restrict __lineptr, + size_t *__restrict __n, + FILE *__restrict __stream) ; + + + + + + + +extern int fputs (const char *__restrict __s, FILE *__restrict __stream); + + + + + +extern int puts (const char *__s); + + + + + + +extern int ungetc (int __c, FILE *__stream); + + + + + + +extern size_t fread (void *__restrict __ptr, size_t __size, + size_t __n, FILE *__restrict __stream) ; + + + + +extern size_t fwrite (const void *__restrict __ptr, size_t __size, + size_t __n, FILE *__restrict __s); +# 673 "/usr/include/stdio.h" 3 4 +extern size_t fread_unlocked (void *__restrict __ptr, size_t __size, + size_t __n, FILE *__restrict __stream) ; +extern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size, + size_t __n, FILE *__restrict __stream); + + + + + + + +extern int fseek (FILE *__stream, long int __off, int __whence); + + + + +extern long int ftell (FILE *__stream) ; + + + + +extern void rewind (FILE *__stream); +# 707 "/usr/include/stdio.h" 3 4 +extern int fseeko (FILE *__stream, __off_t __off, int __whence); + + + + +extern __off_t ftello (FILE *__stream) ; +# 731 "/usr/include/stdio.h" 3 4 +extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos); + + + + +extern int fsetpos (FILE *__stream, const fpos_t *__pos); +# 757 "/usr/include/stdio.h" 3 4 +extern void clearerr (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)); + +extern int feof (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ; + +extern int ferror (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ; + + + +extern void clearerr_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)); +extern int feof_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ; +extern int ferror_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ; + + + + + + + +extern void perror (const char *__s); + + + + + +# 1 "/usr/include/x86_64-linux-gnu/bits/sys_errlist.h" 1 3 4 +# 26 "/usr/include/x86_64-linux-gnu/bits/sys_errlist.h" 3 4 +extern int sys_nerr; +extern const char *const sys_errlist[]; +# 782 "/usr/include/stdio.h" 2 3 4 + + + + +extern int fileno (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ; + + + + +extern int fileno_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ; +# 800 "/usr/include/stdio.h" 3 4 +extern FILE *popen (const char *__command, const char *__modes) ; + + + + + +extern int pclose (FILE *__stream); + + + + + +extern char *ctermid (char *__s) __attribute__ ((__nothrow__ , __leaf__)); +# 840 "/usr/include/stdio.h" 3 4 +extern void flockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern int ftrylockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ; + + +extern void funlockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)); +# 858 "/usr/include/stdio.h" 3 4 +extern int __uflow (FILE *); +extern int __overflow (FILE *, int); +# 873 "/usr/include/stdio.h" 3 4 + +# 2 "gen.c" 2 + + + +# 4 "gen.c" +int main() +{ + int a,b; + int scret=0; + setvbuf( +# 8 "gen.c" 3 4 + stdout +# 8 "gen.c" + , +# 8 "gen.c" 3 4 + ((void *)0) +# 8 "gen.c" + , +# 8 "gen.c" 3 4 + 1 +# 8 "gen.c" + ,5); + while(1) + { + scret = scanf("%d %d", &a, &b); + if (scret == +# 12 "gen.c" 3 4 + (-1) +# 12 "gen.c" + || a== 9999) + break; + printf("%d %d ", a, b); + } + return scret; +} diff --git a/lab03/gen.o b/lab03/gen.o new file mode 100644 index 0000000000000000000000000000000000000000..7b4804338d2218182c0d4b6d2a02ac76b7cf9dd3 Binary files /dev/null and b/lab03/gen.o differ diff --git a/lab03/gen.s b/lab03/gen.s new file mode 100644 index 0000000000000000000000000000000000000000..36d77fe3a0500405ea93f0feb4f08cda2bae5a7c --- /dev/null +++ b/lab03/gen.s @@ -0,0 +1,81 @@ + .file "gen.c" + .text + .section .rodata +.LC0: + .string "%d %d" +.LC1: + .string "%d %d " + .text + .globl main + .type main, @function +main: +.LFB0: + .cfi_startproc + endbr64 + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + movq %rsp, %rbp + .cfi_def_cfa_register 6 + subq $32, %rsp + movq %fs:40, %rax + movq %rax, -8(%rbp) + xorl %eax, %eax + movl $0, -12(%rbp) + movq stdout(%rip), %rax + movl $5, %ecx + movl $1, %edx + movl $0, %esi + movq %rax, %rdi + call setvbuf@PLT +.L3: + leaq -16(%rbp), %rdx + leaq -20(%rbp), %rax + movq %rax, %rsi + leaq .LC0(%rip), %rdi + movl $0, %eax + call __isoc99_scanf@PLT + movl %eax, -12(%rbp) + cmpl $-1, -12(%rbp) + je .L2 + movl -20(%rbp), %eax + cmpl $9999, %eax + je .L2 + movl -16(%rbp), %edx + movl -20(%rbp), %eax + movl %eax, %esi + leaq .LC1(%rip), %rdi + movl $0, %eax + call printf@PLT + jmp .L3 +.L2: + movl -12(%rbp), %eax + movq -8(%rbp), %rcx + xorq %fs:40, %rcx + je .L5 + call __stack_chk_fail@PLT +.L5: + leave + .cfi_def_cfa 7, 8 + ret + .cfi_endproc +.LFE0: + .size main, .-main + .ident "GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.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/lab03/infile b/lab03/infile deleted file mode 100644 index ebc4bdc11a2ffa4b54e6076678b2b82b36fbf520..0000000000000000000000000000000000000000 --- a/lab03/infile +++ /dev/null @@ -1 +0,0 @@ -100 200 300 diff --git a/lab03/lserr b/lab03/lserr deleted file mode 100644 index cd854aa67fdef589441b0e6e0ead2116a7b3433f..0000000000000000000000000000000000000000 --- a/lab03/lserr +++ /dev/null @@ -1,3 +0,0 @@ -ls: cannot access 'infile': No such file or directory -ls: cannot access 'infile': No such file or directory -ls: cannot access 'infile': No such file or directory diff --git a/lab03/teeout b/lab03/teeout deleted file mode 100644 index 1746327fc85690f82bb173183219c627f4b5e2aa..0000000000000000000000000000000000000000 --- a/lab03/teeout +++ /dev/null @@ -1 +0,0 @@ -200 200 300 300 \ No newline at end of file diff --git a/lab03/tlserr b/lab03/tlserr deleted file mode 100644 index 763054937edb0e0a6b2e2adac426c6d5538953e0..0000000000000000000000000000000000000000 --- a/lab03/tlserr +++ /dev/null @@ -1,4 +0,0 @@ -This is ls ERROR mew -ls: cannot access 'infile': No such file or directory -ls: cannot access 'infile': No such file or directory -ls: cannot access 'infile': No such file or directory diff --git a/lab04/func.c b/lab04/func.c new file mode 100644 index 0000000000000000000000000000000000000000..827bd92549dfb93ad61e0371ceb73cdf446db68b --- /dev/null +++ b/lab04/func.c @@ -0,0 +1,8 @@ +#include "func.h" + +int func1(int a){ + return a*10; +} +int func2(int a){ + return a*2; +} diff --git a/lab04/func.h b/lab04/func.h new file mode 100644 index 0000000000000000000000000000000000000000..65c565a2ab9ce293d4c79f24fac63a8e7284506d --- /dev/null +++ b/lab04/func.h @@ -0,0 +1,3 @@ +#define DF(a) ((a)*(a)) + +extern int func1(int x); diff --git a/lab04/func.o b/lab04/func.o new file mode 100644 index 0000000000000000000000000000000000000000..f6e39705b8e0fda6b53d4e786895527af3494730 Binary files /dev/null and b/lab04/func.o differ diff --git a/lab04/gen.c b/lab04/gen.c new file mode 100644 index 0000000000000000000000000000000000000000..392c6977a4434731157eb93f4c1a69d9cec29e28 --- /dev/null +++ b/lab04/gen.c @@ -0,0 +1,13 @@ +#include <stdio.h> +#define AA 9999 + +int main(void){ + int a,b,scanf_ret; + setvbuf(stdout,NULL,_IOLBF,5); + while(1){ + scanf_ret = scanf("%d %d",&a,&b); + if(scanf_ret == EOF || a==AA)break; + printf("%d %d\n",a,b); + } + return scanf_ret; +} diff --git a/lab04/gen.o b/lab04/gen.o new file mode 100644 index 0000000000000000000000000000000000000000..5e2d6084b4bce404bf4a853dc2c726644d82420f Binary files /dev/null and b/lab04/gen.o differ diff --git a/lab04/main.c b/lab04/main.c new file mode 100644 index 0000000000000000000000000000000000000000..0304367a0671b830ff6c5f5d734d9b07fae028b4 --- /dev/null +++ b/lab04/main.c @@ -0,0 +1,18 @@ +#include <stdio.h> +// +#include "func.h" + +extern int toBinaryString(char c[], int a); + +int Global_val = 2; + +int main() +{ + unsigned int a,b,c; + char ch[256]; + scanf("%d", &a); + printf("%d / %d\n",func1(a),DF(a)); + toBinaryString(ch, a); + printf("%s\n", ch); + return a; +} diff --git a/lab04/main.o b/lab04/main.o new file mode 100644 index 0000000000000000000000000000000000000000..84b6e0bbd8e30eb7a6543ab0caa5ddc6a921a519 Binary files /dev/null and b/lab04/main.o differ diff --git a/lab04/mem_test.c b/lab04/mem_test.c new file mode 100644 index 0000000000000000000000000000000000000000..593acd84af1082f14cb3fa2634104a08d90e315d --- /dev/null +++ b/lab04/mem_test.c @@ -0,0 +1,12 @@ +#include <stdio.h> + +int main() +{ +#ifdef __PCC_M32 + printf("CHAR: %d\n", sizeof(char)); + printf(“%d %d \n“, 100, 100); +#else + printf("CHAR: %ld\n", sizeof(char)); + printf(“%d %d \n“, 100, 100); +#endif +} diff --git a/lab04/tobin.c b/lab04/tobin.c new file mode 100644 index 0000000000000000000000000000000000000000..f23315339030ae0bc3969be506112666bea599e9 --- /dev/null +++ b/lab04/tobin.c @@ -0,0 +1,10 @@ +int toBinaryString(char buf[], int a) +{ + int i=0; + for (i=0; i< 32; i++) + { + buf[i] = a & (1<< (31-i)) ? '1' : '0'; + } + buf[i] = 0; + return 1; +} diff --git a/lab04/tobin.o b/lab04/tobin.o new file mode 100644 index 0000000000000000000000000000000000000000..9a509cc44c264891ee0fc3b22be3ab3df2ae19f0 Binary files /dev/null and b/lab04/tobin.o differ diff --git a/lab05/func.c b/lab05/func.c new file mode 100644 index 0000000000000000000000000000000000000000..827bd92549dfb93ad61e0371ceb73cdf446db68b --- /dev/null +++ b/lab05/func.c @@ -0,0 +1,8 @@ +#include "func.h" + +int func1(int a){ + return a*10; +} +int func2(int a){ + return a*2; +} diff --git a/lab05/func.h b/lab05/func.h new file mode 100644 index 0000000000000000000000000000000000000000..5f866f809f4171546c66660a952fe55411a1ae5e --- /dev/null +++ b/lab05/func.h @@ -0,0 +1,4 @@ +#pragma once +#define DF(a) ((a)*(a)) + +extern int func1(int x); diff --git a/lab05/gen.c b/lab05/gen.c new file mode 100644 index 0000000000000000000000000000000000000000..392c6977a4434731157eb93f4c1a69d9cec29e28 --- /dev/null +++ b/lab05/gen.c @@ -0,0 +1,13 @@ +#include <stdio.h> +#define AA 9999 + +int main(void){ + int a,b,scanf_ret; + setvbuf(stdout,NULL,_IOLBF,5); + while(1){ + scanf_ret = scanf("%d %d",&a,&b); + if(scanf_ret == EOF || a==AA)break; + printf("%d %d\n",a,b); + } + return scanf_ret; +} diff --git a/lab05/main.c b/lab05/main.c new file mode 100644 index 0000000000000000000000000000000000000000..a89f40ccf9790c556902085421477792ba2626d3 --- /dev/null +++ b/lab05/main.c @@ -0,0 +1,21 @@ +#include <stdio.h> +// +#include "func.h" +#include "func.h" + +extern int toBinaryString(char c[], int a); + +int Global_val = 2; + +int main() +{ + unsigned int a,b,c; + char ch[256]; + scanf("%d", &a); + printf("%d / %d\n",func1(a),DF(a)); +#if a > 100 + toBinaryString(ch, a); + printf("%s\n", ch); +#endif + return a; +} diff --git a/lab05/mem_test.c b/lab05/mem_test.c new file mode 100644 index 0000000000000000000000000000000000000000..0558c7ae0fafc418025bef59e9aa47be83aad55c --- /dev/null +++ b/lab05/mem_test.c @@ -0,0 +1,23 @@ +#include <stdio.h> +#define str(a) #a +#define astr(a) bbb ## a ## aaa + +str(Hwanyong); +astr(Hwanyong); + +int main() +{ + char buf[512] = "alskdj alkjd alksjd laksjd \ +laskjd laksjd alksjd la skjdla skdjals djal skdjlaksjd \ +laskjd laskjdl askjdla sdjals kdalskjd alskdj alksjd \ +laskdj alskdjal d asldkjl"; +#ifdef __PCC_M32 + printf("CHAR: %d\n", sizeof(char)); + printf(“%d %d \n“, 100, 100); +#else +#error THIS IS ERROR + printf("CHAR: %ld\n", sizeof(char)); + printf("%d %d \n", 100, 100); + printf("%d : %s\n", __LINE__, __FILE__); +#endif +} diff --git a/lab05/test.c b/lab05/test.c new file mode 100644 index 0000000000000000000000000000000000000000..b817fe7620ad03cf2371b0e4dbcda6f62d31546c --- /dev/null +++ b/lab05/test.c @@ -0,0 +1,21 @@ +#if 0 +100 \ +200 +/* Comment */ +300 \ +400 +A A A +#define A B +#define B 99999999 +A +B +#endif +#define HE HI +#define LLO _THERE +#define HELLO "HI THERE" +#define CAT(a,b) a##b +#define XCAT(a,b) CAT(a,b) +#define CALL(fn) fn(HE,LLO) +CAT(HE,LLO); +XCAT(HE,LLO); +CALL(CAT); diff --git a/lab05/tobin.c b/lab05/tobin.c new file mode 100644 index 0000000000000000000000000000000000000000..f23315339030ae0bc3969be506112666bea599e9 --- /dev/null +++ b/lab05/tobin.c @@ -0,0 +1,10 @@ +int toBinaryString(char buf[], int a) +{ + int i=0; + for (i=0; i< 32; i++) + { + buf[i] = a & (1<< (31-i)) ? '1' : '0'; + } + buf[i] = 0; + return 1; +} diff --git a/lab06/const_test.c b/lab06/const_test.c new file mode 100644 index 0000000000000000000000000000000000000000..a2d04b0b9e8fdef33387f72d04b0d6ae8ec93256 --- /dev/null +++ b/lab06/const_test.c @@ -0,0 +1,16 @@ +#include <stdio.h> + +int main() +{ + int a[2] = {10,10}; + int const * b = a; + + a[0] = 200; + *b = 300; + b = &a[1]; + + printf("%d %d\n",a[0],a[1]); +} + +// 10 10 +// 0x7fffb2841630 10 0x7fffb2841628 8 diff --git a/lab07/funcp.c b/lab07/funcp.c new file mode 100644 index 0000000000000000000000000000000000000000..a329069de79995092ede5c6c3e3cd8ba7365936a --- /dev/null +++ b/lab07/funcp.c @@ -0,0 +1,36 @@ +#include <stdio.h> + +int add(int a, int b) +{ + return a+b; +} + +int mul (int a, int b) +{ + return a*b; +} +int sq (float a) +{ + return (int) (a*a); +} + +int main() +{ + char op; + int a,b; + int fnum=0; + + int (*ff[3])() = {add, mul, sq}; + + + scanf("%c %d %d", &op, &a, &b); + if (op =='+') + fnum = 0; + else if (op == '*') + fnum = 1; + else + fnum = 2; + printf("%d\n", ff[fnum](a,b)); + return 0; +} + diff --git a/lab07/po2.c b/lab07/po2.c new file mode 100644 index 0000000000000000000000000000000000000000..c6f770ee70cbac21123ad564041de4b275fc20c8 --- /dev/null +++ b/lab07/po2.c @@ -0,0 +1,19 @@ +#include <stdio.h> +#include <stdlib.h> +int func(int **p) +{ + printf("Func: %p %p %p\n",*p, p, &p); + *p = (int *) malloc(8); + (*p)[0] = 500; + printf("Func:%d %p %p %p\n",**p, *p, p, &p); + return 0; +} + +int main() +{ + int *ppp=NULL; + printf("Main:%p %p\n", ppp, &ppp); + func (&ppp); + printf("Main:%d %p %p\n",*ppp, ppp, &ppp); + return 0; +} diff --git a/lab07/pointer.c b/lab07/pointer.c new file mode 100644 index 0000000000000000000000000000000000000000..18216acf88bad8f311b0622d859bb823b3d3dd6e --- /dev/null +++ b/lab07/pointer.c @@ -0,0 +1,22 @@ +#include <stdio.h> +int func(int a) +{ + static int counter = 0; + int b = 999; + int c = 1000; + counter++; + fprintf(stderr,"func(): %d %p %p %p %p\n", counter, &counter, &a, &b,&c); + if (counter < 10) + func(counter); + return a * 10; +} + +int main() +{ + int z = 200; + int a[2] = {10,10}; + int *a0; + a0 = &a[0]; + printf("%p %p %p\n", a0, &a, &a0); +} +