Program Rakitan Pertama Anda
Siapkan lingkungan pengembangan Anda dan tulis, rakit, tautkan, lalu jalankan program x86 Assembly sederhana 'Hello, World!'.
Program Rakitan Pertama Anda adalah pelajaran Assembly Language & x86 Low-Level Systems Programming gratis di CoddyKit. Ini adalah pelajaran 3 dari 4. Kamu bisa membaca pelajaran lengkapnya di bawah secara gratis — lalu praktikkan langsung di browser dengan editor kode bawaan dan tutor AI 24/7. Ini adalah bagian dari jalur belajar Assembly Language & x86 Low-Level Systems Programming, dan progresmu tersinkronisasi di web dan aplikasi CoddyKit. Kursus Assembly Language & x86 Low-Level Systems Programming mencakup 4 pelajaran total.
Bagian dari pelajaran ini belum diterjemahkan dan ditampilkan dalam bahasa Inggris.
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 $ - msgSystem 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 callEnding 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 callYour 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 callFrom 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.oCreating 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 helloExecute and See the Output!
Now run it with ./hello. "Hello, World!" prints to your console — congratulations, you just ran your first x86 assembly program!
./helloQuick 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.
Pertanyaan yang Sering Diajukan
Apakah pelajaran “Program Rakitan Pertama Anda” gratis?
Ya — teks lengkap “Program Rakitan Pertama Anda” gratis dibaca di sini di web. Untuk praktiknya secara interaktif (editor kode bawaan dan tutor AI 24/7) dan buka sisa kursus Assembly Language & x86 Low-Level Systems Programming, upgrade ke CoddyKit PRO. Kursus Assembly Language & x86 Low-Level Systems Programming mencakup 4 pelajaran total.
Apa yang akan aku pelajari di “Program Rakitan Pertama Anda”?
Siapkan lingkungan pengembangan Anda dan tulis, rakit, tautkan, lalu jalankan program x86 Assembly sederhana 'Hello, World!'. Kamu berlatih Assembly Language & x86 Low-Level Systems Programming dengan kode praktik yang langsung kamu jalankan di browser, dan tutor AI 24/7 menjawab pertanyaanmu saat kamu mengerjakan pelajaran ini.
Apakah aku perlu pengalaman untuk memulai Assembly Language & x86 Low-Level Systems Programming?
Tidak diperlukan pengalaman sebelumnya. Assembly Language & x86 Low-Level Systems Programming di CoddyKit dirancang untuk pemula hingga pelajar tingkat lanjut, jadi kamu bisa memulai di sini atau dari awal dan belajar sesuai kecepatan kamu sendiri. Ini adalah pelajaran 3 dari 4.
Berapa lama pelajaran “Program Rakitan Pertama Anda” memakan waktu?
Sebagian besar pelajaran CoddyKit memakan waktu sekitar 5–10 menit. Setiap pelajaran ringkas dan interaktif, jadi kamu membuat kemajuan stabil dan melanjutkan dari tempat kamu tinggalkan di web dan aplikasi.
Bisakah aku menulis dan menjalankan kode dalam pelajaran Assembly Language & x86 Low-Level Systems Programming ini?
Ya. Setiap pelajaran Assembly Language & x86 Low-Level Systems Programming menyertakan editor kode bawaan, jadi kamu menulis dan menjalankan kode nyata langsung di browser dan mendapatkan umpan balik AI instan — tidak diperlukan penyiapan lokal.
Semua pelajaran dalam kursus ini
- Apa Itu Bahasa Rakitan?
- Dasar-Dasar Arsitektur x86
- Program Rakitan Pertama Anda
- Rantai Alat Perakitan, Penautan, dan Penjalanan