News for hackers. Stuff that matters.
Re:Ask HN: How does 6502 stack pointer store addr 0x10FF bei... by SairajK19 on Saturday January 06, 2024 @02:32AM (#38889324)
Okay I get it now, upper 8bit always hard wired to be 0x01 which is also why lies in page 1. The stack pointer deals with lower 8bits from 00 to FF.

Many thanks!

Re:Ask HN: How does 6502 stack pointer store addr 0x10FF bei... by simonblack on Saturday January 06, 2024 @02:54PM (#38894772)
That also restricts the stack to only 256 bytes, or 128 16-bit words.

I wonder how that affects the use of a stack-machine programming language like C. Especially when running a program like 'Towers of Hanoi'.

Wouldn't the 6502 run out of stack-space?

Re:Ask HN: How does 6502 stack pointer store addr 0x10FF bei... by SairajK19 on Sunday January 07, 2024 @03:01AM (#38899442)
Yes, seems like you can easily run out of stack with 256 bytes. Maybe they used their own secondary stack along with the hardware stack.

I wonder how big is modern 64bit cpu stack.

Re:Ask HN: How does 6502 stack pointer store addr 0x10FF bei... by simonblack on Sunday January 07, 2024 @10:24PM (#38907886)
I wonder how big is modern 64bit cpu stack.

In practical terms, I would consider it infinite. I doubt that we'd ever get to the point where we'd need even one-gigabyte of stack-space. And most modern machines have many, many gigabytes of RAM, as well as terabytes of disk storage that can be used as swap/stack/heap/cache space.