Lcc compiler for Mips

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

Reply to
alpha
Loading thread data ...

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

Reply to
Peter Dickerson

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.

Reply to
alpha

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.
Reply to
toby

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.