# 8051 with Keil-C filesize issue using a Megawin processor

0 down vote favorite

I've written a program using Keil C for a MegaWin 8051 MPC82G516A. When I check the file size of the Intel generated hex file it has a size of 8kb (I see the code in the binary code window), but when I go to program the device using Megawin's tool it increases the code size to around 29kb!? Can anyone provide the reason for why it might be doing this?

Also, something else that is strange is the fact that it seems to be writing the code at the top of the processor memory and not at the start. There are like 4 bytes at the start of the code, but the complete rest of it is in the end of the memory.

Cameron.

• Where are you reading these 29kb? Intel hex format is basically a text file containing the binary data as ascii 0s and 1 characters, so the file itself will be significantly larger than the resulting binary. So perhaps this is your confusion? What is the file size in the windows explorer? – Eugene Sh. Apr 24 '15 at 15:47
• @EugeneSh. - The hex file represents the binary data as two hex digits per byte, not ASCII 0's and 1's, so should be somewhat more than twice the size of the binary data it represents. – Peter Bennett Apr 24 '15 at 15:53
• @PeterBennett Right. Trusted my memory... But it is still Ascii representation, including addresses and separator. – Eugene Sh. Apr 24 '15 at 15:54
• The file size says 8kb in internet explorer, when I place it in the megawin programmer and count the bytes it comes to 29,000 (or there abouts) – user222811 Apr 24 '15 at 15:55
• Can you show the tool's output? – Eugene Sh. Apr 24 '15 at 16:03

• AFAIR, you can reserve memory for your own purposes in a couple of ways- in the compiler or in the linker. Something like $_at_$ in the first case, and Reserve: in the second. Should be in your documentation. – Spehro Pefhany Apr 24 '15 at 17:38