[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 6502 illegal opcodes questions



In article <1148126608.168023.119240@38g2000cwa.googlegroups.com>,
 heuser.marcus@freenet.de wrote:

> > LDIR eats 21 clock cycles per iteration, doing the same with other Z80
> > instructions can be way faster.
> >
> > I tried to use the Z80 in the C128 for block copy/fill because I thought
> > "hey, it has a block copy command, so I guess it is fast" but it wasn't.
> > Then I tried normal opcodes, it was way faster than using LDIR but still
> > not faster than copying the stuff with the 8502.
> 
> But if the 6502-designers had chosen to implement a block move then
> of course it would've been way faster!  ;o)

You could speed up memory moves on the 6809 with the multiple register 
PSHS/PULS/PSHU/PULU instructions.  They can move up to 10 bytes of 
registers plus the PC with only two instruction byte fetches (unlike 
LDIR which constantly branches back 2 bytes to read the opcode again), 
but for memory moves you need to use the other stack register for your 
destination, which means 8 bytes max.  The trick is that you have to 
either disable interrupts or do things such that you can tolerate 
interrupts using either your source or destination memory for a stack.

I dug up some old code of mine which scrolled a bitmap display (6K) by 
doing 256 loops, each with four moves of 6, 6, 5, and 5 bytes.  (I was 
avoiding using the DP register because this code was for OS/9 or I could 
probably have done 8/8/6, but I still don't know why I was moving 22 
bytes per loop instead of 23.)  The difference between that and just 
doing a loop of LDD ,X++ / STD ,Y++ (which is still better than the Z80 
because of the post-increment or 6502 because of 16 bits at a time) was 
enough to make the scrolling tolerable.