Category : Assembly Language Source Code
Archive   : ASM-SUBR.ZIP
Filename : DEC16IN

 
Output of file : DEC16IN contained in archive : ASM-SUBR.ZIP
;-------------------------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---------------------------+


  3 Responses to “Category : Assembly Language Source Code
Archive   : ASM-SUBR.ZIP
Filename : DEC16IN

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/