# I know a spell that you would make help

He who dwells on what he hasn’t

# You think your Commodore 64 is really neato

It is possible to run modern software on classic 6502-based computers such as the Commodore 64 and the Apple II.

Some ground work is in order.  The basic strategy involves beefing up the 6502-based machines as much as possible and dumbing down Linux as much as possible.

The secret sauce involves writing a new, 6502-based emulation of an ARM Versatile/PB development board.  The ARM Versatile/PB is still a first-class target for Linux.  I think that with the make tinyconfig command with cross-compilation, we can get the size of a Linux kernel sufficiently small to have it in expanded memory on the 6502 host.

We will need to write parts of an ARM926EJ-S emulator in 6502/65816 assembly. This sounds a lot harder than it actually will be, and large parts of it probably won’t even have to be written at all.  While the ARM seems to have a ton of instructions, at the bit level, each instruction breaks neatly into its command and operand components.  Most of the work will be in emulating ARM interrupts and user/supervisor modes in 6502 assembly, and for a first bringup it wouldn’t even be necessary to emulate the Versatile/PB interrupt controller. Each of the addressing modes will need to be handled, but no individual addressing mode will be that complicated.  The ARM instruction set has a lineage dating back to the original MOS chips, and many of the state flags for ARM are exactly the same as they were in the 6502 days.

Sixteen megabytes of memory will need to be added to the 6502 machines, with appropriate bank switching logic.  This has been done already for each of the 6502 hosts.  There is also a period-appropriate chip, the 74LS610, which was intended specifically for increasing the addressable memory on the 6502 series.

We use 65816 microprocessor (SuperCPU) instructions to access 16 MB of memory in a 6502 machine.  Or, we develop a virtual memory abstraction that can arbitrarily bank in and out pages of the 16 MB into the lower 64KB of memory on each host. The cc65 development environment already supports RAM expansion drivers for the Apple II and the Commodore 64.

To get Linux to be sufficiently small, we use make tinyconfig with a modern Linux cross-compiled kernel to get it under 8 MB.  We target the version 1 ARM thumb instruction set in the Linux cross compile, and that’s the instruction set we emulate on the 6502.

For testing the correctness of the emulator, we run QEMU emulating the VersatilePB, in parallel with the 6502 emulator emulating Thumb1. We write a script that single-steps both virtual machines and verifies that emulator states run in lockstep.

The performance will be abysmally slow, but who cares.  Most likely the 6502 machines will, at first, themselves be running in emulation on a much faster PC.

See Woz’s SWEET16 emulator for further inspiration and basic proof of concept for the Thumb portion of ARM emulation.

# By pressing down a special key, it plays a little melody

Here are some of the fun exciting behaviors in store if you try to configure CentOS 7 or RedHat 7 as a combined DNS and DHCP server with dynamic DNS updates for a local network.  These notes are for an ipv4 network only; ipv6 is left as an exercise for the reader.

CentOS goes to some effort to silently but sincerely prevent you from doing this in the name of “security”.

You’ll want to do a fresh install and update of CentOS 7 and select Domain name server as the installation option.

Install some packages:

yum install bind-chroot bind dhcp

The key files you’ll be editing are /etc/rndc.conf, /etc/named.conf, /etc/rndc.keys, and /etc/dhcp/dhcpd.conf .

The zone files, normally stored in /var/named, are not given sufficient permissions to be read and written by the named process.  Move them to /var/named/dynamic.  Permissions, generally, are a bitch with this whole setup — expect that other files in /var/named may need to be chown’d to root.named and chmod’ed to 660 or 664.

SELinux silently prevents a lot of things that named and dhcpd want to do to maintain those zone files.  Convince it that this is OK by adding the following to /etc/sysconfig/named:

ENABLE_ZONE_WRITE=yes

Also run this command as well:

setsebool named_write_master_zones on

You will find that named and dhcpd don’t start automatically at boot time when installed.  You’ll have to teach CentOS 7 to do this yourself.  Use systemctl enable to do this.

You can generate a secret key by running rndc-confgen.  The output will give you a hint as to what to put into rndc.conf as well as named.conf.

The secret key, usually stored in rndc.key, wants to be stored in several places, at least in /etc/rndc.key and /etc/rndc.conf and /etc/named.conf and /etc/dhcp/dhcpd.conf.  There is no public/private key exchange in named if you are just running a local DNS server; it’s all just one pre-shared secret key, which is neat.

