home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
magazine
/
drdobbs
/
1991
/
08
/
decconv.asc
< prev
next >
Wrap
Text File
|
1991-07-23
|
896b
|
44 lines
_DECIMAL FRACTIONAL CONVERSION_
by Don Morgan
[EXAMPLE 1: Fractional Conversion Routine]
mantissa word ?
dec_frac word ?
;
; frac- conversion of decimal fractional part to hex
; enter with packed decimal word in ax
; returns with result in dx\
;DS is assumed to point into the Data Segment
;
frac proc
mov cx,10h ;number of bits in resulting mantissa
cnvt:
add al,al ;could add to self, we will see
daa
mov bl,al
mov al,ah
jnc nc1
add al,al ;could add to self, we will see
daa
inc al
jmp short nc2
nc1:
add al,al ;could add to self, we will see
daa
nc2:
mov ah,al
mov al,bl
rcl dx,1
loop cnvt
sub ax,5000h
jc end_frac
inc dx ;for round off
end_frac:
mov word ptr mantissa,dx
ret
frac end