◄ WORLD V · SONNY 5DART 463 · a helldive at the net

THE BLOCK MOVE MVN / MVP — a hardware memcpy in one instruction

The 6502 copies memory the hard way: load, store, increment, branch, repeat. The 65816 adds MVN and MVPblock move instructions that copy a whole run in a single opcode. You set the source and destination banks in the operand, the start addresses in X and Y, and the count minus one in the accumulator; the instruction then streams bytes until the count underflows, decrementing (MVP, for overlapping moves downward) or incrementing (MVN, upward). It is a built-in memcpy: the kind of loop a 6502 spent dozens of cycles per byte on, folded into one instruction the DMA-hungry SNES leans on hard.

THE TECHNIQUE copy count+1 bytes src→dst in one op (X=src, Y=dst, A=count-1)

The demo runs MVN copying 3 bytes from offset 0 to offset 4 in a memory array — one instruction, the run moved: live demo


HISTORY & CREDIT 65C816 MVN / MVP

“Copying memory is always a loop you write.” — the 65816 has the loop as a single instruction. cited

the setup · X=source, Y=dest, A=count−1, operand = src/dst banks.
the stream · one opcode copies byte after byte until A underflows — MVN up, MVP down.
the point · a built-in memcpy where the 6502 hand-rolled a loop.

A whole run of bytes copied by a single instruction — the 6502’s copy loop cast into silicon. resource

RECOMMEND FOR I-13 the block copy, on the compiler

On the canonical compiler, MVN copies [10,20,30] from offset 0 to offset 4 — the destination now holds the run:

$ i13 run pm_blockmove.i13 # MVN copy 3 bytes 0->4 RUN OK · 121 step(s) · peak stack 8 · call depth 4 copied = 1 -- mem[4..6] == [10,20,30] after one block move
Recommend as a NULL — resource, the single-instruction-loop kind. A block move computes the same result as a hand-written copy loop — identical bytes at the destination — in far fewer instructions. That is the resource axis (B40), a cousin to THE TRICK (batch 46): a cheaper mechanism for a fixed output. NULL — the permutation turning the 6502’s copy loop into one opcode.