Compucolor.org – Virtual Media

Listing of file='UTIL.MAC;02' on disk='vmedia/asm_utility_4-sideA-sector.ccvf'

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;	UTILITY ROUTINES
;
;

;
;	COMPARE HL TO DE (I.E. HL-DE)
;
;	HL AND DE ARE TREATED AS UNSIGNED 16-BIT NUMBERS
;
;	DESTROYS A REG.
;
	ENTRY	CMPHD

CMPHD:	MOV	A,H	;MOST SIGNIFICANT BYTE FIRST
	CMP	D
	RNZ		;DONE IF NOT ZERO
	MOV	A,L
	CMP	E	;SET FLAGS
	RET


;
;	MOVE A BLOCK (UP) IN MEMORY
;	IF THE SOURCE AND DESTINATION BLOCKS ARE DISJOINT,
;	THERE IS NO PROBLEM. IF THEY OVERLAP, THE MOVE
;	MUST BE UPWARDS.
;
;	ON ENTRY:
;	   HL -> SOURCE
;	   DE -> DESTINATION
;	   B  =  BYTE COUNT (MUST BE >0)
;
;	DESTROYS ALL REGISTERS
;
	ENTRY	MOVEUP

MOVEUP:	MOV	C,B	;GET BYTE COUNT MINUS ONE
	DCR	C
	MVI	B,0
	DAD	B	;FIND END OF SOURCE BLOCK
	XCHG
	DAD	B	;   AND DESTINATION BLOCK
	XCHG
	MOV	B,C	;RESTORE BYTE COUNT
	INR	B
MVUP10:	MOV	A,M	;GET CHR
	STAX	D	;MOVE IT
	DCX	H
	DCX	D
	DCR	B	;DONE?
	JNZ	MVUP10	;NO
	RET		;YES


;
;	MOVE A BLOCK (DOWN) IN MEMORY
;	IF THE SOURCE AND DESTINATION BLOCKS ARE DISJOINT,
;	THERE IS NO PROBLEM. IF THEY OVERLAP, THE MOVE
;	MUST BE DOWNWARDS.
;
;	ON ENTRY:
;	   HL -> SOURCE
;	   DE -> DESTINATION
;	   B  =  BYTE COUNT (MUST BE >0)
;
;	DESTROYS ALL REGISTERS EXCEPT C
;
	ENTRY	MOVEDN

MOVEDN:	MOV	A,M	;GET BYTE
	STAX	D	;MOVE IT
	INX	H
	INX	D
	DCR	B	;DONE?
	JNZ	MOVEDN	;NO
	RET		;YES

	END