Instruction address in IAR

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Instruction address in IAR

1,713件の閲覧回数
Shruthi_C
Contributor II

HI, 

I want to get address of present instruction running, so I used this in my IAR(GCC Compiler)

 

void *addr = (void *) __builtin_extract_return_addr (__builtin_return_address (0));

but its giving me error 

Error[Pe144]: a value of type "int" cannot be used to initialize an entity of type "void *"

 

Please support

Thanks

 

0 件の賞賛
返信
8 返答(返信)

1,646件の閲覧回数
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @Shruthi_C 

I tried that in S32 Design Studio and it works as expected. Not sure what's wrong in IAR.

Or you can use something like this:

#define __ASM __asm
#define __INLINE inline
#define __STATIC_INLINE static inline

__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_LR(void)
{
register uint32_t result;

__ASM volatile ("MOV %0, LR\n" : "=r" (result) );
return(result);
}

And then:

uint32_t lr;

lr = __get_LR();

This also works on my side.

Regards,

Lukas

 

 

0 件の賞賛
返信

1,608件の閲覧回数
Shruthi_C
Contributor II

HI Lukas,

 

I tried the above content, but I am getting these warnings,

 

Warning[Pe172]: external/internal linkage conflict with previous declaration Hat line 85 of "internal preinclude.h"

Warning[Pe550]: variable "lr" was set but never used 

 

0 件の賞賛
返信

1,577件の閲覧回数
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @Shruthi_C 

what can you see on the line 85 in that file? I can't see such file in S32DS.

And the lr was obviously optimized out. I can see no problem with this.

Regards,

Lukas

0 件の賞賛
返信

1,574件の閲覧回数
Shruthi_C
Contributor II

Hi Lukas,

It shows like, That file does not exists  in S32K146

Shruthi_C_0-1695278843140.png

 

 

Thanks,

Shruthi

0 件の賞賛
返信

1,566件の閲覧回数
lukaszadrapa
NXP TechSupport
NXP TechSupport

Ok, what will happen if you try to use the same code without defines like this?

 

__attribute__( ( always_inline ) ) static inline uint32_t __get_LR(void)
{
register uint32_t result;

__asm volatile ("MOV %0, LR\n" : "=r" (result) );
return(result);
}

0 件の賞賛
返信

1,562件の閲覧回数
Shruthi_C
Contributor II

Hi Lukas,

 

If I dont use #defines same behavior as before, warning

 

Shruthi_C_0-1695286264159.png

 

0 件の賞賛
返信

1,526件の閲覧回数
lukaszadrapa
NXP TechSupport
NXP TechSupport

It looks like the syntax is different in IAR. Please ask IAR for help, it seems I can't help with this.

Regards,

Lukas

0 件の賞賛
返信

1,426件の閲覧回数
Shruthi_C
Contributor II

HI Lukas, 

Thanks for your support

Regards 

Shruthi

0 件の賞賛
返信