;
; SYSLIB Module Name:  SFILL
; Author:  Richard Conn
; SYSLIB Version Number:  2.0
; Module Version Number:  1.0
; Module Entry Points:
;	FILLB		FILLBC		HFILB		HFILBC
; Module External References:
;	None
;

;
;  FILLB and FILLBC, HFILB and HFILBC --
;	Memory fill routines; fill the memory buffer pointed to by HL
; with the byte in Register A; for FILLB and HFILB, B=number of bytes in
; buffer, and for FILLBC and HFILBC, BC=number of bytes in buffer
;	No registers are affected for FILL and FILLBC, HL pts to byte after
;		last byte filled for HFILB and HFILBC
;

FILLB::
	PUSH	B	; SAVE BC
	MOV	C,B	; C=B
	MVI	B,0	; SET B=0
	CALL	FILLBC	; USE FILLBC
	POP	B	; RESTORE BC
	RET

FILLBC::
	PUSH	H	; SAVE REGISTERS
	PUSH	PSW
	PUSH	B
	PUSH	D
	MOV	D,A	; BYTE IN D
	CALL	FILL	; DO FILL
	POP	D	; RESTORE REGISTERS
	POP	B
	POP	PSW
	POP	H
	RET

HFILB::
	PUSH	B	; SAVE BC
	MOV	C,B	; C=B
	MVI	B,0	; SET B=0
	CALL	HFILBC	; USE HFILBC
	POP	B	; RESTORE BC
	RET

HFILBC::
	PUSH	PSW	; SAVE REGISTERS
	PUSH	B
	PUSH	D
	MOV	D,A	; BYTE IN D
	CALL	FILL	; DO FILL
	POP	D	; RESTORE REGISTERS
	POP	B
	POP	PSW
	RET

FILL:
	MOV	M,D	; STORE BYTE
	INX	H	; PT TO NEXT
	DCX	B	; COUNT DOWN
	MOV	A,B	; DONE?
	ORA	C
	JNZ	FILL
	RET

	END
