Steve Underwood wrote:
Peter Jansen wrote:
Hi All,
The real question here is what we should do about these misalignment
issues. If the code handles them properly, you really won't like the
result. The MSP430 doesn't allow misaligned loads and stores, so they
have to be simulated by a mass of instructions. The slow bulky code that
produces isn't going to please many people. Should we just say no
misalignment is permitted? Maybe I should check how the other MSP430
compilers handle this.
The compiler MUST get the code correct for what is written. Fast code
that is incorrect is useless, slow code that functions correctly is a
much better option.
How many projects are pushing the outside of the envelope for
speed/efficiency? If you want efficiency and you think you can write it
faster in assembler then go ahead.
Ill have a look at the sample code.
Regards,
I agree that generating wrong code is no good. However, there are other
options, like complaining and not generating anything. You seem to be
taking a narrow view of efficiency. I wasn't thinking of speed, but of
the size of the resulting code. That matters very much to any embedded
developer.
Efficiency (speed, code size, total instruction power, what ever) is
always secondary to functioning code. You cant make the compiler barf
just because of the way some C code has been written, when the written
code is perfectly valid code.
In my 20 years experience what matters to me is code that functions
correctly, and not over write other variables randomly.
I have compiled the example and I need more code to check that it is not
working. Its something to do with the optimizer (which is taking out the
call to memset).
Here is the generated function,
/***********************
* Function `bar'
***********************/
bar:
/* prologue: frame size = 0 */
.L__FrameSize_bar=0x0
.L__FrameOffset_bar=0x0
/* prologue end (size=0) */
mov #llo(21845), &foo+1
ret
/* epilogue: not required */
/* function bar size 4 (3) */
.Lfe1:
.size bar,.Lfe1-bar
/********* End of function ******/
.comm foo,4,2
The thing is that the ".comm foo,4,2" line specifies that foo must be
word aligned, this goes to the linker which is required to align the
variable foo at link time. This should be done, Ill check. For me the
generated code looks fine.
Regards,
--
Peter Jansen
___________________________________________________________________________
Australian Antarctic Division - Commonwealth of Australia
IMPORTANT: This transmission is intended for the addressee only. If you are not
the
intended recipient, you are notified that use or dissemination of this
communication is
strictly prohibited by Commonwealth law. If you have received this transmission
in error,
please notify the sender immediately by e-mail or by telephoning +61 3 6232
3209 and
DELETE the message.
Visit our web site at http://www.aad.gov.au/
___________________________________________________________________________