Slashdot Mirror


Is Assembly Programming Still Relevant, Today?

intelinsight asks: "Consider the following question given the current software development needs, and also the claims of the Assembly lovers for it being a language that gives one insights of the internal working of a computer. How relevant or useful is it to learn Assembly programming language in the current era? "

113 of 676 comments (clear)

  1. Yes. by bladx · · Score: 3, Insightful

    It's good to know how things work underneath the hood.

    1. Re:Yes. by fm6 · · Score: 2, Insightful

      Looking at assembly code tells you very little about how modern software systems work. Any more than sheet metal fabrication tells you how an airplane works. Ever hear the expression "can't see the forest for the trees?" With assembly language, you're focusing on the individual leaves!

    2. Re:Yes. by A+nonymous+Coward · · Score: 5, Interesting

      I know far too many programmers who haven't a clue what is going on under the hood, so to speak, and have zero comprehension of what operations take longer than others. For instance, consider a C programmer I know who thinks strcat is a good routine to use.

      (For the ignorant, it takes two string pointers and copies the second one to the end of the first one; this requires zipping all the way from the start to the end of the first string to find where said end is. It then helpfully returns the pointer to the beginning of the first string, the very parameter you passed in. Never mind that the new end of the first string would be very handy for the next strcat to that same string.)

      This programmer is generally good at what he does, but the idea that strcat is woefully inefficient is not obvious to him. Even after explaining it to him, yes he will avoid it, but he does not really understand why. He, and far too many other programmers, measure their program's "speed" in lines of code. Sure, they know that a subroutine call has to count those subroutine lines of codes as well, but they simply have no concept of the fact that some operations take longer than others, that there are better ways of doing simple things.

      I think every beginning programmer should have to spend a semester on some funky old z80, for instance, all in assembler, debugging in machine language, before they can call themselves a good programmer. The idea is not to get them skilled in z80s, but to give them a basic idea of how computers work.

      It's the equivalent of learning to drive a stick shift car without understand why there are gears at all. If you are ignorant of the very basics of internal combustion engines and can't understand the dangers of lugging or redlining an engine and the importance of using the right RPM, you will never be a good driver. It matters not whether you ever drive a stick in real life, it's just a matter of knowing how to handle your equipment.

    3. Re:Yes. by Lehk228 · · Score: 4, Insightful

      i agree that everyone should have decent understanding of what's going on behind the curtain, though rather than focus on the what, i would prefer to see more experience with limited environments.

      as in your example, too many people code like the only platform is the multi-GHz PC.


      even a year doing tools in Graphing calculator basic will teach appreciation for not wasting cycles doing everything the lazy way, 'cause sure, you usiung strcat doesn't slow the system in a noticable way, but when half the processes running are using it, and using it in "hotspots" suddenly you need a new machine because it's just not fast enough.

      --
      Snowden and Manning are heroes.
    4. Re:Yes. by BillyBlaze · · Score: 2, Insightful

      Could you design an airplane without a basic knowledge of sheet metal fabrication? I think not.

    5. Re:Yes. by Anonymous Coward · · Score: 2, Insightful
      At no point is it required that you know exactly what order your algorithim is. You should just have a good feel for how good its doing. Use code profilers, etc to help with this.

      Wait a minute. You're going to go all the way through design, design review, and code it up, all based on a "good feeling". And THEN you're going to check it's efficiency with a profiler? You take "iterative" software design very literally, don't you.

    6. Re:Yes. by Dachannien · · Score: 5, Insightful

      I don't think that's a very apt analogy (though few analogies ever are apt). Driving a car to and from work is more akin to using Word (or OpenOffice) on your computer. You don't really need to understand the nuts and bolts of how either one works, but you do need to know what the controls do.

      Programming in a high-level language is more like doing basic maintenance on said car. You definitely need to know something about how the car works, and the more you know, the more work you can do on that car yourself. Programming in assembly is sort of like taking the engine out and repairing or modding it. You may never need or want to do that, but knowing how an engine works on a detailed level can help you diagnose and remedy things that don't actually require going to those lengths. Similarly, knowing how a microprocessor works can help you understand more about what you're doing when you program in a high-level language.

      It also gets you into a mindset where you're thinking about this sort of thing, which is why assembly should still be required teaching in an undergraduate computer science curriculum.

    7. Re:Yes. by smallpaul · · Score: 5, Insightful

      My philosophy is that you should know the layer beneath the layer you program on. Let's say you're working on Groovy code which is half-interpreted and half-compiled on a JVM which is written in C, perhaps using JIT or perhaps not, running on a CPU. Nothing that you can possibly known about how registers work or how jumps work will help you to understand the performance of your program several layers up -- especially given that your program will run on several different runtimes optimized in several different ways on several different CPUs.

      But if you're going to program in Groovy then you should know Java and perhaps JVM IL. If you're going to program in C then you should know assembly. If you're programming in assembly then you should know about how CPUs will reorder your instructions etc. If you're building a CPU, then you'd better know physics.

      I really don't think that if you're writing an app in Rails/Javascript/SQL you are going to achieve any performance or debugging benefits by understanding assembly language. It's just knee-jerk to say that every programmer, no matter what they do day-to-day should be knowledgeable about assembly. The same effort expended learning about the layer UNDER your development environment would have a much better payoff. E.g. a Javascript programmer reading the Firefox source code (or at least benchmarking FireFox and IE on important operations). With each level deeper you go, you achieve quickly diminishing returns.

    8. Re:Yes. by thecheatah · · Score: 5, Insightful

      Wow, the first programming language I learned was z80 assembly :-). I use to make games for the ti86.

      here is a side scroller i made written all in assembly (includes animated screen shot)

      http://www.ticalc.org/archives/files/fileinfo/232/ 23280.html

      The things I learned:
      1. 4mhz processor is REALLY fast!
      2. How the stack works.
      3. How absolute and relative jumps work.
      4. How to create "objects" and implement "methods"
      5. How the smallest variable, the register works.

      I have to say that after making games in assembly, I am actually disappointed in how well the current consoles handle them. I would expect them to be able to crazy things with the hardware they are given. That is also why I am interested in the ps3, it forces programmers to understand the underlying hardware.

    9. Re:Yes. by aj50 · · Score: 3, Insightful
      I think they should know about big-O notation, as in what it means and how it will affect the scaling of your algorithm but I don't think it's useful to have to prove it formally. It's useful to express what usually you should be able to see quite quickly in a way that other people understand. It allows you to say A is better than B because it's O(nlog(n)) rather than O(n^2) without trying to explain why a recursive algorithm can be quicker than one which just has two for loops.

      It's also handy for sanity checking when a quick calculation shows that your algorithm which works fine for n=10 will take something in the order of three years to complete for n=1000.

      --
      I wish to remain anomalous
    10. Re:Yes. by grasshoppa · · Score: 2, Interesting

      You are both right and wrong, in a sense. You are right that he should know what's going on under the hood. You are wrong in that he shouldn't use it. Program execution speed should ( almost always ) take a backseat to code readability. If the organization uses strcat, there is a very strong and valid argument why he should still be using it.

      --
      Mod me down with all of your hatred and your journey towards the dark side will be complete!
    11. Re:Yes. by vux984 · · Score: 2, Informative

      I know far too many programmers who haven't a clue what is going on under the hood, so to speak, and have zero comprehension of what operations take longer than others. For instance, consider a C programmer I know who thinks strcat is a good routine to use.

      Just have your friend write a strcat() himself using C, and he'll learn where/why its inefficient. (Or he won't and he's just dense.) Either way knowledge of assembler or lack thereof isn't the issue.

      It's the equivalent of learning to drive a stick shift car without understand why there are gears at all. If you are ignorant of the very basics of internal combustion engines and can't understand the dangers of lugging or redlining an engine and the importance of using the right RPM, you will never be a good driver. It matters not whether you ever drive a stick in real life, it's just a matter of knowing how to handle your equipment.

      You don't need to understand the dangers of lugging or redlining in terms of the mechanics of what is happening its enough to know that either leads to 'big engine problems' and to avoid them. That the mechanics involve engine strain, overheating, misfiring, etc is superfluous.

      Its easy to feel lugging with just a bit of experience and even a complete neophyte knows what redlining looks & sounds like. From there on, its enough to know to avoid both.

    12. Re:Yes. by ivan256 · · Score: 2, Insightful

      I hate to tell you but pretty much every "modern" system has components that are written in assembly. Some of us still know how to write low-level software, and that's a good thing, because otherwise all of your fancy "modern" languages wouldn't have a system to run on.

    13. Re:Yes. by ekstrom · · Score: 2, Informative

      An example: A few days ago I had to explain to a very competent desktop programmer, who was doing the unfamiliar job of writing test C code to be ported to an MSP430 embedded processor, that taking an integer modulo 1440 was a bad idea. The MSP430 has no divide instruction, so the modulo had to compile to a division subroutine made of subtractions, tests, and shifts. In this case there was a way to code the overall task that evaded the need for the modulo. When doing embedded C on a processor of that size (still a lot bigger than a PIC) I ALWAYS look at the compiler output when I am writing anything where I care about either size or speed of execution.

    14. Re:Yes. by Sigma+7 · · Score: 2, Insightful

      The fact is, that computers today can run even the slowest of code fast enough.


      No, they can't.

      In the current Standings for Al Zimmerman's programming contest, you see a lot of entries that have many submissions, but aren't even close to the optimal result. Even on the smallest scale, the slowest of code would go through all 20 trillion possible cominbations - the next smallest is an order of magnitude larger, and anything larger is within don't-even-bother territory.

      And yet, there's a person who has effectivly maxed-out their score, with a significant lead in the third category compared to the many other submissions. While he has at least one non-top submission, it's not something obtainable just by throwing as much computer power as possible.
    15. Re:Yes. by that+this+is+not+und · · Score: 2, Interesting

      I learned programming at a 'professional' level by being thrown at a task and challanged to get it done. It was a stand alone medical device using a Hitachi 4-bit embedded controller. You learn fast that your code starts at the reset vector and you have to set up and intialize ANY resources your design will be using. A few years in at that job, the company brought online an older experience software engineer, but one who came from 'application' level programming. He knew a lot about what he was doing, but he was horribly reckless about initiating timers, critical configuration registers, etc., because he came from a world where that was all done for you by the operating system.

      Right now I just wish Microchip would do a better job of documenting the resources in their little PIC chips. It's tedious on each new model I decide to code to have to dig deep into all the arcana of the datasheet to figure out which registers to poke something in to to get the chip up and running what I need. They're certainly better, though, than some of the Japanese vendors, whose English manuals are bad translations of the Japanese originals.

      The first word on the first line of the table of contents on one manual I remember having to rely on was misspelled:

      "Beneral Introduction"

      It didn't inspire confidence in the rest of the manual.

    16. Re:Yes. by lordmatthias215 · · Score: 2, Interesting

      I agree that console programmers probably aren't pushing their hardware as hard as possible- unlike PC programmers, they have the luxury of having the same equipment in every unit, so they really don't have an excuse not to learn the system's assembly at least enough to squeeze a few extra cycles out.

      Out of curiosity (i'm not trying to troll here), what about the PS3 makes programmers understand the hardware better than they need to understand the 360 or Wii hardware? I know they have the Cell Processor, but IIRC they're just writing to Sony-provided APIs that thread the processes automatically.

      I'd actually expect programmers would have to know the Wii hardware much more inimately in order to not only obtain more finesse with gesture-based controls, but also squeeze the Wii for all it's worth to produce graphics that can garner people's attention once the 360 and PS3 start pumping out even more advanced graphics. In fact I think that if programmers don't invest the time needed to learn the Wii completely (even though it's very similar to the gamecube in architecture), the system may not be able to hold its momentum for too long. Of course Nintendo may have had this in mind, and will introduce another gen before the normal 5-year cycle is over.

    17. Re:Yes. by shadanan · · Score: 2, Funny

      And if you're in physics, you should know math, and if you're in math, you should know Greek. :-)

    18. Re:Yes. by Anonymous Coward · · Score: 2, Insightful

      You might want to consult the Wright brothers on that one.

    19. Re:Yes. by ravenlock · · Score: 2, Insightful

      Make it work.
      Make it right.
      Make it fast.

      Or,

      The rules of optimization:
      Rule 1: Don't do it.
      Rule 2 (only for experts): Don't do it (yet).

  2. Isn't it the root of all programming languages?? by madhatter256 · · Score: 4, Insightful

    Isn't knowledge of assembly language for microprocessors required to create a higher level programming language?

    --
    Previewing comments are for sissies!
  3. You should not learn it.. by QuantumG · · Score: 5, Insightful

    Please remain ignorant of all lowlevel details of your deployment and development platforms.
    Please continue to treat both computers and the tools you use to program as magic black boxes.
    That way old dogs like me will still have a job.

    --
    How we know is more important than what we know.
    1. Re:You should not learn it.. by LionKimbro · · Score: 3, Insightful

      Yes; Understand too, how the gates work, all the details of how the chips work, (the myriad chips your program may run on,) and have a good understanding of quantum mechanics, as well. Understand all the business supply chains, as well.

      Anything else, is just-- pshaw... Black boxing it.

    2. Re:You should not learn it.. by MenTaLguY · · Score: 5, Insightful

      Um, I know you were being facetious, but that's not a bad idea at all, actually. A comprehensive knowledge of those fields isn't normally worth it for most things, but basic literacy in all the areas you mention is actually very helpful at times.

      --

      DNA just wants to be free...
    3. Re:You should not learn it.. by Bozdune · · Score: 2, Interesting

      How is someone going to learn assembly?

      Well, when I was a wee lad taking 6.251 from Donovan & Madnick at MIT, they threw an IBM Assembler H manual at us and wished us good luck on the first programming task (in two weeks).

      So suck it up and RTFM. Although, to be fair, the Assembler H manual is probably one of the finest computer manuals ever written, so it wasn't as bad as it sounds.

    4. Re:You should not learn it.. by gripen40k · · Score: 2, Informative

      I'd have to agree with you there, and electrical engineers have to know everything from the ground up; microelectronics, digital logic, computer architecture, assembly, and finally programming languages. All of them have their uses, and when building even basic control circuits you have to use pieces of them.

      For example, if I were to build some kind of light controller, I could use... microelectronics knowledge to use a BJT that drives a LED via a microcontroller. The microcontroller uses its analog to digital converter to test some voltage that in turn controls the output to the BJT. I can use some logic circuits to have serial input from a computer to control/program the microcontroller. The computer is programmed in C++, the microcontroller in assembly (or C if you have the neat-o compilers).

      Even if pure software people may not have to use it, and therefore think it's irrelevant, assembly is still a big part of the picture when it comes to the nitty gritty parts of electronics design. I've used the C compilers for the PIC microcontroller and they are nice and all, but don't do anything efficient at all, don't support any power saving states, and generally needlessly use up memory. They are great to use to do preliminary design, then you can go in and do some bit hacking if you want your controller to run as fast and as cheaply as possible.

      --
      Har?
    5. Re:You should not learn it.. by NormalVisual · · Score: 3, Insightful

      680x0 assembly was similar in that respect - the register set was very orthogonal, and the chip in general was a blast to code for. Oh, and no segmentation either. ;-)

      --
      Please stand clear of the doors, por favor mantenganse alejado de las puertas
    6. Re:You should not learn it.. by drolli · · Score: 2, Insightful

      > Yes; Understand too, how the gates work, all the details of how the chips work, (the myriad chips your program may run on,) and have

      If you understand what the gate does, there is no semantical level to break it down any more. Howver, be aware that it consumes Energy.

      > a good understanding of quantum mechanics, as well.

      That is not so important.

      > Understand all the business supply chains, as well.

      Yipp, this indeed is important. Understanding why sometimes a technologically favourable solution is not the best makes you a good engineer. (E.g.: Instead of asking "Could we not transport four video streams more over our ethernet if we use an adapted divx coding with increased buffer size?", it may be better to ask: We need a camera, well tested, avaialble in thousands, weatherproof, from an reliable supplier with a standard protocol, because handling a problem in the firmware of a device which is distributed in hundreds over this large industrial facility will consume time and money.)

      > Anything else, is just-- pshaw... Black boxing it.

      Yepp. More than one Comapany died in such a way.

  4. easy as 1 2 3 by zeromusmog · · Score: 4, Funny

    Nobody has to learn assembly language anymore to create piddly things like compilers or program ultra-small devices or anything like that. You can do all of those things with Ruby on Rails now.

    1. Re:easy as 1 2 3 by nitrocloud · · Score: 2, Insightful

      Like Duke knows anything of electrical engineering. It only takes a State student to tell you that (or a Carolina student, but they can go to hell).

      Curriculum here started with learning about what a gate was, how it was made from transistors (which were magic black boxes then), from gates we learned adders and other MSI devices, and eventually got to an abstraction of a microcomputer. Assembly then was a Godsend and now using that same assembly language, we've implemented C.

      Point is, reference a school for electrical engineering, make a better choice than masking Duke to the country. I mean, look here at State, Ga Tech, Va Tech, MIT, Stanford, Princeton, USC, etc.

      --
      Karma: Good, or bust!
    2. Re:easy as 1 2 3 by FlyByPC · · Score: 3, Interesting

      Not all of us. I'm majoring in EET/ComET at ODU (they didn't offer the pure EE via distance-learning) -- and we're required to learn PIC assembly at least.

      Granted, PICs are much MUCH simpler than anything running a modern OS -- but learning assembler, even on a simple device like a PIC, does teach a lot about how hardware and software integrate. Also, it's kind of cool to know that (for example) exactly 1,000,000 clock cycles after the program starts up, it will be calling *this* instruction, which moves the value in the accumulator to *that* register.

      I can't be the only one out there who finds this extremely refreshing after taking a course in Java (and learning about font objects, GridBagLayouts, and other things so far removed from "real" programming that they might as well call it a Fine Arts course), can I?

      Anyway, I wasn't really looking forward to learning Assembler -- until I got started and saw how powerful, elegant, and just plain beautiful it really is.

      PICs are cool toys -- 5MIPS ain't much compared to the latest and greatest Intel and AMD have to offer -- but when you consider that they'll run for days (weeks? months?) on a CR2032 cell, and cost under a buck apiece, they're very impressive. (Freescale MCUs, too -- although I don't yet know those quite as well.)

      --
      Paleotechnologist and connoisseur of pretty shiny things.
    3. Re:easy as 1 2 3 by afidel · · Score: 2, Informative

      RIT, they have a fab on campus =)

      --
      There are 4 boxes to use in the defense of liberty: soap, ballot, jury, ammo. Use in that order. Starting now.
  5. For most programmers, no. by CosmeticLobotamy · · Score: 5, Insightful

    For good programmers, yes.

    1. Re:For most programmers, no. by Bogtha · · Score: 5, Insightful

      I don't think that's the case. It really depends on what you want to do. Typical desktop applications don't need any assembly language, nor in-depth knowledge of how the CPU works. In fact, it's probably a bad thing to worry about things like this — premature optimisation being the root of all evil and all that. You don't want to put a lot of work into making your application 1% faster and then realise you've ruined your portability.

      In fact, these days, there's a case for even doing away with languages like C for a lot of desktop applications. With the speed of today's computers, if you can write your application quicker in a scripting language, it's a worthwhile trade-off for many organisations.

      Sure, if you want to work with operating systems or things like games where performance is critical, then knowing assembly will make you a better developer even if you don't end up using it. But most of the software industry is working at a level far higher than that, and if you are at that level and making your decisions based on what instructions the CPU is getting, then you're probably doing a worse job than somebody who is entirely ignorant of assembly.

      --
      Bogtha Bogtha Bogtha
  6. Why bother? Just ... by Bin_jammin · · Score: 3, Funny

    Hire someone else to code in assembly.

  7. Yes by Erich · · Score: 5, Informative
    If you're good.

    If you know DSP, are adept with fixed point arithmetic, know a bunch of fun tricks, can schedule well... there are many people who would like to hire you. Including the group I work in.

    Simply, compilers cannot produce code of the same quality that great hand coders can produce code, especially for complex embedded devices like DSPs. But it's not enough to know how to write assembly, you need to know all the tricks the compiler knows, all the tricks you can play with the algorithm, and all the ways in which you can tinker with the code to fit it nicely into the architecture.

    Those things are still highly valueable; people need to get really optimized code for their media players. If you can squeeze 20% out of your MP3 decoder, you can get 20% lower energy usage on your programmable logic.

    --

    -- Erich

    Slashdot reader since 1997

  8. Honestly... by CyberBill · · Score: 2, Insightful

    You really only need to know how to program assembly if you want to be a good programmer. If you want to be a crappy one, learn Java or C#, pretend pointers are magical, and be happy with your life. (I'm not saying those are bad languages, I'm just saying they're opposite from assembly)

    Also, a lot of embedded work is still done in assembly because with a lot of low-level industrial work having very precise clock-counts on everything is very important.

    --
    -Bill
    1. Re:Honestly... by Lehk228 · · Score: 2, Informative

      what the fuck is it with pointers that is so difficult?

      i'm a novice coder and people constantly bitch about how hard pointers are, so when i read what they actually are(this was quite a few years ago) I went back a few times thinking i must have missed something "....surely there is more to it than that...." i thought to myself.

      --
      Snowden and Manning are heroes.
  9. Very relavent by Forrest+Kyle · · Score: 5, Insightful

    Well, given that the world runs on embedded systems, and will probably become more reliant on even greater numbers of even more complex embedded systems, I'd say assembler will be around for quite a while. However, in terms of game programming or something, it's probably not amazingly useful any more. It is my understanding that most of the API calls to advanced graphics libraries are about as optimized as they are going to get. Clearly you don't need it to write a medical billing application.

    I would not encourage universities to start pumping out CS graduates who have never seen assembly laguage, and don't expect it to phased out of the average Electrical Engineering curriculum any time soon.

    Frankly, I don't think it's a very good question. It's sort of like saying, "Given that we now have calculators and computer algebra systems that will do the math for us, is it really worth it to waste students' time learning the nuts and bolts of mathematics?" It has been my (limited) experience in software engineering that knowing how something works on a deeper level will almost always be an asset, and at the worst have no effect at all.

    1. Re:Very relavent by Xner · · Score: 2, Funny

      Even the page you link to acknowledges the terms have been used interchangeably.

      --
      Pathman, Free (as in GPL) 3D Pac Man
  10. Glad I did by linuxwrangler · · Score: 5, Interesting

    I'm glad I took assembly. I've never "used" it in the traditional sense of writing an application other than in school, but understanding how things work "under the covers" (whether at the CPU, hard-disk or network level) has provided valuable guidance in day-to-day design and troubleshooting.

    I've worked with people with very focused high-level programming skills and found that while they could write mostly decent code, their code was also most likely to fail in production since they were completely mentally removed from concepts like disk-seek times or bandwidth constraints. Programmers with a deeper understanding of what actually happened when their code ran tended to make wiser programming choices.

    --

    ~~~~~~~
    "You are not remembered for doing what is expected of you." - Atul Chitnis
  11. Unless your compiler emits C by tepples · · Score: 2, Interesting

    Isn't knowledge of assembly language for microprocessors required to create a higher level programming language? In theory, you could just make your higher-level programming language's compiler emit C or C-- and then let the maintainers of GCC and other mid-level language compilers do the dirty work for you.
    1. Re:Unless your compiler emits C by Surt · · Score: 2, Informative

      A lot of languages these days are emitting java .class (binary) and letting the VM do the work.

      --
      "Who is the Journal of Quantum Physics going to believe?" --Stephen Hawking
  12. Not quite dead... I'm getting better by softwaredoug · · Score: 5, Interesting

    One day won't there be little nanobots floating around with 512 bytes of memory and a 1 mhz processor that need to buzz around your body and eat up your precancerous cells? I imagine as things get smaller, the miniturization fronteir of computing nescesitates limitations in computing power and memory. This may necesitate a new generation of assembly programmers. Even today in the minituarization/embeddedness/realtimeyness world where many enjoy programming away in plain old C (like me) that knowing assembly is useful. First to look at the compiler's output and figure out what the hell its doing, second to just have a plain basic understanding (not necesarilly a detailed one) of what your C statements/operations/etc is probably turning into in assembly instructions.

    Another question, would assembly be more popular if it wasn't such a nightmare to write for Intel's x86 architecture? If we all had nice Motorolla PCs, would assembly be really cool?

  13. Yes by Starji · · Score: 4, Insightful

    Do you write drivers? Or do you need highly optimized algorithms? What about really low level firmware stuff?

    In other words, yes, there are good reasons for knowing assembly. Whether or not you'll actually use it is another matter entirely. Just depends on what you're working on.

    Actually I wouldn't be surprised if in about 10-15 years assembly programmers are in higher demand since none of the CS schools these days ever teach assembly anymore.

  14. Re:All's quiet by Tackhead · · Score: 5, Funny
    > ....... (sounds of crickets) ........

    Give me a moment. I've still gotta figure out the six nested timing loops I need to toggle the speaker cone in and out in such a way that it sounds like a cricket instead of a bird.

  15. Definitely by SaidinUnleashed · · Score: 2, Interesting

    I just got a SDK-86 to start learning it!

    --
    Shiny. Let's be bad guys.
  16. Of course it's relevant. by grub · · Score: 2, Insightful


    How do compilers know what to compile to? Magic? Imagine if all the assembly programmers died: who'd maintain & update compilers, embedded devices, many realtime instruments, etc. ?

    --
    Trolling is a art,
  17. Re:Isn't it the root of all programming languages? by KokorHekkus · · Score: 5, Insightful

    Isn't knowledge of assembly language for microprocessors required to create a higher level programming language?
    To create - yes. To use as a programmer - no. You can still be a good programmer if you know the cost (in terms of resources) for the operations you choose to make use of. A higher level language will most likely give you a wider range of ways to solve a problem within the given limitations. But only if you actually know the computational characteristics of the system (as a whole) that you are using. Simply put you need to realise which operations are expensive and which are cheap from a total perspective.
  18. Re:Assembly _programming_? by dgatwood · · Score: 4, Insightful

    That's a pretty fine line there. If you can understand asm well enough to debug such issues, I would argue that you also probably know enough to write it, or at least very nearly so.

    I would say that you need to know how to program in assembly language, though it doesn't really matter much which ISA you use---MIPS, x86, PPC, ARM, whatever. What matters is the ability to understand what's really happening at a low level so that you don't do stupid things in high level code that cause your machine to have a seizure.

    For example, once you understand that your CPU only has a limited number of registers, you'll understand why (on some CPU architectures) it is a good idea to limit the number of function arguments so that they can be passed via registers, and that you should put the arguments that you are most likely to use at the beginning of your prototype so that they have the best chance of already being in a register.

    --

    Check out my sci-fi/humor trilogy at PatriotsBooks.

  19. YES! by Bluesman · · Score: 5, Informative

    If you never learn assembly language, it's a very strong possibility that:

    - You can't write a compiler
    - You can't debug C/C++ programs
    - You don't really know why buffer overflows are bad
    - You don't really understand memory management and what the heap and stack really are
    - You don't really know why threads are different than processes
    - You can't write a device driver
    - You don't know any computer architecture at any depth that matters
    - You won't ever understand garbage collection
    - You don't know how your CPU works
    - You won't think the movies with "hacking" in them are as funny as the rest of us do.

    If not being able to do those things doesn't bother you, by all means, don't learn assembly.

    The thing is, in order to be a really good programmer, you have to know how the machine works, all the way down. Once you do, you can pick up any language very easily, because you know what they're trying to do and how.

    Just learn it. It's really one of the simplest languages to learn. Realize it's not a programming language, but simply the actual machine code represented by mnemonics. So you'll have to learn an architecture. Intel 386 is a great place to start, and it couldn't be easier than on Linux. You have a flat, protected memory model, GNU "as" is likely already installed, and you make system calls using interrupt 0x80 after setting up the arguments.

    You should be printing stuff to the screen within minutes, and interfacing with C object files in hours. You can write the GTK "hello world" program in a combination of C and assembly fairly easily.

    Get to work.

    --
    If moderation could change anything, it would be illegal.
    1. Re:YES! by Cyrano+de+Maniac · · Score: 5, Informative

      So you'll have to learn an architecture. Intel 386 is a great place to start...

      Choke. Cough. Laugh. Thanks a lot, now I have to clean soda off my keyboard.

      While the rest of your comment is pretty much spot on, this advice is, frankly, absurd. x86 has one of the most convoluted, non-orthogonal, legacy-laden instruction sets and list of constraints of any architecture, ever. Introducing someone to assembly programming via x86 is sure to warp their brain, and will certainly send the vast majority of people running away, never to revisit the idea. You might as well recommend Malbolge, Intercal, Brainf*ck, or Befunge to them -- it'll result in the same reaction.

      If you want to introduce yourself to assembly language programming, start with something sane and simple. To that end, you can't get much simpler than the Motorola 6800 family of processors. Then, step up to something with a richer instruction set, such as the Motorola 68000 family. After having a good grasp of those a person will have correctly oriented their brain to take on more complex but sane architectures, such as MIPS or Alpha. For a challenge after that point, I'd highly recommend IA64 (i.e. Itanium) -- which introduces some really complex ideas, but implements those ideas in a sane and consistent manner. It might be worth learning a DSP processor assembly language (such as the TI TMS320 series) before IA64, to get a handle on concerns regarding explicit parallelism.

      Only after learning a number of well-designed instruction sets and architectures such as those should you even consider exposing yourself to x86 and (most likely) the PC architecture. At that point you'll have built up enough intellectual rigor in your approach to assembly programming to survive in the Lovecraftian realm of programming for this architecture. If you're lucky, you'll realize just how truly terrible the instruction set and system architecture are, and avoid programming in x86 assembly whenever possible.

      Seriously, I'd even recommend IBM 360 mainframe assembly ahead of x86 for an initial learning experience. Please don't start with x86, it will rot your brain.

      Brent

      P.S. Yes. I have programmed and/or debugged programs in every assembly language mentioned above. x86 rates dead last.

      --
      Cyrano de Maniac
    2. Re:YES! by Ihlosi · · Score: 2, Insightful
      So how does one learn assembly today?

      Many different ways.

      Using an emulator of a legacy machine would be one way. You could also use evaluation kits for various microcontrollers ('51, ARM, PIC, AVR, whatever suits you best). They have the added bonus that you're running on actual hardware. You could also try a processor simulator, which comes with many uC/DSP development kits.

      Say I would learn 68000 Assembler, would that knowledge be much useful when switching to x86?

      Yes, because you have already mastered the concepts behind assembly (registers, processor flags, pointers, etc). A different processor may have different rules, but the concepts stay the same. Some of the rules are the same on many architectures ("If the processor has a zero flag, then counting down in loops is preferable to counting up.", for example). Mnemonics and Opcodes are something you just look up in the documentation.

    3. Re:YES! by CrankyOldBastard · · Score: 2, Informative

      Motorola has some nice development kits. They feature a 68xx or 68xxx processor, a small amount of ram ,a monitor rom, a hex keypad, a 7 seg LED display and an RS232 port. Not very expensive and you can put your fingers into everything.

  20. Re:How to get started? by oaklybonn · · Score: 2, Interesting

    The best way is gcc --save-temps; write your c code and then understand what gets generated and how it differs depending on what you write in a language you're already familiar with.

    I spent 6 months recently working for a company that programmed mainly in C++ and visual basic (I'm a mac programmer, so I was a fish out of water there, which is ultimately why I left...) But the developers there didn't / couldn't / wouldn't understand assembler in any way shape or form. Without the high level debugger, they were lost. So when their app would crash, they'd be helpless to understand how.

    I was appalled. I've spent 20 years debugging crashes and even though I don't speak x86 fluently, I can at least find my way around it. How do people that aren't able to read assembler ever able to ship quality products?

    Of course, the best way to learn it is using an interactive assembler: go back in time to 1998 and use TMON Pro with MPW. With an 11 minute link time, you'll quickly learn that its easier to patch your bugs in assembler and continue execution, or write a little subroutine in "playmem" to do something, rather than terminate your app, make a small change, and relink.

    God I miss TMON.

  21. Re:All's quiet by Qwertie · · Score: 5, Interesting

    Here are a few reasons you might need proficiency in assembly language:

    • You're writing software for a low-speed or low-memory chip for an embedded system (e.g. one of the PIC chips). Such chips are used either because they are cheap or because they need very little power. You can often program these chips in some variant of C, but if you need that last drop of performance, you use assembly.
    • You're writing a compiler. In this case you may not have to write assembly directly, but you'll have to understand it intimately in order to convert source code to machine language. (Replace "assembly" with "bytecode" or "IL", if making a Java or .NET compiler)
    • You are reverse-engineering closed-source software (another case where you must comprehend assembly)
    • You're designing or testing a computer chip, in which case you may have all sorts of tests cases written in assembly language.
    • You're maintaining an old "legacy" system that uses assembly.
    • You're writing an emulator for another computer, and you need high performance. In this case you may need to understand the assembly language of both the real and emulated machines, as I learned when I wrote a Super Nintendo emulator.
    • Those bastards make you study it in one of your college courses.
  22. Re:How to get started? by p7 · · Score: 5, Informative

    Try the "Art of Assembly Language Programming" available free at this website http://webster.cs.ucr.edu/AoA/index.html it should get you started.

  23. One thing... by petrus4 · · Score: 2, Informative

    ...that learning assembly will teach you is that a libc is really a convenience, rather than a necessity. If you know what you're doing you can accomplish pretty much anything either via system calls directly to the kernel, or by writing your own asm functions for various things (print, etc) and then simply calling *them* via includes. If you end up writing your own asm includes for things you'll still get some bloat, but I can guarantee you that it will be an order of magnitude less than using glibc. There are times when that can be valuable...like if you're needing a system which will fit on a floppy or usb stick, or for an older system with less ram etc.

    I strongly recommend checking out asmutils if you want examples of asm programs that actually do something useful. Some of these (such as ls and the basic httpd) are less than 1k in size.

    You might also be interested in Menuet, which is an entire (small) OS including GUI written completely in either 32 or 64 bit asm.

  24. Re:All's quiet by Anonymous Coward · · Score: 5, Insightful
    • Vertex Shader
    • Pixel Shader
  25. learn it well enough to read by moocat2 · · Score: 2, Interesting

    While I have not written any assembly since college, I am really glad I know it. As an engineer who works in C/C++, sometimes it is really helpful in debugging to see what is happening at the assembly level.

    So, I would definitely recommend at least being acquainted enough with assembly so that you can semi understand a listing.

  26. Re:Cheap hardware means less assembler. by FrankSchwab · · Score: 4, Interesting

    We're in the process of doing a SOC ASIC, with a 32 bit CPU, analog sensing hardware, USB and other communications ports, sophisticated low power wakeup mechanisms, and RSA/AES/SHA-256 hardware. It only contains 32KB of ROM and 12KB of RAM. We expect the part to require less than 10ma of current in full-scale operation (generating 1 MB/sec of encrypted sensor data). We expect the parts to sell for less than $3, including several bits of external hardware, into a highly competitive marketplace. If our parts cost $0.10 more than our competitors or take 10 ma more current, we're out of business. We expect to sell millions of parts per month.

    ROM and RAM comprise the largest space on the die. Die cost is about linearly proportional to area - doubling the size of the die doubles the cost. As a result, we don't have the luxury of embedding Linux, throwing a couple more MB of RAM at the problem, or increasing the clock speed. We certainly don't have the luxury of throwing this weeks latest, greatest academic language at the problem. 'C' and Assembly is the only way this product is going to survive.

    I think you can be a fine Web programmer without knowing assembly or 'C'; I think you'd be a better one after one assignment to a project like mine, where every design decision is made and every line of code is written with a thought to "how fast is this going to run, how much code does this generate?", rather than "how do I get this done fastest and easiest?". There are many situations where the "throw more hardware at it" approach is valid; there are also many situations where it isn't.

    --
    And the worms ate into his brain.
  27. Very important by SpaghettiCoder · · Score: 2, Interesting
    You need to have assembly language, to write routines to directly access the CPU (perhaps to make a fast routine to do a simple operation in your program that gets called many times), address specific memory and input/output of various hardware such as your screen, your ports, everything.

    There are limitations to what high-level languages can do. When I started out on the Amstrad CPC, I remember the computer booted up into a very inefficient non-standardised BASIC, which had many added commands which were really functions to allow access to the unique hardware of the CPC (sound and graphics). These were ridiculously slow, with the Z80 processor and 32K memory available for programs. If you wanted to make a simple animation for example (say, a little 2D sprite walking across the screen), you needed to do it in Z80 assembly language IF you wanted the computer to do ANYTHING else at the same time (e.g. scan for keyboard interrupt, play sound chip in background, or even just a second sprite).

    x86 assembly language isn't hard, but it's the only way you're going to be able to play control freak with your PC hardware. Many excellent Linux applications are done almost 100% in assembly language, including the excellent SNES emulator ZSNES (which makes much the same demands on Linux as the old 8-bit Amstrad, and keeps perfect time). If speed is really important then there's no other way. For some reason I think secret organizations like GCHQ would employ skilled assembly programmers so they can keep looking for ways to brute force public-key encrypted messages in the shortest possible time.

    In my opinion, a lot of people are able to use a few libraries in VC++ or similar to be able to make useful programs, and also new things like Python, Perl, etc. but that doesn't necessarily make them a "coder" just because they're able to use some built-in functions. To be a "coder" means you PREFER to use plain C, and know assembly language (even though assembly language is different for every platform - an assembly language programmer knows exactly what info he needs to find out re opcodes and registers and memory addressing and interrupts, to program his program with the same techniques).

  28. It's a pity about the Lisp Machines... by starseeker · · Score: 3, Interesting

    I have always wondered what would have happened if the idea of using Lisp as the assembly language of a machine had actually taken off. If I understand the Lisp machines correctly, they were actually "lisp on the metal". Given the flexibility and power of the lisp language it would have been very interesting to see what the evolution of the Lisp Machines would have been, had they proved viable in the long term.

    --
    "I object to doing things that computers can do." -- Olin Shivers, lispers.org
  29. Yes, in some lines of work by Distan · · Score: 5, Informative

    First, I'll give the disclaimer that I am a hardware engineer, not a software engineer.

    My experience has been that when bringing up new hardware, when you don't yet have a stable bootloader, let alone a compiler or operating system, then being able to write in assembly is very valuable.

    More accurately I think I should say that being able to write in machine language is very valuable, as you might not even have a working assembler depending on what you are working on.

    Being able to peek and poke a few registers, hand code a loop or two, and maybe write some sequential values across a bus can go a long way in helping you get the hardware going. Hook a logic analyzer to the bus and you're golden.

    Even if you do have a whole infrastructure of compilers, device drivers, and operating systems available, none of that helps you when the first damn batch of prototypes (made of the first revision of the PCB, containing the first ever silicon of a new CPU, and the first ever silicon of the the new chipset) won't even boot, and you are trying to get to root-cause ASAP because you've got a whole army of testers ready to have at the hardware as soon as you get it running code.

    In short, if you are the guy designing the raw iron that the software is going to talk to, you better be able to step up and take control of the raw iron when the software can't.

  30. Internal combustion engine alalogy by davidwr · · Score: 2, Insightful

    Knowing assembly language is like knowing how to an internal combustion engine works.

    For most drivers, it's a curiosity.
    For most auto mechanics, it's somewhat useful.
    For anyone doing engine repair, it's very important.

    If you are programming at a hight level like Java, .NET, or web-based programming, knowing assembly language won't help much.

    It's only when you are using a language like C where knowing how the chip works can actually help you write your code does it really matter.

    Anyone doing systems programming, real-time programming, or anyone who needs fine control over their program's execution should learn assembly.

    For non-programmers and very high level programmers, it's about as useful as studying Shakespeare or business law. It'll make you a more well-rounded person but it won't help your code run faster.

    --
    Knowledge is how to play a game, intelligence is how to win, wisdom is knowing what game to play.
  31. My take on how to learn x86 ASM by MannyMax · · Score: 5, Informative
    I spent some time last summer doing exactly this, learning x86 assembly language. Granted, I tried to emphasize a specific area that may or may not be important to you (fast, high-accuracy scientific floating-point), and I already had a passable familiarity with assembly from C dumps, but that just meant I could skip large chunks of many of these references -- they're still good stuff. Some of my opinions on how to go about it:
    • Don't use Windows. Seriously. Don't. I'm a Windows geek at heart; I know Linux OK and can use it happily on a daily basis, but I'm really at home in Windows. I have been for 15 years. And it's the absolute worst way to learn ASM you can possibly come up with. The problem is that Windows is built on DOS, and in assembly that really shows. Not in the sense that it behaves like DOS -- it doesn't -- but all the interfaces were clearly designed in the DOS era, and few have been updated. Linux, in contrast, has the perfect environment for learning assembly: the system calls are easy to make, reasonably well documented (the documentation is actually pretty bad, but it's better than Windows' -- it exists.), and it's got all the things you'd expect of a modern OS, not all of which Windows always has (like a flat 32-bit address space for everything!). Even 64-bit Linux has no trouble running even pure 32-bit assembly programs once you get the linker flags right.
    • Don't use as (or gas, GNU as). If you must, stay the hell away from AT&T syntax, as's default, since no one but as ever uses it. Make sure you learn the standard Intel syntax (like MASM uses) or a very close approximation (NASM or FASM). as used to only accept AT&T syntax, but now it's got a command-line option to accept Intel syntax; honestly, I prefer NASM's slightly simplified, streamlined Intel syntax. They're very close to each other, close enough that once you know NASM syntax you can read Intel syntax no problem. FASM is similar to NASM, and another decent place to start.
    • Use NASM. It's free and open-source. It works. Its no-frills approach is perfect for assembly, and a real breath of fresh air compared to convoluted messes like AT&T syntax. The only downside to NASM is that it's 32-bit-only at the moment; this isn't too big a problem, because almost all existing tutorials teach 32-bit anyway (and all the migration guides for 64-bit ASM assume you know 32-bit). If you want to graduate to 32-bit later, there's FASM, which is free and close enough to NASM that you'll have no trouble.
    • Stay the HELL away from old 16-bit code in any form. It's ugly. It's obsolete. It's just not worth your time. Of course, using the 16-bit registers is fine when they're the appropriate tools for the job, but seriously, any tutorial that mentions segmentation? Just say no. You'll thank me for this later.
    • Don't put too much faith in the Art of Assembly books. In my opinion, they just aren't that good. They were first written in the 16-bit era, and it shows in far too many places. They're also very DOS/Windows-centric, even the Linux version (also not that good), and learning on Linux is much easier with a native Linux tutorial, like this one:
    • Get Paul Carter's NASM tutorial. It's nice and low-level, explaining all the basics from the ground up. It does assume you know C, and it does use libc for a lot of the dirty work, but you can always do it the way I prefer and build everything from the ground up with pure ASM and system calls. I figure that if you're going to use C, just write a C-program and call an assembly function or two. If you're going to write it all in ASM, write it all in ASM. There are lots of nice tutorials out there for doing either (calling ASM from C or pure Linux ASM); google "linux assembly tutorials".
    • Get the official manuals from Intel and AMD. They are the single best references out there. Yes, get both co
    1. Re:My take on how to learn x86 ASM by Anonymous Coward · · Score: 3, Informative

      Could you elaborate on your mention of Windows having DOS-style interfaces please? The Win32 API lives in kernel32.dll which acts as a shim, redirecting calls through to the native api (ntdll.dll if you're on an NT system). DOS interfaces? What the hell are you on about?!?!

      Windows doesn't have a flat memory model? Are you on crack, or are you running Windows 3.1?

      Madness.

    2. Re:My take on how to learn x86 ASM by NoNickNameForMe · · Score: 3, Informative

      Stay the HELL away from old 16-bit code in any form. It's ugly. It's obsolete. It's just not worth your time. Of course, using the 16-bit registers is fine when they're the appropriate tools for the job, but seriously, any tutorial that mentions segmentation? Just say no. You'll thank me for this later.

      I teach Assembly Language Programming, and for that reason I refuse to teach it on x86 because most available books are using 16-bit (DOS/BIOS based) x86 code. Unfortunately learning 32-bit x86 is a much bigger jump (conceptually) for newbies, I'm not sure it can be done in one semester to students who never had Assembly exposure before.

      Ideally, I'd like to use ARM as the reference assembly language for teaching. It's reasonably clean, and has a sufficiently large code base (i.e., PDAs, embedded systems) to be worth the while to learn. I'd love to find out what books are availble for learning Assembly Language Programming on ARM though.

  32. Re:Isn't it the root of all programming languages? by jd · · Score: 2, Interesting
    No. You only have to generate code for another already-existing compiler. For example, this is how people use f2c. You can also write compilers that generate bytecode (some LISP compilers do this, as do many Java compilers).

    Now, if you were to ask "isn't knowledge of assembly language for a given microprocessor required to create a compiler capable of directly generating native code?" then the answer would be yes, because all the other possibilities have been excluded. Alternatively, if you asked "isn't quality knowledge of assembly language for a given microprocessor required to create a compiler that can generate code that is compact, efficient on resources and fast?" then the answer would also be yes.

    However, as most modern programs are anything but compact, efficient on resources or fast, that is a rather moot point. The best compiler in the world can't turn junk into quality, although a trashy compiler can certainly turn quality into junk.

    --
    It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
  33. Re:All's quiet by LiquidCoooled · · Score: 5, Interesting

    Knowing about optimising registers, partitioning the stack, minimising movs, and assembly tuning in general doesn't rely on the same concepts at all.

    The GP is 100% correct in its uses and you are also correct that its current use is crap.

    We have abstracted ourselves far enough away and insulated ourselves so much that I think we are in danger of losing the point of fast computers.

    Anyone with visual studio can get a good example of this if you see how long the immediate window takes to calculate 1+1.
    It might be great and super and empowers the developer to do more, but something has been lost that I feel Visual Basic classic is fast in comparison.

    Finding a decent optimisation of the core .net framework would be a major benefit and you cannot do that without an implicit understanding of assembler.

    Every time this kind of discussion comes up I think of Mel.
    Assemblers are a dying breed but their services are more than needed even today.

    --
    liqbase :: faster than paper
  34. Depends on what you mean by a good programmer by sterno · · Score: 3, Insightful

    Frankly I think a good programmer is somebody who writes well documented and designed code. I don't think somebody's knowledge of the low level assembly programming necessarily helps with that. I'd rather somebody wrote somewhat inefficient code that I could read and, as needed, optimize, then have some spaghetti pile that nobody could understand but was lightning fast.

    --
    This sig has been temporarily disconnected or is no longer in service
  35. The long way by quantaman · · Score: 4, Funny

    I realize that assembly is very useful to know and can be useful in certain instances.

    But writing in assembly has always given me the same feeling as eating rice with a single chopstick.

    --
    I stole this Sig
    1. Re:The long way by Anonymous Coward · · Score: 4, Funny

      Hey, no deadlock.

  36. The C Conspiracy by jd · · Score: 3, Insightful
    There really isn't a language called C. It's just a bunch of assembler macros. :)

    Seriously, assembly is important for all the reasons you noted, but also for some others. If you know assembly, the chances are:

    • You know how to design the software, because you got sick of trying to debug in a disassembler
    • You know how to express the design cleanly - unclean assembly is longer, so takes more effort, and is murder to debug
    • You know how to add structure to the code, as it's easier to test and fix a small subroutine than a gigantic blob
    • You know how to avoid unnecessary structure, as exploding stacks is generally not a good idea
    • You know how to re-use code, as it is pure hell to repeatedly reinvent anything in assembly

    All software engineering, computer science and programming courses should start by requiring people to program a non-trivial application on an ARM processor, or something with an equally limited instruction set, in pure assembly. Why? Because then you get people who think, who program with care and forethought, who think of bloat not in terms of adding more RAM, but in terms of opportunities for bugs, glitches and gremlins. Sure, you'll get more dropouts. The computing world doesn't need more code monkeys, so it's no loss if they did. Who needs a society of half-baked, semi-literate coders?

    This is not elitism, because I'm not saying that anyone should be excluded from the profession. I don't think they should. What I do think is that society needs to make damn sure that the typical coder isn't the worst coder, which is what you get if people are trained to NOT think but to let the computer do the thinking for them. Windows may act like a HAL-9000 at times, but trust me, it isn't remotely capable of anything resembling thought. A bad design or a poor implementation will not be rectified by some magical intelligence in the machine, because there isn't any.

    --
    It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
  37. Steve Gibson seems to feel it's worthwhile by Kevoco · · Score: 2, Informative

    from http://www.grc.com/smgassembly.htm
    Huh? . . . Windows in Assembler?

    Am I sick? Perhaps. Am I a dinosaur destined for early extinction? Yeah, probably. But I truly love programming. It's what I do. It fulfills me and sustains me . . . and I'm never in a hurry to "just be done with it." I can't stand sloppiness in my work, so for me that means writing the smallest, tightest, fastest, most economical computer programs possible. And THAT means authoring Windows applications in Assembly Language.

    Though the rest of the world may argue that they're more "productive" (when measured by hard disk space consumed per second), I stand by the principle that: "Small Is Beautiful".

  38. Re:All's quiet by mrbluze · · Score: 5, Funny

    Nothing to CX here, MOV along.

    --
    Do it yourself, because no one else will do it yourself. [beta blockade 10-17 Feb]
  39. Still relevant, but... by pinkfloydhomer · · Score: 5, Insightful

    Hmm. Assembly is still relevant and useful for certain tasks, of course.

    But two things come to mind:

    1: Handcoders can code better than good compilers?

    Yeah, in some cases after a lot of refining. But it is not as easy as it once was.

    Compilers have gotten much better and processors have gotten a lot more complex. It's not just "how many clock cycles does this instruction use?", you also have to take various forms of micro-parallelism (pipelining, branch prediction, etc.) and cache hierachy issues into account.

    2: It's good to know what goes on under the hood, sure.

    But in many, many software developer tasks, early optimization is the root of all evil.

    I would actually much rather recommend a top-down approach for most problems, abstracting away low-level details, rather than going bottom-up. The teaching approach of the great "Accelerated C++" comes to mind.

    A lot of developers that know a little or a lot about low-level programming write less than excellent code in other regards (algorithmic complexity, design, re-use, etc.) and they can't seem to stop focusing on performance throughout the process.

    For most problems, performance isn't critical, and even when it is, it might be better to look for algorithmic enhancements (lowering complexity) rather than do low-level fiddling. /David

  40. Re:All's quiet by doti · · Score: 4, Insightful

    Those bastards make you study it in one of your college courses. That is justified by all your previous points.

    I see it this way: assembly is still used today, but only in a smaller niche. But that's not the only reason it's relevant. I think it's a good knowledge to have, even if you'll never use in practice, but it's concepts help you understand the whole. Much like Math, or basic Physics.
    --
    factor 966971: 966971
  41. Re:All's quiet by kyashan · · Score: 3, Insightful

    I think some assembly knowledge is important, at least to understand pointers.
    But, shaders are hardly written in assembly anymore, for all the good reasons.

    --
    "La presi e te la pagai (480.000 Lire)"
  42. Re:All's quiet by Austerity+Empowers · · Score: 4, Interesting

    You're writing software for a low-speed or low-memory chip for an embedded system (e.g. one of the PIC chips). Such chips are used either because they are cheap or because they need very little power. You can often program these chips in some variant of C, but if you need that last drop of performance, you use assembly.

    You're writing software for any chip, on any platform, that requires direct hardware level access, e.g. device drivers, boot code, or core-features. No machine, no matter how fast can be programmed exclusively in C. For example, in C you simply cannot a DCR on a PowerPC. You need a special instruction w/o a high-level language equivalent. You can't cast a pointer to a physical address, it is not mapped to physical memory. You also cannot enable, or disable instruction cache from any C function call. The list goes on. There are a number of places it is totally impossible to use a high level language to do things.

    There are a whole lot of these out there, in the consumer, enterprise, military, etc.

  43. Re:All's quiet by brunascle · · Score: 5, Funny
    you missed one:
    • You're writing malware to exploit a buffer overflow vulnerability
  44. Programming in Assembly language is kind of like.. by DoctorPepper · · Score: 3, Insightful

    Communicating in Morse code. It's a pain in the ass to learn, but when you do, you find the rewards more than justify the effort spent.

    Also, it's good to remember that Assembly language is just one more tool in a programmer's tool box. I wouldn't write throw-away scripts in Assembly language, just like I wouldn't use C. I'd probably use Perl, Python or shell script, as necessary. When you need to hand-tune that algorithm to get that last little boost in performance, being able to drop down to Assembly language can save the day. Too bad it is a dying art.

    On another note, I agree with the other posters that said learning Assembly language allows you to learn the hardware better. 8086 Assembly language was my second language (after BASIC), and I used it for several years, until I started using Windows and found it was much easier to write a Windows program in C :-)

    --

    No matter where you go... there you are.
  45. Re:debugging by Anonymous Coward · · Score: 2, Insightful

    They stare at the code for a while, make wild guesses about how the problem could have happened, add a lot of couts, and hope for the best. Seriously.

  46. Re:Well, no. by TwobyTwo · · Score: 2, Insightful

    I think you're suggesting that for certain kinds of optimization it's as important to know about machine architecture and organization, I.e. things like cache associativity and size, relative speed of memory vs. registers vs. cache, etc., as it is to know or optimize the use of particular "assembler" (actually machine) language instructions. Good point. Still, if you want to know how many memory accesses either the presupplied strcat or your own alternative are going to issue, and which addresses they're going to hit, knowing machine language is a big help.

  47. Re:All's quiet by Anonymous Coward · · Score: 2, Funny

    I saw that Francisco - You're getting a special
    version of the Computer Org test tomorrow.
    One just for you.

    Your computer org professor.

  48. More by DeadCatX2 · · Score: 2, Interesting
    • Designing a microprocessor. This is the worst, because you have to understand the entire architecture, what kinds of operands are possible, and you must manually enumerate opcodes and such. Essentially, creating your own assembly language.
    • You want to take advantage of processor-specific instructions which are not in a high level language (except as intrinsics). Things like CPUID, various SSE instructions, etc.
    --
    :(){ :|:& };:
  49. Re:All's quiet by Short+Circuit · · Score: 2, Interesting

    I've found myself in need of CPU burn-in software. Tools I've found apparently weren't designed for multi-core systems, and that's the kind of system I need to push.

    What I'd like to do is write a bunch of assembler routines that repeat different classes of instructions. One would run simple FPU operations several hundred times, another would run integer ops, another, logic ops, more would run mmx ops, sse ops, sse2 ops, sse3 ops, etc.

    The program would poll the CPU temperature every couple seconds, find the routine that causes the greatest amount of heat, and concentrate on it.

    The overall program would be a C/assembler hybrid. The burn routines would be in assembler, but the analysis and scheduling routines would be in C.

  50. Answer to "What's hard about pointers?"... by tlambert · · Score: 4, Insightful

    Answer to "What's hard about pointers?"...

    There are people who cannot grasp the difference between "a thing" and "a respresentation of a thing". In fact, there was an entire century where almost the entire school of French philosophers were unable to grasp that there was a difference.

    For pointers, it comes down to realizing that a pointer to memory is not the memory, it's a representation, and the real memory lives somewhere else: at the dereference of the pointer. And at that location it takes up real space. And so does the representation (but it's comparatively tiny).

    The ability to make this disctinction comes naturally when you've written assembly code of any complexity, since you've had to manage the memory yourself. But if you've never done that, or, worse, you've only ever programmed in languages which eschew pointers and try to pretend that their own internal implementations don't use them, even if they won't let you use them, well, then, you've got a conceptual problem. An that conceptual problem is going to be very hard for you to overcome.

    It also makes it very, very hard for someone to understand row-major vs. column major languages, or how you would link a program in one against a library in another, and be able to usefully communicate your data between the two. Or it makes it hard to understand the difference between "call by value" and "call by reference.

    If I'm interviewing someone, and it becomes clear that they need a "code interview" because some things don't add up between their banter and their resume, the first thing I whip out is a pointer problem.

    -- Terry

    1. Re:Answer to "What's hard about pointers?"... by 4D6963 · · Score: 2, Informative

      I hate to think of pointers as a "representation" of something. (Disclaimer : I'm a C and ARM ASM coder) When I learnt Pascal I thought that to call it a "representation" was utterly confusing. Just call it an address, because that's what a pointer is, it's as simple as that, it's an address, it's so simple.

      --
      You just got troll'd!
  51. Re:All's quiet by Qwertie · · Score: 2, Insightful

    You're writing software for any chip, on any platform, that requires direct hardware level access, e.g. device drivers, boot code, or core-features. No machine, no matter how fast can be programmed exclusively in C. For example, in C you simply cannot a DCR on a PowerPC. You need a special instruction w/o a high-level language equivalent.

    You're certainly right, but programming language extensions could get around these limitations. For instance, I think the PIC C compiler, which is not really standard C, has an extension that lets you write and install an interrupt service routine without any assembly. One could imagine such extensions for almost any hardware feature; it's just that compiler-writers rarely bother to offer such extensions.

  52. Re:Here's another by countach · · Score: 4, Insightful

    Maybe, except that not many assembly programmers can make faster code than a C compiler anyway. It's no use being a mediocre assembly programmer.

  53. Re:All's quiet by FMota91 · · Score: 2, Funny

    You are too thoughtful sir. Thank you! Did I ever tell you how fabulous I think IBM assembly language is? You know, it has all those wonderful registers (yes, all 16 of them, if you count those 4 or 5 registers that you can't use). Ah well, I should know better than to post on Slashdot with my name about a subject on the eve of that test. If you answer this, don't just answer "Indeed". :) Oh, and I know you're going to show this to class tomorrow. Hi his class. :) Anyway, enough that's enough of me mongering around on /. for today. Time to work on Calculus. See you tomorrow. :)

    --
    09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C1 bottles of beer on the wall. Take one down, pass it round... Oh, umm...
  54. Re:All's quiet by that+this+is+not+und · · Score: 2, Informative

    There's no 'PIC C Compiler' for the PIC10F200.

    It's basically a little grain of rice if you buy it in the surface mount package.

    A fairly powerful little grain of rice at that.

  55. Yes, learn it in context. by nadador · · Score: 5, Insightful

    As a marketable skill, assembly won't get you anywhere. There are a handful of places were knowing a specific assembly language is a prerequisite (boot loaders, deeply embedded applications, etc.) but these are just a fraction of the overall job-space for software engineers. Most software engineers never mess with assembly; they are, in fact, afraid of it and think that it's evil.

    Given all of that, assembly language *is* the hardware/software boundary. It's where all of the fancy abstractions from CS dissertations meet reality. Understanding computer architecture is a huge asset as a software engineer, and to properly understand how software and hardware interact, you have to learn at least one assembly language. There is no alternative. For most people, it is an unpleasant experience, but the payoff is enormous. The learning process that you undergo while learning assembly will change the way that you see your software and will help you understand why your code is so slow and how to make it fast by design.

    I have one last point. When you tell a potential employer about the low-level stuff that you know or work that you've done, your assembly skills are a proxy for understanding how hardware works (at least to interviewers with half a brain). If their software needs to run fast, they'll be happy that you understand the deep magic of hardware.

    (Incidentally, I think that the fraction of software jobs that require an understanding of hardware and knowledge of assembly languages, linker internals, etc., are the only fun ones and the only ones worth having. So I learned MIPS, ARM, PowerPC, and TMS320C6 assembly, and they have all served me very well because I don't have to refactor C# for a living.)

    --

    Outside of a dog, a book is a man's best friend. Inside a dog, its too dark to read.
  56. Re:All's quiet- Assembly still relevent by Douglas+Goodall · · Score: 2, Informative

    As a guy who kept programming in assembler for many years after C was around, I would point out that BIOS code is often written in assembler becauses it is so low level and it gets used a lot, or at least it used to. Now days the operating systems take over most of the hardware after the system comes up, but in the original IBM PC, the BIOS provided the interace layer to all the hardware.

  57. Efficiency sometimes irrelevant by davidwr · · Score: 5, Insightful
    In most programs, easy-to-read, easy-to-maintain code is worth a size and speed penalty of up to several times that of hand-optimized assembly code, and it's almost always worth a 0-50% penalty.

    This is particularly true for programs that
    • don't need to be shoehorned into memory or onto disk
    • spend most of their time waiting, not running

    --
    Knowledge is how to play a game, intelligence is how to win, wisdom is knowing what game to play.
  58. Re:All's quiet by UnknownSoldier · · Score: 2, Funny

    > Real-time Raytracing (a myth, yes, but a good one nonetheless)

    2005 called, they want their hardware back.

    --
    How can you understand Life if you don't even understand what happens after Death??

  59. Re:All's quiet by Mekius_ · · Score: 2, Informative

    There's no 'PIC C Compiler' for the PIC10F200. Uhhh...yeah, I'm gonna have to go ahead and disagree with you on that one...http://ccsinfo.com/devices.php?page=devices
  60. Re:All's quiet by wtarreau · · Score: 2, Insightful

    100% agree. There are a lot of missing features in C which require assembly nowadays :

    - bit rotations => have to be coded by ORing bit shifts and masks
    - bit counting (FFS/FLS) => have to be cleverly coded to avoid iterations
    - locking => you need the lock instructions/prefixes of CPUs
    - prefetching => idem
    - memory barriers => idem

    And the list is long. What do we do instead ? typically, bit operations are done by hand with 100 times slower operations and using jumps and loops while a single instruction almost always exists. Locking accesses is performed through calling functions from heavy and slow libraries such as pthreads.

    It always strikes me to see code doing such a thing :
            pthread_mutex_lock(&counter_lock);
            counter++;
            pthread_mutex_unlock(&counter_lock);

    While in assembly you would be able to do this on many platforms :

            LOCK INC counter

    Which is basically what is done in the mutex_lock (with added tests).

    We really need some C extensions to access the lower level, but unfortunately,
    the trend is the other way :-(

    Willy

  61. Re:All's quiet by kyashan · · Score: 2, Interesting

    Assembly for shaders isn't written in stone. Graphics hardware is moving so fast that the concept of a fixed assembly for them is limiting. It's limiting for the hardware makers, limiting for the software developers.
    One can always squeeze that cycle somewhere, but it doesn't make sense. The problem with shaders are different ones, like integrating them with CPU code and balancing between dynamic branching and code permutations (combinations of features in a shader are selected either with an IF or with a bunch of includes.. so to speak).

    Knowing assembly for shaders is definitely not worth it in my opinion. I highly doubt anyone uses it in the game industry.
    LUTs are very much used for common techniques such as PCF shadow mapping and what not in Cg and HLSL.

    --
    "La presi e te la pagai (480.000 Lire)"
  62. Re:All's quiet by ncc74656 · · Score: 2, Informative

    Give me a moment. I've still gotta figure out the six nested timing loops I need to toggle the speaker cone in and out in such a way that it sounds like a cricket instead of a bird.

    .. LDX #$40
    ]1 BIT $C030
    .. LDY #$18
    ]2 DEY
    .. BNE [2
    .. DEX
    .. BNE [1

    That'll give you one cricket-like chirp. Throw some more loops around it to make it repeat with the right cadence. :-)

    (Remove the dots...they're there only to get the columns to line up.)

    --
    20 January 2017: the End of an Error.
  63. Re:All's quiet by aztracker1 · · Score: 3, Insightful

    Sorry, but that "multiplatform code" you speak of requires a lot of Assembly code under the covers. For the most part assembly is delegated to hardware integration, drivers, and performance tweaks. It is still vital to the industry... I will say that most developers have no need to learn it, but it is far from obsolete. C is still widely used for lower-level libraries and APIs, I wouldn't suggest it as a career path for most developers, but it's still pretty necessary.

    Personally, I like higher-level languages that abstract a lot of the inner workings such as C#/.Net, Python or Java. I like to concentrate on solving problems or making things work. However without those that *DO* write in assembly, nothing I write would *RUN* anywhere.

    --
    Michael J. Ryan - tracker1.info
  64. Re:Here's another by Anonymous Coward · · Score: 4, Insightful

    To consistently beat a C compiler: Write your code in C with inline assembly if required, then compile through Assembler to get assembler source code. Next, hand tweak the assembler code and add C as comments. Pretty soon you will start to think like a compiler and your C code will get better too!

  65. Making your own computer and assembly by Alioth · · Score: 2, Interesting

    I'm building my own computer (no, not getting some random PCI cards and plugging them into a motherboard), but designing a simple Z80 system for fun.

    If you want to mess around with this sort of thing, you cannot avoid writing things in asm. I've got this far:

    http://www.alioth.net/Projects/Z80/Z80-Project/Z80 -Project-Pages/Image19.html

    - having laid out a double sided PCB, and got everything shoehorned onto a 160x100mm 'Eurocard' sized motherboard.

    However, I've also retargeted the z88dk (Z88 Development Kit, originally designed for the Cambridge Z88 portable computer) to my Z80 board because while it'll be best to have all the low level stuff done in assembly language, writing things that use floating point will just be ten times faster to write in C.

    But even if you never intend to hack hardware, it's still important to at least be familiar with assembly language - if only to know why unchecked buffers are bad. If you've ever written a program in asm and accidentally overwritten the stack and tromped all over your return address, you fundamentally understand why this is a bad thing. We've got into a whole world of hurt because many programmers didn't understand this.

  66. Erk by Fross · · Score: 2, Funny

    One day won't there be little nanobots floating around with 512 bytes of memory and a 1 mhz processor that need to buzz around your body and eat up your precancerous cells?

    Now I'm picturing something like Alfred Hitchcock's The Birds, only with ZX81s.

  67. Re:All's quiet by Hal_Porter · · Score: 2, Interesting

    If you use Win32, you can use InterlockedIncrement( &counter );

    --
    echo -e 'global _start\n _start:\n mov eax, 2\n int 80h\n jmp _start' > a.asm; nasm a.asm -f elf; ld a.o -o a;
  68. "Assemblers are a dying breed" by burnttoy · · Score: 4, Interesting

    OK, First of all I'll blow my own trumpet. Over the last 20 years or so I've programmed 6502, Z80, x86 (16/32/MMX/SSE/SSE2), ARM and various proprietory SIMD & RISC machines and pseudo-MIMD machines. TBH the payoff for these skills simply isn't worth it.

    As an asm coder I _may_ find a full time job but asm will take as little as 10% of my time. Contract asm work is out of the question and I haven't seen any in years (since I wrote a serial port driver for Win3.1). I actually like programming in assembler but for the sake of my pay packet and career I have reskilled in PHP, MySQL, CSS, XHTML, JavaScript etc simply because I can find contract work that pays well. Something that appears unachievable with asm. Maybe this is why we are a dying breed.

    Lastly, you're right. This discussion crops up so frequently on BBS's, Usenet etc. It seems that the answer must be that asm coders are still needed and asm is still relevant! If they weren't why would we be discussing its relevance!

    Incidentally, if anyone would like to hire an asm coder who like asm mail asm@burnttoys.net ;-)

    --
    Time flies like an arrow. Fruit flies like a banana.
  69. In any case by BrokenHalo · · Score: 2, Funny

    One of the best reasons to learn to do assembly programming is because it's fun.

    Though I can't say that's why I did it. In my case (back in the early fourteenth century), we all wrote assembly code because that's how serious programming was done. Sure, we had COBOL to update ledgers and write reports, and FORTRAN to take the hard work out of maths computation, but for anything that really needed any kind of optimisation on those old core-memory machines, assembly was the only way to go.

    There were other reasons too; I worked in a computer bureau with several Burroughs B3700 machines, and we had one or two clients for whose packages the source code had been long since mislaid.

    So rather than re-writing the thing from scratch whenever mods needed to be made, a couple of us used to hack directly on the binary. It's not all that easy, but it's job security. ;-)

  70. Two main programmer mindsets by justthinkit · · Score: 2, Insightful

    I've worked with people with very focused high-level programming skills and found that while they could write mostly decent code, their code was also most likely to fail in production since they were completely mentally removed from concepts like disk-seek times or bandwidth constraints.

    I'm not a great programmer, but I've always had a good "sense" (for lack of a better word) about technical things. I worked a bit at a company doing mid to high level (V)FoxPro programming. They put me on the least desired machine and I set to work. Within minutes I realized the machine was not running right, CPU at 100% or close to it most of the time. Turns out it was virus-infected (despite NAV, of course). I found the name of the EXE, renamed it in autoexec.bat before it loaded, then deleted same. Problem solved and the oldest 'clunker' became a quite acceptable computer.

    I think this story illustrates the two broad classes of programmers. (1) those able to get a task done, no matter how nerdy or obscure (but who are pathologically incapable of documenting their work, or teaching others) [e.g. my co-worker who had used that computer for months or years without noticing the virus] and (2) those who are good at interface, optimization, and documentation but lack the penetrating power to solve the more difficult problems [e.g. myself -- I had to leave that job because I couldn't 'crack' the OO stuff].

    Speaking to this thread's main question: both classes of programmer would need to understand some assembly, but for different reasons. Group 1ers would likely end up using it (or having to debug/change it) from time to time -- and it would be no big deal to them to learn it, use it, whatever. Group 2ers would likely want to know _when_ to use it, and probably get someone else to do that coding.

    In the geek cred hungry world of /., not many would want to admit to being a Group 2er but I have no problem with it. For example, Group 2ers would also know when a Group 1er's code sucked, from a performance standpoint. Coders with a trailblazer mindset are rarely good optimizers.

    BTW, in considering where Woz, Ciarcia, Kahn and Hertzfeld fit into this, I think they are Group 1ers who simply took an interest in Group 2 stuff. If you can learn both mindsets, you are one powerful programming dude, IMO. [Pity that 2ers like myself can't easily (ever?) become 1ers.] Most 1ers just want to get the job done and move on, yet so much can be learned after you think you have finished your program. [MS deserves props for realizing this and assigning a second unit to work on optimizing the code already working -- Win95 crap became slightly less crappy Win98 through this process (pdf)]

    --
    I come here for the love
  71. Re:debugging by BrokenHalo · · Score: 2, Funny

    They stare at the code for a while, make wild guesses...

    Sure. But that's only because "The C Programming Language [is] A language which combines the flexibility and power of assembly language with the readability of assembly language". ;-P

  72. Would you trust these professionals? by mikehoskins · · Score: 5, Insightful

    The original post asks if Assembly is still relevant today. I'll ask some rhetorical questions (the only kind in a blog) and see how they apply:

    * Would you want an astronaut to understand physics and math?
    * Would you want a doctor to understand chemistry and biology?
    * Should somebody studying to be a Literature teacher take their full set of liberal arts courses, including history?
    * Should somebody earning a business degree take music appreciation?

    Most of us probably said, "Yes" to most or all of those above. Even if the study seems irrelevant or too "low-level" or too "high-level" at the time, there are areas of coursework that help us understand things better.

    I see a lot of dead wood in the IT industry. There are enormous numbers of people who either have no passion or who do not have a deep-enough or broad-enough knowledge of computer science to do their daily data processing job well. They are dependent on others around them for everything, even though they may be very skilled in one area.

    By having both a broader and a deeper knowledge, people are necessarily better at troubleshooting and at understanding the areas outside their particular specialty. It makes them be better at all of IT and helps them do their specific role.

    You should learn IT two ways -- deeply and broadly. You should deeply learn specific skills (Java/C#/Linux/Windows/scripting in Ruby/whatever) and you should learn broad skills (computing theory/relational databases/networking/troubleshooting/programming/a nalysis/architecture/whatever). The difference is training vs. education.

    There is an enormous difference between training and education. Training is learning specific skills for specific tasks (narrow/specific), while education is broader and teaches you how to think, understand, and apply (broad/general).

    While taking Assembly may not seem relevant at the time and you may never directly use it again, for every programming task, having a strong background in all of computing theory (including how the CPU handles its low-level instructions) educates you and gives you a deeper understanding. (Don't just be trained, be educated!)

    My recommendation is the book My Job Went to India (And All I Got was this Lousy Book). If you can't afford it, read the sample chapters, especially the "Being a Generalist" and "Being a specialist" chapters at http://www.pragmaticprogrammer.com/titles/mjwti/in dex.html.

    Personally, unless you need the specific class/training, I'd say that FORTRAN or COBOL ought to be abolished as required material in all colleges and shouldn't be in the degree program. Those should be electives only. Assembly, on the other hand, should remain required, for a deeper and broader education. (Don't settle for a dumbed-down program).

    The difference, again, is training (specific/skill-oriented/task-oriented) vs. education (general/broad/understanding-oriented). Education and being a generalist will reap large rewards, long term. So stick with it and take that class. Assembly is a very important foundation class that educates you, long-term....

    Another rhetorical question I have is this: "Are you passionate for IT or is it just a high-paying (presumably) job?" If it isn't a passion of yours, find you passion and do it well. If it is, take Assembly and like it -- it'll help you appreciate IT, your computer, your high-level language, and give you a more educated view of the "soul" of your computer.

    (They don't make you take Assembly at many/most schools for their health. It would be a crying shame to remove it from the required courses).

    1. Re:Would you trust these professionals? by starX · · Score: 2, Insightful

      Here here!

      Asking why study Assembler is a little like asking "why study Latin." It's important to have an understanding of the low level programming because it will help you understand what's going on when using something higher level like malloc(), which will in turn help you write better programs.

      Just my $.02

  73. Re:All's quiet by bckrispi · · Score: 2, Funny

    ... haven't tried to do much with the latest version of Eclipse, have you? s.l..o...w... to the point of unusability.
    I use Eclipse 3.2 on an Intel dual T2400(1.8gHz), 2gb ram. It runs fine. Maybe it's just you? :P
    --
    Xenon, where's my money? -Borno