|
-
C Programmers Help !
Alright, here's the beef. I'm basically writing a program for a PIC18 microcontroller. There's just one problem, my main asm file, it compiles C into assembly and then turns it into bytecode, is too big to be loaded into memory. So I'm getting compiler errors telling me the section is too long. It's not a very high end microcontroller, but I'm still pretty surprised I hit its limit so fast.
My program has a copious amount of char arrays, size 17. I did some removal of the parts of the program concerning the char arrays. I then declared them before the main method. It didn't compile. When I removed them, it compiled.
I was thinking of splitting up some of the methods into another file. How do I do that ? How do I access said external methods from the class file containing the main method.
Alternatively, a simple way to fix this would be to tell me a way to store some char arrays in another file. I would also need to know how to access them using the main method file.
I was schooled in Java, so I'm not sure how to go about doing this in C. Normally I would make a constructor for an object in that external file. Make that keep all the arrays. Then use dot operators to access the variables I want from the new object.
I'm quite sure I surpassed the maximum size for one such C file. The microcontroller will definitely accept more C files, it has 2 MBs of program space.
Last edited by Transfurzz; 08-11-2007 at 07:08 AM.
Xbox Live Gamertag: Weistber
Gaming Rig Status: Up
| i5-2500 | MSI GTX560 | 2x2GB Corsair ValueRam
Games I'm playing: Witcher 2 (PC), RAGE(PC), Fallout: New Vegas (PC), Gears Of War 3 (X360)
-
NullPointerException
I was schooled in Fortran and currently use Java/C# mostly. C is by far my weakest language, but I have a couple ideas.
Can you reduce the size of your C file by using a header file? Or will the #include be inlined so it still takes up the same space?
To call outside functions, all the data usually needs to be in the same line. Instead of OO things where you create and instance with data, set a tolerance, then return a result in 3 different calls, in C it's more like result = myfunc(data_a, data_b, tol). If you can really include lots of small C files, pulling separate functions out as individual source files sounds sensible.
Open Source is free like a puppy is free.
It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames.
Understanding Evolution
-
Tiger Shark
Just write some asm to load your arrays into a higher part of memory then manually assign your C pointers to those addresses.
-
 Originally Posted by Remington
Just write some asm to load your arrays into a higher part of memory then manually assign your C pointers to those addresses.
Thanks. That sounds about right.
Xbox Live Gamertag: Weistber
Gaming Rig Status: Up
| i5-2500 | MSI GTX560 | 2x2GB Corsair ValueRam
Games I'm playing: Witcher 2 (PC), RAGE(PC), Fallout: New Vegas (PC), Gears Of War 3 (X360)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|