Author Topic: assembler vs another language  (Read 1342 times)

0 Members and 1 Guest are viewing this topic.

Offline vipulan12Topic starter

  • Robot Overlord
  • ****
  • Posts: 181
  • Helpful? 0
assembler vs another language
« on: May 20, 2014, 02:58:55 PM »
When programming a micro controller you could assemble or C, is their any advantage between the two in terms of applications?

asseble takes up less space but is their any other advantages over C?


Offline jwatte

  • Supreme Robot
  • *****
  • Posts: 1,345
  • Helpful? 82
Re: assembler vs another language
« Reply #1 on: May 21, 2014, 09:25:41 AM »
Assembler doesn't take up less space except in certain cases. The main benefit is that you have full control over the hardware.

There are cases, such as certain watchdog, windowed-write, or interrupt-routine applications, where the number of cycles must be controlled very exactly, and with assembler, you can do exactly that.

There are also cases where specific instructions have no equivalent in C, and you must use assembler for that reason. Typically, you implement a C-style function interface in assembler, and call that function from C to get access to the special instruction.

Use assembler when you cannot get what you want in C. Otherwise, use C.

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
Re: assembler vs another language
« Reply #2 on: May 21, 2014, 11:42:18 AM »
Quote
Assembler doesn't take up less space except in certain cases.
This is highly compiler dependent. For example the Free versions of the compilers for MicroChip PICs do not optimize so the code produced is 3 to 4 times larger than if you buy the top end compiler and use full optimization. This also means well written assembler code will be about the size size or smaller than fully optimized C code.

I use C code when code size or execution speed is not as important (using free non-optimizing compiler) else I use Assembler.

Offline jwatte

  • Supreme Robot
  • *****
  • Posts: 1,345
  • Helpful? 82
Re: assembler vs another language
« Reply #3 on: May 21, 2014, 04:22:40 PM »
I assume that you use competent tools for the application you are targeting.
If you choose to shoot yourself in the foot for one reason or another (cost, prejudice, poor vendor choice, ...) then of course you will be limping.

 


Get Your Ad Here