;-------------------------bin16in routine begins--------------------------+
; from BLUEBOOK OF ASSEMBLY ROUTINES FOR IBM PC & XT.
;         page : 42
;
; NAME BIN16IN
; ROUTINE FOR conversion from ASCII binary to internal 16-bit binary
;
; FUNCTION: This routine accepts a binary number from the std input device
; and converts it to internal 16-bit binary form.
; INPUT: The individual digits of the binary number are received in ASCII
; through a call to a std I/O routine.  The valid digits are 0 and 1.  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 moified.  It returns the result.
; SEGMENTS REFERENCED:  None
; ROUTINES CALLED:  STDIN
; SPECIAL NOTES: None
;
; ROUTINE TO CONVERT FROM ASCII BINARY TO INTERNAL 16-BIT BINARY
;
bin16in	proc	far
;
	push	ax		; save registers
;
	mov	dx,0		; initialize dx as zero
;
bin16in1:
	call	stdin		; digit comes in thru al
	sub	al,30h		; subtract 30 hex
	jl	bin16in2	; check if too low
	cmp	al,1
	jg	bin16in2	; check if too high
	cbw			; convert to word
;
	sal	dx,1		; shift dx left once
	add	dx,ax		; add in digit
	jmp	bin16in1
;
bin16in2:
;
	pop	ax		; restore registers
	ret			; return
;
bin16in	endp
;-------------------------bin16in routine ends---------------------------+
