This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to insert machine code in source code?

Hello,

For the test purpose, I want to insert some machine code in my source code? Is it possible?

Thanks,
Simon

Parents
  • Hello,

    This should work:

    void RunThisWeirdOpCodeJustForCuriosity(void) {
     __asm
     {
       DB XX        ;   replace XX, YY with some opcode - e.g. undefined :-) for your MCU
       DB YY
     }
    }
    

    Useful to test the trap while attempting to execute an illegal instruction, e.g.

    P.S. Keep 2 instructions there to make code aligned at even addresses of your target - C16x needs it.

    Regards,
    Nikolay.

Reply
  • Hello,

    This should work:

    void RunThisWeirdOpCodeJustForCuriosity(void) {
     __asm
     {
       DB XX        ;   replace XX, YY with some opcode - e.g. undefined :-) for your MCU
       DB YY
     }
    }
    

    Useful to test the trap while attempting to execute an illegal instruction, e.g.

    P.S. Keep 2 instructions there to make code aligned at even addresses of your target - C16x needs it.

    Regards,
    Nikolay.

Children