 	 	 	 	 	; *********EXAMPLE PROGRAM*************
 	 	 	 	 	;        SORT A BLOCK OF BYTES
 	 	 	 	 	; ***********************************************
2000 	START: 	LXI 	H 	2050 	; Set HL as memory pointer.
2003 	 	MVI 	D 	00 	; Clear register D to set flag.
2005 	 	MVI 	C 	05 	; Set register C for count.
2007 	CHECK: 	MOV 	A 	M 	; Get data byte.
2008 	 	INX 	H 	 	; Point to next byte.
2009 	 	CMP 	M 	 	; Compare bytes
200A 	 	JC 	NXTBYT 	 	; If A<second byte, donot exchange
200D 	 	JZ 	NXTBYT 	 	; If A==second byte, donot exchange
2010 	 	MOV 	B 	M 	; Get second byte after exchange.
2011 	 	MOV 	M 	A 	; Store first byte in second location.
2012 	 	DCX 	H 	 	; Point to first location.
2013 	 	MOV 	M 	B 	; Store first byte in second location.
2014 	 	INX 	H 	 	; Get ready for next comparision.
2015 	 	MVI 	D 	01 	; Load 1 in D as reminder for exchange 
2017 	NXTBYT: 	DCR 	C 	 	; Decremant count
2018 	 	JNZ 	CHECK 	 	; if count!=0, check again
201B 	 	MOV 	A 	D 	; Get flag bit in A
201C 	 	RRC 	 	 	; Place flag bit D0 in carry.
201D 	 	JC 	START 	 	; If flag=1, exchange occured, start next pass.
2020 	 	HLT 	 	 	; Halt execution.
