;-------------------------dec16in routine begins--------------------------+
; from BLUEBOOK OF ASSEMBLY ROUTINES FOR IBM PC & XT.
;         page : 57
;
; NAME DEC16IN
; ROUTINE FOR conversion from ASCII decimal to 16-bit Binary
;
; FUNCTION: This routine accepts an decimal number from the standard input
; device and converts it to internal 16-bit binary form.
; INPUT: The individual digits of the decimal number are received in ASCII
; through a call to a standard I/O routine.  The valid digits are 0 - 9.
; An ASCII code other than for a valid digit will terminate the routine.
;
; OUTPUT: A 16-bit binary number is returned in the DX register.
; REGISTERS USED:  Only DX is modified. It returns the result.
; SEGMENTS REFERENCED:  None
; ROUTINES CALLED:  STDIN
; SPECIAL NOTES: None
;
; ROUTINE TO CONVERT FROM ASCII decimal TO INTERNAL 16-BIT BINARY
;
dec16in	proc	far
;
	push	cx		; save registers
	push	ax
;
	mov	dx,0		; initialize DX
;
dec16in1:
	call	stdin		; a digit comes in in AL
	sub	al,30h		; reduce from ASCII
	jl	dec16in2	; check if too low
	cmp	al,9
	jg	dec16in2	; check if too high
	cbw			; convert to word
;
	push	ax		; save digit
	mov	ax,dx		;
	mov	cx,10		; decimal power of 10
	mul	cx		; multiply
	mov	dx,ax		; store result in DX
	pop	axl		; restore digit
	add	dx,ax		; add in digit
	jmp 	dec16in1
;
dec16in2:
;
	pop	ax		; restore registers
	pop	cx
	ret			; return
;
dec16in	endp
;-------------------------dec16in routine ends---------------------------+
