Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What register points to the heap?

I just finished learning ARM architecture/assembly. If the SP register holds the address of the next memory location to put data into, what holds the address of the heap? For example in C++ if you declare an object on the heap (e.g. MyObj example = new MyObj();) what would the assembly look like, in the sense where would it know where example is?

like image 358
Celeritas Avatar asked Dec 09 '22 21:12

Celeritas


1 Answers

Stack in this context is a lower level structure provided by OS/EABI. That's why there is a conventional register for that. However, heap is a higher level structure provided by OS. So managing and playing with it depends on the agreement with your app and OS. In assembly terms, you'll be using that heap with dereferencing some addresses through registers.

like image 99
auselen Avatar answered Dec 28 '22 20:12

auselen