Embedded

View Original

468: Designed to Kill All Humans

Transcript from 468: Designed to Kill All Humans with Anders Nielsen, Christopher White, and Elecia White.

EW (00:06):

Welcome to Embedded. I am Elecia White, alongside Christopher White, who is easily distracted by the 6502 book sitting in his lap. Our guest this week is Anders Nielsen, and if you have been waiting for a show devoted to the 6502, we are finally here for you.

CW (00:25):

<laugh> Hi Anders. Thanks for joining us on this time machine, time warp thing.

AN (00:31):

Thanks for having me.

EW (00:33):

Could you tell us about yourself, as if we met at, I do not know, electronica?

CW (00:40):

A retro computing conference.

EW (00:41):

A retro computer conference. Thank you.

CW (00:43):

Not that it makes a difference.

AN (00:45):

I am a master of IT management. My job title for the last five years though has been "Mac expert at Aalborg University, Denmark," where I manage about a thousand Macs.

(00:55):

In my free time, I like to put integrated circuits from the seventies and eighties into new use. I have a small YouTube channel where I try to document some of the things I work on, try to make the subjects more accessible to more people. I am also a licensed radio amateur.

EW (01:15):

Excellent.

CW (01:15):

All three of us are. Sort of.

EW (01:19):

That is true.

CW (01:19):

Not practicing. <laugh>

EW (01:21):

Are you ready for lightning round?

AN (01:24):

Yes.

CW (01:26):

Sorry. I will put the book down.

EW (01:29):

Unless you are going to ask questions about the-

CW (01:30):

Favorite-

EW (01:30):

BIT instruction.

CW (01:32):

Favorite processor?

AN (01:35):

That will be the 6502.

EW (01:36):

Favorite bash tool? Ooh, we stumped him on this one.

AN (01:39):

Cat.

CW (01:40):

Cat? <laugh>

EW (01:40):

Cat?

AN (01:40):

Just cat.

CW (01:43):

Favorite 6502 instruction? And why is it TAX? I just like "TAX." Sounds funny.

AN (01:48):

It would be the BIT instruction.

CW (01:50):

BIT. Okay. <laugh>

EW (01:53):

What is the best way to learn electronics, if you are a software person?

AN (01:56):

I would say build a retro computer.

CW (01:58):

First place someone should go when visiting Denmark?

AN (02:02):

Top of my mind, the zoo.

EW (02:04):

Would you rather take apart one board all at once, or take apart a dozen boards at the same time?

AN (02:12):

Oh, I hate to hurt boards.

EW (02:15):

Ooh. The salvaging thing is going to get more interesting, I bet.

CW (02:18):

How tired of Hamlet are people in Denmark?

EW (02:22):

Is this really a question?

CW (02:23):

What does that mean?

EW (02:23):

<laugh>

AN (02:26):

I think Shakespeare got some things wrong.

CW (02:27):

<laugh>

EW (02:30):

Favorite fictional robot?

AN (02:32):

That would be Bender from "Futurama," because he has a 6502 for a brain. But I guess the Terminator would also count on that criteria.

EW (02:42):

Terminator had a 6502 for a brain?

AN (02:44):

You bet.

CW (02:46):

I did not know that?

EW (02:48):

That is awesome.

AN (02:49):

I think there is a scene where you can see the assembly-

CW (02:51):

Oh! Right! Yeah.

AN (02:53):

Code scrolling past.

CW (02:54):

I do remember that. Right.

AN (02:55):

They had a 6502.

CW (02:55):

They had like a HUD overlay, where you are looking through his eyes in a couple scenes. It is scrolling text by and there is a bunch of assembly source. And it is 6502.

AN (03:06):

And they were both designed to kill all humans. So I guess 6502s are good for that.

EW (03:10):

<laugh>

CW (03:13):

<laugh> Oh right, Bender, yeah. <laugh>

EW (03:22):

<music> We are happy to be sponsored this week by Memfault. Memfault provides a device reliability platform for IoT monitoring, debugging, and updates. Device operation no longer needs to be a scramble as issues with fielded units pile up. Instead, Memfault gives developers a more scalable and sustainable process to accelerate time to market, de-risk product launches, cut development costs, and deliver higher quality products.

(03:48):

So if you are wondering how you are going to monitor your units once they are shipped, or whether your firmware update plan is secure enough, it is time to take a look at Memfault. Or you can read their Interrupt blog, for all of its fantastic goodies on how to debug HardFaults, monitor units, or generally write good embedded code.

(04:05):

Embedded.fm listeners will get 25% off their first year with Memfault, if you request a demo through go.memfault.com/demo-request-embeddedfm. It is a link you can find in our show notes. Thank you to Memfault for sponsoring this week's show. <music>

(04:28):

Okay, then let us go to the 6502. One of the listener questions was, in fact, "What is your favorite processor, and why is it the 6502?" So let us go ahead and go with the second part of that. Why the 6502? It is not certainly the latest and greatest.

AN (04:46):

Well, I think it is cool because it really started something. Well, it is a processor from the middle of the seventies, so what could it possibly have to offer? But I think the cool thing about it is the history, and what it made possible suddenly. Because building a microcomputer in the seventies was not something you just did on the weekend. It was expensive. And it was hard. And you needed to learn a lot of things.

(05:16):

The 6502 came along, and suddenly you could get it at a tenth of the price of a 6800. And it was simple to use, had fewer instructions. It was just ready to revolutionize, and that is what it did.

CW (05:31):

