generate an illigal operation

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

generate an illigal operation

1,723 次查看
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 回复数

840 次查看
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 项奖励
回复

840 次查看
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 项奖励
回复

840 次查看
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 项奖励
回复

840 次查看
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 项奖励
回复

840 次查看
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 项奖励
回复

840 次查看
Fijvv
Contributor I

I have used:

 

#define MCU_RESET() asm DCW $9E00

.

.

.

 

if (Result[Ch]>=24)

    MCU_RESET();

0 项奖励
回复

840 次查看
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 项奖励
回复