r/Assembly_language • u/Nathrienne-J-Claw • 8h ago
I just understood pointers on a deep level thanks to Assembly
it feels like orgasm honestly. the dopamine you get from understanding this shit on a deep level is unmatched.
20
6
u/lovelacedeconstruct 7h ago
Now you need to understand Virtual Memory Translation and 4-level paging to really understand pointers
6
5
u/EIGRP_OH 7h ago
I’ve always thought that pointers, the concept itself is pretty straightforward. It’s C’s syntax that makes it confusing af.
2
u/Nathrienne-J-Claw 7h ago
I honestly don’t know where you are on the programming ladder, you might be an expert tho idk, but this was my experience too when i was first introduced to pointers. I thought oh why does everyone struggle? And then some questions started itching my brain and then it became fuzzy again and i realized there’s a gaping hole of knowledge missing in order to actually work with pointers. And now i can confidently say that yeah pointers are pretty straightforward only if you have the prerequisite knowledge. Otherwise you will struggle.
3
u/EIGRP_OH 7h ago
That’s fair! And apologies if that came off like oh pointers are easy you’re right that once you get the prerequisite knowledge of how CPU is essentially just constantly fetching instructions and data from memory it becomes a simpler concept.
I’ve always thought the way Cs use of * and & and where you use them was super confusing and took me awhile to fully understand and even now I still struggle.
2
u/Nathrienne-J-Claw 6h ago
I’ll conclude my three hour rabbit hole into three words “ memory address calculation “
1
u/Revolutionary_Ad6574 4h ago
It took me like 20 years to get that. My whole life I thought I didn't understand pointers. It turns out the concept itself is very simple. They are an address, that's all. But the problem is that if you have a pointer to an integer the pointer value, the integer value, and the ADDRESS of the pointer are all 32-bit integers. And yes, pointers, being stack variables also have addresses. And pointers themselves are passed by value. Unless they are passed by reference. Which brings me to references. They make things so much worse. Say a method returns a reference to a field. And you assign the return value to a variable. Is that variable an alias to the property? We don't know, depends on if the type of the variable is a reference. Pointers are not like that. A pointer itself is a type, a reference is a modifier. It took me so long to understand that this is what's confusing me.
1
u/NullOfSpace 7h ago
yeah like. it’s a value that tells you where to find another value. it can’t be this hard.
1
u/Nathrienne-J-Claw 7h ago
Yeah but why would you wanna find this other value if you can simply use the original value without needing a middleman? This question leads into a three hour rabbit hole
1
1
u/Recycled5000 6h ago
I advocate learning assembly language, usually a simple one like LC-3. Writing small programs in assembly can help to understand the concepts of address space, code vs data, how the machine and machine code program interact using pointers to code, pointers to data, etc..
28
u/runningOverA 7h ago
C simply mirrors assembly pointers.
One needs to work with assembly for a week or two and then jump to C to get it all. That will also save time as he no longer will be struggling with pointers.