Back then there were not a lot of choices. I mean, we talk about embedded these days, and I know these were microcomputers, not embedded projects and things. But some of the projects people did with microprocessors would seem very familiar to people making little Arduino projects now. They were not necessarily full fledged computers.

(05:50):

But now we have got, "Oh, there are 600,000 PICs and 35 different million flavors of STs." There are so many microprocessors and microcontrollers out there. But back then it was what, a half dozen that a hobbyist really had access to?

AN (06:07):

Yeah, I am not even sure you did. There was- You would take something from Intel or Motorola, and that was about it.

EW (06:15):

Where does the 8051 fit in this? I am familiar with that one. More familiar than the 6502.

AN (06:23):

Well, I think it came later, in the beginning of the eighties, like that. Of course it came with- I think it has about twice as many instructions. It has a Harvard architecture, which makes putting it all together a little bit more complicated, if you need separate memory space for- Separate address space for RAM and code.

EW (06:48):

One of the really cool things about the 6502, is not only that it was one of the first we could get-- that people could get their hands on. It feels like one of the last ones that you could write a book about, and the book could be a couple hundred pages long.

(07:07):

If you look at the current processors, you can get a manual that is a thousand pages long, and still has pointers to whole other manuals. It is not a complete manual at all. But the 6502, you can understand all of it.

CW (07:27):

Yeah, this book wastes a hundred pages on explaining binary to you and stacks and basic programming techniques, before it even starts talking about the chip.

AN (07:36):

The 6500 reference manual, it does not read like a legal document. Like, if you read an STM32 reference manual for any chip, it is going to read a legal document, not like a book.

(07:49):

If you read the 6500 programming manual, it is going to sound like a book, something you actually want to read in your free time. It is amazing what people do when they do not have a template that says "We have to protect our behinds."

CW (08:10):

Right.

EW (08:11):

Right. I mean the ST manuals- Sorry to bash on ST today, but all of the microprocessor vendors, the manual does end up being a contract of what they are providing. But the 6502 did not have that formalization.

CW (08:33):

It was a different time. I mean, when you bought a computer in the late seventies, early eighties, half the time it came with a service manual, and the source code of the ROMs, and a schematic. When was the last product you bought, that did not come from EMSL, that had a schematic?

EW (08:51):

Okay. So the 8051 came a bit later and had way more instructions. And then we have, that is another processor that people know about, the Arduino Uno's ATmega328.

CW (09:06):

Just want to jump in here. Those are microcontrollers. There is a slight difference-

EW (09:09):

Okay.

CW (09:11):

In that the microcontroller has most of what it needs in the package.

EW (09:16):

Has the memory, it has the-

CW (09:18):

All the clocking stuff.

EW (09:19):

Clocking stuff.

CW (09:20):

If you are building a computer or a project with 6502, you have a lot more work to do.

AN (09:23):

Right.

CW (09:23):

Because it needs-

AN (09:26):

Like if you talk about an 8051, you have four I/O ports. You have timers. You sometimes even have a serial port. You have, at least for the modern ones, you have flash and RAM and everything built in and the external stuff. Usually you can get away with a one chip solution for an 8051.

(09:47):

But with a 6502, everything is just you get an address space, of completely empty address space from zero to FFFF. You just fill it in with whatever RAM and peripherals and ROM you can think of.

EW (10:06):

So it is kind of like the CPU in a modern microcontroller. It is like the Arm Cortex-M0 part, not the whole chip.

CW (10:19):

Yeah.

EW (10:19):

And so with the 6502, you had to build out a whole computer around it?

AN (10:23):

Yes.

EW (10:23):

Okay. It is funny, because we do not often have to make that distinction any longer. The Raspberry Pi Pico[RP2040] does not come with flash. That was kind of a mind-bender for me. I mean, sure it made it a lot cheaper, but I am so used to having flash. It has been like a decade since I had to worry about where my flash came from. It has always been on the chip.

(10:50):

But that has not always been true. And apparently with 6502 it was never true. Okay, so the ATmega328 in the Arduino Uno has flash, has all of these I/Os, and it has a core. It is the AVR core? The AT tiny core? I do not remember what it is.

CW (11:11):

Yeah. It is something.

EW (11:11):

It was the 8-bit Atmel core. Do you know how that is different from a 6502?

AN (11:20):

I think the architecture of it is somewhere in between a Harvard architecture and a von Neumann. Because it does separate RAM and ROM, but you have instructions to read the code and write the code anyway, to write the flash. So I am not really sure. But it has an ADC and it has everything built in you could dream of.

(11:45):

It is funny because we are comparing microcontrollers from 20 years ago and 40 years ago and almost 50 years ago for the processor, for the 6502. Of course the appeal of the 6502 is that everybody knows it from their favorite childhood gaming platform, or computer, or- The Commodore 64, the Atari 2600, the...

CW (12:15):

Apple II.

AN (12:18):

The Apple II. Of course the Apple II. All the Apples, and the Commodore PETs, all of them. The funny thing was I read an interview, an old interview with Chuck Peddle, a few weeks ago. He made it completely clear the 6502 was not supposed to go in computers.

(12:36):

It was supposed to go into every single cash register in the US, and that was it. That was the intention. Make it an embedded processor, to make something you can use to make a cash register. That was it. And make it cheap.

CW (12:54):

Hence the binary-coded decimal.

EW (12:56):

Okay, so what is the 65uino? Is that how you say it?

AN (13:02):

Yes! That is how I intended for people to say it. It is a 6502 core, in a 6507 package. That is a tiny bit smaller, in a 28-pin package. Then it has got a ROM chip. And then it has got a RIOT, which is my favorite acronym of all time, because it is a RAM, I/O and timer module, a peripheral that connects to the 6502. It includes two I/O ports, and that is it.

