Re: "Illegal instruction" for most trivial of programs
On Mon, Feb 04, 2008 at 12:27:25PM -0800, James Kimble wrote:
> I've got another weird thing going on here. I can't assign values
> greater that 128 to integers. When the program reaches the statement
> that does that I get the same "Illegal instruction" message and the
> program exits without completing. For example if I just add a for loop
> to the end of the above program it will only work for loop values less
> than 128. At 128 the program will exit and give the "Illegal
> instruction" message. What the heck is going on here?
I presume you are assigning constant values into a variable? My first
guess in that case would be that the compiler is emitting a MOVEQ
instruction but not properly checking the limit on the immediate data
field (an 8-bit signed quantity) against the value being assigned. This
also implies a bug in the assembler where it just shoves the value onto
the instruction word without masking out the higher bits. Seems like an
unlikely bug, but stranger things have happened. If it only dies at
exactly 128, it could be an off by one error. Have you tried going
directly to much larger values and avoiding the specific value of 128?
I would suggest trying to disassemble that part of the object file and
see what you get. It might also be worthwhile to look at the assembly
code generated by the compiler (add -save-temps to your gcc options).