Jump to content

GB Programming: Difference between revisions

m
→‎A stack? Can you eat that?: Changed the first three words. Pointless but more consistent with the title, I guess.
>ISSOtm
(→‎Negative numbers: Changed ALL the ranges, the dashes could be mistaken for minus signs.)
>ISSOtm
m (→‎A stack? Can you eat that?: Changed the first three words. Pointless but more consistent with the title, I guess.)
Line 632:
==Stacks==
===A stack? Can you eat that?===
No it'syou notcan't. It's a data structure that has the cool property of not being fixed-length. How does it work? Just like a stack of plates. Imagine you're washing some plates in the back of a restaurant. Next to you is a pile of plates you need to wash. Waiters come and place ("push") plates on top of the stack and when finished washing a plate, you take ("pop") the topmost one. This way of working is called LIFO (Last In First Out).
 
In our case, we will do it by saving the top of the stack as a memory address. This value is called the ''stack pointer''. Here is an example, with the stack growing to the right :
Line 666:
|$00||$03||$4F||$C0||$7C||$2A||??||??||??||??||??||??||??||??||??||??
|}
 
 
===Coding a stack===
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.