EW (13:31):

Okay. RAM, I/O and timer stands for RIOT. Or , the other way, but RIOT is those?

AN (13:38):

Yes. And then we have the ROM and the CPU. That is everything you need to make a- Well, basically anything you need to make a microcontroller, just split out.

EW (13:50):

Is this in a chip? Is this on a board?

AN (13:55):

This is on- It is basically an Atari 2600 and an Arduino clone at the same time.

EW (14:02):

Okay. And the 6502, how does it- You said it just has address space. Does it have address lines coming out of it to go to the ROM?

AN (14:13):

It has a data bus of eight bits, and 16 address lines. Well, not the- Well, technically the 6502 does, but the 6507 on this board only has 12. So we only get- What is that? That is 8K of address space from zero to 1FFF.

EW (14:36):

And so you actually have to have parallel bus-

AN (14:39):

Everything.

EW (14:40):

Address and data comes in over lots of lines. And you have this RIOT chip, and a ROM chip, and the 6502 core inside the 6507? Was that what you said?

AN (14:53):

Yep.

EW (14:53):

And so all of these chips together go on a board that is in the Arduino form factor?

AN (15:01):

Correct.

CW (15:01):

Cool.

AN (15:02):

There is one tiny piece of address decoding needed, and that is an inverter that takes the top address line and dedicates half the board to the ROM.

CW (15:13):

Ohh.

AN (15:13):

So you can read 4K of ROM, and the rest is dedicated to the- So there is half of all the address space dedicated to a timer and two I/O ports, which might seem wasteful, but it is-

CW (15:29):

<laugh> Well how else are you going to split it up <laugh>? Yeah.

AN (15:31):

That is how it worked on the Atari 2600 too.

CW (15:35):

Yeah. You do not need it. Why bother? <laugh>

EW (15:36):

How do you program this? You do not use the 6502 to write to the ROM. And you called it ROM like it is really read-only memory.

AN (15:45):

My intention here is that it works exactly like an Arduino Uno. You grab your serial, and then you connect that, and you use the bootloader in ROM to write to RAM. So it is a little bit like an Arduino Uno, except it is a little bit more volatile.

CW (16:06):

Okay. So you have to program every time you start.

AN (16:08):

So you can write about 50 lines of 6502 assembly and get it in RAM. And then if you are going to reuse those lines, you put them in ROM and you flash a chip.

CW (16:22):

Okay. What if I wanted a hundred lines?

EW (16:23):

Then you have to put them in RAM twice and flash the chip twice.

CW (16:26):

Okay. All right <laugh>.

AN (16:27):

I do have a little project going on with some people. We are talking about, let us put a bootloader on it, put that in the ROM, then make the read-write line available to a flash ROM. So it is possible to swap over the bootloader, throw that in RAM, flash the ROM, and then put the bootloader back. A little bit-

EW (16:56):

Yeah. A little bit- A bit like the goat and the lettuce in the boat. And the chicken? No, the wolf.

CW (17:03):

Yeah, he can just write a script to do it though.

EW (17:06):

Yeah. What are you hoping to use these 65uinos for?

AN (17:12):

Well, a lot of the things we do these days, at least as a hobbyist, is twiddling bits. Just twiddle a few bits. We want to turn on an LED. We want to talk to some I2C peripheral. A lot of the things you would use a normal Arduino Uno board for. We are not going to be doing DSP with it, but it will do a lot of the same things. Hopefully it will teach some things along the way.

EW (17:41):

Do you program it in 6502 assembly? Is there a compiler? How does a compiler only gets to like 50 lines?

AN (17:51):

Well, there is a compiler. I am actually using the cc65 compiler package, but I am only using the assembler, for now at least. And that means yes, I am- I have a few videos out where I teach some basic 6502 assembly, and go through what you can do with it, and how I wrote some of the routines. It is basically to teach, "This is an I2C bus. This is how you can do it, by just putting the lines to high impedance, and use what you have available."

EW (18:29):

I2C is hard though. I2C requires a state machine. And you can have errors. Why I2C?

AN (18:38):

Because then you can talk to a lot of things. Like I said, it is an Atari 2600. But if it only has the CPU and the ROM and a cartridge and a RIOT chip, then how do you- What do you see? So I need a little I2C display on it to act as the screen, if I want to make a little Flappy Bird clone for it.

CW (19:02):

So the cool thing- Just a little digression, because you were talking about programming in assembly, Elecia. The cool thing about these chips, and you kind of alluded to it with talking about the Arm reference manual and stuff, but the cool thing about these chips is they are very simple.

(19:17):

The instruction set- I am holding the instruction set reference pages here in this book. It is 70 pages. And there is a giant diagram- Each instruction is one page with a giant diagram of how it works. That is it. I mean, you could learn enough to write a simple program using the 6502 instruction set in an hour. Maybe not an hour, but it is extremely simple.

(19:48):

I mean, the choice between C and 6502 assembly, it does not seem that big a deal to me. But as a learning platform for how computers work, starting with this instead of starting with something modern seems like a great idea.

EW (20:04):

And the limitations mean you understand the underneath of things. Instead of in C, people can really learn C, and still not truly understand what memory is or how it is laid out in the processor. You do not get that if you are actually dealing with individual addresses.

(20:29):

Anders said "I2C" when I asked, but one of the things he did not say is he has only got two I/O ports. He cannot do SPI.

CW (20:37):

Right.

AN (20:39):

Oh, of course I can. I have two 8-bit I/O ports.

