Re:Z80 arithmetic: also surprisingly terrible (2018)
by jonsen on Monday January 14, 2019 @04:09AM
(#18901720)
Code written by one couldn't be ported to the other, but had to be rewritten.
That’s not my experience. I once ported a program from the 6800 (the mother of the 6502) to the Z80. It was very straight forward. But to my surprise the version on the much “fancier” Z80 turned out to be both larger and slower despite the Z80 ran a little faster clock speed.
Re:Z80 arithmetic: also surprisingly terrible (2018)
by floofy222 on Monday January 14, 2019 @04:40AM
(#18901846)
I don't think the OP literally meant that porting code was impossible, but rather, that it was very hard to do so and have the result run efficiently.
Re:Z80 arithmetic: also surprisingly terrible (2018)
by Arnt on Monday January 14, 2019 @04:57AM
(#18901922)
(OP speaking for himself:) When I ported Z80 code to the 6502 literally, the result didn't use the zero page to its full effect, because the zero page was so much bigger than the Z80's extra registers. When I ported 6502 to Z80 literally (I mean code that used the zero page well), too much of the zero-page work had to be replaced with memory work and not enough with the nice fast registers.
Re:Z80 arithmetic: also surprisingly terrible (2018)
by _Codemonkeyism on Monday January 14, 2019 @04:27AM
(#18901799)
Same here, wrote 6502 (C64) and Z80 (CPC) code and preferred the (double-)registers of the Z80 to work with compared to the limited registers of the 6502.
Re:Z80 arithmetic: also surprisingly terrible (2018)
by Arnt on Monday January 14, 2019 @04:39AM
(#18901845)
That's not a completely fair comparison. BCDE+HL+IXIY offered more space than the 6502's registers, but less space than its zero page, so the hierarchies differed. In both cases "A, something, main memory", but the somethings differed and it mattered.
Re:Z80 arithmetic: also surprisingly terrible (2018)
by _Codemonkeyism on Monday January 14, 2019 @04:53AM
(#18901906)
You're right, though if I remember correctly the zero page was only slightly faster than memory access.
I'm als influenced a lot by my personal circumstances, as though the Z80 took generally more cycles than the 6502, as I moved from a 1mhz 6502 (C64) to a 4mhz z80 (CPC) in general the z80 felt faster.
Re:Z80 arithmetic: also surprisingly terrible (2018)
by Arnt on Monday January 14, 2019 @10:05AM
(#18903454)
Maybe it actually was. Code like (java) for(A a : b) a.c = false; certainly could be written very nicely on the Z80. By keeping a in IX and laying out the data structure as a struct where all of the bools are packed into one byte, the body of that loop could be just one (slow) instruction like RES 3, IX+4. But to get that speed you had to be aware of those possibilities and design the data structure. On the 6502 you'd lay out the data structure differently, playing to that CPU's strengths.
Re:Z80 arithmetic: also surprisingly terrible (2018)
by _Codemonkeyism on Tuesday January 15, 2019 @03:39AM
(#18909669)
Interesting, I have no idea as I was writing assembler only, no code generation (except some assembler macros ;-)
Didn't have much trouble storing things in B/C/D/E/BC/DE, at least I don't remember it as a problem. The innermost loops had to get top priority when deciding what each register was used for, that's all.