TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Assembly Language Programming: Still Relevant Today (2015)

119 点作者 mr_tyzic超过 5 年前

17 条评论

peter_d_sherman超过 5 年前
Excerpt:<p>&quot;Jeff Laughton (Dr Jefyll on the 6502.org forum) says, &quot;I recall hanging out with a programmer pal o&#x27; mine and a younger fella who was in college. The young fella was complaining, &#x27;We <i>have</i> to take assembly language,&#x27; and Len corrected him immediately, saying, &#x27;You <i>get</i> to take assembly language!&#x27;&quot;<p>&lt;g&gt;
评论 #21926647 未加载
joe_the_user超过 5 年前
&quot;...self-modifying code, [is] sometimes appropriate to solve certain problems that have no other solution, or for improving efficiency, as in double-indirect addressing.&quot;<p>I have read that self-modifying code on the x86 architecture is pretty dangerous at the assembly level.<p>More broadly, this kind of comes back to all the issues in the &quot;C is not a low level language&quot; thread. Some level of assembler certainly gives the programmer as full access to the machine as possible. But naive assembler from the 8086 - 80486 eras is going to be rearranged in a lot of ways in a modern Pentium processor and counting on in-order execution may be a mistake.<p>Edit: at the same time, the modern processor doesn&#x27;t really allow a lower level than assembler normally and the default approach is assuming flat memory but being aware of the pitfalls of multiple caches being involved.
评论 #21926863 未加载
评论 #21925369 未加载
评论 #21925286 未加载
评论 #21925325 未加载
评论 #21925288 未加载
shaggie76超过 5 年前
While I can only recall writing real assembly once in 20 years I&#x27;ve <i>read</i> disassembly thousands of times while debugging.
commandlinefan超过 5 年前
&gt; It is common for the beginner to want all the fancy tools too soon<p>Am I the only one who’s never felt that way? I get grief from people around me (especially “hurry up and get it done” management types) for spending too much time in the low levels, trying to really understand what I’m doing and what’s going on.
评论 #21928531 未加载
mjpuser超过 5 年前
Not sure why HN is saying it is obvious that assembly is relevant because compilers... The article&#x27;s intent is around a programmer writing assembly. I&#x27;m sure there are niches but I can see web developers getting away without writing assembly in their professional career.
评论 #21926585 未加载
评论 #21926481 未加载
chrisseaton超过 5 年前
&gt; Assembly language yields maximum control and execution speed.<p>It yields the <i>only</i> control and execution. Almost programs are generated through an assembler and assembly language. How could it possibly <i>not</i> be relevant?
评论 #21925538 未加载
评论 #21925296 未加载
georgeplusplus超过 5 年前
To me, assembly is one of the things while self studying CS that I felt lacked good support in resources such as this, MOOCs, or just plain explaining it. Usually when I post a topic trying to Demystify the topic I am greeted with an extremely hard to digest read about said topic that is more meant for people Already knowledgeable in the subject.<p>And I feel assembly should be more a core building skill in a programmers toolbox. So this article is very welcoming for o me.
评论 #21928045 未加载
评论 #21928437 未加载
评论 #21927772 未加载
评论 #21928595 未加载
FpUser超过 5 年前
As recently as a year ago I used built in assembler in Delphi to perform some low level timing. It was not for just super-duper performance though. Surprisingly it was the most straightforward and simple way. Meanwhile my firmware for 3-Phase AC motor torque and speed control for really low power micro controller was doing fine with plain C without any assembly.
评论 #21926216 未加载
zzo38computer超过 5 年前
There is many kind of assembly language, some for the actual computer hardware, some for VMs, and some used as both.<p>I have used and sometimes still do use assembly language, including 6502 (specifically, NMOS 6502 without decimal arithmetic, including unofficial opcodes), and a little bit of x86 stuff (although the modern x86 is very messy, I think), but also Z-machine and Glulx. I have also used MIX and MMIX assembly (and may use MMIX more if I would actually make a computer with it). And then some other programs (such as ZZ Zero, which is similar to ZZT) has its own kind of assembly language.<p>One feature not mentioned is the relative numbered labels such as 1H and 2H available in MIXAL and MMIXAL; you can then use 2F to find the next 2H label forward, or 2B to find the next 2H label backward. My own assemblers for Glulx and ZZ Zero support the similar feature too.
评论 #21928451 未加载
Lerc超过 5 年前
There&#x27;s food for thought there. As part of my current project I wrote an assembler for 8-bit Avr. (on github <a href="https:&#x2F;&#x2F;github.com&#x2F;Lerc&#x2F;AvrAsm&#x2F;" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Lerc&#x2F;AvrAsm&#x2F;</a> )<p>Part of my motivation for this was to have an assembler that ran in the browser (for my fantasy console that also runs in the browser), but another big part of it was to write an assembler designed to be more friendly to people writing assembly directly.<p>When I wrote 6502 asm I mostly did it from Supermon which is a no frills experience. It&#x27;s nice to see the features that assemblers have now, I think I&#x27;ll be implementing quite a few of those macros from this link in my own assembler.
dang超过 5 年前
A thread from 2015: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=10522158" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=10522158</a>
z3t4超过 5 年前
Optimizations have come a long way. Not only do you need to be an asm programmer to beat the optimizer, you need to be a <i>good</i> asm programmer.
pjmlp超过 5 年前
Sure it is, someone has to write compiler backends and OS bootloaders, even if all instructions would be exposed as intrinsics.
评论 #21926575 未加载
davidhbolton超过 5 年前
Even back in the 1980s, author Lance Leventhal who wrote some great programming books on assembly always warned that productivity wise you write the same number of lines of code whether its 6502 or C.<p>As that 6502 example in the article shows, you don&#x27;t great great productivity with assembly. And even macros don&#x27;t improve on it that much.
评论 #21928075 未加载
p0nce超过 5 年前
On modern x86 it&#x27;s not very useful at all anymore. An ICC or LLVM backend with compiler intrinsics will get you quicker performance, with reduced maintenance and cost. Performance will also move over time with backend optimizations getting better.<p>You can still do it if you care about debug build performance.
buserror超过 5 年前
I&#x27;m rarely keen on posting negatives on articles that clearly took a lot of time to make, but I think this requires a bit of correction.<p>I think this article is very, very simplistic. All of it relates to a 8 bits CPU that is 40+ years old.<p>I switched to HLL as soon as I could get my hand on a compiler, namely, UCSD Pascal at the time! Then the Pascal, then to C and then myriads of other languages. I covered 6502, Z80, 68k (all of them, to 68040), PowerPC (all of them from 601 prototypes to G5s), ARMs (more than I can count) and x86s (same).<p>True to be told, the assembly language I started with &#x2F;helped a LOT&#x2F; with be becoming an efficient developer; a developer who understand what &#x27;code&#x27; is being generated when he writes an expression, a statement, a loop, and one who understands what the runtime implication are for most of the &#x27;sugar coating&#x27; HLL gives.<p>However, starting (a bit) with the 68k, then even more so with the PowerPC, it became pretty much impossible to write &#x2F;from scratch&#x2F; an assembly equivalent that was QUICKER than the compiler generated code. That was 20+ years ago. DRAM latency happened, pipelining happened and SIMD happened.<p>Today, hand writing assembly is pretty much stupid on modern CPUs. Given the register files, timings, shadow registers, bus latencies etc etc the compiler will ALWAYS be better because there is <i>so much</i> criteria to think about when generating code...<p>I&#x27;m not saying that having the knowledge is not useful; the <i>best</i> use of assembly is to write some code il HLL, one that is supposed to be super-mega-critical-quick, then disassemble it and see how it looks. More often then not, you can&#x27;t make it better than it is <i>in situ</i> -- most of the time you will gain is to prepare your data better, align it better etc etc -- basically, &#x27;hinting&#x27; the compiler to do a better job. You can do serious code butchery like that, without a hint of assembler [0].<p>But really, I haven&#x27;t written any assembly for &#x2F;performance reasons&#x2F; in 15 years, and that was Altivec on PowerPC.<p>For 8 bits, it&#x27;s all smooth as butter, but the article also doesn&#x27;t take into account the massive progress in compilers; I&#x27;m the author of SimAVR [1] and I&#x27;ve seen my load of generated code for that CPU, and the GCC toolchain is &#x2F;very hard to beat&#x2F; by hand these days.<p>[0]: critical audio loop on one of my old PCI card driver, converting float&lt;-&gt;int, applying gain etc while using the register file to the max, and making most use of the pipelining of the G4 (at the time) <a href="https:&#x2F;&#x2F;gist.github.com&#x2F;buserror&#x2F;0a3a69cca927b8da6c9c7ee1605007fc" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;buserror&#x2F;0a3a69cca927b8da6c9c7ee1605...</a> -- note, the inner loop was generated by a script that was doing the cycle calculations (!)<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;buserror&#x2F;simavr" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;buserror&#x2F;simavr</a>
评论 #21927424 未加载
评论 #21925876 未加载
评论 #21927151 未加载
评论 #21925701 未加载
aportnoy超过 5 年前
This is like being an architect and noticing that bricks and cement are still relevant... Of course they are!
评论 #21926579 未加载
评论 #21924905 未加载