CW (20:43):

Oh, okay.

EW (20:44):

Oh, okay.

CW (20:45):

They are wider than- Okay. They are two 8-bit ports. Okay.

EW (20:47):

That is not so bad.

CW (20:48):

I thought you had two GPIOs.

EW (20:50):

Yeah, I thought it was two GPIOs <laugh>, which seemed like not enough.

CW (20:56):

But the basic concepts have not changed. They are just built on, right. So this has stacks and interrupts and flags and all that stuff. The instructions do kind of the same thing that modern instructions do. It is just a lot less of it.

EW (21:10):

And the memory map is not something you get from the linker.

CW (21:14):

<laugh>

EW (21:16):

It is something you make as your program, and you have to remember what it is, because if you want to talk to that memory again-

AN (21:24):

No, no, no, no, no.

EW (21:25):

No? No. Okay. Tell me.

AN (21:26):

It is not something you make. It is something you put together on your board, that is-

CW (21:31):

Yeah.

AN (21:31):

Hard-coded. If you do not put in that inverter, you will have code and nothing else, because you have not split your memory map into two yet.

EW (21:43):

Right. Your memory map is half-

CW (21:45):

Wires. <laugh>

EW (21:46):

Is wires.

AN (21:46):

Wires. Yes.

EW (21:46):

4K going to the ROM, and the rest going to the RIOT chip.

AN (21:54):

If the 13th bit is not flipped, then we are talking to something else. If the RAM output is connected to- What is it? Address line 12, basically.

EW (22:07):

I was thinking about where you are putting variables-

CW (22:10):

Oh, sure. Yeah.

EW (22:12):

In your code. Like, when we deal with C, C puts the variables wherever it thinks they should be. Whether they should be on the stack, or globals that are initialized go in data, and ones that are not go in bss. C keeps track of where they are for you. You do not ever have to say, "My variable is at this address." But when you program in assembly-

CW (22:39):

You just set some macros up and say, "Well, this is a variable at this address, and this is a variable at this address," and you kind of partition stuff.

AN (22:44):

I just define everything at the beginning, and override a lot of stuff, and make sure my pointers are all over the place.

CW (22:53):

Because you are the compiler.

AN (22:54):

It makes you appreciate C-

CW (22:56):

Yeah. <laugh>

AN (22:57):

Very quickly. But of course the fact that it only has 128 bytes of RAM means-

EW (23:05):

You can get to know each one individually <laugh>.

AN (23:08):

Yes!

EW (23:10):

But it is those macros-

AN (23:10):

I will know when my stack- When the stack grows downwards and hits what I thought I put in RAM.

EW (23:21):

Yeah. It is those macros that I think of as the memory map in a software sort of way, because you have to do it yourself.

AN (23:28):

And the cc65 compiler, it does have a memory map file, where I get to define what do I have set aside for RAM and stack and ROM, and what do I expect it to do. But it is a nuisance to me, because I do not use it very much. So I just have to fill it out and forget about it from there.

EW (23:50):

So you mentioned you do some salvaging of parts. Is the 6502 a salvaged part, or are there new ones being made?

AN (24:00):

Oh, in my case, most of them are absolutely salvaged, but not by me. I would not want- I cannot recommend anybody to start desoldering components from boards from the seventies or eighties. If I have a 2600 lying somewhere that is kind of broken, I will fix that right up because that is just too sad.

(24:22):

But back in the nineties there was a lot of Atari 2600s and Nintendos lying around, that just were going to the dumps. From the dumps, where did they go? They went to China, where all these boards were salvaged, and of course they saved the chips.

(24:44):

So now they are coming back, because you can just go on the markets and get these chips. I promise you they come from repurposed Atari 2600s that suffered a very sad fate.

EW (25:01):

So you can buy chips that have been taken off of boards, that have been shipped across the ocean, that have been thrown away, that have been toys, that were probably originally built in China and then shipped across the ocean?

AN (25:22):

It is what they call the circular economy, I guess.

EW (25:25):

I guess that is better than the "Circle of Life."

AN (25:28):

But in general, I think I just saw a scary, scary Veritasium video, where he explains the dangers of lead poisoning. Lead in baby teeth and all that stuff, and how it makes you lose a lot of IQ points. So I would not recommend anybody to play with that amount of leaded solder in these days. So absolutely to do it in factories and let us save some old chips, but do not try this at home.

EW (25:56):

This seems like a good way to break the chips. I mean if I was desoldering them, most of them would probably be melted by the time I was done.

CW (26:05):

Hey, if you are working on something old enough, they are just socketed.

EW (26:08):

That is true. Do you worry about the chips you get? Are they usually working? Are you-

AN (26:19):

Oh yes, I absolutely worry about them. I think what happened is a lot of people complain that they get chips with the wrong markings. Yesterday I got two shipments of the same 6532 RIOT. I got 12 in one package and 20 in the other.

(26:37):

The 12 of them I ordered as Rockwell ICs. But I can see from packages that they all have the same writing, but they are all from different manufacturers basically. And in that case, three out of 12 were bad. I had to sit and individually test them all. The other package 19 out of 20 were good.

(27:00):

But basically I think they are pretty aggressive with them when they take them out of these boards, or did take them out of the boards in the nineties I guess. So in a lot of the cases they do have to rewrite the markings, and I think they almost do it to order. If I order 20 UM6532s, I get 20 6532s. But they might have been something completely else, completely different yesterday. So it is the same IC in there, just from a different manufacturer. And it probably works.

EW (27:38):

Do you worry about the way they are treated, or about the silicon degrading itself?

