Shop OBEX P1 Docs P2 Docs Learn Events
Question about -mcog and code size — Parallax Forums

Question about -mcog and code size

RetrobitsRetrobits Posts: 46
edited 2013-11-25 09:33 in Propeller 1
Newbie alert :-)

If I read it right, programs generated with the COG memory model (-mcog) are supposed to run within a cog, with speed/size benefits, if your code is small enough to fit in < 2K.

The trouble I'm having is that even a program that does nothing - with an empty main() function - still gives me an elf file that is 2207 bytes.

I understand -mcog puts data into hub RAM, but in this case, there is no data at all, so I'm assuming it's all executable.

I'm using:

propeller-elf-gcc -mcog -Os -o test.elf test.c

Is some of the executable size bootstrap code, and actually, this really fits? I don't know the architecture of the executable or what it contains, so it could be misleading me. Also, is there an error message generated if your code is too big to fit into the memory model you've selected, or does that happen at load time?

Thanks for help out a newcomer,

- Earl

Comments

  • SRLMSRLM Posts: 5,045
    edited 2013-11-23 15:39
    The .elf file contains additional data besides the actual program. For example, on my (non-mcog) program the .elf file is 25932 bytes on disk but only 12032 bytes downloaded.
  • RetrobitsRetrobits Posts: 46
    edited 2013-11-23 16:06
    That makes sense. I just used the -s flag with propeller-load, to create a .binary file from the .elf file. The size was significantly smaller, under the 2K limit.

    All is well!

    - Earl
  • jazzedjazzed Posts: 11,803
    edited 2013-11-25 09:33
    Just a few thoughts.

    While -s does give a closer approximation of image size, it can also disable variable stuffing functionality of propeller-load.

    SimpleIDE calculates the actual code and data size of a program without using -s and displays it on the bottom left panel.

    Propeller-load also gives the actual code size on load as well as with the binary conversion method you mentioned.
Sign In or Register to comment.