Live data from Hacker News

The Art of 64-bit Assembly

nostarch.com

101–110 of 122 posts

Re: The Art of 64-bit Assembly

#101
post #6

Is anyone still writing assembly in the age of LLMs? Asking seriously because most assembly is just doing one very simple thing very fast and because it's so simple conceptually, an LLM can easily code it without errors.

I write all my code by hand for one simple reason: LLMs suck at programming, and I am both better and faster than they are. When that changes (not bloody likely), I'll consider changing my approach. Until then, I'm going to be over here kicking ass the way I've been doing for years.

Re: The Art of 64-bit Assembly

#103
I don’t get it. I am this books target market. Part of this demographic is that if you challenge me, I will accept the challenge. So challenging me to figure out how to do this by using AI instead of buying this book seems like a serious fail.

Re: The Art of 64-bit Assembly

#104
post #82
post #9

Earlier quoted context omitted.

Last time I checked, software compiled with both Cygwin and MSYS2 internally uses SysV calling convention, only switching to WINAPI when calling, well, Win32 API.

It is more complicated than that. MSYS2 isn't just Cygwin. It has different environments. MSYS environment is just Cygwin and it uses Itanium IIRC for C and C++ non-Win32 calls since it emulates POSIX. If it links with Windows C runtime they use __cdecl. Win32 API calls always use __stdcall convention / ABI. However, Mingw environments (Mingw64, UCRT, CLANG etc.) are intended for native Windows development, hence, th…

TL;DR: You can mix and match calling conventions as long as you actually track what piece of (compiled) software uses what convention.

Re: The Art of 64-bit Assembly

#105
post #70

Earlier quoted context omitted.

I wrote a lisp compiler recently, and that involved generating assembly language. My output is linux/amd64 assembly language which is compiled by nasm. I don't link to glibc, so I had to implement my "print int", "print string", and similar primitives in raw assembly. I successfully implemented a stop&copy garbage collector, and other interfaces to the OS such as reading command-line arguments, environmental variable…

An efficient concurrent garbage collector would be something I would buy a book for. (In fact I have one GC book on my bookshelf). But assembly? I'm not sure, honestly. Architectures change, and you can easily converge to good code by talking to an LLM. May I ask why you didn't use LLVM as a target?

I wanted something standalone I could implement and understand from the ground-up, that's why I did everything myself, rather than using LLVM.

In the future I might try to repeat the process with QBE, or similar, but LLVM is a big dependency and a bit of a moving target too.

I'm only writing toy languages for fun, and for local problem solving. I have no delusions of grandeur and expect that for every compiler/language I come up with I'll have one user at the most, possibly two.

Re: The Art of 64-bit Assembly

#106
post #72

Interesting to see that people are still spending much time on assembly languages :) I've had a lot of fun with it in recent years as well. (Shameless plug: I've written a few on LLVM integrated assembler regarding better fragments and improving expressions and relocations). When comparing GNU Assembler and MASM, GAS is missing many features: while loop, string processing (.e.g strlen) > page 3: "It’s important to un…

The GNU assembler is not intended to be used by humans, but its goal is to assemble the output of compilers.

On Linux, the "standard" assembler for humans is "nasm", though there are also others.

For anyone writing a non-negligible amount of code in an assembly language it is essential to develop or get from elsewhere a comprehensive library of macros, for avoiding to write huge amounts of boilerplate.

Re: The Art of 64-bit Assembly

#107
post #57
post #19

Weird title for a book on assembly - for x64 - on Windows - using MASM There are other 64-bit OSes, CPUs and assemblers for them, and people do use them.

If you're actually writing software in assembly (as opposed to merely optimizing hot functions in an otherwise high-level codebase), in my experience MASM is the most pleasant tool for the job.

MASM was a decent assembler, but it also had some syntax choices that lead to excessive verbosity.

In any case, today nasm is mostly equivalent with it, if not better, while being kept much more up-to-date with the Intel-AMD ISA extensions.

Re: The Art of 64-bit Assembly

#108
post #81

Earlier quoted context omitted.

You mean this: https://www.amazon.com/Art-ARM-Assembly-Randall-Hyde/dp/1718... ? Mmm nice. Will give it a try since ARM-based Mac is my main working environment nowadays.

You might also want to checkout the Assembly books by Larry Pyeatt (ARM only) and Daniel Kusswurm (x86 + ARM). Another excellent classic which you should checkout if you are interested in all things ARM is ARM System Developer's Guide: Designing and Optimizing System Software by Sloss, Symes and Wright. It is old and so does not cover newer ARM architectures but will give you a solid foundation for system programming…

Mr Kusswurm's x86 book is excellent. Didn't know he also write on for ARM. Thank you!

Re: The Art of 64-bit Assembly

#109
post #15

I'm sorry, MASM? All the cool kids use NASM or YASM.

At least it's not HLA or GAS. Who else remembers the flamewars of the 90s between all the different factions of Asm programmers? MASM vs TASM vs RosAsm vs HLA (basically no one took GAS seriously at all)... it was in some ways quite similar to the Chrysler vs Ford vs GM wars.

Comparison of assemblers - https://en.wikipedia.org/wiki/Comparison_of_assemblers

I remember during the DOS era TASM was all the rage; it was wicked fast. Unfortunately didn't get an opportunity to do much assembly programming after moving to Windows/Unix.

When Randall Hyde published his HLA (https://en.wikipedia.org/wiki/High_Level_Assembly) i remember thinking it was a good idea since it allowed many high-level language programmers to easily learn assembly programming as it included all the well-known higher-level programming constructs. It was a proper new language, but the assembly purists were all outraged and Hyde caught a lot of flak which i think was unjustified.

Post reply on HN