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

 
Output of file : TFP2SFP contained in archive : ASM_SUBR.ZIP
;-------------------------tfp2sfp routine begins--------------------------+
; ROUTINE FOR CONVERSION FROM TEMPORARY TO SINGLE PRECISION
;
; from BLUEBOOK OF ASSEMBLY ROUTINES FOR IBM PC & XT.
; page : 80
;
; NAME TFP2SFP
;
; FUNCTION: This routine conveerts from temporary binary floating point
; to single precision floating point.
;
; INPUT: Upon entry a number is stored in temporary binary floating point
; form in FPTEMP1. The temporary binary floating point number has a 72-bit
; binary mantissa with 8 bits to the left of those for internal use, a
; signal byte, and a 16-bit two's complement binary exponent (See fig 5-2).
;
; OUTPUT: Upon exit a single precision floating point number is stored in
; SFPBUFF. The single precision floating point number has a 24-bit binary
; mantissa, a sign bit, and an 8-bit exponent biased by 128 (See fig 5-3).
;
; REGISTERS USED: AX and DX are modified.
;
; SEGMENTS REFERENCED: Upon entry the data segment must contain the
; messages INTERNAL, OVERFLOW and UNDERFLOW, and storage for the temporary
; binary floating point number FPTEMP1 and the single precision floating
; point number SFPBUFF.
;
; ROUTINES CALLED: STDSPACE, MESSOUT and HEX16OUT
;
; SPECIAL NOTES: Equates are used to shorten address fields. This is a
; near procedure needed by FPIN. Include the file FPCEQU_S at assembly.
;
; ROUTINE TO CONVERT FROM TEMP FLOATING POINT TO SINGLE PRECISION
; FLOATING POINT
;
tfp2sfp proc near
;
; move mantissa
mov ax,fptemp1w4 ; below word
rcl ax,1 ; carry for roundup
mov ax,fptemp1w6 ; low word
adc ax,0 ; low word + carry
mov sfpbuffw0,ax ; put in place
mov dx,ax ; check for zero
;
mov ax,fptemp1w8
or dx,ax ; check this part too
and ax,007Fh ; just bottom 7 bits
mov sfpbuffw2,ax ; put in place
;
; move sign bit
mov al,fptemp1b10 ; byte 10 is sign
and al,80h
or sfpbuffb2,al ; bit 7 is sign
;
; move exponent
mov ax,fptemp1w11 ; 16-bit two's complement exponent
cmp ax,-128 ; too low ?
jl ftp2sfp2 ; error message
cmp ax,127 ; too high ?
jg tfp2sfp3 ; error message
;
add ax,80h ; bias
cmp dx,0 ; was mantissa 0 ?
jne tfp2sfp
mov al,0 ; then -128 exponent
;
tfp2sfp1
mov sfpbuffb3,al ; put biased byte back
;
; normal return
;
; show hex for debugging
lea si,internal ; point to message
call stdmessout ; display message
;
mov dx,sfpbuffw2 ; upper word
call hex16out ; show it
;
mov dx,sfpbuffw0 ; lower word
call hex16out ; show it
;
call stdspace ; skip a space
clc
ret ; return
;
; underflow error
tfp2sfp3:
lea si,underflow ; point to message
jmp tfp2sfp4
;
tfp2sfp4:
call stdmessout ; send message
stc ; set carry
ret ; return
;
tfp2sfp endp
;-------------------------tfp2sfp routine ends---------------------------+



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

  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/