Sanding our assholes with 150 grit. Slowly. Lovingly.

Gary the not invented here

To continue the series on people I've worked with over the past 30 years, today's installment in on Gary the not-invented-here guy.

You've probably worked with Jon the incompetent and Greg the secretive, but I'll bet you've never worked with someone as extreme as Gary.

In 1985 I started working for a small company that made communications response time monitors. I didn't want to change to this job, but couldn't resist the 29% raise and Friday's off. I knew right from the start I was in trouble. I was hired to shadow Gary and to straighten out his mess.

I looked at Gary's "code". His program listings were hand-written streams of hexadecimal numbers. There typically were maybe three one-line comments per page. He had a binder full of these. (I kept one page as a keepsake).

I asked Gary what was going on, and why. He said that once he found a bug in an assembler, and so couldn't trust them. He memorized the op codes for the 6809 processor, wrote his programs in hex, calculated his own jump offsets, did his own ascii conversions and typed the hex into a debugger that a contractor had written. The debugger had provision for saving the memory to a hard-disk image.

Likewise, Gary didn't trust operating systems. He had written his own for this data collection device he was developing. All the low level stuff that accesses the hard disk and the monitor. He wrote the math libraries too. All in hex code.

The first thing I did was write a disassembler. I then had an assembly language version of Gary's code that I could work with. Gary would still write in Hex, I'd disassemble it, then make him use the assembler.

Surprisingly, Gary was pretty good to work with, and didn't resist my impositions. I considered him a friend. But I wasn't surprised or disappointed when he was fired two years later.
Permalink Fan boy 
June 25th, 2009 10:12am
Wow, extreme. 

I don't find this level of paranoia as much these days, because most instruction these days doesn't get down to the hexadecimal dump level.  AFAIK.
Permalink SaveTheHubble 
June 25th, 2009 10:21am
Gary also wrote Z80 in hex. He really was a bright fellow. I don't know what he is doing today.
Permalink Fan boy 
June 25th, 2009 10:29am
Yeah, writing 80x86 code in hex is quite a bit more difficult, but it can be done.  Even assuming you don't limit yourself to the Z80 compatible subset.

Michael Abrash was the master of this, writing "The Zen Of Assembly" and several other books about the 80x86 architecture at the assembly level.
Permalink SaveTheHubble 
June 25th, 2009 10:31am
that's some seriously misapplied talent.
Permalink eek-o-tourist 
June 25th, 2009 10:32am
To continue with the pedantic and perfectionist that runs deep inside me, 8086 was not compatible with Z80. It was based on the Intel 8080 and 8085. Z80 was a (superior) Zilog chip.
Permalink Fan boy 
June 25th, 2009 10:34am
I always said Gary as brilliant, but misdirected.
Permalink Fan boy 
June 25th, 2009 10:34am
Have you ever programmed it in hex?

Oh, wait, you're right.  The Z80 was 8080 compatible, not the other way around.  My bad.
Permalink SaveTheHubble 
June 25th, 2009 10:35am
+1 eek-o-tourist.  Amazing skill but wow, overkill to the max baby.

I think if someone like that were in my office we'd take him out back, beat the crap out of him and re-direct him.  I'm only half kidding.  We have people here who can write code that way but they aren't, um, crazy.
Permalink Send private email sharkfish 
June 25th, 2009 12:09pm
The Z80 was a great little chip to learn on, sort of the 'model T' of Uprocessors.
Permalink lorb 
June 25th, 2009 12:20pm
Zilog had great manuals and such.  Then came the bigger brands, more obtuse, but which everyone must conform to because they are the big guys, the new standard.  Just like the PC was at first, with DOS, the big guy, IBM standard.
Permalink lorb 
June 25th, 2009 12:23pm
I used to be like Gary, writing code in hex with a pencil. It always worked too.
Permalink Cowboy Coder 
June 25th, 2009 2:32pm
It might have worked the first time, but it is a real bugger to add new features to.  Gary would overwrite a few instructions with a call to some free memory, do some new code there, do the instructions that were over-written, then return.  Yep, a great way to work. Not.
Permalink Fan boy 
June 25th, 2009 11:31pm
I think that's the original way we got "Spaghetti code".

With teeny-tiny processors (16 registers, golly) with teeny-tiny memory spaces (2K was standard, 8K was big, and 64K well-you-can't-afford-it) writing in assembly with jumps everywhere worked "well enough".

But yeah, it doesn't scale well to bigger processors and huger memory spaces.
Permalink SaveTheHubble 
June 26th, 2009 8:53am
You didn't have 16 registers on the 6809... I don't recall the Z80, but I would be surprised if it had 16 registers.

The workspace was 16-bit registers (A concat B) == D, X and Y.
Then: U, S, PC. [This may have been what you meant?]

It was pretty common to fill code before and after subroutines with some number of NOPs so that you could patch things later. And not have to re-calculate your jump tables.

It also helped minimize the spaghetti code you are discussing.
Permalink Send private email William 
June 27th, 2009 5:02pm
Whoa. This is on the front page of reddit. Nice. Who's "dwdyer"?
Permalink Send private email Philo 
June 27th, 2009 5:16pm
My response to this would be that I don't trust Gary's math libraries as much as any library that's been in widespread use for a while.
Permalink Send private email p 
June 27th, 2009 5:58pm
This is probably an anecdote from 20 years ago.
I didn't use hex code but assembler 20 years ago.
At the time, machine language was the only option to get some speed and some free to use RAM.

Now it would be foolish.

Times they are changing.
Permalink Send private email Peter Muys 
June 27th, 2009 6:56pm
There can bugs in the hardware design, too.  What would Gary have done about those, I wonder...
Permalink Jeb Bush 
June 27th, 2009 7:03pm
I used to crack games in hex, does that count?
Permalink Richard 
June 27th, 2009 8:10pm
Any chance of a pic of the page you have as a keepsake being posted?
Permalink hal from north...Buffalo. 
June 27th, 2009 9:32pm
There is a link between 8085A and 8086A.  The latter was designed to be an architectural superset.  There is a register mapping between the two, for example. 

When the 8086A came out there was a CP/M program called CONV86 which would take an 8085A binary and convert it to 8086A - it was easy enough to do because of the register mapping between the two.  The register mapping (and the segment registers used to allow 8085A programs to run in their own code segments) was intended to remove the transition risk as much as possible but was also probably responsible for the worst aspects of 8086A assembly language programming all caused by needless obsession with backwards compatibility. 

That experience, combined with the diametric opposite of backwards compatibility: 1980s vintage Apollo computers and their Aegis OS, are why I've always found Microsoft's obsession with backward compatibility to be laughably dubious and pathetically wasteful.
Permalink Send private email JSG 
June 27th, 2009 11:21pm
He sounds like a cool guy.  Not a lot of people can do what Gary was doing day-in-day-out.  In all my time in IT, I think I've only met 1 person with that level of skill.  Most people know nothing of assembler or hex, let alone program in them.  I hope you learned a lot from working with him.  People like that are _rare_.  If I had an embedded development company, Gary's the type of hire I'd seek out, weird or whatever, because most programmers aren't John Carmack.
Permalink Send private email Ian 
June 28th, 2009 1:54am

This topic is archived. No further replies will be accepted.

Other topics: June, 2009 Other topics: June, 2009 Recent topics Recent topics