nsupdate is your friend.  If you can’t manually get named to update by using this command to get to control port 953, do an experiment to see if you can add and delete records via the rndc interface by running rndc and issuing commands something like this:

update add dumb.yourdomain 900 IN A 10.1.1.1
debug on
show
send

If you can’t do this yourself, then dhcpd won’t be any luckier; don’t bother trying to make dhcpd happy until named is properly responding to requests to update the zone files.

CentOS firewalls off all the relevant ports against you.  You’ll have to open these yourself.

For setting up a dhcp server:

For setting up the dns sever:

# We need to fly ourselves before someone else tells us how

If you’re experiencing a constant inexplicable 30%-50% CPU spike on the latest version of Windows 10, and Task Manager CPU usages don’t add up to the total amount of CPU that is being taken away, and you have a copy of Prey 1.6.2 or later installed, and you’re running Windows Defender for antivirus protection, uninstall Prey.

Something about the combination of Prey and Windows Defender causes this spike in CPU, and this spike in CPU won’t be properly reported in the Performance Manager or Task Manager.

# I found the secret, the key to the vault

Q. We will have 600 people at a conference.  How many possible two-person pairs does that allow?

A. In order to solve this problem, let’s solve some easier problems first.

Let’s have all 600 people line up in a row. How many ways are there to line up 600 people? Well, first we have to choose the first person. There are 600 choices for that first person, that is, any of those 600 could go first. Then, who goes second? We have 599 people left. So, to figure out how many ways we can choose the first and second people in a line of 600 people, we calculate $600 \times 599$.

Now if we continue this logic through all 600 people, choosing the first, the second, the third and so on, we have $600 \times 599 \times 598 \times ... \times 2 \times 1$ ways to line up 600 people in a row.

In other words, there are:

$n!$

ways to line up n people in a row.

But that’s not the right answer to our original problem. Let’s try to get that answer closer to the original answer we wanted. Let’s say we divided each of those $n!$ rows of people evenly into pairs, taking them each two by two in order of the row. In that case, it wouldn’t matter if the first pair contained Alice or Bob, or Bob and Alice. Within a single pair, we don’t care what the ordering of the people in that pair is.

For 600 people, there are $\frac{600}{2}$ pairs or 300 pairs. So, the number of ways those pairs might have swapped the first for the second is:

$2^{(n/2)}$

or

$2^{300}$

Therefore, the number of ways to order 600 people, ignoring the ways to merely swap a pair of people, is:

$\frac{n!}{2^{(n/2)}}$

We’ve only got one more step to get an answer. Notice that while we’ve taken care of the case where a single pair of people are swapped, we haven’t taken care of the case where a pair of people is swapped with another pair of people. In other words, we don’t care whether it’s Alice and Bob followed by Carol and Dan, or if it’s Carol and Dan followed by Alice and Bob. So, we need to also divide by the number of ways to order 300 pairs of people. As we know from above, there are $300!$ ways to order 300 things. To ignore swapping pairs of n things, we need to divide by:

$(\frac{n}{2})!$

So let’s take a look at our final formula, which takes into account the ways we can choose n people, ignoring a swapped pair of two people, and also ignoring swapped pairs of people:

$\frac{n!}{2^{(n/2)}(\frac{n}{2})!}$

Let’s plug in $600$ for $n$:

$\frac{600!}{2^{(600/2)}(\frac{600}{2})!}$

You can calculate this answer yourself if you use this online calculator and type in this formula:

factorial(600)/((2^300)*factorial(300))

20299494504975046998919287449873410470997357804758211063721976583706422622634310664749224388884590269998727324428213387255541766852932670293525215442782845850504673539731874399587442544304231110137690187784329507343362926071687926881971286798898101131291812616898256941583266763117277837275494612974900361671054080465269588991957333261517244301454739566468807941392242311971355600470078712743427938618979975606792194984446656667657442933360294907518626757601942083083777871670367139824740426506309108861774164088710713776707958145172725276913976407882104654927353162897086086095583774650925737362888935120898319907547868981167560993231144350620620065824638747855636344841201434974209405481815338134765625

…exactly.

Addenda: This is a semi-demi-hemi famous problem in combinatorics.  This problem and its solution tends to rear its head in a lot of superficially unrelated areas.  Here’s a menagerie of problems that all have this same solution.

When figuring out how to explain this problem, I stole a lot of ideas from here.

# Ten thousand men of Harvard gained victory today

As I do every year, I want to congratulate the current class year on completing your Harvard degree. Your Harvard degree provides you access to important advantages and benefits as you go through life. About two months after you graduate, the bursar’s office will be sending you an alumni card that looks like this.

