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

 
Output of file : BCDOUT contained in archive : ASM-SUBR.ZIP
;-------------------------bcdout routine begins--------------------------+
; from BLUEBOOK OF ASSEMBLY ROUTINES FOR IBM PC & XT.
; page : 66
;
; NAME BCDOUT
; ROUTINE FOR conversion from BCD to ASCII decimal
;
; FUNCTION: This routine converts a 36-digit number sstored in BCD form
; to ASCII decimal form which is sent to the std I/O device.
;
; INPUT: Upon entry a 36-digit number is stored in an 18-byte BCD buffer
; called BCDBUFF in the DATAS data segment.
;
; OUTPUT: A string of ASCII digits representing a decimal number is
; stored in a buffer called TBUFF and then sent out through a standard
; output device.
;
; REGISTERS USED: No registers are modified.
; SEGMENTS REFERENCED: DATAS is a data segment containing BCDBUFF
; and TBUFF.
;
; ROUTINES CALLED: STDOUT
; SPECIAL NOTES: None
;
; ROUTINE FOR CONVERSION FROM BCD TO ASCII DECIMAL
;
bcdout proc far
;
push ds ; save registers
push si
push dx
push cx
push ax
;
; set up a data segment
mov ax,datas ; point to data segment
mov ds,ax
;
mov cx,18 ; for a count of 18
lea si,bcdbuff ; point to bcd buffer
add si,17 ; point to end of bcd buffer
mov dh,0 ; clear flag for leading zeros
;
bdcout1:
push cx ; save count
mov al,[si] ; get BCD byte
dec si ; and point to next
mov dl,al ; save it
;
; upper digit
mov cl,4 ; for a count of four
rol al,cl ; rotate byte
and al,0Fh ; just the digit
or dh,al ; leading zeros?
jz bcdout2 ; if so skip digit
add al,30h ; make it ASCII
call stdout ; send it
;
bcdout2:
pop cx ; restore count
cmp cx,1 ; last digit ?
jnz bcdout3 ; skip if not
mov dh,0FFh ; set flag if so
;
bcdout3:
push cx ; save count
;
mov al,dl ; get byte back
;
; lower digit
and al,0Fh ; just the digit
or dh,al ; leading zeros?
jz bcdout4 ; if so skip digit
add al,30h ; make is ASCII
call stdout ; send it
;
bcdout4:
;
pop cx ; restore loop count
loop bcdout1
;
pop ax ; restore registers
pop cx
pop dx
pop si
pop ds
ret ; return
;
bcdout endp
;-------------------------bcdout routine ends---------------------------+


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

  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/