home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / math / mul_f.asm < prev    next >
Assembly Source File  |  1986-01-17  |  3KB  |  63 lines

  1. MUL_F    PROC     NEAR
  2. ;***************************************************************
  3. ;                        floating point
  4. ;                    multiplication routine
  5. ;***************************************************************
  6.          PUSH     SI              ;save index registers
  7.          PUSH     DI
  8.          SUB      DX,DX           ;clear work registers
  9.          MOV      AX,DX
  10.          MOV      BX,DX
  11.          MOV      CX,DX
  12. ;                            check for zero operand
  13.          OR       DX,[DI]+2       ;OP1 high word in DX
  14.          JZ       MF2             ;zero only if operand is 0
  15.          OR       CX,[SI]+2       ;OP2 high word in CX
  16.          JZ       MF2
  17. ;                            compute exponent
  18.          MOV      AL,DH           ;E1 in AX
  19.          MOV      BL,CH           ;E2 in BX
  20.          SUB      BX,128          ;subtract bias
  21.          ADD      AX,BX           ;E=E1+E2+bias
  22. ;
  23.          MOV      BX,[SI]         ;get OP2 low word in BX
  24.          MOV      SI,AX           ;save exponent in SI
  25.          MOV      AX,[DI]         ;get OP1 low word in AX
  26.          SUB      DH,DH           ;clear high bytes
  27.          MOV      CH,DH           ;M1 is DL:AX; M2 is CL:BX
  28. ;                            compute result sign
  29.          MOV      DI,DX
  30.          XOR      DI,CX
  31.          AND      DI,10000000B    ;isolate sign bit in DI
  32. ;                            restore leading ones
  33.          OR       DL,10000000B
  34.          OR       CL,10000000B
  35. ;                            multiply mantissas
  36.          CALL     MUL32           ;47-48 bit product in AX:CX:BX
  37. ;
  38.          OR       AX,AX           ;is it normalized?
  39.          JS       MF1
  40. ;                            normalize product
  41.          SHL      BX,1            ;shift it left 1
  42.          RCL      CX,1
  43.          RCL      AX,1
  44.          SUB      SI,1            ;and decrement exponent
  45. ;                            check for overflow
  46. MF1:     CMP      SI,255
  47.          JG       MF3             ;exit if exponent > 255
  48. ;                            check for underflow
  49.          CMP      SI,0
  50.          JLE      MF4             ;exit if exponent <= 0
  51. ;                            reformat for output
  52.          MOV      DL,AH           ;mantissa in DL:AX
  53.          MOV      AH,AL
  54.          MOV      AL,CH
  55.          MOV      DH,CL           ;trailing bits in DH
  56.          MOV      CX,BX           ;and CX
  57.          MOV      BX,SI           ;exponent in BH
  58.          MOV      BH,BL
  59.          JMP      R0              ;ROUND in addition routine
  60. MF2:     JMP      FINISH
  61. MF3:     JMP      OVER_F
  62. MF4:     JMP      UNDER_F
  63. MUL_F    ENDP