Does anyone program in assembler




















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? Sign up. By signing in, you agree to our Terms of Use and Privacy Policy. Already have an account? Sign in. Your toothbrush? There will always be a new device, appliance, toy, common-life item to be programmed in assembly.

Some of the later versions of TASM had have? First: most languages have moved toward a structure that's at least somewhat tree-like. Whether object oriented, or object-based, or exactly what, there's quite a bit defined about the relationships between different parts of a system.

There's also quite a bit to "protect" one part of a system from accidental "meddling" but other parts even though the protection can usually be bypassed if you want to. By contrast, assembly language is relatively "flat" -- most of the relationships between the code and data in different parts of the system are established primarily by documentation and to a lesser extent naming conventions. The result of this is that it's often much easier to couple code much more tightly than would be ideal.

The requirements that drove the choice of assembly language to start with higher performance, smaller size, etc. The language and tools themselves do much less to restrict what you do good or bad , which places a much greater burden on the managers to prevent problems. I wouldn't say it's qualitatively different, but quantitatively it is -- i. Mitigating this is largely a matter of more careful guidelines, more guidance from more experienced personnel, and more specific, carefully enforced naming conventions.

Staffing is something of a problem. The problems I've encountered, however, where not primarily the ones I expected. Finding guys with a bit of a "fighter jock" personality who were happy to jump into assembly language code was fairly easy. Most did quite a reasonable job, despite an almost total lack of prior experience in using assembly language.

The difficulty I encountered was in finding more senior personnel -- people who could keep the project under at least some semblance of control, and weren't completely accustomed to languages that would provide and largely enforce the guidelines necessary to keep the code reasonably maintainable and understandable.

I can see two sources of problems on my part. First, by the time of the project I'm thinking of, I'd been coding primarily in higher-level languages for quite a while, and using assembly language only as a last resort. As such, when I did use it, nearly every possible trick to gain performance was not only fair game, but expected.

Second, back when I had worked on some systems written entirely or primarily in assembly language, it was under some rather iron-fisted project managers. 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. Once the macro problems are solved then collapse to the micro level. I guess micro problems are within the control of a single programmer and in a smaller domain.

Altering behavior at the macro level requires communication with more people - a thing some programmers avoid. That whole cowboy vs the team thing. But, understand that for the most part the benefits of writing code in assembler are not worth the effort. The return received for writing it in assembly tends to be smaller than the simply focusing on thinking harder about the problem and spending your time thinking of a better way of doing thigns.

John Carmack and Michael Abrash who were largely responsible for writing Quake and all of the high performance code that went into IDs gaming engines go into this in length detail in this book. These days, for sequential codes at least, a decent compiler almost always beats even a highly seasoned assembly-language programmer.

But for vector codes it's another story. Widely deployed compilers don't do such a great job exploiting the vector-parallel capabilities of the x86 SSE unit, for example. I'm a compiler writer, and exploiting SSE tops my list of reasons to go on your own instead of trusting the compiler. I've three or four assembler routines in about 20 MB source in my sources at work.

All of them are SSE 2 , and are related to operations on fairly large - think x and bigger images. For hobby, I work on a compiler, and there you have more assembler. Runtime libraries are quite often full of them, most of them have to do with stuff that defies the normal procedural regime like helpers for exceptions etc.

I don't have any assembler for my microcontroller. Most modern microcontrollers have so much peripheral hardware interrupt controled counters, even entire quadrature encoder s and serial building blocks that using assembler to optimize the loops is often not needed anymore. With current flash prices, the same goes for code memory.

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. But I'm not in that category. A lot of people think embedded is an excuse for assembler, but their controllers have more CPU power than the machines Unix was developed on. However a lot people are stuck with legacy, since changing microchip architecture is not easy.

So there are sometimes good reasons to keep maintaining a project in assembler I was lucky to be able to setup affairs on a new architecture from scratch. But often people kid themselves that they really need the assembler. Please submit the essay with your results. I've used that as a guiding principle for lowlevel features.

