Active Topics

 


Reply
Thread Tools
Posts: 1,224 | Thanked: 1,763 times | Joined on Jul 2007
#21
In short:

C is a language that combines all the elegance and power of assembly language with all the readability and maintainability of assembly language.
...
 
Posts: 2,102 | Thanked: 1,309 times | Joined on Sep 2006
#22
with all the readability and maintainability of assembly language.
Hmm, well I think it's easier to read (and therefore maintain) C myself, but perhaps I'm just not getting the joke in that quote.
 

The Following User Says Thank You to lardman For This Useful Post:
Posts: 37 | Thanked: 9 times | Joined on Nov 2008
#23
...I want to learn assembler, in order to understand how the machine works, then indeed, to make a little C stuff ! it's the main goal...

Some well commented assembler source code will provide you with much of what you want to know.

Believe it or not, before I could afford a computer, I used to write Z80 assembler programs on paper. I made a little chart showing all of the registers, then I would manually execute the program using pencil and eraser.

When I took my assembler class, the first programs we wrote were in machine language. All input was via front panel switches, output was by front panel lights. We would load the program into memory one instruction at a time, and then step to the next memory location.

You only need to do a little of this to get the idea of how a cpu works.
 
Posts: 37 | Thanked: 9 times | Joined on Nov 2008
#24
C is a language that combines all the elegance and power of assembly language with all the readability and maintainability of assembly language.
If you go back and read the interviews and articles of Dennis Ritchie, his goal was to produce a portable high level assembly language.

Your quote on C is exactly right. C was designed to be a language for expert programmers. Unfortunately most people think they are experts. I have looked at a great deal of C code over my career, and I have to say that there is more crap out there then you would believe, including the code I wrote.
 
Posts: 503 | Thanked: 267 times | Joined on Jul 2006 @ Helsinki
#25
Originally Posted by pycage View Post
Speed is not a matter of choosing a certain language, speed is a matter of choosing the right algorithms.

Apart from that, writing whole programs in assembler is not recommended on modern operating systems because you would have to program against a C-level interface. But nothing (except for portability) speaks against writing small functions (e.g. for image processing) in assembler. But don't get the illusion that asm is faster than C. Most C-compilers nowadays produce optimized asm code that is faster than anything you would write yourself in asm.
But unfortunately gcc for arm is not one of these compilers. It does rather poor job at instructions scheduling and registers allocation. Leaf functions containing loops and nontrivial branching logic can be hand optimized quite well using assembly with rather good results. Of course optimizing these functions only makes sense if they are performance hotspots.
 
Posts: 37 | Thanked: 9 times | Joined on Nov 2008
#26
Originally Posted by Matan View Post
C is no compromise. If you never programmed in assembly (or C, C++, python, perl) then your assembly code is not going to be faster than your C code for anything more useful then a countdown loop, for at least a few years. By then, even ARM might be superscalar and out of order, so you will need to start optimizing your super fast code all over again.

If you do want to learn ARM assembly (it is useful for a lot of things, just not for speed), you need the ARM ARM, since that is the standard text.
I agree with this, but I think, it is more a function of modern optimizing compilers rather than the language per se.
 
Posts: 3,841 | Thanked: 1,079 times | Joined on Nov 2006
#27
Originally Posted by CVBruce View Post
I agree with this, but I think, it is more a function of modern optimizing compilers rather than the language per se.
.. combined with the complexity of writing assembly on modern CPUs: Optimizing for the pipeline, out-of-order execution, delay slots, and other tricks (depending on which CPU you're programming for). Those things can be really tricky to get right when doing assembly programming by hand. Back in the days when I did assembly programming myself I didn't have to think of any of that (6502, z80,6809, minicomputer assembly).
__________________
N800/OS2007|N900/Maemo5
-- Metalayer-crawler delenda est.
-- Current state: Fed up with everything MeeGo.
 
briand's Avatar
Posts: 566 | Thanked: 145 times | Joined on Feb 2008 @ Tallahassee, FL
#28
Originally Posted by TA-t3
Back in the days when I did assembly programming myself I didn't have to think of any of that (6502, z80,6809, minicomputer assembly).
ha.. cool. I had the honor and great privilege to work alongside (and learn from) the guy who (literally!!) wrote the book on 6809 Assembly programming -- Lary Myers.
__________________
N800 / OS2008
Now running Canola-free (by invitation) since 2215 UTC 21 May 2008.
 
Posts: 45 | Thanked: 17 times | Joined on Nov 2008 @ Montreal, Canada
#29
I've programmed assembler on the ZX81 (Z80), C64 (6502/6510), Amiga (68000) (those for fun), for the 68HC11, PIC (16C74), and TI DSPs (c50) (for pay) and PPC (for school). I've spent a lot of time coding C for fun, school and work, too. And a smattering of other languages as well, from FORTH to Lisp.

Now? I write in MATLAB, and am learning Python. There is a golden rule: the right tool for the right job. Don't use ASM "just because". If you want to learn about the internals of CPUs, be aware that architectures are all different, and evolve. My 6502 assembler didn't prepare me for RISC, or the Harvard architecture of the PIC chips. What you learn for ARM today can't easily be carried over to i686, or the cell processor or DSP chips, or whatever the chip designers are dreaming of today. VHDL might be more useful!

If your goal is to learn about to-the-metal computer programming, I recommend getting yourself an Arduino or maybe a Parallax Propeller kit. I've got myself the former and they're great fun. Programmable with very little ramp-up in C, and ASM if you dig a little. Dead easy to interface.

If you want to write applications, start with Python, until you hit a performance or capability bottleneck. Then switch to C++ or C.

If you want to learn about OS design, hit the books. Then learn C. Then look at the Linux source. Read more books. OS design is very complex and academic these days, and there are many difficult algorithms at play.
 
Reply

Tags
arm, asm, programming


 
Forum Jump


All times are GMT. The time now is 15:53.