;
; GRDP
;
; Copyright(c) LADsoft
;
; David Lindauer, camille@bluegrass.net
;
;
; FILL.ASM
;
; Function: Fill memory
;
	;MASM MODE
	.MODEL SMALL
	.386


include  eprints.inc 
include  einput.inc 
include  emtrap.inc 
include  eoptions.inc

	PUBLIC fill


	.CODE
;
; fill command
;
fill	PROC
	call	WadeSpace
	jz	errx
	call	ReadAddress		; read start address
	jc	errx
	call	defDS			; Get DS
	call	WadeSpace
	jz	errx
	call	ReadNumber    		; read length
	jc	errx
	mov	ecx,eax
	sub	ecx,ebx
	jc	errx
	call	WadeSpace
	mov	al,0           		; default fill = 0
	jz	gotfill
	call	ReadNumber		; else read a fill val
	jc	errx
	push	ax
	call	WadeSpace
	pop	ax
	jnz	errx
	test	[optdwordcommand],1
	jnz	gotfill
	movzx	ebx,bx
	movzx	ecx,cx
gotfill:
	push	es			; fill mem
	mov	es,dx
	mov	edi,ebx
	db	67h
	rep	stosb
	pop	es
	clc
	ret
errx:
	stc
	ret
fill	endp
end