SDCC generates invalid programs for PIC 16f628a
What's the physical configuration of your MCLR pin?  Your config has MCLR enabled, so if you aren't supplying VCC to the MCLR pin(pin4/RA5) then you're basically holding down the reset button.

Change your config statement to:

uint16_t __at 0x2007  __CONFIG = _CP_OFF &amp; _LVP_OFF &amp; _BOREN_OFF &amp; _MCLRE_OFF &amp; _WDT_OFF &amp; _PWRTE_ON &amp; _INTOSC_OSC_NOCLKOUT;


In more general advice, I have found it useful to explicitly disable all the config options I'm not using. It prevents things like being bitten by MCLR, but it also forces me to read more of the datasheet and learn more of the microcontroller's features.

I also see from your comment that you're using SDCC 3.3. As of this post, SDCC 3.5.5 is available. The current SDCC manual recommends using #pragma config to set configuration bits, as the method used in your example is deprecated. Here's an excerpt from the manual:

4.6.17 Configuration Bits
Configuration bits (also known as fuses) can be configured using one of two methods:

• using #pragma config (see section 4.6.6), which is a preferred method for the new code. Example:

#pragma config CP0=OFF,OSCS=ON,OSC=LP,BOR=ON,BORV=25,WDT=ON,WDTPS=128,CCP2MUX=ON
#pragma config STVR=ON

• using ‘__code’ and ‘__at’ modifiers. This method is deprecated. Possible options should be ANDed and
can be found in your processor header file. Example for PIC18F2550:

#include &lt;pic18fregs.h&gt; //Contains config addresses and options
static __code char __at(__CONFIG1L) configword1l =
_USBPLL_CLOCK_SRC_FROM_96MHZ_PLL_2_1L &amp;
_PLLDIV_NO_DIVIDE__4MHZ_INPUT__1L &amp; [...];
static __code char __at(__CONFIG1H) configword1h = [...];
static __code char __at(__CONFIG2L) configword2l = [...];
//More configuration words

Mixing both methods is not allowed and throws an error message ”mixing __CONFIG and CONFIG directives”.


So, using the method recommended in the SDCC manual, your config block would be:

/* CONFIGURATION Bits */
#pragma config CP=OFF,CPD=OFF,LVP=OFF,BOREN=OFF
#pragma config MCLRE=OFF,PWRTE=OFF,WDTE=OFF
#pragma config FOSC=INTOSCIO