Kids Projects
 

Is the C or Assembly Programming Language Better

The Objective : Microcontrollers are used to control almost everything electronic from game consoles, automobile airbags and life support systems. My project was devised to determine whether the C programming language is less than or equally efficient as the assembly programming language for programming PIC microcontrollers. My hypothesis is that assembly would be more efficient for very complex programs compared to the popular high level C language.

Methods/Materials

I first taught myself how to program PIC microcontrollers in C and assembly.

I created 12 pairs of programs that performed identical functions for the PIC 16F887 in both C and assembly.

Some programs were converted to work on the PIC 16F690 to ensure that the results were similar for different microcontrollers.

I used Microchip's MPLAB IDE (integrated development environment) on a Windows XP computer to program the PIC 16F887 microcontroller with the PICKit 2 device programmer.

The HI-TECH C compiler was used to translate C into machine code and the MPLAB IDE integrated assembler to translate assembly into machine code.

The amount of program memory occupied would be measured in bytes for the matching C and assembly programs.

Results

The assembly programs used the least amount of memory on the microcontroller for all tests.

C used more memory than the assembly programs for all of the tests.

In complex programs, C occupied about twice the amount of memory compared to assembly.

In simple programs, C used about 3 more instructions.

Conclusions/Discussion

In conclusion, assembly should be used for programming complex programs where memory is limited because the HI-TECH C compiler adds unneeded instructions and organizes the program in a less efficient way than assembly. C can be used but more money would be required to buy a microcontroller with a larger program memory. For small programs which needed to be prototyped or programed quickly, C could be used because the difference of program memory compared to assembly is very small. For devices requiring precise timing, without an external timer, assembly should be used because the C compiler adds extra instructions adding extra instruction cycles. For microcontrollers that control life support systems, the programmer might want the microcontroller to respond exactly as programmed so assembly would be used for programming the microcontroller.

This project was to determine whether the C programming language is less than or equally efficient compared to assembly language for programming 8bit PIC microcontrollers.

Science Fair Project done By Michael L. Monaghan

 

 

<<Back To Topics Page...................................................................................>>Next Topic

Related Projects : Is the C or Assembly Programming Language Better , Longevity and Diet , Marco Polo , Mathematical Approaches to a Neat Problem , Maximum Angle of Attack Before Stalling , MgCl(2) Stimulating Effect on Osteogenesis , Motion Detection Algorithm , Multi-Drug Resistance and the Mechanism of Orlistat-Induced Cell Death , Nanocrystalline Dye-Sensitized Solar Energy II , Natural Human Interface for Technology , Now You See It, Now You Don't , Number Theory Meets Algebra , Optimization of the Water Flow Rate in a Clean Energy Electrostatic Power Generator , Optimizing the Chicken Soup Can , Optimizing the Efficiency of Home Hydropower

 

 

 

 

Copyright © www.kidsprojects.info 2012 through 2014

Designed & Developed by Freddy