AN (27:44):

Not really because these are for hobby use. I would never put them into production. I would never trust my life on them. But when it is for experimenting, I think it is a very cool way to get really, really cheap chips.

EW (28:02):

And you said you test them. How do you verify the component?

AN (28:07):

I put them in a socket. I usually have some software to test the ports, and there is not a lot to test. Usually if an address line is bad then it does not work. If the port is in a bad state, then I can see that easily, because it is either pulled high or pulled low or something is up. So if I can see that it behaves like it usually would, then it is probably good.

(28:40):

I can test most of it in software of course. If I went through the- So many people have written so many routines to test 6502s over the years, that I can find down to the instruction level tests, for how does this instruction affect this flag that is not supposed to affect. It is so cool. I do not go that deep, but I could if I was worried about the quality.

EW (29:09):

So you make YouTube videos, and you make the 65uino, to help people learn more about what is actually in the chip. To rip away some of the abstraction and start to understand the concrete what is happening. Why do you do this?

AN (29:27):

Well, I think if you separate the CPU from the peripherals, it is easier to understand the relationship between them. And if you know a little bit about the logic, the way the address lines are moved around to address certain peripherals and ROM and RAM, it is easier to understand how everything works. How a computer is made. How a microcontroller works on the inside, because you cannot really take apart an ATmega328 and see how it is made on the inside.

EW (30:02):

Who are you making these things for?

AN (30:04):

To be honest, mostly myself, maybe. I do not think I will make a video that is just teaching basics, because usually I learn a lot myself.

EW (30:17):

How did you get into making the videos? Or what came first? The 6502s, or the videos?

CW (30:24):

6502 predates almost all video.

EW (30:25):

<laugh>

AN (30:29):

It predates me, that is for sure. <laugh>

EW (30:31):

Thank you, Captain Obvious. When you started working on this, did you start working on the 6502 as a board first, or the videos first?

AN (30:44):

Oh, I started with the board first. I think I stumbled on Ben Eater's videos, and I started making my full size 6502 computer. It is a little bit more full fledged. It has the VGA, it has everything you need in a decent size, not like the 128 bytes of RAM, but more like 32K of RAM. So it can actually do some stuff.

(31:11):

When I had that going, I started putting out some videos. I think my first videos was about "Can I?" Can I make this 6502 computer running at 2MHz- Can I use that to drive WS2812 LEDs? Can I do that? So it was more like a personal feeling, can I do this? It has been done before in so many other ways. Can I do it this way?

EW (31:39):

Quests.

CW (31:41):

We were talking about what other chips were around at that time. The other one that comes up a lot, which was also in console arcade games- Not console. The cabinets. That is the word I am looking for. Arcade cabinets and big arcades, was the Z80 which was another 8-bit processor that everybody loved. Which I think was actually a little bit- It was similar in price I think to the 6502 at the time.

(32:07):

There were some home computers that were based on the Z80. There was the Z80. Later on I think RadioShack used the 6809 and a couple of things. There were a lot of these 8-bit processors. Some of them continued on in their lives. Like the Z80 was, I think it was related to the 8080, right?

EW (32:29):

I am shrugging my shoulders, going "Aha, aha."

AN (32:31):

Umm. Yeah, I think so.

CW (32:33):

So it kind of is a part of the family tree of x86.

AN (32:38):

Oh, I think I remember now. It was- His name was- Okay, do not quote me on my history here, but I think it was Federico Faggin that was on the Intel 4004 team, and then he went off to make Zilog.

CW (33:00):

Yeah, that sounds right.

AN (33:01):

So it was the same guy that went off and made a better CPU, at a different company.

CW (33:06):

And the 6800 was Motorola, and they then made the 68000, and then PowerPC. All of those sort of kind of exist. Why- Here, I finally arrived at the question <laugh>. Why do you think the 6502 kind of died? They had the 16-bit version that went in the Apple IIGS, and then that was kind of it.

AN (33:24):

Better things came along. Better, more powerful things. Commodore kept using the same old, same old 6502. No optimizations, until they called it the "80 series." The way later series, before they optimized that. It was just underpowered. That is what I think. The world had moved on.

CW (33:55):

Have you ever played with the 65816? 65C816. That was it?

AN (34:02):

Nope, I have not. I have stumbled on a 65CO2 once in a while. Usually I try to make everything absolutely compatible with both the 6502, the original, and the CMOS version because they do have a little bit of an incompatibility. So I try when I make a board to make a little jumper you can switch if you use a CO2 instead.

(34:28):

I try not to use the- What do we call them? Not the- Well, let us just call them what they are, the illegal instructions that you can-

CW (34:40):

Oh. That was my next question.

AN (34:42):

It has 56 instructions, but it also has a bunch more that will also do this thing, but also randomly transfer the accumulator to X at the same time. So you save some time like that. But of course they only work if the silicon is exactly the same, and they are unintentional from the designer.

CW (35:04):

Ah, okay. Yeah, I did not know the whole story behind those. I knew of those, because the op code is what? Is it eight bits? Yeah. So there are only 56 populated in there, and you can put one-

EW (35:17):

200 are free! You can do whatever you want with them.

AN (35:21):

Oh, yes! And I think Rockwell and Western Design Center did. Western Design Center put some instructions in there. Rockwell also put some instructions in there, but not the same ones all the time, I think.

CW (35:37):

Ah. I see.

EW (35:37):

Of course not.

CW (35:38):

Were those undocumented? Or secret Rockwell instructions?

AN (35:44):

