Wave 언어로 직접 Hello World 출력하기: Bare-metal 환경에서의 시스템 호출 이해
🤖 AI 추천
Wave 언어의 동작 방식과 저수준 프로그래밍, 컴파일러의 역할에 관심 있는 모든 개발자에게 유용합니다. 특히 시스템 프로그래밍, 임베디드 개발, 언어 설계에 관심 있는 개발자에게 추천합니다.
🔖 주요 키워드

핵심 기술
Wave 언어는 표준 라이브러리 없이 'Hello World'를 출력하기 위해 인라인 어셈블리를 활용하여 시스템 호출(syscall)을 직접 구현하는 방법을 상세히 설명합니다. 이는 언어의 저수준 동작과 시스템과의 상호작용을 이해하는 데 중점을 둡니다.
기술적 세부사항
- Wave 언어의 제약: 표준 함수
println()
,print()
가 임시적이며, 공식적으로 지원되는 빌트인 함수는import()
뿐입니다. bare-metal 환경에서는 표준 라이브러리 사용이 불가합니다. - 인라인 어셈블리 (
asm {}
): Wave는 인라인 어셈블리를 지원하며, 이는 CPU별 어셈블리 코드를 직접 작성할 수 있게 합니다.in("register") value
: Wave 변수를 지정된 레지스터로 로드합니다. (예:rdi
는 syscall의 첫 번째 인자).out("register") variable
: 레지스터의 값을 Wave 변수에 할당합니다. (예:rax
는 syscall 반환 값을 저장).
- 시스템 호출 구현:
x86-64
아키텍처에서write
syscall (번호 1)을 사용하여 "Hello World" 문자열과 개행 문자를 표준 출력(file descriptor 1)으로 보냅니다.mov rax, 1
: syscall 번호를rax
에 로드합니다.in("rdi") 1
: 파일 디스크립터 (stdout)를rdi
에 설정합니다.in("rsi") s
: 출력할 문자열 주소를rsi
에 설정합니다.in("rdx") l
: 출력할 문자열 길이를rdx
에 설정합니다.
- 문자열 길이 측정 함수 (
len
): null 종료 문자열의 길이를 계산하는 사용자 정의len
함수를 구현합니다. - 출력 함수 (
println_s
):len
함수와 인라인 어셈블리를 사용하여 "Hello World" 및 개행 문자를 출력하는println_s
함수를 정의합니다. import()
함수: 외부 Wave 파일에서 함수를 로드하는 데 사용됩니다.- 버전 호환성:
v0.1.3-pre-beta-nightly-2025-07-11
이상 버전에서 테스트되었습니다.
📚 관련 자료
wave-language
The official repository for the Wave programming language. This is the primary source for understanding the language's syntax, compiler, and core features discussed in the article, including inline assembly and its standard library limitations.
관련도: 95%
osdev-wiki
A comprehensive resource for operating system development. While not specific to Wave, it provides in-depth knowledge about bare-metal programming, bootloaders, and system calls on various architectures, which are foundational concepts for implementing code like the article's example.
관련도: 70%
gcc
The GNU Compiler Collection. Although Wave is a distinct language, understanding how compilers handle inline assembly, register allocation, and system integration (as demonstrated by GCC) provides valuable context for the low-level programming discussed in the article.
관련도: 50%