Jump to content
IGNORED

Z80 vs. 6502


BillyHW

Recommended Posts

The vast majority of the systems in the late 70s and early 80s were built around these 8-bit CPUs. Could anyone with programming or engineering experience from that era chime in with what some of the advantages and disadvantages or each chip were? Which do you think was better? For computing? For gaming?

 

Here's a quick list that I can think of. Please correct me where I'm wrong and add your own that I've missed.

 

Z80:

 

Adam/ColecoVision

Sega SG-1000

Sega Master System

MSX

most early arcade games

Game Boy

Game Gear

Astrocade

(Also listed as a coprocessor on many 16-bit arcades/consoles)

 

6502:

 

Atari 2600

Atari 8-bit computers/5200

Apple II

NES/Famicom

Atari Lynx

Commodore 64

PC Engine/TurboGrafx 16/Duo/Express

 

The Commodore 128 was unique in that it had both a Z80 and a 6502.

 

And what ever happened to Zilong and MOS? Why were they never able to translate their success in the 8-bit market over into the 16-bit market and beyond?

Link to comment
Share on other sites

Well, MOS got bought out by Commodore, though Western Design continued the 6502 line into 16-bit. Then...apparently interest died. Their 32-bit CPU became vaporware, but Western Design's still around and still making the 65C02 and 65C816.

 

Zilog? I guess the Z80 alone's been enough to keep 'em afloat despite their development of 16-bit Z80 successors...everyone who wanted a *Zilog* processor pretty much wanted a *Z80*. Pretty sure they're still around too.

Link to comment
Share on other sites

The vast majority of the systems in the late 70s and early 80s were built around these 8-bit CPUs. Could anyone with programming or engineering experience from that era chime in with what some of the advantages and disadvantages or each chip were? Which do you think was better? For computing?

 

