Pierwszy program w asemblerze
Skonfiguruj środowisko programistyczne oraz napisz, zassembluj, zlinkuj i uruchom prosty program „Hello, World!” w asemblerze x86.
Pierwszy program w asemblerze to bezpłatna lekcja Assembly Language & x86 Low-Level Systems Programming na CoddyKit. To lekcja 3 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Assembly Language & x86 Low-Level Systems Programming, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Assembly Language & x86 Low-Level Systems Programming zawiera 4 lekcji w sumie.
Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.
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.
Często zadawane pytania
Czy lekcja „Pierwszy program w asemblerze” jest bezpłatna?
Tak — pełny tekst „Pierwszy program w asemblerze” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Assembly Language & x86 Low-Level Systems Programming, przejdź na CoddyKit PRO. Kurs Assembly Language & x86 Low-Level Systems Programming zawiera 4 lekcji w sumie.
Co nauczysz się w „Pierwszy program w asemblerze”?
Skonfiguruj środowisko programistyczne oraz napisz, zassembluj, zlinkuj i uruchom prosty program „Hello, World!” w asemblerze x86. Ćwiczysz Assembly Language & x86 Low-Level Systems Programming z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.
Czy potrzebuję doświadczenia, aby zacząć Assembly Language & x86 Low-Level Systems Programming?
Nie wymagamy żadnego doświadczenia. Assembly Language & x86 Low-Level Systems Programming w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 3 z 4.
Ile czasu zajmuje lekcja „Pierwszy program w asemblerze”?
Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.
Czy mogę pisać i uruchamiać kod w tej lekcji Assembly Language & x86 Low-Level Systems Programming?
Tak. Każda lekcja Assembly Language & x86 Low-Level Systems Programming zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.
Wszystkie lekcje w tym kursie
- Czym jest język asemblera?
- Podstawy architektury x86
- Pierwszy program w asemblerze
- Łańcuch narzędzi: asembler, linker i uruchamianie