Conversion of assembly language code into c language

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

Conversion of assembly language code into c language

ソリューションへジャンプ
2,801件の閲覧回数
FAISAL0323
Contributor II

Hi Experts, 

 I am using MPC5748G where my issue is ; it’s sometimes got stuck some where in code hence making  watchdog to reset the microcontroller.  

To find root cause of above issue, mine objective is to send out certain CAN messages before watchdog reset our microcontroller.

That logic already has been  implemented successfully by enabling watchdog interrupt and its ISR and it’s working normally. 

Now I want to covert below written assembly language instructions into c language instructions and want to send out the content of these registers through CAN in watchdog interrupt ISR.  Please let me know following things.

1 How I can convert these instructions into C language? 

2 How to get access to these registers. What kind of statement I should write so that I can get access to these registers. 

269A0808-1A0B-4C50-9B99-D58318DD3451.jpeg

10E86CC5-C6BA-47D2-B662-11DB860942AE.jpeg

Regards 

0 件の賞賛
返信
1 解決策
2,771件の閲覧回数
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

MSR is a core register, it's not memory mapped. The only way to access core registers is to use asm instructions. In C language, you can use macros like this:

#define MFMSR() ({unsigned int rval; __asm__ volatile("mfmsr %0" : "=r" (rval)); rval;})
#define MTMSR(v) __asm__ volatile("mtmsr %0" : : "r"(v))

And then use them in C code:

unsigned int temp;

temp = MFMSR(); //read MSR

MTMSR(temp); //write MSR

If you want to store the content in asm function (like in IVOR handler), you need to get address of C variable and store it to the variable using asm instructions.

Regards,

Lukas

 

 

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
2,772件の閲覧回数
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

MSR is a core register, it's not memory mapped. The only way to access core registers is to use asm instructions. In C language, you can use macros like this:

#define MFMSR() ({unsigned int rval; __asm__ volatile("mfmsr %0" : "=r" (rval)); rval;})
#define MTMSR(v) __asm__ volatile("mtmsr %0" : : "r"(v))

And then use them in C code:

unsigned int temp;

temp = MFMSR(); //read MSR

MTMSR(temp); //write MSR

If you want to store the content in asm function (like in IVOR handler), you need to get address of C variable and store it to the variable using asm instructions.

Regards,

Lukas

 

 

0 件の賞賛
返信
2,741件の閲覧回数
FAISAL0323
Contributor II

Hi Lukas,

Thanks for your response. It has been solved

 

Regards

 

0 件の賞賛
返信