Don't be too cramped to use it, but make sure you motivate it properly. Even throw up an artificial barrier or two like the essay to avoid convoluted reasoning as justification. For example, checking for overflow on x86 is the simple overflow flag. This option is not available in C. Defects tend to run per-line statement, code point, etc. Most of these cases involve the usual suspects, such as drivers and bit-banging in embedded systems.

If you were around for all the Y2K remediation efforts, you could have made a lot of money if you knew Assembly. There's still plenty of legacy code around that was written in it, and that code occasionally needs maintenance. Another reason could be when the available compiler just isn't good enough for an architecture and the amount of code needed in the program is not that long or complex as for the programmer to get lost in it.

Try programming a microcontroller for an embedded system, usually assembly will be much easier. Beside other mentioned things, all higher languages have certain limitations. Thats why some people choose to programm in ASM, to have full control over their code.

In my collection I have more then 20 such gold controls from Excell like ssheets to html renders. Most games I know of use as little assembly as at all possible. In some cases none at all, and at worst, one or two loops or functions. If you are programming a low end 8 bit microcontroller with bytes of RAM and 4K of program memory you don't have much choice about using assembly.

Sometimes though when using a more powerful microcontroller you need a certain action to take place at an exact time. Assembly language comes in useful then as you can count the instructions and so measure the clock cycles used by your code. Games are pretty performance hungry and although in the meantime the optimizers are pretty good a "master programmer" is still able to squeeze out some more performance by hand coding the right parts in assembly.

Never ever start optimizing your program without profiling it first. After profiling should be able to identify bottlenecks and if finding better algorithms and the like don't cut it anymore you can try to hand code some stuff in assembly. Aside from very small projects on very small CPUs, I would not set out to ever program an entire project in assembly. However, it is common to find that a performance bottleneck can be relieved with the strategic hand coding of some inner loops.

In some cases, all that is really required is to replace some language construct with an instruction that the optimizer cannot be expected to figure out how to use. A typical example is in DSP applications where vector operations and multiply-accumulate operations are difficult for an optimizer to discover, but easy to hand code. For example certain models of the SH4 contain 4x4 matrix and 4 vector instructions. I saw a huge performance improvement in a color correction algorithm by replacing equivalent C operations on a 3x3 matrix with the appropriate instructions, at the tiny cost of enlarging the correction matrix to 4x4 to match the hardware assumption.

That was achieved by writing no more than a dozen lines of assembly, and carrying matching adjustments to the related data types and storage into a handful of places in the surrounding C code.

It doesn't seem to be mentioned, so I thought I'd add it: in modern games development, I think at least some of the assembly being written isn't for the CPU at all. It's for the GPU, in the form of shader programs. This might be needed for all sorts of reasons, sometimes simply because whatever higher-level shading language used doesn't allow the exact operation to be expressed in the exact number of instructions wanted, to fit some size-constraint, speed, or any combination.

Just as usual with assembly-language programming, I guess. Almost every medium-to-large game engine or library I've seen to date has some hand-optimized assembly versions available for matrix operations like 4x4 matrix concatenation. It seems that compilers inevitably miss some of the clever optimizations reusing registers, unrolling loops in a maximally efficient way, taking advantage of machine-specific instructions, etc when working with large matrices.

These matrix manipulation functions are almost always "hotspots" on the profile, too. I've also seen hand-coded assembly used a lot for custom dispatch -- things like FastDelegate, but compiler and machine specific. Finally, if you have Interrupt Service Routines, asm can make all the difference in the world -- there are certain operations you just don't want occurring under interrupt, and you want your interrupt handlers to "get in and get out fast" I have only personally talked to one developer about his use of assembly.

He was working on the firmware that dealt with the controls for a portable mp3 player. Doing the work in assembly had 2 purposes:. 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".



0コメント

  • 1000 / 1000