This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Object-Oriented Techniques with C51

Hello All,

Do you know any application notes, tutorial, or example program that is using Object-Oriented Techniques in 8051 ? I heard about Abstract Data Type, Jump Table and so on.

Thanks
-Cahya

Parents
  • // Becuase of the limitations of a 8051,
    //    most(if not all) of your 'classes' should singletons
    //    with statically allocated storage, 
    //
    // I use the ClassName_Member notation on 'public' members
    //    to mimic the ClassName.Member notation
    //
    // Here is one example of a singleton, statically allocated class:
    
    
    //
    // ClassName.h
    //
    extrn int  ClassName_property1;
    extrn char ClassName_property2;
    
    void ClassName_Ctor(void);
    void ClassName_Dtor(void);
    
    int  ClassName_Method1(char* p);
    char ClassName_Method2(void);
    
    //
    // ClassName.c
    //
    #include "ClassName.h"
    
    //public:
    int  ClassName_property1;
    char ClassName_property2;
    
    //private:
    static int property1;
    static int property2;
    
    //public:
    void ClassName_Ctor(void)
    {
      ClassName_property1 = 0;
      ClassName_property2 = '\0';
      property1 = 0;
      property2 = '\0';
    };
    //void ClassName_Dtor(void) //rarely used
    //{};
    
    int  ClassName_Method1(char* p)
    {};
    char ClassName_Method2(void)
    {};
    
    //private:
    static int  Method1(char* p)
    {};
    static char Method2(void)
    {};
    
    
    //
    // Main.h
    //
    
    static void Ctor(void)
    {
      ClassName_Ctor();
      //.. other Ctors 
    }
    
    void main(void)
    {
      Ctor();
      
      ClassName_property1 = 1;
      ClassName_Method1(1);
      
      while( 1 );
    }
    
    

Reply
  • // Becuase of the limitations of a 8051,
    //    most(if not all) of your 'classes' should singletons
    //    with statically allocated storage, 
    //
    // I use the ClassName_Member notation on 'public' members
    //    to mimic the ClassName.Member notation
    //
    // Here is one example of a singleton, statically allocated class:
    
    
    //
    // ClassName.h
    //
    extrn int  ClassName_property1;
    extrn char ClassName_property2;
    
    void ClassName_Ctor(void);
    void ClassName_Dtor(void);
    
    int  ClassName_Method1(char* p);
    char ClassName_Method2(void);
    
    //
    // ClassName.c
    //
    #include "ClassName.h"
    
    //public:
    int  ClassName_property1;
    char ClassName_property2;
    
    //private:
    static int property1;
    static int property2;
    
    //public:
    void ClassName_Ctor(void)
    {
      ClassName_property1 = 0;
      ClassName_property2 = '\0';
      property1 = 0;
      property2 = '\0';
    };
    //void ClassName_Dtor(void) //rarely used
    //{};
    
    int  ClassName_Method1(char* p)
    {};
    char ClassName_Method2(void)
    {};
    
    //private:
    static int  Method1(char* p)
    {};
    static char Method2(void)
    {};
    
    
    //
    // Main.h
    //
    
    static void Ctor(void)
    {
      ClassName_Ctor();
      //.. other Ctors 
    }
    
    void main(void)
    {
      Ctor();
      
      ClassName_property1 = 1;
      ClassName_Method1(1);
      
      while( 1 );
    }
    
    

Children