	title	'Z80 block compare routine'
;
$*macro
	maclib	z80
;
	org	100h
;
	lbcd	size	;block length in BC
	lhld	blk2	;block 2 start addr...
	xchg		; in DE
	lhld	blk1	;block 1 start addr
cmplp:	ldax	d	;get a block 2 byte
	cci		;[A-(HL++),--BC]
	jrnz	nomatch	;jrif bytes differ
	jpo	done	;jump if all bytes compared
	inx	d	;else increment blk2 ptr
	jr	cmplp	;and go again
;
nomatch:
	dcx	h	;restore blk1 ptr
	shld	blk1sv	;save blk1 ptr
	xchg
	shld	blk2sv	;save blk2 ptr
	inx	b	;restore byte count
	sbcd	szsv	;save byte count
	lxi	d,diffmsg  ;msg ptr in DE
	jr	done1
;
done:
	lxi	d,okmsg	;msg ptr in DE
done1:	mvi	c,9	;BDOS print string
	call	5
	rst	7	;back to debugger
;
diffmsg:
	db	'Blocks different.$'
okmsg:	db	'Blocks compare OK.$'
;
	if	($ mod 2)
	ds	2-$ mod 2
	endif
size	dw	980h	;count of bytes to compare
blk1	dw	180h	;block 1 start addr
blk2	dw	1f80h	;block 2 start addr
;
szsv	ds	2	;bytes remaining to compare
blk1sv	ds	2	;addr of diff in block 1
blk2sv	ds	2	;addr of diff in block 2
;
	end
