Reputation: 3
Heyo everyone,
Lets say I got a register SP, in which is stored some int (more specific in form of uint8_t).
Now I want to use that int as an address for a pointer.
How exactly would I do that? I've searched nearly everywhere and didn't find a solution...
Upvotes: 0
Views: 41
Reputation: 31399
It's not something you want to do under normal circumstances, since it can easily cause undefined behavior if you don't know what you're doing.
But you can do something like this:
uint8_t address;
// Do something to address
char *ptr = (char*)address;
or if you want to skip an intermediate pointer:
uint8_t address;
// Do something to address
char c = *(char*)address;
Change char
for whatever type you want.
Upvotes: 1