Why do computer scientists have to overcomplicate the stack so much? You are the first person that I've found to give a straightforward explanation of the order in which the stack frame is created. Thank you very much!
@ComputerScienceLessons3 жыл бұрын
My motto - K.I.S.S. :)KD
@sorvex92 жыл бұрын
Some of them don't really understand it themselves.
@beverlyukandu93375 жыл бұрын
This clarified 10 years of confusion with the ordering of how parameters are pushed onto the stack. Thanks!
@ComputerScienceLessons5 жыл бұрын
You're very welcome. :) KD
@NoobUCantBeat2 жыл бұрын
been studying this for a couple hours... this has been the most straight forward and simplest explanation that finally makes everything make sense! thanks!
@dickvanfreedman4 жыл бұрын
FINALLY this makes sense. You did a better job explaining than most professors and text books.
@ComputerScienceLessons4 жыл бұрын
Thank you :)KD
@ostracean3 жыл бұрын
The first video to actually explain the difference between callee and caller cleanup of parameters
@user-xo3fn1fj2g2 жыл бұрын
Wow thanks for the clear explanation, I’ve been banging my head trying to understand this. Watching this video made everything click in place
@ComputerScienceLessons2 жыл бұрын
You're welcome :)KD
@abdoullatifabdoumoussa19904 жыл бұрын
Finally someone who makes this idea much clear for me. Thanks very much, thumb up
@ComputerScienceLessons4 жыл бұрын
Thank you. Much appreciated :)KD
@JordanRohilliard3 ай бұрын
understanding this is so key to understanding recursion. Always having this knowledge in the back of your mind makes it easier
@ComputerScienceLessons3 ай бұрын
I agree. Understanding the recursive sorting algorithms depends on this :)KD
@tobi34978 жыл бұрын
A truly great explanation; I'd watched a previous one filled with ambiguity, and lacking the actual detail you coherently portrayed - I'll be sure to explore your series.
@ComputerScienceLessons8 жыл бұрын
Your comment is much appreciated.
@keeganfisher19007 жыл бұрын
this helped me get over some confusion with implementing recursion in assembly... I was forgetting that the arguments should be considered part of the called procedures stack frame!!! thank you!
@Wrtvrxgvcf557 жыл бұрын
mate you keep surprising me by the amount of content your channel offers. high quality content as well.
@NOPerative7 жыл бұрын
Sweet explanation. Call/stack frames can be extremely confusing for those whom are new to memory management at lower levels.
@franhm1006 жыл бұрын
I'm a new man now. Thanks!
@satyasingh61444 жыл бұрын
So, no one noticed how insanely 'unique' the name of this channel is? I bet this channel started with the inception of KZbin.
@ComputerScienceLessons4 жыл бұрын
It was called Kevin Drumm to begin with - not so catchy :)KD
@humanflybzzz45686 жыл бұрын
Fantastic and eloquent explanation!!! This is a bit of a tough nut to crack on a first few tries, kinda like learning subnetting for the first time. I like how you don't just attack the viewer with a barrage of concepts rushing to complete the video, so that the ones with add can follow more easily :) Thanks dude!
@SleepyLink14 жыл бұрын
Great video! Thank you I was struggling with this concept a little, but it's very clear here.
@ComputerScienceLessons4 жыл бұрын
You're welcome :)KD
@lizdenhup5 жыл бұрын
Such a helpful video! I love this channel!!
@ComputerScienceLessons5 жыл бұрын
Thanks for the comment. :) KD
@TomerBenDavid5 жыл бұрын
By far the best explanation please continue uploading videos
@ComputerScienceLessons5 жыл бұрын
Thanks. I really appreciate the comments.
@sidchakravarty8 жыл бұрын
Thank you Kevin for creating this video. This is one of the best videos I saw that clearly explained call stack. Do you have any videos on Heap Memory?
@cm57543 жыл бұрын
It is interesting to present things in terms of popping individual elements off the stack, rather than just accessing them directly in memory and then restoring the frame pointer one time when a procedure returns.
@ComputerScienceLessons3 жыл бұрын
I agree; this is an abstract view of an abstract data structure. My videos on the stack data structure mention how a stack might actually be implemented. :)KD
@gristlelollygag7 ай бұрын
This is fantastic, thank you!
@BB-wh2vm4 жыл бұрын
Truly amazing explanation, thank you.
@ComputerScienceLessons4 жыл бұрын
Thank you :)KD
@mohalelebeya94698 жыл бұрын
very clear and easy to follow, thanks guy!
@johnywhy46794 жыл бұрын
4:50 : Unclear: In the scheme described, parameters passed from P1 to P2 are pushed onto stack before P1 address. Thus, P2 must clean up the parameters P1 passed to it. This was confusingly stated in the vid as "P1 must clean up the stack". Confusing since it was implied (but not stated) that, in the alternate scheme, P1 must clean up the parameters it passes to P2.
@pumbo_nv9 жыл бұрын
It should be noted that parameters are not always passed through the stack. It depends on calling convention and architecture. For example, on x64 first several parameters are passed in registers.
@medvfx33706 жыл бұрын
that's not what he said, he was talking about the return value, which is what happens in cdecl the return adress is in EAX @Frank Madrid
@davidnguyen90237 ай бұрын
This is great, thank you!
@LongVu-sm8wm2 жыл бұрын
thanks. the explanation is very clear.
@YuhuiZHI7 жыл бұрын
Very nice video. No technical word but very clear.
@ComputerScienceLessons7 жыл бұрын
"Everything should be made as simple as possible, but not simpler" :)
@Decco63064 жыл бұрын
thank you for these
@ComputerScienceLessons4 жыл бұрын
My pleasure. :)KD
@Decco63064 жыл бұрын
@@ComputerScienceLessons Im working on a smol z80 computer with 32k ram and rom and an 8255 pia for io this has helped my digest the information in the datasheets they throw out at you with no context as well as under the assumption you know what they are talking about. I got it to blink an led and im so happy. thanks again! (apparently they still make the 8 bit z80 and other supporting chips from zilog brand new. you can buy from Mouser.com and digikey.com as well as the 6502 from WDC from the same two suppliers mentioned)
@ComputerScienceLessons4 жыл бұрын
Crikey! The Sinclair Z80 was my first ever computer, before I upgraded to a Spectrum. You might enjoy Ben Eater's channel. kzbin.info/door/S0N5baNlQWJCUrhCEo8WlA
@Decco63064 жыл бұрын
@@ComputerScienceLessons that's neat. My first PC was a win 98 PC from Packard Bell. play command & conquer for hours on end. mind you, this was wayyyy out of date. I got this in 2005.And you're too late! I'm already caught up with his videos! you're videos are filler for more "modern/relevant" topics if you will.
@henrychen15954 жыл бұрын
Question: Are the parameters and variables shuffled out of the stack if the procedure traverses it but does not use it?
@arpittiwari374911 ай бұрын
Very straightforward answer
@SJ_462 жыл бұрын
Great explaination, one equestion: Why doesn't the initial frame or main() frame have any return address? I know that it's the first func, still the control goes to somewhere, r8? Maybe to the OS or somewhere.. Can you pls put some light on it?
@mariyehcloud Жыл бұрын
well explained! thanks a lot
@ComputerScienceLessons Жыл бұрын
Thank you :)KD
@FaresYch16 Жыл бұрын
i love u, you are a hero
@ComputerScienceLessons Жыл бұрын
You are too kind :)KD
@arturasbrk55217 жыл бұрын
10 out of 10 ! very helpful!
@humanflybzzz45684 жыл бұрын
Amazingly explained indeed ! Could you please do a vid on the topic of GOT and PLT tables, as well as got.plt ....
@ComputerScienceLessons4 жыл бұрын
I am planning to do a video on linkers and loaders. In the mean time, you might find my playlist on compilers interesting: kzbin.info/www/bejne/mamxnZVofLl-f8U
@evolvOwns7 жыл бұрын
Wow, excellent conceptual explanation.
@OneNordicWarrior8 жыл бұрын
Kevin, you're my man!
@Nobody-df7vn4 жыл бұрын
Hi, do you have a video on binding? and how different binding works? AMAZING VIDEO BTW!
@ComputerScienceLessons4 жыл бұрын
Thanks for the comment. :)KD I haven't covered binding explicitly, but it does come up in some of my videos. I have made a series of Python programming videos which mentions implicit variable declaration; in Python, a variable need not be declared explicitly, as it must in VB.NET (with Dim or Public), rather, Python infers the variable data type from the data you assign. This is called dynamic binding. I have also made a series of videos on object oriented programming with VB.NET. This includes a technique known as method overloading. When a program that calls an overloaded method is compiled, the compiler has to work out which variation of the method will be called at runtime based on its method signature. This 'resolved' call becomes part of the compiled code. This is known as static binding. These videos might help: kzbin.info/www/bejne/l6C9lpiBjbFnl68 kzbin.info/www/bejne/b4bcZZ5vr9OYpKc
@laurentiustefan3985 жыл бұрын
great vid.
@bettyswunghole33104 жыл бұрын
Do you have to manually push the return address onto the stack and then manually pop it back to the program counter? Forgive me if this is a dumb question...I'm a bit of a noob, and so far I've only seen the "ret" instruction that seems to "magically" take care of return addresses.
@kindalost19 жыл бұрын
10x. elaborated and clear.
@magica2z6 жыл бұрын
Great video.. Thank you and Subscribed..
@Xpingwinz9 жыл бұрын
Awesome video and thank you!!
@alimeree42998 жыл бұрын
thanks allot man , very clear .. keep going ..
@bestsaurabh3 жыл бұрын
Great explaination. One question: Why are agruments of a function read from right to left? The right most argument is at the bottom of the stack. Can someone please help me understand what if we read it other way round( left to right). ??
@ComputerScienceLessons3 жыл бұрын
Interesting question. I believe it has to do with the fact that functions can be defined with optional parameters. For example, here is a VB.NET function definition with two mandatory parameters, a and b, and an optional parameter. Function myFunction(a As Integer, b As Integer, Optional c As Integer = 0) Any optional parameters must be specified at the right hand side of the comma separated list. When these arguments are read onto the stack, the mandatory ones will end up at the top, and their memory locations (offsets) will be known at compile time, so it's possible to access them more easily. Optional arguments, which may or may not be there, are lower down. :)KD
@zoutuzhuren33707 жыл бұрын
thank you, this is really really Great!!!
@ComputerScienceLessons7 жыл бұрын
Cheers :)
@jjjww9756 жыл бұрын
Well done!
@ppotter103 жыл бұрын
Hardly any video that explains how the stack is actually being used. Thanks!
@tobiasdummling61444 жыл бұрын
What I dont understand is how can the subprocess read their parameters? They pop the return address and than it says the next process cleans up the stack. But shouldnt it be cleaned up by the process automatically as it has to pop the parameters to read them (LIFO)?
@jedmuff55977 жыл бұрын
So what is the "Stack"? An order that the procedures must follow when carrying out there instructions? Like a BODMAS sort of thing that they do in maths? Or is it more like how the computer sorts out the procedures that are calling each one another? Also, which way does the procedure have to travers the stack(top to bottom or bottom to top) and does the procedure do the whole stack or does the procedure just do its selected stack frame?
@ComputerScienceLessons7 жыл бұрын
Take a look at this one kzbin.info/www/bejne/pJqlpHqtac1or6s
@anirudh85756 жыл бұрын
Is there any specific reason why the parameters are stored in the reverse order on the stack?
@muktadir.rahman9 жыл бұрын
Thank you so much for this video.
@coasterfreak-4863 жыл бұрын
Informative video
@ComputerScienceLessons3 жыл бұрын
Thank you :)KD
@sinisatadic19598 жыл бұрын
Excellent! :)
@ComputerScienceLessons8 жыл бұрын
Tnx
@NinaHProductions18 жыл бұрын
Is this for all stacks i.e. does this work for the JVM?
@rajeevsawant22817 жыл бұрын
Hi , Can you please give an example (name of the architecture )where the above implementation method of pushing the parameters first and then pushing return addr of previous procedure is implemented ??
@gaithsabah10264 жыл бұрын
Thanks
@ComputerScienceLessons4 жыл бұрын
You're welcome :)KD
@akashkhunt41915 жыл бұрын
Hi, Why does all recursion calls have same return address ? Thank you
@jdeleca4 жыл бұрын
I think it's because it's calling it-self, well, it does need to call it self, just update the memory/registers inside a conditional loop
@tharangamadhusankha Жыл бұрын
Thank you
@sia35403 жыл бұрын
How do I troubleshoot Windows 10 error "new guard page for the stack cannot be created"? I know nothing about programing!
@ComputerScienceLessons3 жыл бұрын
This error indicates that you are low on memory, or virtual memory. (Virtual memory is a swap file on your hard drive, or SSD, that is used to supplement the RAM when it's getting full.) The circumstances under which the error appears are important. Is it being triggered when you are playing a particular game? Does your computer meet the requirements of the software you are using? What has changed since you started seeing the error message - did it start after you download something? Grand Theft Auto for example can be problematic. A lot of computers these days boot from an SSD (solid state drive). The SSD holds the operating system (such as Windows) and is usually labelled drive C. SSDs tend to have a much lower capacity than magnetic drives and will fill up quickly if you install all of your applications on it, leaving little space for virtual memory. How full is your drive C looking? (Click on This PC in File Explorer to check.) If your computer has another (magnetic) drive (labelled drive D), install your software there instead of the SSD in future. You could also try moving some of your software from C to D. (I put all of my Epic and Steam games on drive D). Be careful how you do this, you can't just cut and paste files. Maybe you could also do with a general clear out. Uninstall any applications (incl. games) that you don't use anymore, and delete any photos and videos you don't want to keep (or move them to an external drive). Be careful not to throw the baby away with the bath water! You could also defragment your drive if you haven't done it for a while (right click the drive in File Explorer and select Properties then Tools). If you have a PC that you can expand, you could also consider putting some more RAM sticks inside it (but make sure you research how to do this, or get someone else to do it for you, if you are not sure what to do). Good luck :)KD
@sia35403 жыл бұрын
@@ComputerScienceLessons Thanks for replying! I will try your suggestions.
@thlu3087 жыл бұрын
Wouldn't it make more sense to push the return address first, then the parameters? This way, when the called function returns control to the calling function, the stack frame is already clean.
@yaroxkendo30436 жыл бұрын
It's really just a conventional issue to decide who is responsible to clear the stack. In the given design, the procedure which pushed the parameters is responsible to pop them again. When programming in Assembler you can 'abuse' this functionality whenever you push the same parameters over and over again to (different) procedures, so you don't even need to push pop them over and over again, just once pushing them onto the stack when calling the first procedure and popping them after a last call.
@RahulKumar-ci4by3 жыл бұрын
Good very good
@ComputerScienceLessons3 жыл бұрын
Thank you :)KD
@stevedcohen4 жыл бұрын
Great video, although it would have been better to use 83 procedures instead of 4.
@ComputerScienceLessons4 жыл бұрын
I totally agree :)KD
@saurabhjha8733 Жыл бұрын
what if procedure 4 calls procedure 5?
@rajvijay32766 жыл бұрын
perfect
@SwissPhil023 жыл бұрын
I thought the stack grew downwards not upwards ???
@ComputerScienceLessons3 жыл бұрын
At the risk of sounding glib, it's a matter of perspective. These are abstract diagrams. Conventionally, you are correct, but my students find it more intuitive to imagine it growing up. :)KD
@violinsheetmusicblog7 жыл бұрын
thank you!!!!!
@guilhermetomishiyoteixeira47319 жыл бұрын
Thank you! Not that hard...I was looking around the internet trying to get a better grasp in the subject.
@MRAXELGRINDER5 жыл бұрын
great
@allisonscanlan41443 жыл бұрын
Great video but the sound static makes it hard to listen
@poojanaregal99076 жыл бұрын
Can u get us a opengl program for this ...
@mushahidhussain15166 жыл бұрын
Your voice man.
@YouB3anz4 жыл бұрын
nice bass
@Theexacc7 ай бұрын
bro is defining a recursion
@cslogs16334 жыл бұрын
cool
@ComputerScienceLessons4 жыл бұрын
:)KD
@venkzvenki6 жыл бұрын
Saintgits peopls....Like adikke...😋🙋♂️
@johnywhy46794 жыл бұрын
Awesome vid! But, could have been made shorter by eliminating one or two procedures. After P2, it's just redundant.
@shalineebhawnani7 жыл бұрын
itti English aati to video dekhne ko jarurt ni padhti
@J2897Tutorials8 жыл бұрын
I can't see no code, circuit, tracks, ICs, nor electrons, just silly diagrams. Still makes no sense. So a clicking I will go, a clicking I will go, E I antio, a clicking I will go...