generate an illigal operation

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

generate an illigal operation

1,380件の閲覧回数
admin
Specialist II

Dear All:

 

i'm now using the 9s08dz32. i want to generate an illigal operation to force the mcu to reset. when in asm, the code looks like this:


ILOP        MACRO      ;
            DC.B    $8d             ; this is illegal operation code
            ENDM        ;

but i don't know how to implement this code into C.

 

could anyone help me?

ラベル(1)
0 件の賞賛
7 返答(返信)

497件の閲覧回数
bigmac
Specialist III

Hello,

 

I am not sure whether this can be done with inline assembly?

 

However, a method that should work would be to create an ASM file to contain the illegal operation code within a sub-routine.  The sub-routine would then be called from within the C file (as a function with the same name).  A prototype will be needed within the C file, and an XDEF reference within the ASM file.

 

Perhaps others will be able to provide a simpler method.

 

Regards,

Mac

0 件の賞賛

497件の閲覧回数
admin
Specialist II

could you please explain it in detail, or where can i find the instructions on how to call a sub-routine which is in assembly in C?

 

sorry for my cross post

0 件の賞賛

497件の閲覧回数
eckhard
Contributor V

Hello,

 

Fabio Pereira has an example for an ILAD reset on his page.

Look at the Code for chapter 5.

It should be easy to adapt it to ILOP.

 

The reset function is implemented als follows :

 

void reset(void)
{
  unsigned int temp = 0x9E00;
  __asm
  {
    LDHX  @temp            // load the address of temp into H:X
    JMP   ,X              // jump to the address pointer to by H:X
  }
}

 

 

Eckhard

0 件の賞賛

497件の閲覧回数
bigmac
Specialist III

Hello,

 

Maybe the following might work for an ILOP reset.

 

void reset(void)
{
  byte temp = 0x8D;


  __asm JMP @temp;  // Jump to the illegal opcode
}

 

 

 

Regards,

Mac

 

0 件の賞賛

497件の閲覧回数
CompilerGuru
NXP Employee
NXP Employee

As it was discussed in the past, there is no need for the jmp.

https://community.freescale.com/message/10910#10910

 

The HLI supports to embed arbitrary bytes into the instruction stream.

 

Daniel

0 件の賞賛

497件の閲覧回数
Fijvv
Contributor I

I have used:

 

#define MCU_RESET() asm DCW $9E00

.

.

.

 

if (Result[Ch]>=24)

    MCU_RESET();

0 件の賞賛

497件の閲覧回数
peg
Senior Contributor IV

Hello,

 

I think this has been covered before. Search this forum. Maybe include ILOP in search.

It has definately been discussed before but I am not sure on the 'C' details.

Worth a try anyway.

 

0 件の賞賛