News for hackers. Stuff that matters.
Re:NASM Assembly Language Tutorials by tarkin2 on Monday January 03, 2022 @05:59PM (#29788289)
Why do people use NASM? Faster binaries? When is it needed? Where do the binaries run?
Re:NASM Assembly Language Tutorials by sigjuice on Monday January 03, 2022 @06:22PM (#29788529)
Portions of a program or library might be written in assembly for performance. This list should give an idea of the type of software that does this

  $ cd /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula
  $ grep depends_on.*nasm * | sed 's,:.*,,' | xargs grep desc
  dav1d.rb:  desc "AV1 decoder targeted to be small and fast"
  dssim.rb:  desc "RGBA Structural Similarity Rust implementation"
  ffmpeg.rb:  desc "Play, record, convert, and stream audio and video"
  handbrake.rb:  desc "Open-source video transcoder available for Linux, Mac, and Windows"
  isa-l.rb:  desc "Intelligent Storage Acceleration Library"
  jpeg-turbo.rb:  desc "JPEG image codec that aids compression and decompression"
  libass.rb:  desc "Subtitle renderer for the ASS/SSA subtitle format"
  libavif.rb:  desc "Library for encoding and decoding .avif files"
  libvmaf.rb:  desc "Perceptual video quality assessment based on multi-method fusion"
  lrzip.rb:  desc "Compression program with a very high compression ratio"
  mozjpeg.rb:  desc "Improved JPEG encoder"
  mvtools.rb:  desc "Filters for motion estimation and compensation"
  openh264.rb:  desc "H.264 codec from Cisco"
  openj9.rb:  desc "High performance, scalable, Java virtual machine"
  pce.rb:  desc "PC emulator"
  ppsspp.rb:  desc "PlayStation Portable emulator"
  rav1e.rb:  desc "Fastest and safest AV1 video encoder"
  vapoursynth.rb:  desc "Video processing framework with simplicity in mind"
  x264.rb:  desc "H.264/AVC encoder"
  x265.rb:  desc "H.265/HEVC encoder
Re:NASM Assembly Language Tutorials by the_only_law on Tuesday January 04, 2022 @10:55AM (#29796146)
Interesting how many of these are related to video encoding. While I can understand wanting to micro optimize performance for this sort of work when done in the CPU, I would think that if you truly wanted maximum performance, you’d offload this to something like a GPU or other hardware offering this feature.

Emulators make sense I suppose.

I’ve only ever seen modern assembly in the wild in small parts, in say a kernel or something like coreboot. I’ve been told by graphics programmers and game devs that’s its not uncommon to hand roll assembly code in those domains, which was suprising to me

Re:NASM Assembly Language Tutorials by totorovirus on Monday January 03, 2022 @10:16PM (#29790862)
I am truly impressed by your command line skills. Awesome
Re:NASM Assembly Language Tutorials by yjftsjthsd-h on Monday January 03, 2022 @06:58PM (#29788905)
I'm about to use it for really early OS development. You kind of need assembly for some bits in early boot / setup, and nasm seems friendlier to me than the alternatives.
Re:NASM Assembly Language Tutorials by sharikous on Monday January 03, 2022 @06:12PM (#29788427)
More control on the machine. For example you may want to use certain CPU instructions, or as you mentioned you can eliminate a lot of overhead in certain cases.

Look at it like melting your own metal piece. Sometimes the screws that you find in the shop are not the exact shape you need and it's better to build your own.

I bet most of the things you code with Nasm are not entire binaries. You can write functions entirely in assembly and link the compiled outputs to any binary file once you know the calling convention

Re:NASM Assembly Language Tutorials by sebow on Monday January 03, 2022 @11:49PM (#29791469)
Better documentation (I'm pretty sure the latest official documentation from gnu/as is from like 2009), packages on all distros & *nix flavors: linux, deb/rpm-based, freebsd, etc. And also why not a lot of people use it.I think gnu/as has a bit better tooling,more flags, etc., but that's quickly changing.
Re:NASM Assembly Language Tutorials by Koshkin on Monday January 03, 2022 @08:31PM (#29789923)
Go to Java for the climate, NASM for the company. (Or was it the other way around?) In any case, even Windows programming in NASM is easy!

https://news.ycombinator.com/item?id=28790747

Re:NASM Assembly Language Tutorials by chrisseaton on Monday January 03, 2022 @07:16PM (#29789065)
> Why do people use NASM? Faster binaries?

There's nothing NASM can do to produce faster binaries than any other assembler - as it doesn't control which instructions to generate - they're specified entirely by the user.

Re:NASM Assembly Language Tutorials by glandium on Monday January 03, 2022 @09:06PM (#29790283)
Actually, nasm does have optimization passes. https://nasm.us/doc/nasmdoc2.html#section-2.1.24 That's not full of details, but one thing that it does on x86_64, for example is replace instructions that set 64-bits registers to immediate values smaller than 2^32 with instructions that set the equivalent 32-bits register (because that's a shorter equivalent, because those instructions zero-extend the value).
Re:NASM Assembly Language Tutorials by pjmlp on Tuesday January 04, 2022 @02:33AM (#29792346)
That is common in most Assemblers, RISC ones like MIPS even go further with pseudo instructions to work around how low level RISC opcodes tend to be.