Make sure not to lose this card.

I am going to give you a lot of information on the benefits and rewards you receive by being a Harvard graduate. Normally I have handouts at this point, but there was a problem with printing, so just take notes on your iPhones and things. There’s a web site with all this information on it. Before the end of the presentation, I will… try to get that web site address for you.

Harvard alumni get free upgrades from economy to first class on any airline trip within the lower 48 states. This is a really valuable benefit, so make sure to use the Harvard discount code when booking.

When you enter a boardroom during a board meeting, all people who graduated from non-Ivy League schools must stand at attention until you are seated.

You receive 15% off any Disney multi-park pass, Tuesday through Thursday, holidays excepted.

The Band-Aid corporation provides you free Band-Aids in our own computer matched skin tone. Click on the “Harvard” link on www.band-aid.com .

At most four-star hotels, when you check in, you will receive a special bar of soap that deep cleans without drying out the skin. This should happen automatically; you won’t need your card for this.

You get a special dispensation that allows you to drive up to 75 mph in 55 zones. If a police officer pulls you over, present your alumni card, and the officer will scan the barcode into a computer. At this point, you pay the police officer $1, and then you should be permitted to leave. If he detains you at this point, make sure to contact the bursar’s office. Some of you own apartments and condos. If one of your tenants has just been married, you may at your option sleep with the wife or the husband or both during the first night of their marriage. But in fairness I must tell you, times are changing. Since 2005 this has become frowned upon and rarely happens anymore. So, I am not going to tell you what to do here, but try to use good judgement, okay? Also, Harvard alumni have seniority when a group is deciding who will lead the Pledge of Allegiance. For a while we got a dollar off any KFC$5 Fill Up Meal, but I think that expired. Does anyone know if that expired?

Other than that, I can’t think of anything. So, that’s it… welcome to the society of educated men and women.

# Drag it drop it zip unzip it

GIF is pronounced with a hard g, contrary to the claims of its “creator”, Steve Wilhite.

Steve Wilhite only “created” the GIF format to the extent he didn’t copy it from previous creators. At the time he wrote it, he worked for CompuServe.  The GIF format contains the concept of global vs. local palettes, and it contains origin information for frame within a frame. That’s really the extent of the novelty in the GIF format. All of the actual color data is stored within a Lempel-Ziv-Welch compressed table. Wilhite copied the LZW algorithm direct from this seminal 1984 paper and hence from the Unix compress program. I know this, because as a Harvard undergrad struggling through CS175, I implemented a converter between Harvard’s image format and GIF.  My program used the guts of Unix compress, along with that paper, to encode and decode GIF images.

In the mid 1990s, Unisys used threats to try to shake down a few companies over its claimed ownership of the LZW algorithm.  This is after one of the authors published the algorithm publicly and went to work for another company.  As is usually the case in high tech, Unisys’s attempt to screw other companies backfired.

In essence, Wilhite’s and CompuServe’s only practical novelty was simply stamping a copyright notice on the front of some existing technology that they didn’t invent.

So the best we can do is to call it as we would any American acronym, by taking the first sounds of the words that comprise the object. Say GIF, think Graphics Interchange Format.

# My baby just wrote me a letter

In 1477, Margery Brews wrote a letter to her fiancé, John Paston. Her handwriting is very fine and ornate. She wrote the following: “If you love me, as I truly believe you do, you will not leave me… Because even if you did not have half the wealth that you do, and I had to undertake the greatest toil that any woman alive should, I would not forsake you. And if you command me to remain faithful wherever I go, I will indeed do everything in my power to love you and no one else ever. Even if my friends say I am acting wrongly, they will not prevent me from so doing. My heart commands me to love you truly above all earthly things for evermore. And however angry they may be, I trust it shall be better in time to come.”

And this, we think, is the first ever love letter.

When we say “e-mail” today, we’re discussing a very specific type of digital transmission; namely, transmission of an original human readable message from one source to one or more destinations, using the SMTP protocol, which in turn is built on the telnet protocol, which in turn is built on the TCP protocol. But “e-mail” as a technical concept predates its current SMTP implementation.

There are other, parallel forms of e-mail as well. In the mid 1980s, Tom Jennings wrote a BBS system and a protocol document called FidoNet. At the time, BBS systems were still quite popular. They required a dedicated computer that answered calls on a dedicated phone line. In particular, FidoNet required that compatible BBS software obeyed what was called Zone Mail Hour, or ZMH, which was a period during which the BBS was expected to send and receive EchoMail to and from other BBSes, typically by calling them directly. Because this wasn’t always practicable, FidoNet had a basic routing capability that permitted you to route messages to through other nodes to their destination nodes.

