
Steve Wozniak's floating point routines for the 6502 - jamesbowman
https://tinyletter.com/jamesbowman/letters/i-have-found-an-excellent-programmer-named-steve-wozniac
======
redis_mlc
Woz was scary good at both hw and sw (author of Apple BASIC.) If you have
time, go through his various Apple documents online.

I believe he was never the same after his small plane crashed. (Back then,
wealthy people used small planes like ATVs, and had about the same safety
record.)

I worked with another hw engineer of similar ability back in the 80s.

Mind-blowing watching him just pick up a pen and draw out a complete board
schematic at lunch, then getting the working board back from mfg. the
following week and launching it on the Space Shuttle.

~~~
bigred100
I wonder why rich people have such a high urge to fly small airplanes. It
seems to expose you to a lot of risk, which you could easily avoid (I’ve lived
a considerable number of years without facing a single situation where I was
likely to fly an airplane).

~~~
DanielBMarkham
Airplanes are a great hobby for people who need to get out of the office, love
traveling, and need a hobby that has a lot of little detailed things to stay
on top of. Flying real IMC to minimums in a small plane is like solving a
real-time fluid dynamics/trig problem, where if you fail, you die.

I guess there are people who do it for the danger, but the beauty of it is
that you can get really down in the details and master things so it's not that
risky. Once you really master the game, your biggest danger is yourself: get-
there-itis, sloppy preflights, pushing things a little at a time, getting away
with them, then pushing more, and so on.

I have done nothing in my life that I loved as much as flying. Mankind has
been staring up into the sky for eons wishing we could fly. Now we can. Who
wouldn't want to be part of that?

~~~
barrkel
_Once you really master the game, your biggest danger is yourself: get-there-
itis, sloppy preflights, pushing things a little at a time, getting away with
them, then pushing more, and so on._

Normalization of deviance, for people interested in the literature.

~~~
DanielBMarkham
This is a big killer, moreso than most pilots realize. The reason it's so
deadly is that it turns up in a bunch of crashes where it's not identified.
That VFR pilot who was scud-running and ended up in some culmulo granite? He
probably did it and got away with it several times before the crash happened.

I don't fly anymore, but when I did? I used to get all the aviation safety
magazines and read them cover-to-cover. I also knew some flight instructor
instructors; people known for teaching safety in the industry.

A surprising number of well-trained pilots get in perfectly good airplanes and
fly them until they run out of gas. Just because you pushed it those last
dozen times doesn't mean you're going to get away with it this time.

EDIT: One of the more unusual crashes I will mention since this is HN happened
out in the mountain states. A couple of thousand hour+ MEII pilots get into a
multi-million dollar brand new jet. It's CAVU -- clear skies, visibility
unlimited. They then proceed to fly the plane into the side of a mountain --
all the time trying to figure out the new switches and displays in the
cockpit. I still think of that one when designing UX. Aviation is really
complex, detailed, fun, and full of math like programming. But it is also a
life-and-death endeavor if you take it too lightly. If you're safety paranoid,
take up boating. It's much more forgiving than aviation.

~~~
JoeAltmaier
John Denver ran out of gas while flying over a mountain pass. Exactly at the
top - dropped and hit the tip of the peak while fumbling for the fuel switch.

~~~
DanielBMarkham
Another good one. From what I've heard, he was a good pilot. The switch was
mounted in an awkward and non-standard position. (Behind the pilot's seat, I
think?)

Aside from the downdraft issue, running out of gas at altitude in VMC can be
very interesting, but it doesn't have to be fatal. Even in heavily-forested
areas, in a small plane you can put out the barn doors and decrease your
horizontal speed quite bit, especially with a headwind.

We had a guy in Virginia in the 90s, I think. He was a student-ish pilot in a
150 that ended up in IMC (fog) in the heavily-wooded mountains while running
out of gas.

He slowed the plane down as much he could, somehow kept the wings level, and
ended up on somebody's back deck. Walked away. That's not guaranteed, of
course, but in general planes are crash-rated based on flying directly into
something. It's the failure to maintain control that kills many times more
than the crash itself. Heck, they used to have shows where people crashed
planes on purpose.