I think they did manage to stick with some of the same ones for the CO2. But they all lost the undocumented ones when they remade the 6502 into the 65CO2, because brand new silicon so those random op codes did not do the same thing anymore.

(36:06):

I think they were used heavily in the Nintendo, the Nintendo Entertainment System. A lot of programmers needed that extra oomph.

EW (36:16):

I found a list of some 8-bit processors and their timing, so let me clear that up. The 8080 and 6800 were launched in 1974. The 6502 arrived in 1975.

CW (36:30):

Darn.

EW (36:31):

The Z80 in 1976. And the 6809 in 1978.

CW (36:38):

Okay.

EW (36:40):

There were also the ones of the 1980s, in no particular order. The 65C02 and 65802, and the 8051. And the AVRs, which are the core of the ATmega.

CW (36:55):

Those are eighties?

EW (36:57):

The AVR, yeah, that is an eighties core. And it is 8-bit. So it was not like- I mean yes, they were 20 years apart, but they were both 8-bits and they are both chips that were initially programmed in assembly more than C. And then there is the 68HC-

CW (37:16):

11.

EW (37:16):

Which is in the eighties as well. So that is a little bit of the history. The Z80 was in the TRS-80.

CW (37:28):

Right. Hence the "80," I guess.

EW (37:29):

I guess. Now putting it that way, it makes it obvious. Yes. So yeah, that is a little bit of the 8-bit history of early processors. Then things went to 16-bit, although they did it in a very inconsistent way. Now we are in 32 and 64.

AN (37:50):

What about PICs?

CW (37:52):

Well-

EW (37:52):

We do not talk about those in this show.

AN (37:54):

<laugh>

CW (37:54):

No one knows where those came from.

EW (37:57):

Given the way that their instructions is. Yes. No, I mean PICs have a good history, and they do fit in here. I do not remember. There are RISC...

CW (38:11):

By comparison, every single processor you are talking about is RISC. <laugh>

EW (38:15):

Well, yes.

AN (38:17):

So we do not get to talk about Intel at all?

CW (38:20):

Go ahead.

EW (38:21):

I did not. Did they have an-

AN (38:23):

IBM liked them in the beginning of the eighties.

CW (38:26):

Yeah, the 8086 was- Or the 8080 and the 8088 were 8-bit.

EW (38:31):

Well the 8080 was 8-bit in '74, so that was Intel. That was one of the earliest, as opposed to the Motorola 6800.

CW (38:41):

PICs came out in '76.

EW (38:44):

Yeah. I wonder why PICs were not on my list.

CW (38:47):

They do not have a number.

AN (38:49):

I have my PC/XT motherboard here, which I would call my favorite salvage. Yeah, it has an 8088 CPU. I think the funny thing about that is it has an internal 16-bit bus-

CW (39:05):

Right.

AN (39:06):

But external 8-bit buses. So is it a 16-bit? Well.

EW (39:10):

<laugh>

CW (39:13):

But it has 16-bit instructions, right? It can do 16-bit things. Whereas the 6502 could not, if I remember.

EW (39:23):

So you have salvaged boards? You said you do not salvage the chips yourselves. Do you salvage the boards yourself, or do you buy those from somewhere?

AN (39:30):

If I find something I can fix up, I will absolutely do that. I will not buy things just to tear them apart.

EW (39:39):

Where do you find things to salvage?

AN (39:41):

That would be on the Danish version of Craigslist, or something like that? I wish I had a better place to go.

EW (39:50):

No, that works. How do you do it? Do you just open it up and look for something wrong, or are there tools you use? Is this about checking volts? Although you may not have a schematics, so how do you- Tools and techniques, what do you have?

AN (40:11):

I start with a multimeter. First let us check if all the power lines are shorted. That is a very good place to start, because everything old has bad caps, right?

EW (40:22):

Yeah.

AN (40:26):

Of course we have what we did not have in the eighties. We have Google. Every board has its usual suspects by now, if it is that old. It does not matter if it is a PS2 or a PC/XT on an original PC or an Atari 2600. They all have the usual suspects when it comes to bad caps, and what degrades, and where does the electrolytic fluid run out, and where does it go.

(40:53):

And how to fix a bad floppy drive. What is it? Adrian's Digital Basement. I saw him do a session where he just fixed, what was it, fifty 5 1/4" floppy drives. You can find anything about how fixing anything old by now. I bet even ChatGPT knows.

CW (41:18):

Yeah, I should probably open up this Apple II and make sure the caps are all right. Last time I ran it was eight years ago.

EW (41:25):

Were you not going to get the ethernet working?

CW (41:27):

Yeah, I bought an ethernet board for it, but I never used it. I was going to put it on the internet or something. I do not know.

(41:33):

It is amazing. You asked about the hardware degrading or the silicon degrading. The chips themselves are pretty resilient. I had some RAM chips go bad, but I do not know how often an old CPU goes bad, if nothing bad has happened to it.

AN (41:48):

Umm.

CW (41:48):

Do not tell me. <laugh>

AN (41:49):

Well, speaking of Steve Wozniak, when he was making the Apple II, he was going to the edge of what this poor 6502 could handle. So he said he always needed a fresh 6502 at hand, because the ones he had would go bad. What he was talking about was the capacitance rating on the internal caps going down a little bit with burn-in.

CW (42:20):

I see.

AN (42:21):

Though he was trying to stop the clock for more than 40 microseconds, but it turns out he was wrong when he read the Synertek data sheet, because it did not say he could stop the clock for 40 microseconds. It said you could lower the cycle time to 40 microseconds, but it still had to be a fifty-fifty cycle.

CW (42:46):

