Skip to content

Latest commit

ย 

History

History

libasm

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
ย 
ย 

0๏ธโƒฃ1๏ธโƒฃ libasm

@42seoul : (2020.11.20 ~ 2020.12.01)

๐Ÿ“– About

  • ์ด ํ”„๋กœ์ ํŠธ๋Š” ์–ด์…ˆ๋ธ”๋ฆฌ ์–ธ์–ด๋ฅผ ๊ฐ€์ง€๊ณ  ๋ช‡ ๊ฐ€์ง€ ํ•จ์ˆ˜๋ฅผ ๊ตฌํ˜„ํ•ฉ๋‹ˆ๋‹ค.(The aim of this project is to get familiar with assembly language.)
Type Function Description
<string.h> ft_strlen.s man strlen
<string.h> ft_strdup.s man strdup
<string.h> ft_strcpy.s man strcpy
<string.h> ft_strcmp.s man strcmp
<fcntl.h> ft_write.s man write
<fcntl.h> ft_open.s man open
  • write, read ํ•จ์ˆ˜๋Š” systemcall ํ˜ธ์ถœํ•˜๊ณ  error ๋ฐœ์ƒ ์‹œ __error ํ˜ธ์ถœํ•˜์—ฌ errno๋ฅผ ์ €์žฅํ•˜๊ณ  ๋๋‚ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

๐Ÿ“ Review

  • assembly language๋ฅผ ๊ฒฝํ—˜ํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค.
  • Computer-Achitecture ์Šคํ„ฐ๋””๋„ ํ•จ๊ป˜ ์ง„ํ–‰ํ–ˆ๋‹ค.
  • CPU, ๋ ˆ์ง€์Šคํ„ฐ, Stack ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ์ดํ•ดํ•˜๊ฒŒ ๋˜์—ˆ๊ณ  read, writeํ•จ์ˆ˜๋ฅผ ๊ตฌํ˜„ํ•˜๋ฉด์„œ ๊ฐ๊ฐ์˜ ์‹œ์Šคํ…œ์ฝœ ๋ฒˆํ˜ธ๋ฅผ ํ˜ธ์ถœํ•˜๋ฉด ์ปค๋„๋ชจ๋“œ๋กœ ๋ณ€๊ฒฝ ๋˜๋ฉฐ sys_open() ์ปค๋„ ํ•จ์ˆ˜๊ฐ€ ํ˜ธ์ถœ๋˜๊ณ  ํ•จ์ˆ˜๊ฐ€ ๋๋‚˜๋ฉด ๋‹ค์‹œ ์‚ฌ์šฉ์ž ๋ชจ๋“œ๋กœ ๋ฐ”๋€Œ๊ณ  ๊ฒฐ๊ณผ๊ฐ€ ๋ฆฌํ„ด๋œ๋‹ค. ์ด๋•Œ ์‹œ์Šคํ…œ์ฝœ์ด ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜๋ฉด ์บ๋ฆฌํ”Œ๋ž˜๊ทธ๊ฐ€ ๋ฐœ์ƒ๋˜๊ณ  rax ๋ ˆ์ง€์Šคํ„ฐ์— errno๊ฐ€ ๋“ค์–ด์žˆ๋‹ค. ์ด๊ฒƒ์„ __error๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ error๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ๋ณ€์ˆ˜์— rax ๊ฒฐ๊ณผ๋ฅผ ์ €์žฅํ•œ ๋’ค ์ตœ์ข…์ ์œผ๋กœ -1์„ ๋ฆฌํ„ดํ•˜๊ณ  ์ข…๋ฃŒ๋œ๋‹ค.
  • Level 0 ํ”„๋กœ์ ํŠธ Libft์—์„œ ๋งŒ๋“ค์—ˆ๋˜ ft_strlen๊ณผ Libc์˜ strlen ๋ฒค์น˜๋งˆํฌ ๊ฒฐ๊ณผ ์™„ํŒจํ–ˆ๋Š”๋ฐ ๊ทธ ์ด์œ ๊ฐ€ ์–ด์…ˆ๋ธ”๋ฆฌ ๋‹จ์—์„œ ์ตœ์ ํ™” ๊ณผ์ •์„ ๊ฑฐ์ณค๊ธฐ ๋•Œ๋ฌธ์ด์ง€ ์•Š์„๊นŒ ํ•œ๋‹ค.

๐Ÿ Run

  • Assembly Env
    • nasm compiler
    • x86_64 macos
    • intel
  • Unit-test : Libc - ์–ด์…ˆ๋ธ”๋ฆฌ ๊ตฌํ˜„ ํ•จ์ˆ˜ ๋น„๊ต libasm

โ”œโ”€โ”€ Makefile
โ”œโ”€โ”€ ft_read.s
โ”œโ”€โ”€ ft_strcmp.s
โ”œโ”€โ”€ ft_strcpy.s
โ”œโ”€โ”€ ft_strdup.s
โ”œโ”€โ”€ ft_strlen.s
โ”œโ”€โ”€ ft_write.s
โ”œโ”€โ”€ libasm.h
โ””โ”€โ”€ main.c


๐Ÿ”— Reference

๐Ÿง‘๐Ÿปโ€๐Ÿ’ป Author

kukim