This report provides an in-depth technical analysis of the "Guess the Number" program written in x86_64 Assembly language for Linux systems. The program serves as an educational model demonstrating fundamental low-level programming concepts, system call interactions, and efficient memory management.
Memory Sections Architecture:
section .data ; Initialized data section (46 bytes messages + 12 bytes variables)
section .bss ; Uninitialized data section (5 bytes input buffer)
section .text ; Code section (147 bytes instructions)
global _start ; Entry point
Memory Layout Model:
0x00400000: _start (Program Code)
0x00401000: .data (Messages and Variables)
0x00402000: .bss (Temporary Input Buffer)
0x7ffffff0: Stack (Function Management)
; Theory: System time as random seed
mov eax, 13 ; sys_time - NR 13 in syscall table
mov ebx, 0 ; NULL pointer
mov ecx, num ; Storage address (0x00401050)
mov edx, 4 ; int size (4 bytes)
int 0x80 ; Transition to kernel mode
; Mathematical transformation: f(x) = (x mod 100) + 1
mov eax, [num] ; Load value (64-bit timestamp)
xor edx, edx ; EDX = 0 (for DIV operation)
mov ecx, 100 ; Divisor
div ecx ; EAX = quotient, EDX = remainder
inc edx ; EDX = EDX + 1 (Range 1-100)
mov [num], edx ; Store final result
Statistical Analysis:
String Processing Stages:
; Phase 1: Read from STDIN
mov eax, 3 ; sys_read
mov ebx, 0 ; file descriptor 0 (STDIN)
mov ecx, input ; buffer address (0x00402000)
mov edx, 5 ; buffer size (4 digits + newline)
int 0x80 ; System call
; Phase 2: ASCII to Integer Conversion
mov ecx, eax ; Bytes read count
dec ecx ; Exclude newline (0xA)
mov esi, input ; Data source
mov edi, 0 ; Index
xor eax, eax ; Clear EAX (result = 0)
convert_loop:
mov bl, byte [esi] ; Load character
cmp bl, 0xA ; Check end of line
je convert_done ; Jump if end
sub bl, '0' ; ASCII to binary: '5' → 5
imul eax, 10 ; Result = Result × 10
add eax, ebx ; Result = Result + Digit
inc esi ; Next pointer
loop convert_loop ; ECX--, if ECX≠0 jump
Mathematical Formula: