home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
RBBS in a Box Volume 1 #3.1
/
RBBSIABOX31.cdr
/
msch
/
ms_ieee.asm
< prev
next >
Wrap
Assembly Source File
|
1983-01-21
|
3KB
|
84 lines
; 2) From: ST0030 50-Lines
; On:15 JAN 1983 At: 02:22
; To: ST3891 Cc: ST0030
; Subject: REAL NUMBER HELP
;
;
; MIKE,
;
; THE FOLLOWING PROGRAMS (asm) WILL CONVERT TO AND FROM MICROSOFT
; REAL NUMBER AND THE IEEE STANDARD. THE ONLY DIFFERENCE IS THE EXPONENT
; BIAS.
; KEEP IN MIND THAT IN MEMORY THE FIRST THREE BYTES ARE THE MANTISSA
; AND THE 4TH BYTE IS THE EXPONENT.
;
; GOOD LUCK, DAVE BAKER ST0030
;
;
TITLE CONVERT IEEE/MICROSOFT REAL FORMATS
NAME CONV_REAL
;
BSEG SEGMENT WORD PUBLIC 'CODE'
ASSUME CS:BSEG,DS:BSEG,ES:BSEG,SS:BSEG
;
;
M2IREAL PROC NEAR
PUBLIC M2IREAL
;
; ENTRY - DX:AX = MICROSOFT REAL NUMBER
; EXIT - DX:AX = IEEE REAL NUMBER
;
PUSH CX
PUSH BX
MOV CX,AX ; SAVE LS PART
MOV BX,DX ; AND MS PART
XOR DX,DX
MOV AL,BH ; AL = MICROSOFT EXPONENT
SUB AL,2
SHR AL,1 ; SHIFT EXPONENT
JNC M2_00
MOV DL,80H ; SEL BIT 0 OF EXPONENT
M2_00: MOV AH,BL ; GET MICROSOFT SIGN
AND AH,80H
OR AL,AH ; AL = IEEE EXPONENT AND SIGN
MOV DH,AL
AND BL,7FH
OR DL,BL
MOV AX,CX ; DS:AX = IEEE FORMAT
POP BX
POP CX
RET
M2IREAL ENDP
;
;
I2MREAL PROC NEAR
PUBLIC I2MREAL
;
; ENTRY - DS:AX = IEEE REAL NUMBER
; EXIT - DS:AX = MICROSOFT REAL NUMBER
;
PUSH CX
PUSH BX
MOV BX,DX ; SAVE MS PART
MOV CX,AX ; AND LS PART
XOR DX,DX ; CLEAR DX
MOV AL,BH ; GET EXP AND SIGN
SHL AL,1 ; SHIFT EXPONENT
JNC I2_00
MOV DL,80H
I2_00: TEST BL,80H
JZ I2_01
OR AL,1
I2_01: ADD AL,2 ; AL - IEEE EXPONENT
MOV DH,AL
AND BL,7FH
OR DL,BL
MOV AX,CX
POP BX
POP CX
RET
I2MREAL ENDP
BSEG ENDS
END