EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Illegal opcode

Started by Alowonle, Musibau July 17, 2003
Hi Everyone,

My code locks-up in an infinite loop by getting into the Illegal Opcode
interrupt routine. Now the book says the way to get out of this is by
popping/pulling the stack of the return address of the illegal opcode. I
know I can do this by using the In-line assembly function " _opc( opcode
); "

My question is what opcode should I use to pop the return address from the
Illegal opcode instruction. I know it is a PULL instruction opcode, but how
do I specify popping the return address which would be the last address
placed on stack??

Regards,
Musibau O. Alowonle
Project Engineer - Electrical
Ph: 763-540-1506
fax: 763-513-1710
e-mail:



----- Original Message -----
From: Alowonle, Musibau <>
To: <>
Sent: Friday, July 18, 2003 1:01 AM
Subject: [m68HC11] Illegal opcode > My code locks-up in an infinite loop by getting into the Illegal
Opcode
> interrupt routine. Now the book says the way to get out of this is
by
> popping/pulling the stack of the return address of the illegal
opcode. I
> know I can do this by using the In-line assembly function "
opc( opcode
> ); "
>
> My question is what opcode should I use to pop the return address
from the
> Illegal opcode instruction. I know it is a PULL instruction opcode,
but how
> do I specify popping the return address which would be the last
address
> placed on stack??

Illegal opcode exceptions are next to impossible to recover from. For
one, you can't be sure the instruction causing the exception was the
first one to execute out of order. For example, a huge sequence of
valid opcodes could have executed right before the illegal opcode.

Retrieving the address of the illegal opcode is useful not so much for
recovery as for debugging or special purposes, meaning the addition of
user-specified opcodes that are not part of the original instruction
set and are taken care of inside the Illegal Opcode Handler.

I would not trust to continue execution of a program that unexpected
enters the Illegal Opcode Handler, without initiating some kind of
reset.

> Musibau O. Alowonle




--- "Alowonle, Musibau" <> wrote:
> Hi Everyone,
>
> My code locks-up in an infinite loop by getting into the Illegal Opcode
> interrupt routine. Now the book says the way to get out of this is by
> popping/pulling the stack of the return address of the illegal opcode. I
> know I can do this by using the In-line assembly function " _opc( opcode
> ); "
>
> My question is what opcode should I use to pop the return address from the
> Illegal opcode instruction. I know it is a PULL instruction opcode, but how
> do I specify popping the return address which would be the last address
> placed on stack??
>
> Regards,
> Musibau O. Alowonle
> Project Engineer - Electrical
> Ph: 763-540-1506
> fax: 763-513-1710
> e-mail:

Here is a routine I use to skip illegal op-codes. It will just
step through a section of bad code until it reaches executable
code. In most cases, though, you would want to signal your
program or the operating system that you had this problem.

This is the interupt handler for the IOT exception:

HandleIOT
tsx ; get stack pointer in X
ldd 7,x ; get current program counter
addd #1 ; point to next op-code
std 7,x ; put new PC back on stack
; < here, signal your program that something bad happened >
rti

This routine will return to the location one byte after the
illegal op-code.

Regards,

Jim Dodd
Onset Computer Corp. __________________________________




Memfault Beyond the Launch