The early 1990’s explosion of FidoNet was predicated on the existence of cheaper, faster modems as well as cheaper, faster personal PCs. By 1996, while schools and universities were using Internet based email to send messages, the FidoNet community contained almost 40,000 nodes.

As the Internet, and the World Wide Web in particular, exploded in popularity in the early 1990s, FidoNet rapidly died off. Internet e-mail benefited from an “always on” design in which central servers could theoretically speak with dozens of e-mailers at the same moment. E-mail delivery on the Internet was nearly instantaneous. FidoNet servers could typically speak to only one or two users at any given moment, and EchoMail could be delayed up to a day.

Now you would think, given the Internet’s clear advantages on e-mail, that FidoNet should be well dead by now. But as you can see from FidoNet’s most recent nodelist as of this writing, there are several hundred nodes still operating and still interchanging EchoMail with one another.

Successful technology dies very slowly. And very successful technology doesn’t die at all.

Some people think that the automobile destroyed the horse and carriage industry.  These people have never been stuck behind an Amish buggy.

Ten decades in the future, people will take a break from augmented reality in order to write an e-mail, just like their grandparents did. Because e-mail is so quaint, and so old-fashioned, and so romantic.

Why is this the case? Why are people still using this outdated and quaint form of communication with one another?

Perhaps for the same reason that amateur ham operators still try to talk across the Atlantic on longwave radio, when international phone calls are cheap and reliable.

Perhaps for the same reason that vinyl records have seen a resurgence in manufacturing, even though compact discs have significantly better signal-to-noise ratios.

And perhaps for the same reason that handwritten love letters still travel through the post office, a thousand million times slower than an e-mail might.

E-mail (and programs that send e-mail) will be with our race centuries after you and I die, because it has sculpted and defined the lives of countless millions; and we are a nostalgic and romantic race of beings, much more so than being a technologically efficient race.

# Hail victory, hail victory victory, hail victory victory

In honor of Memorial Day, I propose the following improvement on Martin Niemöller’s text, to make it more historically accurate. This poem should be read, slowly and heavily, at memorials, funerals, military gatherings, wakes, brises and significant ceremonies of all sorts.

