Andrew Collier
Sat, 24 Oct 2009 16:11:05 -0700
On 24 Oct 2009, at 23:46, Thomas Harte wrote:
By the way:ld d, (NUMVERTS)I don't think you can do this?No, you're right, you can't. It silently substituted ld a, (NUMVERTS), so that loop was running quite a bit longer than it needed to and the result not being visibly different unless the polygon hits the first scanline. So easy to miss.
Which version of pyz80 are you using? For me, this instruction is caught by a testcase:
$ cat > test.z80s NUMVERTS: db 0 ld d,(NUMVERTS) $ pyz80 test.z80s pass 1 ... Error: Illegal combination of operands test.z80s:1 "ld d,(NUMVERTS)" Error: OpCode not recognised test.z80s:1 "ld d,(NUMVERTS)" Presumably your longer code sequence is catching it out somehow...As an aside, it's rather unfortunate that zilog chose to use parentheses to denote memory dereferences, as they're ambiguous with mathematical ordering operators. It's not immediately obvious that the following examples generate entirely different instructions, but that is a consequence of the only useful way I could parse them!
ld hl,(NUMVERTS + 1)
ld hl,(NUMVERTS) + 1
Andrew
--
http://www.intensity.org.uk/