i suspect it's one of those things where you get used to one and the other feels "wrong"; i'm mostly a 6502 bunny but know a little Z80 (to the point i've had things on screen and moving with music playing on a couple of machines) and find it quite difficult to work with. But i know folks who started with the Z80 tend to feel that way about the 6502.

 

The Z80 has more registers available but has to do pretty much everything with them whilst the 6502 can use the first 256 bytes of memory for those jobs and, essentially, gets more "registers" for it. Generally speaking, Z80 commands take more cycles to execute so, whilst it depends on the specific situation, very generally speaking 1MHz of 6502 is equivalent of 2MHz of Z80 so a 1.7MHz Atari 8-bit is about the same speed for code as a 3.5MHz Sinclair Spectrum, give or take.

 

For gaming?

 

That tends to be more about the machines wrapped around the processors and indeed which genre of game you're interested in; personally, i'd go for 6502-based machines since i like scrolling shoot 'em ups and the C64 and Atari 8-bit in particular are well stocked for hardware on that front, fans of 3D games (either true 3D or isometric) will usually go for the Atari 8-bit, BBC Micro or Sinclair Spectrum since they fare well on those fronts due to the processor speed and disk-based systems tend to do better for text adventures because things like the Infocom or Magnetic Scrolls parsers can keep huge lists of possible actions and responses on the disk rather than having to cram everything into RAM.

 

Here's a quick list that I can think of. Please correct me where I'm wrong and add your own that I've missed.

 

Z80:

 

Also the Sinclair ZX80, ZX81 and Spectrum (as well as the clones like the Pentagon, Scorpion or the more recent ZX Evolution), the Amstrad CPC, Jupiter Ace, Radio Shack TRS-80 or the Research Machines 380Z and 480Z from memory.

 

6502:

 

As well as the BBC Micro/Master and just about everything Commodore 8-bit (the PET and CBM series, VIC 20, 264 series, even the 1541, 1570,1571 and 1581 disk drives!)

  • Like 1
Link to comment
Share on other sites

I few years ago I wanted to compare the 6502, Z80, 6803, and 6809 so I ported some code across the different CPUs.

The code I ported didn't do any memory moves which would favor the Z80 over the 6502 further, but the Z80 code was around 20% smaller than the 6502.

 

The thing that seemed to make the biggest difference on code size between the 4 CPUs was 16 bit support.

If you don't need 16 bit support, the 6502 might fare better but you will only gain so much.

Page zero and advanced address modes on the 6502 are nice, but they just aren't a substitute for 16 bit registers.

The 6803 and 6809 have page zero and 16 bit support but require less than 40% of the code of the 6502 in the code I ported.

Given that, guess which CPUs require the least coding time?

Z80 16 bit support isn't quite as simple as the Motorola CPUs though so YMMV there.

 

The clock cycle difference between the Z80 and 6502 is around 2 to 1, maybe slightly higher like 2.2 to 1.

The Z80 is microcoded (if I remember right), so it executes instructions and accesses memory a bit different which is why it's common to see higher MHz Z80s than 6502s without the machines costing significantly more because of faster RAM. But this is also one of the drawbacks of the Z80. Interleaving video and CPU access to memory wasn't possible without stealing a lot of clock cycles from the CPU. The NEC Trek slowed significantly when using hi-res graphics because of this. Machines like the VZ/Laser and Spectrum used separate video and program memory areas to keep from slowing the CPU. When the Z80 accessed video RAM you either created wait states on the CPU or the video image shows sparkles. Programmers tried to time writes to the screen when they won't cause waits or sparkles. Several Spectrum games draw to a buffer and then copy it to the screen.

 

One of the biggest issues with the Z80 is that there is a big difference in clock cycles between some instructions and others.

For example, even though the Z80 has IX and IY index registers, it's faster to use HL whenever possible.

Just using different registers and instructions can significantly increase the number of clock cycles for a piece of code.

I could have written slightly smaller Z80 code for my comparison but it would have been slower.

 

The Z80 and 6502 aren't very efficient when it comes to dealing with the stack.

This makes stack based language support less than stellar but if I were to use a C compiler, I'd prefer the Z80 over the 6502.

 

I think Z80 assembly is slightly easier than 6502 because it's a little more obvious once you get used to it.

I learned a little Z80 before 6502 but I didn't really know that much until I learned the 6502 in college.

 

Which do I like more, the 6502 or Z80? Back in the day I'd probably pick the machine with the most capable hardware (besides CPU).

And yet I spent most of my time on machines without sprite or sound hardware.

Now, I really don't care, I enjoy coding on about anything, though I prefer the Motorola CPUs over the Z80 or 6502.

The 6803 was good but was an address mode and a couple instructions short of great. The 6809 is a joy to program.

Too bad Atari didn't use the 6809 and the 6509 wasn't released.

  • Like 10
Link to comment
Share on other sites

I second the "too bad Atari did not use the 6809", and would add that to the Apple ][ as well, though 1Mhz might not have made the most sense as a clock speed.

 

IMHO, that's a 6502 advantage at times. it's got little, short instructions that can get some kinds of things done very quickly compared to other CPU's, IMHO. Some of the more powerful 6809 instructions run 2X+ the clock cycles of 6502. A lot happens, but that might not favor all the flogging on chips that has been done over the years.

 

Very interested to see whether or not anyone attempts that kind of thing on the A8 / C64 with the 6809 add on projects. Atari is done, but I don't have the time right now... Might regret that, but that is how it is. C64 is on the workbench, from what I hear. There is a 6809 board for Apple ][ already.

 

Still don't know enough Z80 to comment. I've worked with it some, but only for trivial things. Just didn't have a machine back then. For me, it was Intel 808x, which I really didn't like too much, 6502 (my first and it was on Apple ][, then Atari), and 6809 (coco 2, 3)

Link to comment
Share on other sites

I enjoyed playing with page zero and graphics compression/decompression on the 6502 & Apple //e. Fun times. I also tended to like games built around the 6502, but that could be attributed to the machines and their custom chipsets surrounding the cpu; and not a direct effect of the cpu itself.

 

I believe a lot of the success of the 6502 was the cost. Wasn't it the cheapest 8-bit cpu at the time?

  • Like 1
Link to comment
Share on other sites

The advantage is skewed towards 6502 in that the most of the best systems had much better sound/video hardware than the Z80 equivalents. That same advantage shines through when comparing against the earlier TRS-80 Colour Computer models, the 6809 being a better CPU but let down in a big way by inferior hardware elsewhere in the machine.

 

Disregarding the Sam Coupe that is, which came when 8-bit computing was in it's last days. Similarly you could say the same for the Apple IIgs.

 

So, that leaves the Atari 8-bit and C64 to carry the flag for 6502 in the computer arena, then you have handhelds/consoles like Lynx, Atari 7800 and Nes (which uses a 6502 workalike).

 

For the Z80 brigade, the strongest contenders would likely have been the Amstrads and MSX. MSX never achieved the success it aimed for and the first generation at least used somewhat out of date sound/video hardware.

 

Z80 wasn't so common among consoles - Sega Master System and Megadrive/Genesis (Z80 coprocessor). Gameboy used a cutdown Z80 workalike.

 

 

The 6502 was somewhat less popular among arcade games. Almost all the Japanese manufacturers used Z80s in the early 1980s, 6502 was comparitively rare but used in most of Ataris games from ~ 1979-1984.

  • Like 3
Link to comment
Share on other sites

The Z80 machine code is higher level than 6502. Unless you have some macro capability in your 6502 assembler you're going to spend a lot of time repeating some small routines for 16-bit operations.

 

In Z80 there are a lot more registers, instructions to move a block, search for a byte, output block to port, input port to block, adding/substraction 16 bits, adding/substraction without carry (in 6502 you've to clean Carry flag,) conditional returns/jumps/calls (saves a lot of code.)

 

As said before the 6502 needed more help from peripherals, so there is the C64 where the VDP has pixel scrolling capability and the PSG could do FM style sound, everything without processor help, even the Atari had a lot of help with its associated chips.

 

While the poor Z80 stuck with not so powerful graphics and sound, like the SG-1000, Colecovision and MSX, and the better were the Sega Master System, and MSX2 and MSX2+ (this one with FM sound) that came a little too late.

Link to comment
Share on other sites

AFAIK back in the 70ties, a system with similar performance was generally cheaper to build with the 650x than the Z80. So while the Z80 was the more sophisticated CPU, the 650x gave you more "bang for the buck".

That is certainly true to a point, but I think there's more to it. WOZ is the main reason we hear about the 6502 being cheaper, but remember that WOZ was talking about development of the Apple I.

 

You have to look at the timeline and CPU features a bit to really understand why the 6502 and Z80 dominated the market.

 

The 6502 was introduced in 1975 and Apple computer was officially formed in the spring of 1976. I'm sure WOZ had started or possibly finished the Apple 1 design before Apple was formed. The Z80 didn't even exist until 1976, in 1975 the competition would have been the 8080 or 6800. The 6800 was several hundred dollars and the 8080 was certainly much more expensive than the $25 6502. WOZ certainly would have had a chance to use the Z80 but I think his mind was pretty much made up by the time it arrived.

 

The 6809 was introduced in 1978. The Apple series and the PET, were already set on the 6502. Switching to a CPU that wasn't compatible would mean starting code over from scratch. Remember, the code for the later Apples and Commodores grew out of those companies first machines. The Apple II grew out of his Apple 1 design which grew into the Apple II+ and so on. The PET ROM grew into the VIC 20, which grew into the C64, Plus/4, and C128. Each machine's software was the basis for the next machine and with Apple even the hardware was a series of stepping stones.

 

Atari probably had the opportunity to use a 6809 or 6509 if it had been released. But the 6509 seemed to be vaporware and there was no existing code base for the 6809 to port programs over to the new Atari. The existing 2600 game console had already used a stripped down 6502. Atari had a group of experienced game developers that could easily migrate to the new machine. I'm sure the 6809 was attractive but there were a lot of reasons to stick with the 6502. If the 6509 had been available, Atari probably would have used it and I'm guessing other manufacturers would have started shipping new models with the 6509 as well, after all it would have still supported the 6502 code base. Talk of the 6509 may also have helped convince Atari to stick with the 6502. After all, their computer had a separate board with the CPU and it would be relatively easy to swap in a new CPU that still runs the old software.

 

So why did anyone use anything but the 6502?

The biggest advantage of the Z80 from a hardware standpoint was the built in DRAM controller. When the Z80 was introduced, other CPUs required external logic to interface to the cheaper DRAM memory chips. This reduced costs and simplified designs. The chip also supported existing 8080 code and support chips.

You saved money by not having an external DRAM controller.

The Z80 also inherited all the 8080 software from the early hobby machines.

 

WOZ built his own DRAM controller out of standard TTL logic chips. Sure it had a higher parts count but the chips were dirt cheap.

Tandy used the Z80 and didn't require a super Guru to build everything from scratch.

The PET... I think it used the memory controller for the 6800 series but I'm not really up on it's design. It was more expensive as a result.

Atari was designing custom chips already, adding a DRAM controller was no big deal.

 

Which machine was cheapest? The TRS-80 and it used a Z80.

  • Like 2
Link to comment
Share on other sites

So how come the Z80 shines on SMS but on Spectrum it all looks like regurgitated toe nails?

LMAO!

 

The Spectrum basically has a monochrome 256x192 video layout with an added layer of color attributes.

Each byte of the screen buffer is 8 pixels and the color attributes determine what the foreground and background colors are for that byte.

The color attributes control blocks of 8 bytes stacked on top of each other (if I remember right) so you end up with a very blocky looking screen unless you change the attributes on the fly. With only 16 (sometimes less than desirable) colors you get... well you get something that looks a bit like a coloring book where someone didn't stay inside the lines and the artist didn't get the big box of crayons. :)

 

Now, if you look at the FPGA replacement for the Speccy's custom chip (ULAPlus), you get something like this... and it didn't require a lot more logic.

 

It's still no match for the SMS but it certainly doesn't look like regurgitated toe nails.

 

Machines like the Speccy, VZ/Laser, Tandy CoCo, all could have had much better graphics with a little extra logic. But it seems logic was expensive and much more time consuming to develop in those days. The SMS came out in 1986, about 10 years after the first home computers.

Edited by JamesD
  • Like 3
Link to comment
Share on other sites

Maybe the cheapest, but IIRC we called it Trash-80 back then. :)

