generate an illigal operation

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

generate an illigal operation

1,377 Views
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?

Labels (1)
0 Kudos
7 Replies

494 Views
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 Kudos

494 Views
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 Kudos

494 Views
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 Kudos

494 Views
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 Kudos

494 Views
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 Kudos

494 Views
Fijvv
Contributor I

I have used:

 

#define MCU_RESET() asm DCW $9E00

.

.

.

 

if (Result[Ch]>=24)

    MCU_RESET();

0 Kudos

494 Views
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 Kudos