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

Wrong code generation.

I'm using the Keil C251 Compiler
Optimizing 80251 C Compiler
Version 1.x
(DLL 1.24)

The following instruction is in a function called after an SIO Interrupt:

byLength = abyRecBuf[0]

And the generated code is
7E7301D0 MOV R7,ABYRECBUF
7E004D MOV R0,#4D
A5A607 MOV @R0?#BOOTDOWN#Value

4D is byLength's memory address
and Value is a parameter from BootDown witch has nothing to do with the SIO interrupt.

Is it a compiler bug ????

  • I am only familiar with the C51, but I suspect that the same points apply. When looking at code, the disassembler will attempt to find labels that match a value - but it's not psychic and consequently may display an inappropriate label that just happens to have the right value. This can be very confusing.

    The important question is: is the code actually wrong?

  • Yes the code is actally wrong, seeing that after the execution of the c-line :

    byLength = abyRecBuf[0];

    The value of byLength is wrong.

  • We've been using the 251 compiler for a couple of years and haven't seen a bug like this. One thing to do is to turn off the optimization and see if this fixes the problem. Have you checked with the simulator or an emulator to make sure that there is a real bug? Sometimes the compiled code is not...obvious, especially with the expanded 251 instruction set.