0Pricing
Assembly Language & x86 Low-Level Systems Programming · レッスン

初めてのアセンブリプログラム

開発環境をセットアップし、x86アセンブリで簡単な「Hello, World!」プログラムを記述、アセンブル、リンク、実行します。

「初めてのアセンブリプログラム」はCoddyKit上の無料Assembly Language & x86 Low-Level Systems Programmingレッスンです。 これはレッスン3/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはAssembly Language & x86 Low-Level Systems Programming学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Assembly Language & x86 Low-Level Systems Programmingコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

Your First Assembly Program

Time to go hands-on: you will set up the tools, write a "Hello, World!" in assembly, and turn it into a runnable executable. This is the fun part.

Get Ready: Assembler & Linker

You need two tools: an assembler (we use NASM) to make an object file, and a linker (LD) to turn that into a runnable program.

Anatomy of an Assembly Program

An assembly program splits into sections. .data holds initialized data like strings; .text holds your instructions, starting at _start.

Storing "Hello, World!"

Store the message in .data. The db directive defines bytes; we add a newline (0xA) and compute the length right after.

section .data
    msg db 'Hello, World!', 0xA
    len equ $ - msg

System Calls: Printing Text

To print, ask the OS via a system call. On Linux that is sys_write (number 1): you pass the output, the address, and the byte count.

section .text
    global _start

_start:
    ; sys_write (syscall number 1)
    mov rax, 1         ; syscall number for sys_write
    mov rdi, 1         ; file descriptor 1 (stdout)
    mov rsi, msg       ; address of the string to write
    mov rdx, len       ; number of bytes to write
    syscall            ; execute the system call

Ending Our Program (Syscall)

When done, the program must tell the OS to stop with a second syscall: sys_exit (number 60), passing an exit status — 0 means success.

    ; sys_exit (syscall number 60)
    mov rax, 60        ; syscall number for sys_exit
    mov rdi, 0         ; exit status 0 (success)
    syscall            ; execute the system call

Your First Full Program!

Here is the full "Hello, World!" — save it as hello.asm. The .data section holds the message, .text prints it and exits.

section .data
    msg db 'Hello, World!', 0xA
    len equ $ - msg

section .text
    global _start

_start:
    ; sys_write (syscall number 1)
    mov rax, 1         ; syscall number for sys_write
    mov rdi, 1         ; file descriptor 1 (stdout)
    mov rsi, msg       ; address of the string to write
    mov rdx, len       ; number of bytes to write
    syscall            ; execute the system call

    ; sys_exit (syscall number 60)
    mov rax, 60        ; syscall number for sys_exit
    mov rdi, 0         ; exit status 0 (success)
    syscall            ; execute the system call

From Assembly to Object File

First, assemble: nasm -f elf64 turns hello.asm into the object file hello.o — machine code, but not yet an executable.

nasm -f elf64 hello.asm -o hello.o

Creating the Executable

The object file isn't runnable yet. The linker (ld) wires up the _start entry point and produces the final executable.

ld hello.o -o hello

Execute and See the Output!

Now run it with ./hello. "Hello, World!" prints to your console — congratulations, you just ran your first x86 assembly program!

./hello

Quick Check: Process Steps

You've seen the full process to create an executable from assembly code. What is the correct order of steps?

Recap: Your First Assembly Program

You ran the full workflow: define data, call sys_write and sys_exit, then assemble, link, and execute. Next: registers and data types.

よくある質問

「初めてのアセンブリプログラム」レッスンは無料ですか?

はい。「初めてのアセンブリプログラム」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Assembly Language & x86 Low-Level Systems Programmingコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Assembly Language & x86 Low-Level Systems Programmingコースには全4レッスンが含まれています。

「初めてのアセンブリプログラム」で何を学びますか?

開発環境をセットアップし、x86アセンブリで簡単な「Hello, World!」プログラムを記述、アセンブル、リンク、実行します。 ブラウザで直接実行するハンズオンコードでAssembly Language & x86 Low-Level Systems Programmingを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Assembly Language & x86 Low-Level Systems Programmingを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのAssembly Language & x86 Low-Level Systems Programmingは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン3/4です。

「初めてのアセンブリプログラム」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このAssembly Language & x86 Low-Level Systems Programmingレッスンでコードを書いて実行できますか?

はい。すべてのAssembly Language & x86 Low-Level Systems Programmingレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. アセンブリ言語とは
  2. x86アーキテクチャの基礎
  3. 初めてのアセンブリプログラム
  4. アセンブル・リンク・実行ツールチェーン
← Assembly Language & x86 Low-Level Systems Programmingに戻る