Live data from Hacker News

Ask HN: What is hand-coded assembly language used for these days?

news.ycombinator.com

51–60 of 60 posts

Re: Ask HN: What is hand-coded assembly language used for these days?

#51
post #9

Earlier quoted context omitted.

That has more to do with reading assembly than writing it by hand.

There are certainly people who write shellcode. As I understand it, people have written shellcodes that use only bytes that happen to map to ASCII, are obfuscated to bypass intrusion detection systems, and so on. I'm sure it requires quite a bit of (specialized) knowledge.

That was more common in the late '90s than it is now (and note that it involves knowing only a very few instructions; enough to call a function or the system call gate).

There are occasional exploits that can't be pieced together out of other people's shellcode, but there are also perhaps 10 people in the world that write those exploits.

Re: Ask HN: What is hand-coded assembly language used for these days?

#52

Earlier quoted context omitted.

There are certainly people who write shellcode. As I understand it, people have written shellcodes that use only bytes that happen to map to ASCII, are obfuscated to bypass intrusion detection systems, and so on. I'm sure it requires quite a bit of (specialized) knowledge.

Well, more like bytecode that doesn't contain a zero-byte, which'd stop a string dead-on.

In '96 when I wrote the Crispin IMAP server bug, I can't remember which way it was but you either couldn't have uppercase letters, or could only have uppercase letters, in the shellcode. I thought I was kind of badass for writing that code. Of course, by '99, that was a triviality.

Just saying, it's not just NUL.

Re: Ask HN: What is hand-coded assembly language used for these days?

#53
Lots of time small embedded programs, especially on underpowered micro's, see this sort of attention.

Additionally, low level hardware interfacing is often done with hand coded assembly, because it is easier to "get right" on some crappy compiler toolchains that you face, then C.

Re: Ask HN: What is hand-coded assembly language used for these days?

#55
post #27
post #20

Earlier quoted context omitted.

Having read and written assembly on a daily basis for years, I have to disagree entirely. The only simple thing about assembly is that it happens to map to machine code directly, but macros and quasi-instructions even make that iffy. There are so many idiosyncrasies in every ISA, so many ways in which the code you write has side effects. Assembly isn't just complex in practice, it's complex in concept. If you want si…

Try ARM. x86 assembly is ugly and wart ridden. ARM is like a breath of fresh air. Unbelievably well designed.

I learned ARM while working on iPhone reversing, and it's certainly nicer, but there are still a ton of considerations. It's much nicer to write, but when reversing it you have to handle so many edge cases it's not even funny. Writing a decompiler for it really drives that home.

Re: Ask HN: What is hand-coded assembly language used for these days?

#56
Thanks to all for the many informed and detailed replies!

I am now assistant-teaching a college course in low-level computer programming. It's an excellent course: the students reprogram a children's toy robot that uses the ARM processor. http://www.amazon.com/Little-Tikes-Giggles-Remote-Control/dp... They're getting up to speed very quickly on how to get hardware to actually do stuff.

Yes, I actually left Silicon Valley to do grad school. I haven't given up the principle of "do real stuff, see real results", though. I'm looking to design a couple fairly small homework assignments consisting of optimizing some ARM code. I want the examples to be real. Now mulling over which to do...

Re: Ask HN: What is hand-coded assembly language used for these days?

#57
I've done it for cryptography code and cryptanalysis code. Specifically, optimizing code to take advantage of specific instructions available in certain processors or to make use of vector registers and instructions. I wrote my programs in C and then went back and wrote assembly for parts of the code that could deliver a significant overall speedup with hand optimization.

One place I did this was various RSA Challenge attack clients.

Re: Ask HN: What is hand-coded assembly language used for these days?

#58
post #50
post #38

It's used in bits of kernel programming - often because there is no other way to do the task.

Modern kernels have very little assembly, outside of things like locore. They've heavily abstracted away the things you'd normally write in assembly, like modifying MSRs; also, so much of what you do now is simply memory mapped. In all of xnu, not counting AES, there are ~17kloc in x86 assembly, most of it in osfmk/i386 --- where no normal developer is ever going to go. There are over 730kloc in C.

I wasn't implying there was a lot, just that sometimes that's the only way.

Re: Ask HN: What is hand-coded assembly language used for these days?

#59
post #58
post #50

Earlier quoted context omitted.

Modern kernels have very little assembly, outside of things like locore. They've heavily abstracted away the things you'd normally write in assembly, like modifying MSRs; also, so much of what you do now is simply memory mapped. In all of xnu, not counting AES, there are ~17kloc in x86 assembly, most of it in osfmk/i386 --- where no normal developer is ever going to go. There are over 730kloc in C.

I wasn't implying there was a lot, just that sometimes that's the only way.

I'm just saying, even as a kernel dev, you're unlikely to need to write things in assembly.

Re: Ask HN: What is hand-coded assembly language used for these days?

#60
I've re-written many perl things in C to speed up processing time - for me, it's better than buying more/newer hardware. Also, for smallish scripts that I invoke millions of times or a small perl script that does regexps, I can rewrite those in C to boost speed as well. I don't do any ASM code anymore, but C is a really good optimization step for me and my projects.
Post reply on HN