------
dekhn
I don't think many people realize that Woz's dad was an electrical engineer at
Lockheed who would bring home computer manuals that Woz would read as a kid.

This seems to be a fairly effective way to create world-changing computer
engineers.

~~~
dangwu
If you gave computer manuals to kids today, they'd cry and beg for their
phones back

~~~
lacampbell
What's your point? Most kids back then would have cried and begged for their
comics back, or for the television to be switched back on.

~~~
dangwu
I'm disagreeing with OP's suggestion that giving computer manuals to kids is a
"fairly effective way to create world-changing computer engineers."

~~~
fao_
You could give computer manuals, but you have to:

a) praise achievement not intelligence

and

b) Create an interest first. Maybe make it seem like magic or show something
that you can do with it.

------
justinjlynn
Steve Wozniak is one of the few people of note in the tech industry who, the
more I learn about them, seems more and more worthy of my respect. When I hear
others speak of their sense of humour, how they stuck by their friends even
when those friends clearly took advantage of them, the work and exemplary
engineering skill they so clearly poured into their projects, their financial
success and, then after having enjoyed that success, their leaving that
successful business behind to engage in improving things for the future - to
invest in educating children - I feel a sense of loss. Steve Wozniak just
seems like the kind of person one would be lucky to have the opportunity to
have as a friend one could learn so much from. It's rare to feel that way
about people one doesn't know first hand and, while it does feel like missing
out, it's nice to have a prominent example of such a person, a financially
successful person, within the tech industry - often a dark place indeed. A
reminder that one doesn't have to be soulless in order to succeed in the
valley - just skilled and, hopefully, lucky. "So shines a good deed in a weary
world."

~~~
canada_dry
Maybe not in the same category (i.e. electronic design), but the other guy
that I admire the hell outof is Adam Savage. The guy is just bloody brilliant
at D-I-Y and, like Woz, a down-to-earth-nice-guy. I've had the great pleasure
of meeting both men and they dispelled the myth about meeting your heroes.

------
js2
See also his (probably better known) 16-bit VM, Sweet 16. Published in Byte
November, 1977:

[https://archive.org/details/byte-
magazine-1977-11/page/n147](https://archive.org/details/byte-
magazine-1977-11/page/n147)

