errantember: (St. Ember)
[personal profile] errantember
So I'm trying to help a customer figure out how to use a pointer transparently whether it's in p-memory or x-memory. First I try to declare all the variables locally, but the compiler won't let me declare any p-memory variables locally, because the stack, where locals are stored, is in x-memory. So I declare them globally instead. Then I assign each type of pointer to an integer stored in the same kind of memory, doing the address assignment with the declaration. The compiler eats this without complaint, but fails to actually place the correct address of *either* integer into the appropriate pointer.

At this point, I break for bacon.

After bacon, I try doing the address assignments inside main, and now the addresses are correct. So finally I go for the typecast, going through a void pointer. However, assigning the address of the int to the void pointer results in some crazy address that isn't where the int is located, so there's no point in even *trying* to make the p-memory pointer point toward the x-memory pointer since the intermediate void pointer isn't getting the correct address.

So *finally* I just decide to typecast the entire operation in one line, skipping the void pointer. I fear an error, but the compiler eats it!

Fabulous.

I run it, and when I get to the actual assignment statement, the debugger jumps to an "incorrect long-word alignment exception."

Time for bed.
(deleted comment)

Re: It could be...

Date: 2008-04-29 02:59 pm (UTC)
From: [identity profile] errantember.livejournal.com
I definitely think the inability to properly assign the address of a variable in global space during compile time (or, at least, link time) is a bug, and I'm going to investigate that further.

The two types of memory are Program and Data memory. The CPU has a Harvard architecture, but it's possible to store data in program memory for flexibility. However, the pointers to each region are effectively non-castable for various reasons, which is why this is so complicated.

Profile

errantember: (Default)
errantember

December 2015

S M T W T F S
  12 345
6 789101112
13141516171819
20212223242526
2728293031  

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 5th, 2025 01:40 am
Powered by Dreamwidth Studios