0% found this document useful (0 votes)
15 views2 pages

Assembly Language Basics for Beginners

This document introduces Assembly language, explaining its low-level nature and its relationship to machine code and high-level languages. It outlines the importance of learning Assembly for understanding computer operations, cybersecurity, and performance optimization. Additionally, it provides setup instructions for different operating systems and includes a simple 'Hello World' example in Assembly code.

Uploaded by

melek
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views2 pages

Assembly Language Basics for Beginners

This document introduces Assembly language, explaining its low-level nature and its relationship to machine code and high-level languages. It outlines the importance of learning Assembly for understanding computer operations, cybersecurity, and performance optimization. Additionally, it provides setup instructions for different operating systems and includes a simple 'Hello World' example in Assembly code.

Uploaded by

melek
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Assembly for Beginners – Module 1

■ Learning Goals
- Understand what Assembly is.
- See how Assembly relates to machine code and high-level languages.
- Set up the environment to run Assembly programs.

■ What is Assembly?
Assembly is a low-level programming language. It talks directly to the CPU using instructions that
are very close to machine code (binary). Each line of Assembly corresponds to one CPU
instruction.

Example:
C code:
x = x + 1;

Assembly (NASM, x86):


mov eax, x
add eax, 1
mov x, eax

■ Why Learn Assembly?


- To understand how computers really work.
- Useful for cybersecurity & reverse engineering.
- Essential in embedded systems & IoT.
- Performance optimization in critical programs.

■■ How Does Code Reach the CPU?


1. High-level language (C, Python) → Easy to read for humans.
2. Compiler → Translates into Assembly / Machine Code.
3. Assembly → Human-readable version of machine code.
4. Machine Code (binary) → What the CPU executes.

■■ Tools You Need


Depending on OS, we use different assemblers:

- Linux: NASM (Netwide Assembler)


Install:
sudo apt update
sudo apt install nasm

- Windows: MASM or TASM (Microsoft / Turbo Assembler).


- Mac: NASM works too (but syscalls differ).

■ Example 1: Hello World (Linux NASM, 64-bit)


section .data
msg db "Hello, World!", 0xA ; string to print with newline
len equ $ - msg ; length of the string

section .text
global _start

_start:
; write(1, msg, len)
mov rax, 1 ; syscall number for write
mov rdi, 1 ; file descriptor (stdout)
mov rsi, msg ; address of string
mov rdx, len ; length of string
syscall

; exit(0)
mov rax, 60 ; syscall number for exit
xor rdi, rdi ; exit code 0
syscall

■ Exercise 1
1. Modify the program to print your own name instead of “Hello, World!”.
2. Add another line so it prints two messages.

You might also like