Why is the CALLSTACK so Important? Assembly Tutorial for Beginners | x86-64 Architecture Programming

Опубликовано: 09 Май 2026
на канале: Mxy
6,939
298

;######################
;# CODE TO COPY AND PASTE:
;######################
.intel_syntax noprefix
.global _start
.text


_start:
lea r15, [resume_here]
jmp print_hello

resume_here:
jmp exit


exit:
mov rax, 60 ;# system call code for exit
xor rdi, rdi ;# zero out rdi
syscall ;# execute system call


print_hello:
mov rax, 1 ;# write
mov rdi, 1 ;# to terminal
lea rsi, [hello] ;# start of string
lea rdx, [hello_len] ;# length of string
syscall ;# execute / call kernel

lea r15, [resume_hello]
jmp print_goodbye

resume_hello:
jmp r15


print_goodbye:
mov rax, 1
mov rdi, 1
lea rsi, [goodbye]
lea rdx, [goodbye_len]
syscall
jmp r15

.data
hello: .ascii "hello, world!\n"
hello_len = . - hello

goodbye: .ascii "goodbye!\n"
goodbye_len = . - goodbye

;# CODE END
;######################



Emulator Link: https://x64.halb.it
Next Video:    • IF STATEMENTS & Loops in Assembly | Condit...  
FIRST Video in Course:    • Learn Assembly For Beginners | Introductio...  
PREVIOUS Video in Course:    • How to Make Functions in Assembly: The JMP...  


00:00 Why do functions fail without the callstack?
01:09 Infinite loop!
02:24 How Callstacks Work
5:54 Infinite Loop Problem in Code
7:27 Coding the Callstack in Assembly
18:13 Using the Real Callstack
22:30 Stack Commands: PUSH and POP