Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

How to set program counter to illegal address while code is running ?

Status
Not open for further replies.

jani12

Member
I'm trying to create illegal instruction reset.

I'm programming Infineon TC29x Aurix Tricore Microcontroller based embedded system in 'C' language.

I need to set program counter to illegal address, i.e. 0x00FF FFFC. Can this be done with assembly language instructions?
If yes, please instrument assembly language instruction that would set program counter to 0x00FF FFFC while code is running.
 
So far as I know, an "illegal" memory location will appear as something else, but won't simulate or run.

In this example of code for a 12F1840, I assign 0xFFFF as an illegal location for the CBLOCK directive. In theory, it rolls over:
upload_2017-6-20_18-43-9.png

The disassembly is shown on the left (MPLab 8.92). Notice that register "temp" is set as 0x1. That will, of course cause problems. The Watch window for an attempted simulation shows:

upload_2017-6-20_18-45-16.png


I could try to force something more, but first, why do you want to do that?

John
 
Even in C execution of random areas can happen, with a table of pointers to functions and an out of bounds index would do it. In fact, that is the answer to the ops question, a pointer to a function with a random address should produce the required result.

Mike.
 
Even in C execution of random areas can happen, with a table of pointers to functions and an out of bounds index would do it. In fact, that is the answer to the ops question, a pointer to a function with a random address should produce the required result.

Mike.
Hi Mike... Problem here is... Even with a bad pointer, no exception will be generated.. One of C golden rules.. Initialise pointers as you get no warnings in runtime...
 
I'm assuming the chip he is using generates exceptions and he wants to test his exception handler. I'm not familiar with the chip.

Mike.
 
If you have access to the return stack, you could put the illegal address on the return stack and then execute a return instruction.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top