[http://amigan.1emu.net/kolsen/programming/sweet16.html](http://amigan.1emu.net/kolsen/programming/sweet16.html)

~~~
beautifulfreak
Woz says the article you linked in Byte is a followup to the OP. Good find.

------
sagebird
I jumped into reading this note without looking at the url or author and near
the end I was wondering who wrote it -- Then I saw the reference to the SPI
driver which was a dead give away for James Bowman. I am continuously
impressed with his work in the embedded scene after discovering the gameduino.
It feels like even though there are thousands of voices on the web I actually
only care about what perhaps 50 people are writing.

~~~
dilippkumar
I have never heard of James Bowman before. I’ll look into his writing some
more.

Would you mind pointing me to some more of these interesting writers?

------
dev_dull
> _They took the limitations of their computers as a challenge, sat down, and
> made these tiny machines do impressive things._

Poets knew from long ago that using pentameter and constraints fosters
creativity. Here we see the same principle applied in computing.

~~~
natashabaker
This is what I love about the C256 project
([https://c256foenix.com/](https://c256foenix.com/)). From an interview with
her:

 _By limiting its resources, future developers will have to be clever to find
new ways to create amazing things that early on we thought we could never do.
Memory is cheap, so I could easily spend the same amount of money on a single
chip that could have given me the chance to fill the memory space with RAM.
But instead, I am choosing to use many chips with much lower capacity. It’s
more limiting, but that’s the point. "_

~~~
cmrdporcupine
If you haven't, order a Rev C board and contribute!

[https://c256foenix.com/product/c256-foenix-rev-c-bare-
board-...](https://c256foenix.com/product/c256-foenix-rev-c-bare-board-with-
floppy/)

------
phaedrus
Floating point can be tricky.

I competed in the first couple years of Sparkfun's autonomous vehicle
competition. My robot had a keypad where you could enter GPS coordinates for
waypoints. The microcontroller I was using had 32-bit soft floating point
routines in its standard library, but I had to code my own string-to-float
routine. (I think only float-to-string was provided, but not the inverse.)

Every year, the robot worked in Oklahoma but in Colorado would make a wild
turn and head the wrong way. The morning of the last time I competed I
realized the problem was in my string to floating point conversion code. I had
made a programming assumption which was mathematically incorrect. It happened
to work in Oklahoma because the fractional part of the GPS coordinates at home
were in a range that didn't trigger the bug.

I also realized it meant the conversion algorithm was more subtle than I had
assumed, and there was no way I was going to be able to figure out the correct
algorithm in the field, under time pressure. In those years I either didn't
yet have a smartphone, or I looked and couldn't find code on the web for my
microcontroller.

(And I couldn't just drop in some C code - it was a Parallax Propeller and my
robot's code was in the Spin language. Quirks of the chip made it unusually
hard to port C to it and so C compilers for the Propeller were still what I
would consider "experiemental" \- or were when I started the project.)

The incorrect floating point code had been one of the first things I'd written
- it'd been responsible for my robot crashing every year, including that
morning. (I'd blamed hardware, upgraded the GPS unit, improved sensors, etc.)

One year later to the day, this was all on my mind again because I couldn't
make it to the competition that year, and I had a shower thought. I had had a
KNOWN GOOD floating point conversion routine on my hard drive and running
inside my microcontroller that whole time!! I was using a Propeller GPS
library. GPS data comes in NEMA strings which are... strings! By necessity,
there was a private routine in the GPS object which had to be doing the
conversion. I went and looked - yes, all I would have had to do was change
this private routine to "public" and I could have called it.

------
WalterBright
Having written a lot of 8 bit assembler for the 6800 microprocessor for 2K
eproms, I can attest it is a very different skill from writing modern
software.

~~~
paulsmith
Would love to hear more about this - have you written on your experiences?

~~~
WalterBright
No, and sadly I've lost the code I wrote, I don't know what happened to it.

Anyhow, programming an 8 bit 6800 for an embedded controller means keeping
track of 6 or more things going on at the same time, while modern software
focuses on one thing at a time and isolating it from everything else.

Those things include the contents of each register, the stack level, the size
of the code, interrupts going off, polling that has to be done, counting
cycles, etc. Organizing code into functions is a luxury not usually
affordable.

It sounds tedious, but it was fun. I attached my own hard disk drive to my
LSI-11, meaning I had to build an interface board and write a device driver.
To figure out how to write the device driver, I dumped the floppy driver code.
It was a marvel of tight engineering. The bootstrap loader was executing code
only an instruction or two behind it getting loaded. I was just in awe.

~~~
cmrdporcupine
If you think about it, it's pretty crazy. Register allocation using graph
colouring is an NP-complete problem. Writing assembler by hand, one is doing
this constantly in one's head, and often with better results than a compiler
would do.

------
commandlinefan
I learned to program on a 6502 when I was younger - it's a little depressing
that computers went and got so fast that there's no real justification for
doing this sort of thing any more in almost any domain (except, I guess, if
you manage to land a position developing embedded I2C drivers).

~~~
jhayward
Join the ultra-low-power crowd! There are lots of fun things to make while
trying to squeeze it in a couple of KB and a few kHz.

------
mothsonasloth
As a senior Java / CPP developer, reading what Wozniak had written, it might
have been some incantation in a forgotten language.

I really wish I had done more embedded and assembly at school. I can't
understand it or appreciate it.

Maybe SW and HW shouldn't mix, bar a few visionaries who bridge both worlds?

~~~
NonEUCitizen
Why should SW and HW not mix?

~~~
mothsonasloth
Well, my day to day job is writing applications that will be managed at
runtime by a JVM on a Linux distro which is in turn virualised.

I am so far away from the bits...

------
jackhack
How curious that there's a reference to Jef Raskin on the facing page (p.205).
Raskin, of course, was a visionary at Apple who would go on to advocate for a
version of Macintosh quite different from what Steve Jobs envisioned (but
which later appeared as the Cannon Cat). (a standalone system, but also an
Apple ][ expansion card:
[https://en.wikipedia.org/wiki/Canon_Cat](https://en.wikipedia.org/wiki/Canon_Cat)
)

And yes, Wozniak is one of the great engineers of our time. I cut my teeth on
an Apple ][, and it was both amazing and mysterious to me then, as a child.
Now, with 40 years of professional programming experience, the mystery is
largely gone but my appreciation for the elegance of his design is only
amplified.

On the off-chance he'll see this:

Mr. Wozniak, thank you for creating something that has give me a career and a
lifetime of joy.

------
ananonymoususer
The 8051 platform can present even more challenges for assembly language code
developers than the 6502. It has been over 35 years since I wrote any 6502
code, and over 30 years since I wrote any 8051 code, but I remember the
biggest issue on 8051 was the lack of RAM. You get a total of 384 bytes of RAM
(256 bytes of normal RAM and 128 bytes of "zero page" RAM). When I needed to
write floating point math functions for the 8051, I realized that fixed point
decimal math would meet my requirements. I took advantage of the large ROM
space to store a bunch of constants (powers of 10) and the code I wrote
operated on decimal ASCII strings. Because of the limited memory, all of my
operators would destroy the second argument and replace it with the result.

Code is available upon request.

~~~
protomyth
Yeah, Intel is an odd bunch. If I had to program an 8-bit machine again, I
think the 6809 is still my favorite.

~~~
ananonymoususer
The 6809 was a great 8-bit microprocessor. Any CPU with a SEX instruction is
okay in my book.

------
simonebrunozzi
The title says "Wozniac" but it really should be with a final "k", as in
"Wozniak".

~~~
JadeNB
As, curiously, it is spelt everywhere in the article itself _except_ the
title.

------
iainmerrick
I was always very impressed by the floating point routines in BBC Basic (also
on the 6502). Anyone know who wrote those, and if they were derived from this
work by Rankin and Wozniak?

BBC Basic is the best all-round Basic of its era that I know of, with rich
control flow features, proper recursion and built-in assembler. But I don't
know how much was original work from Acorn and how much was borrowed from
elsewhere. Are there any other 8-bit Basics that are especially good?

~~~
vanderZwan
Sophie Wilson apparently did most of the BBC Basic implementation, no idea if
that also included the floating point routines.

[https://en.wikipedia.org/wiki/Sophie_Wilson](https://en.wikipedia.org/wiki/Sophie_Wilson)

------
ARandomerDude
He was 2nd author on the paper. No doubt, Woz has a well-deserved reputation
for brilliance, but I wonder about the 1st author's contributions too. Anyone
familiar with Roy Rankin of Stanford?

[https://archive.org/details/dr_dobbs_journal_vol_01/page/n20...](https://archive.org/details/dr_dobbs_journal_vol_01/page/n207)

~~~
peteri
Roy contributed the log/exp routines. The code in the Apple II ROM are missing
the log/exp routines and it's copyright just credits Woz.

------
Udik
For the two people who might not have seen it yet, here's that fabulous joint
interview to Steve Jobs _and_ Bill Gates, where they recount the story of the
(missing) floating point routines in Woz's BASIC for the Apple, and how
Microsoft came to rescue.

[https://www.youtube.com/watch?v=-LUGU0xprUo#t=14m20s](https://www.youtube.com/watch?v=-LUGU0xprUo#t=14m20s)

The whole interview is fantastic.

------
dang
A thread from 2014:
[https://news.ycombinator.com/item?id=7768465](https://news.ycombinator.com/item?id=7768465)

------
gomijacogeo
He also wrote a nifty article back in '81 about calculating e to 118,000
decimal places.

[https://downloads.reactivemicro.com/Users/Grant_Stockley/App...](https://downloads.reactivemicro.com/Users/Grant_Stockley/Apple%202%20Woz%20e%20Calc%201981.pdf)

------
Mauricio_
"They presume a four-byte floating point operand consisting of a one-byte
exponent ranging from -218 through +127..." Is this a mistake on the magazine?

------
constmu
There are a couple of famous books for reading Steve Jobs' biography. Are
there similarly good books to read about Steve Wozniak's biography?

~~~
jcl
His autobiography?:
[https://en.wikipedia.org/wiki/IWoz](https://en.wikipedia.org/wiki/IWoz)

~~~
JKCalhoun
Kept going until about a quarter of the way in but I just couldn't finish it.
It is told very matter of factly — not, I'm afraid, conducive to keeping my
interest. YMMV, of course.

------
hi41
I need to confess. I am absolutely petrified by floating point. Is there a
good resource I can learn it from.

------
michelinman
Woz ur the man.

------
justinjlynn
While I think Woz sets a good example, they're human - and I'm sure they've
done and/or said things that are less than one might expect and which one
probably wouldn't approve of or condone - or perhaps which one might even
condemn. I'd caution against canonising people - it sets too high a standard;
which no one real can meet.

~~~
vasco
Perhaps out of place but why are you consistently calling Woz "they"? I'm not
a native speaker and it sounds very weird.

~~~
justinjlynn
As I'm not aware of what pronouns they personally prefer, I fall back to using
the singular, gender-neutral, "they/them/their". It's a fairly new usage in
colloquial English but I find it to be common enough so as to not impair
understanding.

~~~
bsaul
completely off topic, but is this where we’re at now ? Calling someone « they
» and thus create confusion, just in case he doesn’t belong to the 99.9% of
the population who is just fine with his DNA, and eventhough he never
expressed any kind of opinion leading you to think he isn’t fine with his
gender ?

~~~
vidarh
There is no implication that "he isn't fine with his gender". The implication
is that the speaker doesn't know, and it doesn't matter enough to find out or
make a judgement call.

Personally I still use he/she most of the time unless I have a reason not to,
but I also try to get into the habit of assuming less, not least because
online in particular it is increasingly noticeable how often we assume
someone's gender even in situations we have no reason to.

It's not unsurprising that some choose to carry that over into discussing
people they don't know the preference of when it doesn't otherwise matter.

One reason to do so may be to explicitly normalise the usage so it doesn't
imply a value judgement e.g based on appearance.

~~~
bsaul
« One reason to do so may be to explicitly normalise the usage so it doesn't
imply a value judgement »

That’s some scary sentence here. so gender is now a « judgment ». Like,
there’s no reason to assume because steve wozniak has all the physical
characteristics of a male, and has always been called « mister », using « he »
(which is the grammatically correct way of designing a male human in the
english language by default) is the expression of a value judgement... Seeing
this kind of mental twist in a scientific forum (which believes there is
something called nature, with laws and hard facts) makes me really scared.

~~~
foldr
It looks as though you're just looking for an excuse to go on a pre-packaged
rant about gender and sex. I find it scary that an innocuous use of singular
"they" (which has been in use as long as English as existed) would provoke
such a thing.

~~~
bsaul
I'm not native english, so it could be possible that i overestimate the change
to the english language using "they" as a default pronoun implies.

I'm extremely sensitive to ideology wanting to change a language to better
reflect its theory. It's the first step to totalitarism, and it's almost
always done with perfectly good intentions (until we start to see the damaging
side effects).

~~~
foldr
Singular 'they' has been in use for hundreds of years. See e.g. this article
that I linked to elsewhere in the thread:
[https://stroppyeditor.wordpress.com/2015/04/21/everything-
yo...](https://stroppyeditor.wordpress.com/2015/04/21/everything-you-ever-
wanted-to-know-about-singular-they/)

Note that many of the historical examples involve contexts where gender would
not even have been in doubt (e.g. all students at Cambridge would have been
men).

~~~
bsaul
Thanks for link. So am i dreaming when i think using this term is
(re)appearing recently following the whole gender neutral pronoun discussions
? Has it already been as common but i just didn’t happen to notice it ?

~~~
foldr
I think you're conflating the issue of gender neutrality with more recent
discussions of non-binary and trans gender identities. People have always
needed gender neutral pronouns to say things like "Everyone has their flaws",
or to talk about individuals whose gender is unknown or irrelevant. The only
question has been whether it's 'he/him/his' or 'they/them/theirs'. If you
speak a dialect of English where 'they' can function as a gender-neutral
singular pronoun, then there's really no reason at all not to use that pronoun
to refer to Steve Wozniak.

The use of singular 'they' has been common for (at least) several decades,
long before any substantial number of people were worried about trans issues.

