Posts

Showing posts with the label Assembly

How an Executable File Operates

Image
1. Assembly The machine language understood by the CPU is binary code . Assembly expresses machine language in human-readable mnemonic instructions. Therefore, the programming language most similar to machine code is Assembly . To understand how machine code is executed, we will examine a simple Assembly program. The following Assembly code performs the operation of printing the result of "2 + 3". ; Ubuntu 24.04 x86-64 (NASM, ELF64) section .data msg db "result: " msg_len equ $ - msg newline db 0x0a section .bss buf resb 1 section .text global _start _start: mov al, 2 add al, 3 mov bl, al mov rax, 1 mov rdi, 1 mov rsi, msg mov rdx, msg_len syscall mov al, bl add al, '0' mov [buf], al mov rax, 1 mov rdi, 1 mov rsi, buf mov rdx, 1 syscall mov rax, 1 mov rdi, 1...

Understanding How Computers Work with 0s and 1s

Image
1. ON/OFF When electricity flows through a light bulb, the bulb turns ON . When no electricity flows, the bulb turns OFF . In the same way, computers use the binary system (Binary), where ON is represented as 1 and OFF as 0. 1.1. Bit and Byte The smallest unit used to represent values with 0 and 1 is called a bit . (0 or 1) 8 bits make up 1 byte, and 1 byte is the basic unit used to represent a character. 1.2. Char 8 bits, or 1 byte, are used to represent English (ASCII) characters as a char . When representing code, binary values such as "00010001" are long and difficult to read. For this reason, hexadecimal notation such as "0x11" , which can express 8 bits (1 byte) in two digits, is commonly used.       [Source] Computer Architecture - The ASCII character representations 1.3. Code Just as characters are defined using binary code, executable code is also defined in binary form. The CPU operates based on machine language ( Assembly ), and t...