4 ms·
"This is a very simple algorithm, and it needs only very simple tools. Perhaps this is why dc, the UNIX RPN calculator, was the first utility ported to UNIX, wa
by throwaway81523 2y ago
"This is a very simple algorithm, and it needs only very simple tools. Perhaps this is why dc, the UNIX RPN calculator, was the first utility ported to UNIX, way back in the PDP-11 days. It even predates the C programming language; originally it was implemented in B"
I'm pretty sure the version with v6 Unix was written in PDP-11 assembler. It's possible it was translated from a version written in B? It wasn't THAT simple, since it had to implement arbitrary precision arithmetic. I have a vague memory of it using a "buddy system" storage allocator, a scheme also described in Knuth volume 1. Maybe the code is still around somewhere.
- throwaway81523 2y agoSelf-followup: yes, the v6 source code is here: dc1.s, dc2.s, etc. https://minnie.tuhs.org/cgi-bin/utree.pl?file=V6/usr/source/s1 https://minnie.tuhs.org/cgi-bin/utree.pl?file=V6/usr/source/...