	.TITLE	DEPOSIT
	.IDENT	"V1.4"
;
;   Author:	D. Mischler	10-JUN-87
;
;   This module implements the DEPOSIT command.
;
;   DEPOSIT[/type] address=value
;

	.PSECT	CODE,I,RO
DPOSIT::
	MOV	#M$WD5,R4	; Set up default deposit routine address.
10$:	CALL	U$FNXT		; Find qualifier or address expression, OK?
	BCS	70$		; No, complain about missing argument.
	CMPB	#'/,-1(R0)	; Was a qualifier found?
	BNE	20$		; No, it must be an address expression.
	MOV	#TYPTBL,R1	; Point to type keyword table.
	CALL	U$DCOD		; Look up qualifier in table, OK?
	BCS	100$		; No, complain.
	MOV	R2,R4		; Save memory deposit routine address.
	BR	10$		; Search for next command element.
;   Process address expression.
20$:	CALL	XPRESS		; Evaluate address expression, OK?
	BCS	100$		; No, complain.
	MOV	R1,R5		; Save address for later.
	MOV	#2,R3		; Assume word deposits.
	CMP	#M$WDB5,R4	; Are bytes being deposited?
	BNE	30$		; No, words are OK.
	DEC	R3		; Adjust address increment.
30$:	CMPB	#'=,(R0)+	; Is the equals sign where it belongs?
	BNE	60$		; No, tantrum time (scream and kick).
	CMP	#M$WI5,R4	; Are instructions being deposited?
	BEQ	50$		; Yes, cooperate.
;
;   Data deposition loop.
;
40$:	CALL	XPRESS		; Evaluate contents expression, OK?
	BCS	100$		; No, complain.
	CALL	(R4)		; Deposit value at specified address, OK?
	BCS	80$		; No, display write failure message.
	ADD	R3,R5		; Adjust address for next deposit.
	CMPB	#',,(R0)+	; Does a comma follow the value?
	BEQ	40$		; Yes, get next value expression.
	RETURN
	.PAGE
;
;   Instruction deposition loop.
;
50$:	CALL	ASSMBL		; Assemble an instruction, OK?
	BCS	100$		; No, complain.
	CMPB	#';,(R0)+	; Does a semicolon follow the instruction?
	BEQ	50$		; Yes, get next instruction.
	TSTB	-(R0)		; Was line terminated normally?
	BNE	90$		; No, complain.
	RETURN

;   Missing equals sign.
60$:	MOV	#E.EQMS,R1	; Point to error message.
	BR	100$

;   Missing argument.
70$:	MOV	#E.RAMS,R1	; Point to error message.
	BR	100$

;   Write failure.
80$:	MOV	#E.MWF,R1	; Point to error message.
	BR	100$

;   Line not terminated normally.
90$:	MOV	#E.KWNF,R1	; Point to error message.
100$:	CALLR	ERROR

	.PSECT	RODATA,D,RO
;
;   Deposit data type table.
;
TYPTBL:
	KEYWRD	BYTE,M$WDB5
	KEYWRD	INSTRUCTION,M$WI5
	KEYWRD	WORD,M$WD5
	.WORD	0
	.END
