Ваша первая программа на ассемблере
Настройте среду разработки и напишите, соберите, скомпонуйте и выполните простую программу «Hello, World!» на ассемблере x86.
«Ваша первая программа на ассемблере» — бесплатный урок Assembly Language & x86 Low-Level Systems Programming на CoddyKit. Это урок 3 из 4. Ты можешь прочитать весь урок бесплатно ниже — а потом практиковать его прямо в браузере с встроенным редактором кода и ИИ-репетитором 24/7. Это часть пути обучения 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 $ - 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.
Часто задаваемые вопросы
Урок «Ваша первая программа на ассемблере» бесплатный?
Да — полный текст урока «Ваша первая программа на ассемблере» бесплатно доступен здесь в веб-версии. Чтобы практиковать его интерактивно (встроенный редактор кода и ИИ-репетитор 24/7) и разблокировать остальной курс Assembly Language & x86 Low-Level Systems Programming, подпишись на CoddyKit PRO. Курс Assembly Language & x86 Low-Level Systems Programming содержит 4 уроков всего.
Чему я научусь в уроке «Ваша первая программа на ассемблере»?
Настройте среду разработки и напишите, соберите, скомпонуйте и выполните простую программу «Hello, World!» на ассемблере x86. Ты практикуешь Assembly Language & x86 Low-Level Systems Programming с помощью реального кода, который запускаешь прямо в браузере, и ИИ-репетитор 24/7 отвечает на твои вопросы во время урока.
Нужен ли мне опыт, чтобы начать Assembly Language & x86 Low-Level Systems Programming?
Предыдущий опыт не требуется. Assembly Language & x86 Low-Level Systems Programming на CoddyKit структурирован для всех уровней — от новичков до продвинутых, поэтому ты можешь начать отсюда или с самого начала и учиться в своем темпе. Это урок 3 из 4.
Сколько времени занимает урок «Ваша первая программа на ассемблере»?
Большинство уроков CoddyKit занимают около 5–10 минут. Каждый из них компактный и интерактивный, поэтому ты постоянно делаешь прогресс и продолжаешь с того же места в веб-версии и приложении.
Можно ли писать и запускать код в этом уроке Assembly Language & x86 Low-Level Systems Programming?
Да. Каждый урок Assembly Language & x86 Low-Level Systems Programming включает встроенный редактор кода, поэтому ты пишешь и запускаешь реальный код прямо в браузере и получаешь моментальную обратную связь от AI — локальная установка не требуется.
Все уроки этого курса
- Что такое язык ассемблера
- Основы архитектуры x86
- Ваша первая программа на ассемблере
- Инструменты сборки, компоновки и запуска