News for hackers. Stuff that matters.
Re:On choosing the Z80 over the 6502 (2014) by hyperpallium on Sunday December 20, 2015 @02:53AM (#10766415)
\oblig HN pedantry: In this specific simplified problem, I think you could use stripes for Z80, with x in (HL), flag in (DE), and use literals for max/min (as in 6502) instead of D/E? But it would still be much slower than the 6502, and you run out of registers if need more than two fields of an object...

I'd forgotten (IX+n) instructions were so expensive! It's a shame, because your example is their purpose.

I guess Z80 is a higher-level micro-coded language: easier but slower. I also always found the orthogonal mnenonic style of Z80 much clearer, which I think 6502 could have used. e.g. "LDA $F453,X" could be "LD A,($F453+X)"

PS some references I found: 6502 addressing modes: http://www.dwheeler.com/6502/oneelkruns/asm1step.html

  LDA $F453,X  where X contains 3      
Absolute Indexed Addressing - Load the accumulator with the contents of address $F453 + 3 = $F456.

Z80 timings: http://map.grauw.nl/resources/z80instr.php

Re:On choosing the Z80 over the 6502 (2014) by to3m on Sunday December 20, 2015 @09:31AM (#10767103)
Hmm... in this case, you might be right. You'd then need to advance 2 registers by 8 each time, and you'd be paying an extra 3 T-states per compare for the fetch of the immediate operand, but you'd be saving 4+ cycles in various places from never needing a DD prefix...

(Actually, MIN_X and MAX_X are supposed to be values you fetch from memory, as you can see from the 6502 code. I have no idea why I wrote what I did for the Z80 version. You could use self-modifying code to put constants in the right place, though - which, thinking about it, is actually what I should have done for the 6502 version.)