	title	'Z80 block compare routine'
;
	.Z80
;
	aseg
;
	org	100h
;
	ld	bc,(size)	;block length in BC
	ld	hl,(blk2)	;block 2 start addr...
	ex	de,hl		; in DE
	ld	hl,(blk1)	;block 1 start addr
cmplp:	ld	a,(de)		;get a block 2 byte
	cpi			;[A-(HL++),--BC]
	jr	nz,nomatch	;jrif bytes differ
	jp	po,done		;jump if all bytes compared
	inc	de		;else increment blk2 ptr
	jr	cmplp		;and go again
;
nomatch:
	dec	hl		;restore blk1 ptr
	ld	(blk1sv),hl	;save blk1 ptr
	ex	de,hl
	ld	(blk2sv),hl	;save blk2 ptr
	inc	bc		;restore byte count
	ld	(szsv),bc	;save byte count
	ld	de,diffmsg	;msg ptr in DE
	jr	done1
;
done:
	ld	de,okmsg	;msg ptr in DE
done1:	ld	c,9	;BDOS print string
	call	5
	rst	38h	;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
