Lcc compiler for Mips

Sep 20, 2005 3 Replies

Hi,



I am writing an assembler for "MIPS" compiled by lcc. I meet an issue: a local array will be copyed into its stack. For example: void foo(void){ char s[]="1234567"; .... } lcc will put string "1234567" in to .rdata section, then copy them back to stack in function foo(). There may have alignment situation, so lcc uses ulw, usw etc.. The processor, I am targeting, does not support unaligned memory access e.g. LWL, SWL, LWR.



How can I deal with it in my assembler? or how to force Lcc not to use these unaligned memory access instruction.



PS. Actually, I am trying to make an asmebler working for an my MIPS like processor on FPGA.


Thanks



Assembling calls to support functions in place of the missing instructions would be a good start. That would allow you to progress with other issues while finding a better (performing) solution.

Peter

Thanks, This is exactly want I need. How come LCC does not provide this mechanism? If I decalared a local 258 byte string, does it get copied in to stack word by word?

BTW: I have a simple but silly solution now: "copy data in byte" - this removed alignment issue, but get more instruction count.

If you make sure the frame variable is aligned & rounded up to whole words, you can copy by words if you prefer. Depending on the number of words you can unroll word copies, inline a loop, or call a helper. The lcc book includes a good discussion of optimising block copies.

In this situation 'static' storage class avoids the copy.

> > BTW: > I have a simple but silly solution now: "copy data in byte" - this > removed alignment issue, but get more instruction count.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required