Yeah yeah... funny how my Model I trash 80 still works great.

That nickname was because the edge connectors on the computer and expansion interface weren't gold plated.

You had to take an eraser to the connectors every couple weeks or risk having the machine lock up because of a bad connection.

It's never a good idea to interface RAM through a ribbon cable anyway. :)

 

But hey, look at the Apple II (not II+ or IIe), and Pet.

The II ROM was very primative. It was only after many patches, tools, and upgrades were integrated into the II+ that it became a decent machine and EVERY Apple II has that crappy interleaved hi-res graphics memory map. Only the IIgs added new modes that ditch that.

The first Pet had a calculator keyboard and those gargantuan external drives were around until the VIC-20.

Lets face it... they were all trash back then!

Link to comment
Share on other sites

You know that interleaved memory map ended up being a feature on some displays. Really, it is not bad if you make up an index table. Not optimal, but not horrible either. IMHO that is task one for an Apple 6502 programmer. It was mine. (I always like to write a dot plotter, then make it fast and the code that drops out of that gets one to a bitter pretty quick)

 

On scrolling games, slow display fills tend to be seen easily with a wipe or tear effect seen when that operation can't be buffered, or done during one VBlANK.

 

The interleaved screen broke that up some. which made it less noticeable, IMHO. That and binary picture loads looked cool, but otherwise PITA.

  • Like 2