First, they came for the Socialists, and I did not speak out, because I was not a Socialist. Then, they came for the Trade Unionists, and I did not speak out, because I was not a Trade Unionist. Then, they came for the Jews, and I did not speak out, because I was not a Jew. Then, they came for the sick, the so-called incurables, and I did not speak out, because I was not sick or incurable. Then, they came for the Catholics, and I did not speak out, because I was not a Catholic. Then, they came for the disabled, and I did not speak out, because I was not disabled. Then, they came for the homosexuals, and I did not speak out, because I was not a homosexual. Then, they came for the Bohemians, and I did not speak out, because I was not a Bohemian. Then, they came for the Slovaks, and I did not speak out, because I was not a Slovak. Then, they came for the Czechs, and I did not speak out, because I was not a Czech. Then, they came for the Austrians, and I did not speak out, because I was not an Austrian. Then, they came for the West Prussians, and I did not speak out, because I was not a West Prussian. Then, they came for the Bolsheviks, and I did not speak out, because I was not a Bolshevik. Then, they came for the Serbs, and I did not speak out, because I was not a Serb. Then, they came for the Protestants, and I did not speak out, because I was not a Protestant. Then, they came for the Albanians, and I did not speak out, because I was not an Albanian. Then, they came for the Austrians, and I did not speak out, because I was not an Austrian. Then, they came for the Latvians, and I did not speak out, because I was not a Latvian. Then, they came for the Lithuanians, and I did not speak out, because I was not a Lithuanian. Then, they came for the Estonians, and I did not speak out, because I was not an Estonian. Then, they came for the Poles, and I did not speak out, because I was not a Pole. Then, they came for the Freemasons, and I did not speak out, because I was not a Freemason. Then, they came for the Ukrainians, and I did not speak out, because I was not an Ukrainian. Then, they came for the Byelorussians, and I did not speak out, because I was not a Byelorussian. Then, they came for the Moldavians, and I did not speak out, because I was not a Moldavian. Then, they came for the Sammarinese, and I did not speak out, because I was not Sammarinese. Then, they came for the Monacans, and I did not speak out, because I was not a Monacan. Then, they came for the Yugoslavians, and I did not speak out, because I was not a Yugoslav. Then, they came for the Romanians, and I did not speak out, because I was not a Romanian. Then, they came for the Dutch, and I did not speak out, because I was not Dutch. Then, they came for the Esperantists, and I did not speak out, because I was not an Esperantist. Then, they came for the Italians, and I did not speak out, because I was not an Italian. Then, they came for the Hungarians, and I did not speak out, because I was not a Hungarian. Then, they came for the Danish, and I did not speak out, because I was not Danish. Then, they came for the Belgians, and I did not speak out, because I was not a Belgian. Then, they came for the Aegeans, and I did not speak out, because I was not an Aegean. Then, they came for the Finns, and I did not speak out, because I was not a Finn. Then, they came for the Croatians, and I did not speak out, because I was not a Croatian. Then, they came for the Macedonians, and I did not speak out, because I was not a Macedonian. Then, they came for the Luxembourgers, and I did not speak out, because I was not a Luxembourger. Then, they came for the Montenegrans, and I did not speak out, because I was not a Montenegran. Then, they came for the Romanis, and I did not speak out, because I was not a Romani. Then, they came for the citizens of Danzig, and I did not speak out, because I was not a citizen of Danzig. Then, they came for the Soviets, and I did not speak out, because I was not a Soviet. Then, they came for the political prisoners, and I did not speak out, because I was not a political prisoner. Then, they came for the leftists, and I did not speak out, because I was not a leftist. Then, they came for the Jehovah’s Witnesses, and I did not speak out, because I was not a Jehovah’s Witness. Then, they came for the German Mennonites, and I did not speak out, because I was not a German Mennonite. Then, they came for the Lutherans, and I did not speak out, because I was not a Lutheran. Then, they came for the Christian clergy, and I did not speak out, because I was not clergy. Then, they came for the Amish, and I did not speak out, because I was not Amish. Then, they came for the Hutterites, and I did not speak out, because I was not a Hutterite. Then, they came for the lesbians, and I did not speak out, because I was not lesbian. Then, they came for the transgender people, and I did not speak out, because I was not transgender. Then, they came for the deaf, and I did not speak out, because I was not deaf. Then, they came for me, and I told them, what took you so fucking long?

# Cars and trucks fly by me on the corner

It really pisses me off when you ask me to fix your computer.

It pisses me off, because I love you.

When you give me the “can you fix my computer” call, the call means something different to me than it means to you.

To me, it means I will have to stay up all night, buy and try and swap replacement parts, image and restore your hard drive, remove all the malware, and make your computer work the way you imagine it once did, all while ignoring my other family members, my paying work and life commitments.

At my standard rates I would typically charge around $4,000 to fix your seven year old virus-ridden Dell. Your seven year old virus-ridden Dell isn’t worth$100 on Ebay. Should I tell you that? Will you think I am lying or making the $4,000 number up? I am not. You will think I am insulting you if I tell you I make$4,000 for similar work. You are too poor to pay me anywhere near that much though.

Of course I could always send you to Geek Squad. They would of course stupidly and automatically reformat your hard drive and reinstall the OS. If I do that, you will lose all your bank records and baby pictures permanently, to vastly less competent technicians than myself. They would take your money and destroy your data, and they would not even fix the true source of the problem. And you would be very, very, very sad.

And I would know in my heart I could have helped you, but didn’t.

No. I won’t do that to you.

I will take pity on you because you are clearly panicking and unable to eat, sleep or breathe until I save you and your data.

For you, and you alone, I will do a first-rate professional forensic data recovery and reinstallation. I’ll image the drive, work around all the bad sectors, copy it onto a virtual machine, extract your baby pictures and Quicken data, install a new non-shitty hard drive, reinstall all the apps and operating system and your recovered data (sans viruses and spyware), replace the dying fan, update the BIOS, and I will furthermore provide you with an external drive and teach you how to back up your system regularly with it.

Disappointingly, you will fuck up your computer again in a few years, when you refuse to take my advice and do regular backups on the backup drive that I bought for you, specifically for that purpose.

And when your piece of shit computer fails again, you will call me. Panicking. Again.

And the agonizing cycle will repeat.

Being the computer expert in the family is like being the doctor in the family, except you’re the surgeon and everyone expects you to operate on them constantly, suddenly, perfectly, AND pay for the operating room and sedatives and hospital recovery, AND you still consistently refuse to follow my medical advice.

I do all this, for free, because you are so thankful afterwards.