Ohh.

AN (42:48):

He was trying to stop it for 40 microseconds, but they only said "Do not go over 20." So he would lose registers while he was trying to write the screen. He settled on something different, something a little bit better. But that is the stuff you are up against. So if you do not try to run it at multi megahertz, you will be fine.

(43:14):

And I think- What was it? It was, they interviewed someone who had a lot to do with the original 6502. They said, "If it does 3MHz, we put a good rating on it. If it does not do 3MHz, we call it 1MHz."

CW (43:33):

<laugh>

AN (43:33):

So that is how they sorted them in the beginning. Either it does three and it is a good one, or it does not do three and we will see.

EW (43:42):

Is not that how they sort ST chips now?

CW (43:45):

I mean there is chip binning still, for all kinds of things.

EW (43:48):

Memory more than anything. How much good flash you have.

CW (43:52):

GPUs as well.

EW (43:54):

You had a question for us Anders. Do you want to ask it, or do you want me to look up what I have?

AN (44:00):

I can ask it.

EW (44:01):

Go ahead.

AN (44:01):

Why do you think it is so common, it seems to me that way at least, that when you are making something new, that you start with an overpowered MCU or development board for something really simple. Then when you finally get to production, you try to work your way down and you fail to actually do it, when you need to make a million of something.

(44:24):

Like you start with a board that has Bluetooth, so you use Bluetooth and Wi-Fi and everything. Then you realize, "Oh, it has to scale too." When does it make more sense to start with a ten cent CH32V003, ten cent micro, and then work your way up instead?

EW (44:45):

It depends on how long you have between time to market and when you are starting, because Moore's law works in our favor. If I have a chip that is $5 now and I need it to be $2 for the bulk of my sales, and my ship date is in two years, I have a good chance of making it.

(45:16):

The processors get cheaper all the time, and engineering gets more expensive all the time. So if you start with an overpowered processor and you just wait for it to get cheaper, that is an option.

(45:34):

But if you start with an underpowered processor and you do not have enough engineering resources to understand that level of engineering. Or you have a marketing team that is not sure what they want, which seems to be all marketing teams. The overpowered MCU gives you so much more flexibility. As well as putting you in a space where you might be able to get more skilled and experienced engineers.

(46:06):

If you start out with an 8051, sure- Or a 6502 core-

CW (46:12):

You are not going to do that. <laugh>

EW (46:13):

I know you are not going to do that. You have a lot of people who like it and who enjoy it, but do not necessarily program professionally for it. You want somebody who can play Tetris with what few resources you have. They need to be an expert and they need to be given time and understanding of what the goals are.

(46:36):

If you change the goals, they are going to start the assembly all over again. You do not get the flexibility of parallel processing a lot. So it is just simpler to start with something too big, and let the market take the pain of the price away, ideally. Do you have a different thought?

CW (47:00):

Those thoughts, plus a couple other things. One is I have not actually seen that be a problem that often. The opposite problem has happened more often, where you bought something you thought was overpowered, and then by the end of the project you realize you do not fit in that either. Especially with modern stuff, like you were talking about, Bluetooth or networking-

EW (47:22):

And then you say "OTA," and suddenly you need twice the amount of flash.

CW (47:25):

Or the worst thing, a display.

EW (47:27):

Oh my God, yes.

CW (47:28):

You want graphics. Once graphics gets involved in a display, well now you have a huge amount of memory moving around. You have to move it around at a certain rate. If you do not pick the right processor, then you do not have enough for say, double buffering or storing assets and things.

(47:41):

This is where marketing starts to input, and they say, "Oh, we want this to be fancier. We want the graphics to be fancier."

EW (47:47):

Faster.

CW (47:48):

As they move up the fancy, faster, smoother ramp, your processor starts to be not enough. Even when on paper at the beginning of the project, it is "Oh, this is all fine. We can fit all of this." But-

EW (48:00):

"We can totally sample 44.1kHz audio. And do this. And that. And signal processing. And yay!" "Oh, but then we added a display. Oh crap. Now we cannot do anything."

CW (48:10):

I have not seen it be that often where- It definitely happened, but on much larger projects where people were spending tens of thousands on electronics, when they should be spending hundreds. Rather than something that is $5, and they might be able to get away with something that is a quarter.

(48:23):

The other thing is that EEs hate changing parts. Once they make a board, they do not want hear from you in a year, that you need to put a different micro on it. In my experience <laugh>.

(48:38):

Then that goes on all the things Elecia is talking about, with having to- If you do not have a big enough part, you can get away with things, but then you have to be a specialist in different ways. Whereas now there is so much infrastructure for STM32s and AVRs-

EW (48:57):

Any Cortex.

CW (48:58):

Any microcontroller out there, there are libraries and things to help you. Even though I complain about tools all the time, there is just a ton of infrastructure and language support. If you want to write software quickly, you want those things.

(49:09):

Even all the way up to things like MicroPython or CircuitPython, where if you have got this overpowered processor, now you can write code in very high level languages that people are used to from desktop world. So I agree it can be a problem, but it is going to be highly project dependent. Oftentimes you are hurting yourself by trying to fit into a small space too early. I think.

AN (49:39):

You hear about it more often than it actually happens. You hear about it, because it is a big deal when it goes that way. Or it makes projects fail or it makes companies fail, that they could not deliver on time or for the right price point. But I guess as a EE, you do not get paid more to go ten times under BOM cost for one part.

CW (50:03):

Right <laugh>.

AN (50:05):

You do not get a promotion for that. "You wasted our time. We have to write more complicated code now." Or something like that.

