Shop OBEX P1 Docs P2 Docs Learn Events
Is assembly language a dead skill set? — Parallax Forums

Is assembly language a dead skill set?

HollyMinkowskiHollyMinkowski Posts: 1,398
edited 2011-04-27 17:22 in General Discussion
Interesting article here http://www.embeddedinsights.com/channels/2011/02/02/is-assembly-language-a-dead-skillset/

The comments that follow the article are very good.

I can't imagine working with a uc that I could not write asm
for....and asm is actually the easiest language to use of all,
it's just a bit tedious, tiny baby-steps to accomplish
your task.
«13

Comments

  • LeonLeon Posts: 7,620
    edited 2011-02-12 12:13
    It depends on the assembly language.

    One minicomputer had such a complex instruction set that a Snobol preprocessor was supplied.

    Writing ARM assembly language is quite difficult and the compiler does a better job in many cases.
  • HollyMinkowskiHollyMinkowski Posts: 1,398
    edited 2011-02-12 12:22
    Yes, ARM asm is tougher than writing asm for 8bit AVR or the Prop.
    Most code I write is C but I lean heavily on asm to speed up interrupt
    routine code.

    This statement from the comments below the article is particularly good.
    "when you need to squeeze the extra performance or program space out of the inexpensive 8 bit micro driving your cost sensitive product, assembler may be the only answer."
  • LeonLeon Posts: 7,620
    edited 2011-02-12 12:38
    The smaller PICs aren't suitable for C, although there are C compilers for them. Most non-hobbyists program them in assembler.

    I couldn't afford an assembler when I started, so I hand-assembled my programs. I got quite good at it, and even produced a comprehensive debugger for the 8088 - about 15 pages of hand-written and hand-assembled code. It got easier when the basic debugger was working as I was able to use it to debug the next version.
  • rod1963rod1963 Posts: 752
    edited 2011-02-12 13:00
    Depends on the processor. ARM and MIPS are unfriendly. I really like the AVR, 6809 and 68K chips.
  • HollyMinkowskiHollyMinkowski Posts: 1,398
    edited 2011-02-12 13:07
    Actually creating machine code without an assembler...now that's really working at the bottom level.

    Since you are in the UK I bet you are aware that the ARM is very much a British creation.

    I hear MS is porting W8 to ARM.... WIntel is joined by WARM ..LoL
  • HollyMinkowskiHollyMinkowski Posts: 1,398
    edited 2011-02-12 13:19
    rod1963 wrote: »
    ARM and MIPS are unfriendly.

    Sort of unfriendly, but there are lots of nice ARM asm tutorials on the web.
    You can pick up a basic working knowledge in a week or so if you put in
    a few hours a day. MIPS I'm really not acquainted with.

    http://www.coranac.com/tonc/text/asm.htm#sec-arm

    http://www.google.com/search?rls=ig&hl=en&source=hp&biw=1680&bih=873&q=arm+assembly+tutorial&aq=2&aqi=g10&aql=&oq=arm+assembly
  • ctwardellctwardell Posts: 1,716
    edited 2011-02-12 13:28
    I started out on the RCA CDP1802 as a kid writing machine code by hand, and the first few things I did on the 8085 were hand assembled. I still prefer assembly as a way to get well acquainted with a new processor, but you do typically need to work in a higher level language to be productive.

    C.W.
  • Dave HeinDave Hein Posts: 6,347
    edited 2011-02-12 13:41
    The C compilers I'm familiar with generate highly optimized code. I work with DSP and image processing chips, and it is very difficult to write assembly for some of these processors. There are pipelining issues, register crossbars and multiple instruction slots that make it difficult to program in assembly. Compilers can keep track of all these requirements and generate very efficient code. It is also very difficult to maintain assembly code in large projects. So, I don't think assembly programming is used much in high-end development.

    Of course, there are a lot of processor that don't have an optimized compiler where assembly is needed to get the most out of the chip. So at the low-end of the scale assembly language is still very important.
  • potatoheadpotatohead Posts: 10,261
    edited 2011-02-12 13:43
    Ok, one of my assertions: Writing assembler costs more in development and maintenance. Hypothetical situation – given that you’re going to get about the same code anyway, would you rather write ten lines of C, or 100 lines of assembler? [My assumption: it takes an average of ten asm instructions to represent one line of C/C++ - I know this is highly application and processor-specific] Ok, you went with assembler, fair enough. Now you need to add a major new feature. Even though you did a sterling job of compartmentalizing your code, you still have to modify 1000 lines of assembler. Chances are, that equates to less than 100 lines of a high level language that need to be reviewed and edited.

    This is one area where the prop is kind of interesting. Because of how the cogs work, assembly bits can be very easily compartmentalized and used in tandem with higher level things. Worth some thought, IMHO.

    Also, some other comments to the article were spot on. Assembly language will fall out of popular favor, but won't ever go away. The higher level stuff depends on the skills assembly language programmers have, and there are always legacy systems too. Those with good skill will always find there is a need to employ it. Can't boot strap, just like we've been doing with the Propeller, without those skills either. New tech then always starts with assembly language as all the little bits of code needed to fold it into the higher level constructs are assembly language by default, because of the need for boot strapping the tech into general use.
  • Dave HeinDave Hein Posts: 6,347
    edited 2011-02-12 14:00
    I made my earlier comment without actually reading the article, so I read the article. It's odd that the author emphasized that assembly is needed to take advantage of caching and registers. Of course, this premise is entirely false. The C language has a "register" keyword that tells the compiler to use a register for that variable if possible. Even without the register keyword an optimized compiler can do everything in the registers unless it needs to use the stack or memory. One compiler I used would even pass calling parameters in registers unless you told it use the stack.

    Efficient cache utilization is more a function of code and data organization than anything else. Some processors allow for preloading the cache with DMA and locking ia portion of it. This can be done in a high level language as easy as assembly.
  • Martin_HMartin_H Posts: 4,051
    edited 2011-02-12 15:39
    I used to make a living programming in assembler (6502 and later VAX Macro). I first heard the assembler is dead refrain back in the late 80's, but people are still using it in timing or space critical code. So it still has its place, but compilers are good enough that it should be used sparingly.
  • rod1963rod1963 Posts: 752
    edited 2011-02-12 16:36
    There will always be a need for it. I just like it personally because that's how I learned to program some 25 years ago and the architectures back then were assembly friendly.

    But it's assembly's role is shrinking. Recently I bought one of those el cheapo TI 430 kits, come to find out TI expects you to code for the lilliputian in C even though it has a easy to learn ISA. And to me to install a bloated piece of excrement like Eclipse and play C compiler games just to work with this chip was nothing short of a insult.
  • Lord SteveLord Steve Posts: 206
    edited 2011-02-12 20:11
    If you think that ARM assembly programming is user-unfriendly, then you have never studied the Itanium programming model.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-02-12 21:13
    I had a customer for whom I designed a linescan inspection system using the SX. The original deal was that I would write the sensor and communication drivers in SX assembly, and they would write the (rather confidential) app code in C. Well, when crunch time came, the C code still wasn't performing adequately, so I rewrote their app in assembly. Of course, with its segmented memory architecture, the SX was very C-unfriendly, so I can't blame the language entirely -- as much as I'd like to. :) But the take-home lesson was that sometimes there's just no substitute for finely-tuned assembly code when you have to wring every ounce of performance from a micro.

    I doubt that good assembly programmers will ever be wanting for work. And if there are fewer and fewer practitioners, so much the better for the rest of us! At least Browser will still be getting his shrimp treats.

    -Phil
  • rod1963rod1963 Posts: 752
    edited 2011-02-12 22:28
    I've been told the latest Intel stuff is a nightmare at the assembly level and is best avoided. But it's the price we pay for MS compatibility.
  • davidsaundersdavidsaunders Posts: 1,559
    edited 2011-04-20 17:28
    If assembly is dead or dying, then I am a dinosour :) .
    I have always felt that Assembly and machine lang are the way to go for most applications, easier to debug, fewer bugs period, easier to read (with a few exceptions). I also use BASIC, UCSD complient Pascal, ANSI C (NOT gcc style [yuk]), and a few custom languages (starting to even do some SPIN). Though assembly remains the best for any serious project in my book, the high level languages are good for small rarely used code, you need assembly for any big and/or serious project.
  • localrogerlocalroger Posts: 3,452
    edited 2011-04-20 19:33
    While my take isn't as extreme as davidsaunders' I do think that any project where assembly is off the table is a crippled project. In the late 1980's / early 1990's I developed an 80/20 target whre 80% of the source code would be in, generally, something like QuickBasic (although I went through a couple of generations of the HLL) and the other 20% in ASM. Windows killed even the possibility of the .asm component and forced me to VB as the HLL. I wasn't much interested in other/better models in PCworld because I was doing that stuff in embedded land. Some of it with BASIC stamps LOL.

    My current problem is that in timing critical applications PC's have been impossible for more than a decade, so you need ether a really elaborate interrupt driver that can somehow convince the OS not to freeze it out (good luck with that) or outboard processing. I am currently going with outboard processing, and after using Blue Earth Controllers in a similar way (I have better interrupt driven serial drivers than the manufacturers do) and for some things Basic Stamps, I have now had one of our esteemed peers here make a board to do those kind of things with a Propeller. Not planning to look back.

    What I really want to do is ditch the PC and put the app on the web via an ethernet adapter from one of these embedded boards. That doesn't quite fit in 32K but I'm working on what looks like a very viable alternative.
  • kwinnkwinn Posts: 8,697
    edited 2011-04-20 19:34
    Leon wrote: »
    The smaller PICs aren't suitable for C, although there are C compilers for them. Most non-hobbyists program them in assembler.

    I couldn't afford an assembler when I started, so I hand-assembled my programs. I got quite good at it, and even produced a comprehensive debugger for the 8088 - about 15 pages of hand-written and hand-assembled code. It got easier when the basic debugger was working as I was able to use it to debug the next version.

    I did the same for my first 8080 computer up until I hand assembled a floppy disk bootstrap program for CPM. The hex digits were then entered by hand on our 1702 eprom programmer. Took several tries to get it right but by the time I did I knew 8080 machine code really well. I was also very happy to type "B" at the monitor prompt and have CPM load.
  • Heater.Heater. Posts: 21,230
    edited 2011-04-20 23:17
    Some of the best programmers in the world are very familiar with assembler and down and dirty machine architectures.
    Although they may never actually write in assembler.
    How so?
    Because they are the guys who write the compilers that the rest of us mere mortals use:)
  • JasonDorieJasonDorie Posts: 1,930
    edited 2011-04-20 23:30
    I work in games, and while most of the code is written in C/C++, there is certainly still a place for assembly, or code that is very close to it using a hybrid called "compiler intrinsics". Most high level languages can't deal with things like SIMD registers (like MMX, SSE, AltiVec, etc), so the compiler writers create "functions" that are just macros recognized by the compiler to make it produce specific opcodes under the hood. It's very close to assembly, but lets the compiler handle register allocation and instruction dependency and scheduling. Even then, sometimes it can still be beaten by hand tuned code if someone knows the architecture of the machine well enough. My video codec uses it in a few select places.
  • Heater.Heater. Posts: 21,230
    edited 2011-04-21 02:22
    Davidsaunders,

    I admire your spirit but there are a few issues to deal with.
    I have always felt that Assembly and machine lang are the way to go for most
    applications,...

    Quite possibly true on small systems where you need the speed and or small size
    of code. And where you are not expecting to move the code from architecture to
    architecture. For anything large and cross-platform we have to deal with the
    following:
    ...easier to debug,...
    I guess most would disagree for obvious reasons that I won't state. But
    consider this: If I need a large and complicated piece of code, an operating
    system or a web browser for example, and if I want it to run on many different
    platforms, x86, ARM, MIPs, Spark etc etc then if I work in assembler I have to
    write it as many times as there are platforms. That is of course not going to
    happen, life is short and humans have better things to do than write the same
    thing 100 times.

    Anyway it means I have multiplied the number of of possible bugs by the number
    of platforms. Ergo debugging is harder.

    ...fewer bugs period...
    No, same reason as above.
    ...easier to read (with a few exceptions).

    No, same reason again. Every time I have a new platform I have to learn the
    assembler syntax, the mnemonics, the machine architecture all over again.
    ...the high level languages are good for small rarely used code, you need
    assembly for any big and/or serious project.

    At this point I might think you are joking with us:) Or perhaps I misunderstand
    what you mean.

    Am I to assume that large and commonly used code like say, Windows, or Mozilla
    or a million apps we use every day is better written in assembler?
    I have to say that I'm happy that Linux and the whole ecosystem on top of it is
    written in C and C++ because I would think it's unlikely that I would be
    running the same programs on my PC and my ARM embedded systems if they were
    written in assembler.
    ...Though assembly remains the best for any serious project in my book,

    Can you give one example of a large and commonly used program that is written
    in asm?

    Now I have to agree we should all be against code bloat and inefficiency. We
    should not adopt the common attitude of "we can throw any large and inefficient
    code at the problem and let Moores Law speed it up for us" that seems to have
    been common recently.

    I also like to get into assembler. It's the first thing I do when a new architecture comes my way. It's a way of evaluating the architecture and or just satisfying curiosity about how it works. It provides puzzles that need solving. Like how to get an FFT to run at any decent speed on a Prop.

    P.S. Whats up with gcc style?

    P.P.S. I'm not getting at you I just like a nice debate:)

    P.P.P.S Did anyone ever actually like to program in x86 assembler? Especially in the days of the 64K segmented architecture. Yuk.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-04-21 08:13
    I have to agree with Heater that the abstraction layer provided by a high-level language enhances a program's readability significantly -- not only by hiding the hardware details but also by compressing drawn-out machine instruction sequences into fewer lines that require less scrolling or thumbing through.

    As to the reliability issue, I agree there as well. However, I believe the biggest leap in reliability occurs when you use a language with bounds checking (or even better: autovivification, as in Perl) and automatic garbage collection. Buffer overflows and memory leaks (from poor heap management) are probably two of the biggest contributors to software instability. And I blame this directly on the profusion of programs written in C.

    Assembly language definitely has its place, especially for programming micros or PC device drivers. But for big projects (and despite the fact that Chip wrote the Spin compiler in X86 assembly), I think HLLs are the way to go.

    -Phil
  • JimInCAJimInCA Posts: 80
    edited 2011-04-21 08:21
    Heater. wrote: »
    Davidsaunders,

    P.P.P.S Did anyone ever actually like to program in x86 assembler? Especially in the days of the 64K segmented architecture. Yuk.

    Yes, me for one! I loved programming in x86 assembler in the good ol' days of DOS!
  • Mike GreenMike Green Posts: 23,101
    edited 2011-04-21 10:39
    There is always some overhead in using something other than assembly language, both in terms of execution speed and space. The better the compiler and its optimization ability, the smaller is the overhead. As others have mentioned, you get potential increased reliability of the program by using high level structures, both control flow and data structures. Some hardware, usually when designed for high level language use, is much harder to program in assembly language than in a matching high level language. The Burroughs Algol machines come to mind there. Spin would also fit in that group even though it's not a high level language in the same sense ... it's sort of medium level. PL360 was one excellent example of a structured assembly language where the various constructs had a nearly one-to-one relationship with specific instructions, yet had IF, FOR, and CASE statements and subroutine calls looked like ordinary procedure and function calls. There was no stack since the hardware didn't provide one.

    Anyway, assembly language isn't a dead skillset, but is a diminishing one as cheap microcontrollers become more and more capable and more supportive of high level language constructs, allowing the overhead to become a more and more insignificant part of development and implementation costs. There will always be special applications where the "utmost" performance is needed from the hardware or functionally limited hardware needs to be used for cost, space, or power reasons and assembly language will be needed for at least part of the coding.
  • vaclav_salvaclav_sal Posts: 451
    edited 2011-04-21 10:52
    The common “argument” goes like this – the critical part of the program should will be done using assembly. For whatever the reason is – real or just “because it is cool”.

    How can one do the critical part (effectively) in assembly when he has only rudimentary knowledge of such?

    I am sure someone will come up with real argument for learning and programming in assembly.

    Assembly language should be placed in museum and not be subject of lessons in one of the nation's “educating for future” institution.
    I think I'll Google for “assembly language “ job.

    PS I did start computer programing ( 1973) using assembly language – the reason – we had whopping 4K ( four kilobytes) of memory to run our test program.
  • HollyMinkowskiHollyMinkowski Posts: 1,398
    edited 2011-04-21 11:03
    I'm slowly moving away from using asm except for time
    critical interrupt code. I do enjoy it but since so few programmers
    are using it it makes my code hard to work with for others.
    I comment my small asm routines exhaustively in hopes that
    they will be understandable to someone with weak asm skills.

    As uCs get faster and faster I am discovering that I can do some
    really good work in pure C.

    I do admit that it is fun to be sought out to write some fast code in asm though :-)
  • Heater.Heater. Posts: 21,230
    edited 2011-04-21 11:21
    vaclav_sal,
    Assembly language should be placed in museum and not be subject of lessons in one of the nation's “educating for future” institution.
    I think I'll Google for “assembly language “ job.

    I have to disagree:)

    The "future" of computing has been and looks like it still is made by two important groups, the hardware designers bringing us ever more powerful processors and the software designers, guys who will have to write compilers for those new processors. The point at which these specialists come together is the instruction set, the assembly language. Both the hardware and the software guys need to know what a computer is.

    Its quite possible for the hardware designers to come up with amazingly fast and powerful machines that have such a contorted architecture that the compiler writers cannot deal with it. They cannot write smart enough compilers to realize the potential performance. The Intel Itanium and i860 before that come to mind as examples.

    Conversely I'm sure the language designers can come up with all kinds of theoretically brilliant language concepts that make no practical sense to implement in hardware.

    So whilst I'm not suggesting comp. sci. and digital design students be taught assembler with a view to ever writing serious code with it, they both have a serious need to know it. If they want to design sensible processors or be able to write efficient compilers.

    So whilst you may not find jobs advertised for assembler programmers you will find things like this:
    https://www.xcore.com/forum/viewtopic.php?f=33&t=1194

    Note the requirements: Minimum upper second class honours degree from a top university.
    I'm sure they would expect any candidates to very familiar with assembler.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-04-21 11:35
    Interesting want ad example, Heater! Are you contemplating a career move to the Dark Side? :)

    -Phil
  • Heater.Heater. Posts: 21,230
    edited 2011-04-21 11:58
    Phil,

    Ha! Sadly not. Too old, too ugly, under qualified, wrong degree subject, wrong university anyway. And now living in the wrong country:)

    I would imagine that a suitably qualified candidate could command a much bigger salary at Google or Microsoft or Facebook or whatever.

    But given the choice would you help boost advertising revenue, make crappy operating systems, peer into peoples affairs?
    Or would you rather work with Chip Gracey at Parallax or David May at X..cough, cough developing something real and useful that people love?
  • localrogerlocalroger Posts: 3,452
    edited 2011-04-21 16:49
    Heater. wrote: »
    The "future" of computing has been and looks like it still is made by two important groups, the hardware designers bringing us ever more powerful processors and the software designers, guys who will have to write compilers for those new processors.

    These are their stories. BADUMP.

    MEDIUM SHOT: DEAD COMPUTER LANGUAGE

    TURING: Looks like we got another one.

    VON NEUMANN: Oh Smile, that's COBOL.

    TURING: You knew this guy?

    VON NEUMANN: I knew his mother. Nice lady. Knew the neighborhood well. Damn, he was getting up there but it looked like he was doing pretty well through the whole Y2K thing.

    TURING: Any idea who popped him?

    VON NEUMANN TURNS OVER BODY

    VON NEUMANN: Access. Microsoft Access.

    TURING: Never heard of him.

    VON NEUMANN: Filthy piece of ignorant bloatware that gets its fingers into everything in this business. Well this is it. I'm gonna nail the bastard for this. And we're gonna start by leaning on all his friends.

    TURING: Guy like that won't have many friends.

    VON NEUMANN: Oh, but this one does. And we're gonna start with the first, the worst, and the dirtiest: Visual Basic Dot Net.

    FADE TO COMMERCIAL
Sign In or Register to comment.