Link to comment
Share on other sites

Sure. I was just kidding. :)

 

Anyway, since many early CPUs back then had 1 MHz and less, I wonder if the required ~2 MHz for the Z80 for similar performance might have been a problem.

I think the big issues at first were RAM, and CPU cost.

The TRS-80 ran at 1.78 MHz but if you look at how easy it was to hack to a faster clock speed it's obvious it was designed to be faster.

I think they cut the speed to cut costs. Faster RAM, a faster CPU... and suddenly it doesn't meet the price point that made it a hit in those days.

The Model III was really the same design integrated onto 1 board and it ran at 2.03 MHz.

I also have a hunch Tandy cut specs just in case the machine was a flop. I think it would have sold even better at the higher MHz.

 

One thing you have to consider on the 6502 or 6809 machines which interleaved CPU and graphics access to memory, they were accessing RAM twice as fast as the CPU. WOZ's approach was a total hack but it worked. Later machines like the Atari and CoCo had CPUs running more in time with video and used custom chips to do the timing. I think the Oric took a similar approach to Apple but used a custom chip for the timing. I believe the Oric has some picky buss timings for add on hardware as a result and the Apple had similar buss issues but it was better documented. Anywho... what you end up with is RAM that has to be rated at around 2MHz just like the TRS-80.

 