EW (50:12):

There is a trade-off between code complexity and processors to some extent. When I worked at LeapFrog, when we made toys and we did ship in the millions, then we used some pretty sketchy processors. And it was worth it.

CW (50:26):

Yeah, the volume. The huge volume push definitely puts pressure on.

EW (50:31):

But when I work with smaller companies now, that are more startup range, I strongly encourage them to over plan. Because they will not make it without a product in the market. Cost reducing second is so much simpler, when you know what you are making.

(50:50):

Startups do not usually know what they are making. Or what they are making when they start, is not the same as what they are making when they end. So you need the flexibility. It is a trade-off between flexibility and cost, more than anything else.

CW (51:05):

Yeah, it is hard. The design phase is hard too. Fitbit was difficult because those were all Arm Cortex somethings I think, for the most part. So they are designing say a smartwatch, and you have got a lot of inputs to that spreadsheet, to tell you whether or not you have got a part that can do your thing. And there are a lot of unknowns.

EW (51:29):

Animation, speed.

CW (51:31):

Yeah. All of that.

EW (51:31):

Number of animations marketing truly needs, versus how many they want.

CW (51:36):

Yeah, I am just remembering back to trying to come up with clever algorithms to cheat stuff, because this thing just did not have the speed-

EW (51:45):

Fireworks!

CW (51:45):

They were still expensive chips, a few dollars a pop probably, which is not- When you are making a hundred dollar wearable or whatever, that is a lot.

EW (51:58):

But when you are making a $20 toy, you are still talking about 8051s, and chips that you maybe never heard of. At LeapFrog we used Sunpluses. They were very specialized to program. Very few instructions.

CW (52:15):

I want to know why somebody has not put a massively parallel 6502 core together, with like a million 6502s.

EW (52:20):

That is not what the Propeller is, is it?

CW (52:22):

No. <laugh>

EW (52:24):

Those were like BASIC Stamps or something?

CW (52:26):

I do not remember what those were. I think they were some custom thing.

AN (52:29):

Were they not- I do not know. Were they an FPGA? Or something in a-

CW (52:35):

A Parallax Propeller, yeah. 32-bit RISC chips of some kind. Yeah.

AN (52:42):

But of course people still do use 6502s, for the same reason they use an 8051.

EW (52:51):

Yeah, because you do not have to pay Arm for the CPU core. You can just pop it in there, and add your own stuff, and make your own processor.

CW (52:57):

Is it public domain? <laugh>

AN (53:01):

RISC-V is coming.

CW (53:02):

What is the status of the 6502 IP? Is that public domain now? Can I make my own?

AN (53:08):

If you make the- Ohh, do not quote me on this.

CW (53:12):

That is fine.

AN (53:13):

I am not a lawyer. I think if you stick with the original 6502 and MOS design, and you just copy that and do not try to copy the 65CO2, then you are fine. Because Western Design Center, they are still selling 6502 cores.

CW (53:30):

Really? Okay. I wonder who is buying those?

EW (53:35):

We should see if TinyTapeout would do those.

CW (53:39):

Do not know <laugh>.

EW (53:40):

All right <laugh>. So many ideas! Let us see. You are selling your 65uino as kits? As boards? As both?

AN (53:52):

I am selling them as kits. I did a sponsored video and I got way too many boards, so I gave a few away and now I am just selling the rest.

EW (54:02):

People can find them on your website?

AN (54:05):

Yes. I have an old web shop. I used to do something completely different, so I reuse that web shop. I am selling those boards on that site.

EW (54:13):

Which is?

CW (54:14):

<laugh>

AN (54:16):

Which is imania.dk. I hope you will put the link in the show notes.

CW (54:20):

Oh, yeah.

EW (54:22):

Yes.

AN (54:22):

So we get it in English and not Danish, and all those kinds of funny things.

EW (54:27):

imania.dk

AN (54:31):

I have sent to the whole world by now. They went to Australia and Canada and the US just fine. From Canada to Melbourne.

EW (54:42):

Did you in fact talk to Nelson?

AN (54:43):

I did. Wow. That is a treasure trove he has there. I have no idea how to use that many parts. But it would be so cool to make a "How to use the Small Device C Compiler with 8051s," and stuff like that. I would love to do a video on stuff like that.

EW (55:02):

Well, you two are talking to each other. I have a few more folks who have emailed to talk to Nelson. I am excited that his parts will be going out into the world to find other uses. And hopefully more people who can use these boards to learn things and to teach others.

(55:22):

Anders, it has been really great to talk to you. Do you have any thoughts you would like to leave us with?

AN (55:26):

I would just like to say thank you two so much for doing this for over ten years. It has been absolutely amazing to listen to you so often. Thank you so much to your supporters as well. Thank you for doing something to keep this going longer.

EW (55:44):

Our guest has been Anders Nielsen, Mac expert at Aalborg University in Denmark. You can check out his YouTube channel. And you can buy your own 65uino kits on his store at imania.dk or check out his website at abnielsen.com. There will be a link in the show notes.

CW (56:04):

Thanks Anders.

AN (56:06):

Thank you so much.

EW (56:08):

Thank you to Christopher for producing and co-hosting. Thank you to Memfault for sponsoring the show. Thank you to our Patreon listener Slack group for their questions. And of course, thank you for listening. You can always contact us at show@embedded.fm or hit the contact link on embedded.fm.

(56:24):

Now a small factoid to leave you with. Do you remember hearing about the Cray, the super powerful supercomputer, amazing Cray? Yeah. The Raspberry Pi 3B is nearly ten times more powerful than the first Cray.