Hi,

I wonder how small the code can it be if I use as many internal peripherals as I could (and I know).
The task is simple, alternately slowly flash LEDs on ports RA0 and RA1. If the supply
voltage goes below 3V lit up the LED on port RA2.
I used PIC12F1840 mcu. Used it's comparator, fixed voltage reference and Timer0.
The code compiles used 42 words.

Just for fun, I wonder if it is possible to program it more effectively?

Code:
#CONFIG
  __config _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_ON & _CLKOUTEN_OFF & _IESO_ON & _FCMEN_ON
  __config _CONFIG2, _WRT_OFF & _PLLEN_ON & _STVREN_ON & _BORV_19 & _LVP_OFF
#ENDCONFIG

DEFINE OSC 4
OSCCON = %01101010 


TRISA   =    %010000   ; RA4 input, rest output
ANSELA  =    %0000     ; ADC Disable
OPTION_REG = %10000111 ; Disable internal pull-ups, TMR0 On, prescaller to 256

FVRCON  =    %10011000 ; Internal reference to 2048V

CM1CON0 =    %10100110 ; comparator uotput to C1OUT, switch on LED if voltageis beloe ref 2,048V
CM1CON1 =    %00100001 ; C1IN1- pin is RA4, comparator voltage input, C1IN1+ positive input to FVR set to 2,048V

LATA    =    %000010   ; init state of pin RA0 and RA1, LEDs connected to these port

n var byte  : n=0      ; init n value to 0

Main:

if INTCON.2 = 1 then n=n+1 : INTCON.2 = 0 ; if TMR0 owerflow increment n by 1, then clear owerflow flag

if n=10 then LATA = LATA ^ %000011 : n=0  ; if n=10 then invert bit 1,0. Pins RA0 and RA1 alternately flash the LEDs

goto Main