| Assembler | | | | You can also make use of white space (areas of |
| Assembler is the most obvious language that you'll | | | | no code) to separate out the various operations |
| consider using as you probably won't need to buy | | | | within the program - typically assembler code is |
| any other tools to use it. More than likely the | | | | just one great big list that is really very difficult to |
| manufacturer will provide an assembler for the | | | | read - I know there are comments but you need |
| chip and you won't need any books as all the | | | | to comment almost every line so that someone |
| instructions are in the datasheet and you just | | | | else canunderstand the code. |
| start coding. | | | | HLL: Task splitting |
| This route to programming is very easy but you | | | | One of the best features of a HLL is that you |
| may be setting yourself up for problems later on | | | | can split tasks into separate functions that you |
| as: | | | | can concentrate on them individually (as the HLL |
| | | | takes care of local variables etc.). For assembler |
| 1. It is trivial to write short programs. | | | | even when using a call instruction you have to |
| 2. It becomes progressively more difficult to write | | | | take care of preserving the register state - in the |
| large programs. | | | | HLL it's all donefor you. |
| 3. It seems to be the best option as it gives the | | | | HLL: Code re-use |
| fastest code. | | | | Once you learn the HLL you will find it easy to |
| 4. It seems to be the best option as it gives the | | | | read code written by other people and you will be |
| smallest code. | | | | able to re-use code that you have already written |
| Assembler: Fast & small code | | | | whereas with assembler you will constantly need |
| There is no doubt that assembler gives the | | | | to analyze the code to see if it fits in with your |
| fastest and most optimized code (your brain is | | | | new functions. |
| better at optimization than any compiler!) but | | | | The only decision then is which high level |
| assembler is difficult - typically you'll spend ten | | | | language? There are really three contenders |
| times as long writing assembler as you would | | | | BASIC, C and Pascal - these are the most popular |
| writing in a high level language. | | | | languages and for popular microcontrollers there |
| Assembler / Compiler Trade off | | | | will be an HLL compiler for each one. I'll just list |
| This is the trade off; to write the fastest most | | | | the advantages and disadvantages of each |
| optimized code or to get the task solved more | | | | BASIC Advantages |
| quickly. | | | | |
| Another problem with assembler is that to do | | | | 1. Very easy to learn and use. |
| even the most trivial task you have to think | | | | 2. A BASIC compiler will produce code that runs |
| about every aspect of the code and all | | | | fast as a C compiler. |
| implications on registers and register flags. | | | | 3. Many in built functions (depending on compiler). |
| Even making a microcontroller perform the most | | | | 4. Very popular - large user base with many |
| trivial task is difficult e.g. for making a loop in | | | | example programs. |
| assembler you need to think about which register | | | | BASIC Disadvantages |
| to use and which instructions all the while thinking | | | | |
| about how those registers should not interact | | | | 1. Non standard language. |
| with the loop register/other registers etc. | | | | 2. If using an interpreted HLL will run very slowly. |
| Assembler: Problem - changing the target | | | | Note: Because the language is not standardized it |
| Another difficulty is when you change from one | | | | will be difficult to move code to a new processor |
| microcontroller to another (even in the same | | | | target type. |
| device family) the assembler instructions may be | | | | Pascal Advantages |
| changed e.g. more instructions to improve | | | | |
| microcontroller performance. So you will have to | | | | 1. Easy to learn and use. |
| learn an entirely different instruction set when | | | | 2. A Pascal compiler will produce code that runs |
| moving either to a new target microcontroller or | | | | fast as a C compiler. |
| moving to a different device within the same | | | | 3. Many in built functions (depending on compiler). |
| family i.e. code re-use is not possible unless you | | | | Pascal Disadvantages |
| stay with one microcontroller (or devices with a | | | | |
| similar internal architecture). | | | | 1. Not as popular as C - so not as many |
| High level languages | | | | compilers. |
| HLL: Retarget | | | | 2. A bit wordy - it was originally intended as a |
| Retargeting code to another microcontroller is | | | | teaching language. |
| easier since the HLL will know the details of the | | | | 3. Not as flexible as C. |
| new target i.e. instruction set, fuses etc. All you | | | | C Advantages |
| need to worry about is the specific differences | | | | |
| between the different microcontrollers (in the | | | | 1. Compiled language - always runs fast. |
| same family this will be setting up the internal | | | | 2. Standardized language (ANSI)- easier to port to |
| peripherals). | | | | different compilers / target devices. |
| The important point is that the HLL takes care of | | | | 3. Many compilers available. |
| the assembler code needed to do the job. | | | | 4. Many in built functions (depending on compiler). |
| HLL: Easy to understand. | | | | 5. Very popular - large user base with many |
| The most useful aspect of a high level language | | | | example programs. |
| (HLL) is that the language is written in a form you | | | | 6. Used in many different industries. |
| can easily understand - there are no cryptic | | | | 7. Usable at the hardware level as well as higher |
| assembler commands that you have to | | | | abstraction levels (although C++ is better for |
| remember and most commands are made up of | | | | very abstracted programming models). |
| several machine code instructions - saving you | | | | C Disadvantages |
| coding effort (often there are built in libraries of | | | | |
| code e.g. LCD driver, Serial port driver, I2C driver | | | | 1. Hard to learn at first. |
| etc | | | | 2. Strong type checking means you spend time |
| So the HLL makes it easy to write code as it | | | | pleasing the compiler (although this protects you |
| generates the correct assembler for the target | | | | from making errors). |
| microcontroller. | | | | You can find more information from the website |
| HLL : Whitespace | | | | here and how to build a website like it here. |