ARM Technical Support Knowledge Articles

FUNCTION POINTER VALUES DIFFER IN THUMB MODE

Applies to: ARM Development Tools

Answer


Information in this article applies to:


QUESTION

In the following ARM Thumb test program:

void (*ptr1)(void);
void main(void){ while(1){ ptr1=main; } }

The linker map file shows main() function located at 0x15C, but ptr1 is set to 0x15D. What's wrong?  Why are the addresses different?

ANSWER

There is nothing wrong.  ARM mode instructions are located on 4-byte boundaries.  Thumb mode instructions are located on 2-byte boundaries.  In the ARM architecture, bit 0 of a function pointer indicates the mode (ARM or Thumb) of the called function, rather than a memory location.  When bit 0 = 1, Thumb mode is selected.

MORE INFORMATION

Article last edited on: 2005-10-21 09:53:41

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential