Programa 3: Sumar 4 bits

Programa 3: Sumar 4 bits + 4 bits....


Solucion:

/*Sumador de 4 bits*/

#include <16F84A.h>

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES XT                    
#FUSES NOPUT                    //No Power Up Timer
#FUSES PROTECT                  //Code protected from reads
#use delay(clock=4000000)

#byte port_a=0x05
#byte port_b=0x06

int8 sumando1;                  
void main()
{
   int8 sumando2;            
   char aux;              
  
   set_tris_a(0b00000000);      
   set_tris_b(0b11111111);      
  
   do                         
   {                                  
      aux=port_b;
      sumando1=aux&0b11110000;
      swap(sumando1);      
      sumando2=aux&0b00001111;
      port_a=sumando1+sumando2;
   }
   while(true);                 
}

comentarios: en la simulacion uso puntas de prueba para simular entradas en RB.. mirar la grafica
Aunque es un circuito muy sencillo, para no perder la costumbre pondre nomas la simulacion. al joder..