Hacker News new | past | comments | ask | show | jobs | submit login
FreeBSD x86 Assembly Language Programming: Using the FPU (freebsd.org)
64 points by majke on Aug 23, 2015 | hide | past | favorite | 9 comments



Just to be clear, this is a historic document (2001), not a current introduction to x86 assembly. There's entirely new floating-point architectures introduced since this was written (SSE and AVX).


Original source: http://int80h.org/bsdasm/

My recollection is this was published on the author's site years before being added to the "handbook" on the FreeBSD website. I could be wrong. Perhaps check archive.org.


I wonder if the engineers at Intel were inspired by the HP RPN calculators, since the stack-based x87 is quite unlike the register-based x86.

The fact that it's stack-based also makes for some very high code-density; a lot of the tiny demoscene demos (<=256b) make heavy use of the FPU, like these:

http://www.pouet.net/prod.php?which=3397

http://www.pouet.net/prod.php?which=53816


William Kahan consulted on the design of both.



FWIW, the assembly in the link is ancient. Treating FPU registers as a stack was considered a mistake 20 years ago. In this day and age it's been replaced with MMX and then SSE. It will technically still work because of backwards compatibility, but modern compilers will output newer, faster SSE instructions.


A bit of a nitpick here about MMX. Although the MMX registers were aliases of the floating point stack registers, the MMX instruction set consisted of strictly integer operations, not floating point.


Actually the FPU instruction set, even if stack-based, is quite complete and the implementations are effective, not often not slower than the more "modern" ones, except when there is a possibility for parallel processing. And SSE doesn't have 80-bits precision at all.

MMX is something that is probably not much useful today. But FPU and SSEx are both usable, especially when using assembly.


The developers handbook is just rife with gems.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: