Wednesday, December 16, 2009

Non-aligned Access

So, I decided to make a run at writing a little heap memory manager. Essentially, this would be a stack that would keep track of where in my heap I stored some values.

I considered a few designs and settled on this: 256 bytes of memory managed by a queue 256 words long. The astute reader will have noticed that I planned to pack 256 bytes into five times as much space.

Stunning, is it not?

Actually, since I planned to allow memory storage in 1, 2, 3, or 4 byte amounts, the maximum amount of items to be stored would be 256, which means I'd need a management queue that oculd handle that many members. The fact that I wanted to use words, not bytes, for the management queue was just a simplifying assumption.

On the bus, on the way home, I made a list of things to do:

  1. Adjust the SPACE allocation to allow for 0x500 bytes.
  2. Create a new section of the heap to act as a manager for the managed area.
  3. Load and read some test values into the heap.

Well, 1 and 2 were learning experiences that I managed to work my way through.

What happened when I tried to do 3 was "Non-aligned Access" - since I was trying to manage all the bytes, it was loading more than it should.

That would not have been a problem - or at least not one that I hadn't expected.

The bigger problem was that it was writing over some of the writes. I'm still not sure why, but I gather that ARM takes non-aligned matters into its own hands.

On the bus, tomorrow, I'll decide what to do next.

No comments:

Post a Comment