I was studying computer architectures and got to the Call Stack
As wikipedia says
why there are so many names for the same thing?
Also why we use stacks and not queques? FIFO makes more sense to me in this case
I was studying computer architectures and got to the Call Stack
why are there 40,000 different flavors of christianity?
There are huge differences between christian denominations
^ this.
Wikipedia is trash if you want to learn anything. Great for picking up useless trivia or getting the (((official story))) for controversial events.
you look like a baby
this is why Zig Forums is the worst place to discuss anything
I used to lurk treads of things I didn't even care about just because people actually argued and explained their views and it was nice to read
Nowadays is just (((>jews)))
go back to >>>Zig Forums faggots
Uneducated brainlets who can't make the difference between stacks and queues aren't interesting.
Uneducated brainlets who can't make a single coherent sentence aren't interesting either.
I know the difference, I was just asking why we use those
and actually while waiting for a decent reply, I understood why stacks are used
Good for you.
It's literally programming 101, covered in the first week of every decent Programming course.
But it still shouldn't take much to imagine for anyone who has a minimum grasp on how local declarement works.
I'm not following a programming course
My uni is more EE with lots of mathematics and a couple of CS courses
Think about the implementation here. How many pointers would you need to keep track of a queue? With a stack, it is just one. This is used so frequently, it's kept in a register, can you spare more registers to support a queue structure? Why wouldn't that be a good idea?
Because you would have to waste cycles loading the register with the additional pointer?
Thanks for the help
still, if you understand how local declarment manages the memory, then you should automicatically understand why it is the way it is
More than that, it just doesn't make sense a to use a queue for function calls. Why would you want to remove the oldest part of the stack? You'd have nowhere to return to. I guess it could work if you used jumps everywhere instead of calls, but that would be pretty retarded, like only using goto's in C.
Well the fact that you have to waste a register is bad enough. The queue would give you no advantages at all, and many disadvantages. A key thing to remember is that just because things are thrown onto the stack in FIFO order, doesn't mean they cannot be accessed arbitrarily. There are memory fetch instructions built into the assembly language to fetch a location with offset.
Thanks, really, it makes a lot more sense now
Err, scratch that part out.
You're welcome.
Assemblers do sometimes have pseudoinstructions that translate into 2 or more actual instructions, easy examples to point out would be how various fixed width ISAs like MIPS deal with having registers larger than their encoding allows (32bit MIPSIV with 64bit registers). I mean its one way to add a couple "missing" instructions, or you can staple shit into a heavily microcoded trashheap every few months instead...
Human pride
Yeah, but the point of scratching that out was because I phrased the sentence poorly.
This probably stems from different processor manufacturers calling them different things.
A queue is not how a program typically works. Using a queue would be more applicable if we only ever entered a new function at the end of the last one. Even then the queue would only have a size of 1. Since 99% of the time function calls are in the middle of a function we need to use a stack. It should be pretty simple to visualize entering and exiting functions to be like a stack. Think of calling a funcion as pushing it onto a theoretical stack and return instruction as popping off the top of our theoretical stack. With this mental model you should notice how function calls, even recursive one closely align with the idea of FIFO. A function that has returned must also have been the last function that was called.
You don't want fifo when the first ones are your kernel.