Emulator link: https://app.x64.halb.it/
How to read/write Hex: • Why is Hexadecimal Used So Much? | Program...
How stack allocations work: • How Assembly Functions Work - The Stack Ex...
(Code below chapters!)
00:00 Recursion in Assembly
00:56 How the stack works
04:38 Start of recursion call
09:08 The collapse of the stack (end of recursion)
14:20 How long until a stack overflow occurs?
15:38 What would cause a stack overflow here?
16:00 How to output to console in Assembly
21:05 Using an emulator to run Assembly code
** CODE BELOW ** I will set up a repository soon!
=================
format ELF64 executable 3
segment readable executable
entry _main
mov rbp, rsp
_main:
mov rbp, rsp
mov rdi, 3
call _countdown
xor rdi, rdi
call _exit
_countdown:
push rbp
mov rbp, rsp
push rdi
mov rax, rdi
add rax, 48
sub rsp, 8
mov rdi, 1
mov [rbp-16], eax
lea rsi, [rbp-16]
mov rdx, 1
mov rax, 1
syscall
add rsp, 8
pop rdi
cmp rdi, 0
je _end__recursion
dec rdi
call _countdown
_end__recursion:
pop rbp
ret
_exit:
mov rax, 60
syscall
=================
** C code below **
int main()
{
countdown(3);
return 0;
}
void countdown (int arg)
{
char digit = (arg + '0');
write(1, &digit, 1); // printf("%c", digit);
if(arg == 0) return;
arg = arg - 1;
countdown(arg);
return; // I hope the teacher allows me to change the 'F'!
}
In questa pagina del sito puoi guardare il video online How Recursion Works in Assembly | Machine Code | Programming Fundamentals della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Mxy 04 aprile 2025, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 3,215 volte e gli è piaciuto 126 spettatori. Buona visione!