views:

180

answers:

2

Taking my first course in assembly language, I am frustrated with cryptic error messages during debugging... I acknowledge that the following information will not be enough to find the cause of the problem (given my limited understanding of the assembly language, ColdFire(MCF5307, M68K family)), but I will gladly take any advice.

...

jsr out_string

Address Error (format 0x04 vector 0x03 fault status 0x1 status reg 0x2700)

I found a similar question on http://forums.freescale.com/freescale/board/message?board.id=CFCOMM&thread.id=271, regarding on ADDRESS ERROR in general.

The answer to the question states that the address error is because the code is "incorrectly" trying to execute on a non-aligned boundary (or accessing non-aligned memory).

So my questions will be:

  1. What does it mean to "incorrectly" trying to execute a non-aligned boundary/memory? If there is an example, it would help a lot

  2. What is non-aligned boundary/memory?

  3. How would you approach fixing this problem, assuming you have little debugging technique(eg. using breakpoints and trace)

+1  A: 

It has been a long time since I've used a 68K family processor, but I can give you some hints. Trying to execute on an unaligned boundary means executing code at an odd address. If out_string were at an address with the low bit set for example.

The same holds true for a data access to memory of 2 or 4 byte data. I'm not sure if the Coldfire supports byte access to odd memory addresses, but the other 68K family members did.

The address error occurs on the instruction that causes the error in all cases.

Find out what instruction is there. If the pc matches (or is close) then it is an unaligned execution. If it is a memory access, e.g. move.w d0,(a0), then check to see what address is being read/written, in this case the one pointed at by a0.

I just wanted to add that this is very good stuff to figure out. I program high end medical imaging devices in my day job, but occasionally I need to get down to this level. I have found and fixed more than one COTS OS problem by being able to track down just this sort of problem.

Richard Pennington
If that is the hex address of out_string, then that is an odd address, the 1 at the end is definitely odd. You need the .align in front of the out_string symbol as the other guy mentioned.
Richard Pennington
thank you so much for your post; I resolved the problem
Midnight Blue
+1  A: 

First of all, it is possible that isn't the instruction causing the error. Be sure to see if the previous or next instruction could have caused it. However, assuming that exception handlers and debuggers have improved:

An alignment exception is what occurs when, say 32 bit (4 byte) data is retrieved from an address which is not a multiple of 4 bytes. For example, variable x is 32 bits at address 2, then

const1:   dc.w   someconstant
x:        dc.l   someotherconstant

Then the instruction

          mov.l x, %r0

would cause a data alignment fault on a 68000 (and 68010, IIRC). The 68020 eliminated this restriction and performs the unaligned access, but at the cost of decreased performance. I'm not aware of the jsr (jump to subroutine) instruction requiring alignment, but it's not unreasonable and it's easy to arrange—Before each function, insert the assembly language's macro for alignment:

      .align long
func:   ...
wallyk