Stack implementation in memory