6502 to z80 asm

DanP

Administrator
Staff member
vacBacker
Feedback
5 (100%)
Credits
2,174CR
Hi guys, before I delve too deeply and reinvent the wheel, does anyone have a quick 101 on the differences between 6502 and z80 assembler? What are the major differences in architecture,instruction sets, etc? I've done a bit of 6502 but no z80, it was always on the list and I was planning on targeting the Galaxian/Pac Man hardware because it's ubiquitous.

TIA

Dan
 

cmonkey

Active member
vacBacker
Feedback
4 (100%)
Credits
1,658CR
You'll be swimming in the abundance of registers when you jump ship from 6502 to Z80!

6502 only has A, X, Y, SP, PC and the status register.

Z80 has A, B, C, D, E, F, H, L, IX, IY, SP, PC and then a completely alternate set of registers too (A', B', C', D', E', F', H', L'). You can combine certain 8-bit registers together to make a 16-bit register for 16-bit addition/subtraction operations. Both CPU's are little endian.

I learned Z80 first and found it quite hard to learn 6502 afterwards mainly due to the massive shortage in registers on the 6502. It forces you to use some very creative code due to register shortage.

On the filp side one could say that it's easy to write sloppy code on Z80 because you've got so many registers to play with.

IMO the major thing you'll find between the two architectures will be the registers, the instruction set is relatively comparable.

Z80 has a few more addressing modes than 6502.

Grab the official Z80 user manual from Zilog and see what you think :-

http://www.zilog.com/manage_directlink.php?filepath=docs/z80/um0080
 

Mr Halibut

Newbie
Feedback
2 (100%)
Credits
29CR
You'll be swimming in the abundance of registers when you jump ship from 6502 to Z80!
Hah, that's what I thought when I went from Z80 to 68000. 16 registers, all 32 bits long, multiply and divide instructions... how did Z80 programmers ever cope?
smiley1.gif
 

RGP

Meeter & Greeter
Feedback
5 (100%)
Credits
2,039CR
Mr Halibut said:
You'll be swimming in the abundance of registers when you jump ship from 6502 to Z80!
Hah, that's what I thought when I went from Z80 to 68000. 16 registers, all 32 bits long, multiply and divide instructions... how did Z80 programmers ever cope?
smiley1.gif

Yeah, just wait until you need to do things with scores on an 8-bit system like turning a 32 bit number into printable decimal.

Doable obviously but the work can get quite daunting.

The abundance of registers are something that you immediately grow to love but the mental block of converting something you're used to doing on the 6502 series to Z80 will get you for an hour or two.

I pushed past most of it in a few hours last night after not writing Z80 since probably 89.

Well worth it though to tinker with Galaxian, Pac-Man, Galaga, Dig-Dug, etc type boards as they're all Z80 based.
 

cmonkey

Active member
vacBacker
Feedback
4 (100%)
Credits
1,658CR
Mr Halibut said:
Hah, that's what I thought when I went from Z80 to 68000. 16 registers, all 32 bits long, multiply and divide instructions... how did Z80 programmers ever cope?
smiley1.gif

And then you make the jump up to a RISC CPU and wonder how did the 68000 programmers ever cope?
smiley36.gif
 

cmjones01

Newbie
Credits
194CR
I'm natively a 6502 person too, and have always struggled to figure what to do with all those registers on the Z80 and x86 family. Fundamentally the 6502 is a load-store processor: its operations are done on the accumulator, and the data and results have to be loaded from and stored into memory separately. That's nice and simple for my brain to cope with, and doesn't involve much planning!

I've been doing a bit of 6502 programming recently and realised something: you can actually think of the 6502 as a processor with 256 registers, because there are a number of instructions and addressing modes which work specially with zero page (memory addresses from 0x00-0xff) and are pretty quick about it.

Chris
 

cmonkey

Active member
vacBacker
Feedback
4 (100%)
Credits
1,658CR
cmjones01 said:
I've been doing a bit of 6502 programming recently and realised something: you can actually think of the 6502 as a processor with 256 registers, because there are a number of instructions and addressing modes which work specially with zero page (memory addresses from 0x00-0xff) and are pretty quick about it.

Yes, that's one of the features of the 6502 that I *really* like.

cmonkey2014-12-30 16:03:26
 
Top