As they already told you, the main function MUST be a loop.
What you're doing is undefined behavior. If there's more code after the main end address (initialization, whatever), it will inmediately excecute it.
Or skip everything until it reaches the end of the flash, causing a reset (hence the flickering you see).
If you want to stop forever at some point, then use while(1).
Something like this:
#define data GPIObits.GP0
#define clock GPIObits.GP1
#define repeat_val (unsigned long)500000 // Value to use as a timer. Adjust as you need for longer or shorter time
void main(void){
unsigned char display = 7; // Digit to display. Better to use char (int is 16 bit, slower on 8bit PIC12), as you can only display 0x0-0xF digits (0-15 decimal)
unsigned long tim = 0; // Huge 32bit variable to use as a timer (Better to use a real timer)
while(1){ // Forever
for (int count = 0; count <8; count++) { // Update display
data = (display >> count) & 1; // Right shifts by 0,1,2,3.. then blanks all but bit0
clock = 1; // Clock pulse on
clock = 0; // Clock pulse off
}
clock = 1; // Final pulse that RCLK is expecting as
clock = 0; // it is one pulse behind SRCLK.
if(++tim>repeat_val){ // Increase value. If reached limit:
tim=0; // Reset variable
asm("sleep"); // Sleep (CPU stops here)
// sleep(); // I think this worked too...
// When it wakes up, it will repeat the cycle (You need to enable some event to wake up. Like an external input, a timer...)
}
while(1); // If at some point you want to stop the CPU forever, do this.
// This program code will never reach this, as it's locked inside the previous while(1).
}
}