Category : Assembly Language Source Code
Archive   : ASM_SUBR.ZIP
Filename : DEC8OUT

 
Output of file : DEC8OUT contained in archive : ASM_SUBR.ZIP
;-------------------------dec8out routine begins--------------------------+
; from BLUEBOOK OF ASSEMBLY ROUTINES FOR IBM PC & XT.
; page : 59
;
; NAME DEC8OUT
; ROUTINE FOR Conversion from 8-bit Binary to ASCII decimal
;
; FUNCTION: This routine accepts a 8-bit binary number in the DL register
; and converts it to ASCII decimal form which is sent to the std input
; device.
;
; INPUT: Upon entry an 8-bit binary number is in DL
; OUTPUT: A string of ASCII digits representing a decimal number is
; stored in a buffer called TBUFF and then sent out through the std output
; device.
; REGISTERS USED: No registers are modified. DL is used for input.
; SEGMENTS REFERENCED: DATAS is a data segment which contains TBUFF.
; ROUTINES CALLED: STDOUT
; SPECIAL NOTES: None
;
; ROUTINE TO CONVERT FROM INTERNAL 8-BIT BINARY TO ASCII DECIMAL.
;
dec8out proc far
;
push ds ; save registers
push di
push dx
push cx
push ax
;
mov ax,datas ; point to the data segment
mov ds,ax
;
; binary number is in DL
;
; Put the digits in a buffer
;
mov cx,0 ; initialize a counter
mov di,offset tbuff ; point to a buffer
;
dec8out1:
push cx ; save the count
mov al,dl ; AX has the numerator
mov ah,0 ; clear upper half
mov cl,10 ; divisor of 10
div cl ; divide
mov dl,al ; get quotient
mov al,ah ; get remainder
;
add al,30h ; increase to ASCII
mov [di],al ; put in tbuff
inc di ; point to next byte
;
pop cx ; restore count
inc cx ; count the digit
cmp dl,0 ; done ?
jnz dec8out1
;
; dump tbuff out
;
dec8out2
dec di ; back up through the tbuff
mov al,[di] ; get the byte from the tbuff
call stdout ; send it
loop dec8out2
;
pop ax ; restore registers
pop cx
pop dx
pop di
pop ds
ret ; return
;
dec8out endp
;-------------------------dec8out routine ends---------------------------+


  3 Responses to “Category : Assembly Language Source Code
Archive   : ASM_SUBR.ZIP
Filename : DEC8OUT

  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/