/* PROGRAM EN asm QUE ENCIENDE O APAGA UN LED(LED1 Enable LED1 Disable LED1 PTB6 6)
  DEPENDIENDO DEL ESTADO DE UN SW(SW1 Enable SW1 Disable SW1 PTA2 14)
  CON MICRONTROLADOR MC9S08QG8 ADAPTADO DE EJERCICIO 1 DEL CAPITULO 4   */
#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
#include "demo9S08QG8.h" //* placa demo
#include "rutinas.h" //rutinas
#ifdef __cplusplus
 extern "C"
#endif
void MCU_init(void); /* Device initialization function declaration */
unsigned char TMR;
unsigned char bandera;
void main(void) {
MCU_init(); /* call Device Initialization */
  /* include your code here */
//inicializo IO
LED1_DDR=1; // led1 como salida
LED2_DDR=1; // led2 como salida
SW1_DDR =0; // sw 1 como entrada 
SW2_DDR =0; // sw 2 como entrada 
LED1=0;
LED2=1;
Bucle:
if ( SW2==DOWN) 
{  
  if(LED1==1){
     LED1=0;
  }else
    LED1=1;
  retardo();
}
goto Bucle;
  for(;

 {
    /* __RESET_WATCHDOG(); by default, COP is disabled with device init. When enabling, also reset the watchdog. */
  } /* loop forever */
  /* please make sure that you never leave main */
}
en el archivo rutinas.h esta esto
//Rutinas varias
//************************************
/* Control Antirebote de las teclas.*/
//************************************
char n,i;
void retardo(){
for (n=0;n<250;n++){
     for(i=0;i<=250;i++);
     }
}
Saludos yo estoy aprendiendo asi que no se demasiado!
Porrale