Search The Web

Wednesday, December 28, 2011

Cissembly - where c and assembly meets I

 The world of software development has reached a stage where in merely writing the algorithm generates the code!.There are software which validates other software. But still the demand exists for low level language programing. Lot of firmwares are written using the c and assembly.
  
In my last post i have described how C++ is growing in embedded domain. But in this post i wold like to explain the combination of c and assembly language. Aim is to discuss how exactly we improve the performance by using C for fast development and assembly for fast execution.

Some of the basic thumb rules is to use assembly code to
1) Develop low level drivers which helps to improve the performance. And also helps to enjoy the specialized features the controller.

2) Use assembly code to develop software delays. We can go in the instruction execution cycle details of the data sheet to tune the timing.

3) If you want to decrease the foot print. But for that penalty is increased development time :P

4) Let the application layer in c as it is best idea for portability.

The cocktail of c and assembly language is known as Cissembly.  I love this language as I have coined this word at least!

source code structure may include in line assembly code. c might call a assembly routine or viceversa.
Data handling is a crusial thing because variable or memory access from assembly is out of the purview of the compiler. So if any overlaping occurs in data section then compiler cannot identify it.

To generate a good c and assembly language combination, developer needs to know following things
i) proper understanding of the compiler  especially the topics related to c and assembly
ii) function call conventions.

Please refer my upcoming post "Cissembly - where c and assembly meets II"



For any further information please feal free to mail at contact_ehobby@gmail.com -eguru

Sunday, September 18, 2011

My experiment with C++

 
E Balaguruswamy mentions in his famous book object oriented programming with c++ "C++ is going to replace the C language in near future". It is an important thing to all embedded C developers. So it is better to learn C++ quickly.



A good c programmer can learn C++ in only one week!. This I can guarantee you all because i achieved it with the same amount of time :)



One main thing in OOP is, it helps to design the program based on the real life entities. We can easily extract the real time features to the design using the concepts such as



1) Polymorphism - one name multiple forms

2) Abstractions - Provide only the necessary information

3) Encapsulation- Wrapping up of Data and function together

4)Data hiding- Hide the unnecessary information based to safeguard the data

5)Inheritance- Deriving the features from already existing one




For example if want to write program based on line. Then we need to create point as it is basic necessity.

So line inherits the properties of the point also. So we can make point as base class and line as derived class.




Please find the appended c++ program which will helps to understand inheritance clearly.




/******************************************************************************************************
;All rights reserved -embeddedhobby.blogspot. com
;
;A C++ program written to understand OOP concepts 18-09-2011
;Author: eguru
; Inheritance
;Constructors
;overloading
;******************************************************************************************************/
#include<iostream.h>

class point
{
  int x;                 // x coordinate
  int y;                 // y coordinate
 public:
  point(int x1, int y1)  // parametrized constructor
  {
   x =x1; 
   y =y1;
  }

  point()                // Non parametrised constructor
  {
   x =0;
   y =0;
  }
  void PutData(void);    // function to display the point
};


class line : public point            // line is class which inherits the properties of the derived class.
{
 point point1,point2;             // point is base class
   public:
     void DisplayLength(void);
     line (int x1,int y1,int x2, int y2) : point1(x1, y1), point2(x2, y2) // constructor list
  {
        cout<< " line initialised";
            
  }
  line():point1(), point2()
  {
   cout << " line is initialised zero";
  }

};
/******************************************************************************************************
;All rights reserved -  embeddedhobby.blogspot.com
;******************************************************************************************************/
void line::DisplayLength(void)
{
   point1.PutData();
   point2.PutData();
}
void point::PutData(void)
{
  cout << "\n origin x="<<x;
 cout << "\n origin y= "<<y;
}
main()
{
 cout  << "WellCome to C++";
 cout<<" Input 1 to display line";
 int x;
 cin >>x;
 line straight;
 switch(x)
 {
  case 1:
       cout<< " Line coordinates are as follows" ;
       straight.DisplayLength();
       break;
    
  case 2:
                cout<< " Add code for your experiment" ;
       break;

  default:
    cout << "  Bye Bye ";
       break;
 }
    point ORG;
 cin >>x;
 return 0;
}


For any further information please feel free to mail at contact_ehobby@gmail.com -eguru

Wednesday, July 20, 2011

Computer vs Embedded systems

Hardly we can find any difference between General purpose computer and Embedded systems when we glance over the capabilities. Basically both are computing systems, both have the combination of software and hardware.  But still why there is a separate field called as  "Embedded systems" other than the General purpose computers/ personal computers?
       But if we get in to the detail based on the different integral parts of the system we can list few important differences.
   
No
Characteristics
Embedded System
General Processing Computing System
1
Product quality/performance
Sophisticated
General
2
Presence in a system
Usually it will be  a small part of a large system
Whole system
3
Time constraint 
Output should be available in the specified of time else it may lead to failure
No such strict rule for most of the task
4
Flexibility
Less flexible for modifications as it is developed for specific purpose
More flexible for up gradation 
5
Input/ Output
Nonstandard input output devices.
Standard input output devices
6
System software's used for development 
Generally cross compilers and cross assemblers, RTOS
compilers, assemblers, OS etc
7
Power
Demands low power consumption to sustain in the market
Less restriction. 
8
Packaging of the product
Will be unique and varies from product to product
Most of the time well defined
9
Examples
Washing machine, Cell phone, set top box
Personal computer, Server etc





For any further information please feel free to mail at contact_ehobby@gmail.com -eguru