Why does my NMI handler address end with a 0, but the vector address ends with a 1?

Happy Sunday guys, I am working with an STM32-F49ZI Nucleo board, which features an ARM Cortex-M4 32-bit MCU. I am using GCC as my compiler and GCC linker. For debugging, I am using OpenOCD and I inspected the addresses through the memory window in the debugger I have written my own NMI handler function, NMI_Handler, and when I inspect its address in the debugger, I see that it ends with a 0. However, the vector address for the NMI handler contains the same address, but the last bit is set to 1. I understand that this might be related to the ARM Cortex-M4’s support for Thumb instructions (which are 16-bit), but I'm having trouble understanding why the last bit is set to 1. Here's the handler code:
void NMI_Handler()
{
// Handler code
}
void NMI_Handler()
{
// Handler code
}
For instance, the debugger shows the following: - NMI_Handler address: 0x8010 1000 - NMI vector address: 0x8010 1001 Could you explain why there is a discrepancy between these addresses and how the ARM Cortex-M architecture influences this behavior?"
Solution:
The last bit of the vector address is set to 1 to indicate that the handler uses Thumb instructions. When the processor jumps to the handler, it automatically clears this bit to get the actual function address, Cortex-M processors always operate in Thumb mode.
Jump to solution
1 Reply
Solution
wafa_ath
wafa_ath5mo ago
The last bit of the vector address is set to 1 to indicate that the handler uses Thumb instructions. When the processor jumps to the handler, it automatically clears this bit to get the actual function address, Cortex-M processors always operate in Thumb mode.
Want results from more Discord servers?
Add your server