So Assembly is pretty much exists but in arch-specific sections and more limited to specific usage where compact size code and fast operation is required. This is the historic one that was exclusively devoted to Unix.
Dennis Ritchie says that the kernel has lines of Assembler in it. None of this is for performance purposes, apparently.
So another why could, arguably, still be that assembler should be a first language to learn. Actually, programmers coding in C or Java are generally compiling to an intermediate language that is executed by an interpreter at run time. The metrics my company used to do suggested that there was a bug every lines of code, whatever language you wrote in.
The bug rate is determined by those found after initial release over the product lifetime — maybe five years, and there are probably others in there that are never detected. They all come out about the same bug rate. So my view is that, if you write in C, Python or whatever, your code will be about 10 times smaller than the assembler equivalent, and you wil get 10 times fewer bugs. If you write assembler, you just lose the coherence of the functionality by concentrating on the lowest level of implementation.
These days Assembler is primarily when used at all use in microcontrollers, but the fact of the matter is that the C family of languages is quicker to write and debug in, if you as equally as familiar with them as you are with Assembler. I personally had the ill luck of learning BASIC as my first language and had to unlearn a lot before I could program properly.
My thorough reeducation was done in C, so even though I did also learn Assembler I am much more comfortable with C.
So when the choice comes up whether to use Assembler as an alternative for whatever reason, my choice is to go with C. Usually assembler is applied for writing some low-level functions or even whole libraries where it is important to take into account specifi features of the platform for which the library is being written. Sometimes I have used inline assembly in order to ensure that I end with at least some of the bytes that I was aiming for. No Account? At the time I'd been relatively young, and quite frankly resented the way they'd run things, so tended to do the opposite.
In retrospect, what they were doing really was important, and not done just because they were old and inflexible which, I'm pretty sure was how I saw things at the time.
I think you're asking "are trucks still relevant if we have cars? I mean, assembly has a very wide range of applications but not as wide as high level programming has, the same way that there are much less trucks than cars. In new processors with new architectures remember when Cell microprocessor was released , for sure they had to write boot loaders and so on in assembly and with old processors too, but long time used processors have a very stable ground and is difficult to improve it. And staff availability, it depends on, I guess that if you ask in Intel, Qualcomm, What happens if you ask "how many car drivers are around here?
Assembly is like the Natasha Romanoff of Avengers. It's a charm and magic. First, it will bite you but trust me you will never forget the taste. Sign up to join this community. The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Learn more. Is Assembly still relevant? Asked 10 years, 3 months ago. Active 6 years, 4 months ago. Viewed 24k times. Improve this question.
Why would anyone write a complete project solely in assembly language today? Or are you asking about a mixed-language environment, which is how assembly is typically used today? Note that there are areas of non-[PC web enterprise] programming, where Assembly is predominant or very popular. I'm talking micro-controllers, industrial automation or robotics. Sure, there are high level languages in these areas too, but you see Assembly a lot.
I would have guessed that it's very uncommon to use assembly exclusively. Actually in industrial automation you can meet a whole branch of languages that simply do not exist outside of that field. Part of that comes from differences in hardware Harvard architecture as opposed to von Neumann architecture we're so used to.
That's how LD en. See the linked article for some more languages used in automation. I've got a small installer that I support now that's in assembly. It was as easy to write in assembly with Windows API as anything else, so why not? I've also got a credit card swiper interface written in assembly. Started in high level languages, but had so many difficulties getting it to work that I rewrote in assembly to get better control of all the bits flowing Add a comment.
Active Oldest Votes. Yes - but not often. I think in , the main uses for assembly would be: To read disassembly dumps when debugging, which I occasionally do even today. Dealing with non-standard CPU features, like that funky graphics mode.
Compiler writing - it provides an intermediate, human-readable format to translate higher-level languages into. Improve this answer. Bob Murphy Bob Murphy As an example, the entirety of Roller Coaster Tycoon was written in assembly minus the graphics which were done in c and was amazingly powerful for it's time.
Hundreds of individual AIs acting independently, almost seamlessly, when most game had a few 16x16 pixel sprites doing predefined motions. The only assembler coding I continue to do is for embedded hardware with scant resources. As leander mentions, assembly is still well suited to ISR s where the code needs to be fast and well understood. A secondary reason for me is to keep my knowledge of assembly functional. Being able to examine and understand the steps which the CPU is taking to do my bidding just feels good.
Last time I wrote in assembler was when I could not convince the compiler to generate libc-free, position independent code. Of course, I used to have other reasons. A lot of people love to denigrate assembly language because they've never learned to code with it and have only vaguely encountered it and it has left them either aghast or somewhat intimidated.
True talented programmers will understand that it is senseless to bash C or Assembly because they are complimentary. The organized syntaxic rules of C improves clarity but at the same gives up all the power assembly has from being free of any structural rules!
C code instruction are made to create non-blocking code which could be argued forces clarity of programming intent but this is a power loss. I have myself written code that cannot be written in C code without becoming hugely inefficient because of the above mentionned limitations.
And i have not yet talked about speed which most people think is the main reason for writting in assembly, well it is if you mind is limited to thinking in C then you are the slave of you compiler forever.
I always thought chess players masters would be ideal assembly programmers while the C programmers just play "Dames". No longer speed, but Control. Speed will sometimes come from control, but it is the only reason to code in assembly. Every other reason boils down to control i. SSE and other hand optimization, device drivers and device dependent code, etc.
I keep looking at coding assembly again, and it's nothing more than the challenge and joy of the thing. I have no other reason to do so I once took over a DSP project which the previous programmer had written mostly in assembly code, except for the tone-detection logic which had been written in C, using floating-point on a fixed-point DSP! I ended up rewriting almost everything from scratch. Almost everything was in C except for some small interrupt handlers and a few dozen lines of code related to interrupt handling and low-level frequency detection, which runs more than x as fast as the old code.
An important thing to bear in mind, I think, is that in many cases, there will be much greater opportunities for speed enhancement with small routines than large ones, especially if hand-written assembler can fit everything in registers but a compiler wouldn't quite manage. If a loop is large enough that it can't keep everything in registers anyway, there's far less opportunity for improvement. The Dalvik VM that interprets the bytecode for Java applications on Android phones uses assembler for the dispatcher.
This movie about 31 minutes in, but its worth watching the whole movie! I don't, but I've made it a point to at least try, and try hard at some point in the furture soon hopefully. It can't be a bad thing to get to know more of the low level stuff and how things work behind the scenes when I'm programming in a high level language.
But I will give at go in due time, that's for sure. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams?
Collectives on Stack Overflow. Learn more. Why do you program in assembly? Asked 12 years, 6 months ago. Active 2 years, 9 months ago. Viewed 62k times. Improve this question. Tom Ritter Tom Ritter Similar questions are already there, I think Those questions are both why learn assembly, this is why program in it, which..
I think is different? Show 3 more comments. Active Oldest Votes. High-Performance Computing Outside the domain of games, people in scientific computing frequently optimize the crap out of things to get them to run fast on the latest hardware. Improve this answer. Stephano 5, 7 7 gold badges 39 39 silver badges 57 57 bronze badges. Todd Gamblin Todd Gamblin Wish we could put this in a wiki!
Questions and answers on StackOverflow are licensed creative commons attribution. My answer there points out that reading compiler asm output and tweaking the source can help when the compiler isn't noticing a useful optimization.
So you mentally or actually write in asm, then hand-hold the compiler to doing what you want, but now you have future-proof portable C. Add a comment. I have not coded in assembly language for many years, but I can give several reasons that I frequently saw: Not all compilers can make use of certain CPU optimizations and instruction set e.
Peter Mortensen 29k 21 21 gold badges 97 97 silver badges bronze badges. Uri Uri Heh, it's the result of the assembler work! You write lots of macros in asm usually. Not just satisfaction, but an appreciation of precision. A concise process with everything about it declared is a joy to behold. Humans are very bad at writing long asm code. Keep in mind that said tools were not always available when the assembler was written.
DanM DanM 2, 1 1 gold badge 17 17 silver badges 14 14 bronze badges. Norman Ramsey Norman Ramsey k 57 57 gold badges silver badges bronze badges. In that case, I'd use a compiler intrinsic. Still not the same. It's like a compiler without register optimizer — Marco van de Voort. It depends on what kind of seasoning your asm programmer has. If you've read and grokked agner. At least half the time I see missed minor optimizations when looking at compiler output for small functions.
Where compilers are great is optimizing over large codebases with inlining and constant propagation. Macke Macke Good point, you need a compiler that does a decent job with intrinsics. Also there are often ranges of pin-compatible devices, so upscaling if you systematically run out of cpu power or flash space is often not a problem Unless you really ship devices and programming assembler makes it possible to really make major savings by just fitting in a flash chip a category smaller.
Marco van de Voort Marco van de Voort I like the essay-test; I may need to use this more often ; — ad absurdum. Unknown Unknown 44k 24 24 gold badges silver badges bronze badges.
You can compute overflow flags in C with bit operations. Justin Love Justin Love 4, 21 21 silver badges 36 36 bronze badges.
I think a lot of game developers would be surprised at this bit of information.
0コメント