I wanted to write a piece of code in C for my Stellaris launchpad just to turn on the onboard LED by keeping the library usage to minimum. To my surprise, the compiled code was around 800 bytes in size. So to check what was put in to the compiled code by the compiler, I checked the assembly code using a dissambler. It had a lot of code which I didn't write the C code for. I would like to know what those codes are for and how did it enter the compiler setting. I am trying to learn how a compiler behaves and what behind-the-scenes things the compiler is doing. Please help me.
This is my C program:
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/rom.h"
#include "driverlib/sysctl.h"
#define GPIOFBASE 0x40025000
#define GPIOCLK *((volatile unsigned long *)(0x400FE000 + 0x608))
#define FDIR *((volatile unsigned long *)(GPIOFBASE + 0x400))
#define FDEN *((volatile unsigned long *)(GPIOFBASE + 0x51C))
#define FDATA *((volatile unsigned long *)(GPIOFBASE + 0x3FF))
void main(void) {
ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
GPIOCLK |= (1<<5);
FDIR |= 0xE;
FDEN |= 0xE;
FDATA |= 0xE;
while (1);
}
The only API call I used was to set the Clock setting using a Onchip ROM library. Please check the dissambly code at this pastebin: (The main: is at 0x190.)