I know I'm wandering from the topic a bit here but the Oric really amazes me. It had pretty decent graphics (sadly no sprites), a sound chip, 64K (though the switch to disable the ROM and switch in the overlay RAM had to be external), and all in a tiny package. The display concept was very innovative but sadly, programmers didn't really figure out how to take advantage of it until long after the machine was dead. The sound was basically the equivalent of a single AY chip Mockingboard.

Ok, the Oric 1 keys were difficult and the color of the Atmos is something out of a Halloween nightmare, but to offer what the Apple II did and more in such a small and inexpensive machine was... "bloody brilliant!" ;)

Elite on the Apple and C64 doesn't look this good.

Edited by JamesD
Link to comment
Share on other sites

I know I'm wandering from the topic a bit here but the Oric really amazes me. It had pretty decent graphics (sadly no sprites), a sound chip, 64K (though the switch to disable the ROM and switch in the overlay RAM had to be external), and all in a tiny package. The display concept was very innovative but sadly, programmers didn't really figure out how to take advantage of it until long after the machine was dead. The sound was basically the equivalent of a single AY chip Mockingboard.

Ok, the Oric 1 keys were difficult and the color of the Atmos is something out of a Halloween nightmare, but to offer what the Apple II did and more in such a small and inexpensive machine was... "bloody brilliant!" ;)

A friend of mine had an Oric 1 before I had the money to buy my own C64. It was really a nice little machine, though at that time we mainly played with the pretty capable BASIC.

 

Elite on the Apple and C64 doesn't look this good.

http://www.youtube.com/watch?feature=player_embedded&v=kC1cJGLGlxo

I know. I helped a bit. :)

  • Like 1
Link to comment
Share on other sites

The color attributes control blocks of 8 bytes stacked on top of each other (if I remember right)

 

That's right, although it's a little more fiddly than that; there's actually eight colours with two brightnesses (so generally speaking there are only fifteen colours, some models make a distinction between dark and bright black but it's tiny) and the attribute byte is split into three bits that select the colour for the unset bits, another three for the set ones and the remaining two bits control bright and flash for the entire cell so an artist can't have one regular and one bright colour in a single cell.

  • Like 1
Link to comment
Share on other sites

You know that interleaved memory map ended up being a feature on some displays. Really, it is not bad if you make up an index table. Not optimal, but not horrible either. IMHO that is task one for an Apple 6502 programmer. It was mine. (I always like to write a dot plotter, then make it fast and the code that drops out of that gets one to a bitter pretty quick)

 

On scrolling games, slow display fills tend to be seen easily with a wipe or tear effect seen when that operation can't be buffered, or done during one VBlANK.

 

The interleaved screen broke that up some. which made it less noticeable, IMHO. That and binary picture loads looked cool, but otherwise PITA.

I vote for PITA. Talk about taking some simple code and making it explode in size!

Ultimately, the machine is what you make of it but I think the Apple suffered as a result of that.

But then it used a chip to read the keyboard instead of time consuming polling so I guess it had it's advantages.

Disabling the keyboard polling in BASIC really speeds it up on some machines.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...