Mlt
Listing index
Norm
Routine:        Mult
Function:       Multiply two floating point numbers
Called by:      Divide, Input, Meas, Print, Read, Visc
Calls:          Mlt, Norm, Regld, Regsv
Entry:          BC points to #1, DE points to #2, HL points to result
Exit:           Result stored at HL
Preserved:      All


MULT    CALL    REGSV
        PUSH    HL
        PUSH    BC
        LD      IX,MLTBUF
        CALL    MULT7
; Move number 2 to mltbuf.
        LD      A,(DE)
        LD      (MULTE),A
; Exponents are held in Multe.
        POP     DE
        CALL    MULT7
; Move number 1 to Mltbuf+4.
        LD      A,(DE)
        LD      B,A
        LD      A,(MULTE)
        ADD     A,B
; Add the exponents.
        LD      (MULTE),A
        LD      A,(MLTBUF+3)
        BIT     7,A
        JR      NZ,MULT1
; Check the sign of number2: the B register is set to 0 if positive, 255 if negative.
        LD      B,0
        SET     7,A
        LD      (MLTBUF+3),A
        JR      MULT2
MULT1   LD      B,255
MULT2   LD      A,(MLTBUF+7)
        BIT     7,A
        JR      NZ,MULT3
        SET     7,A
        LD      (MLTBUF+7),A
; Check the sign of number 1, if it is positive then the result sign is that of number two, otherwise invert the sign. The sign is held in Mltsgn.
        LD      A,B
        JR      MULT4
MULT3   LD      A,B
        CPL
MULT4   LD      (MLTSGN),A
; 32 bit multiplication is performed by Mlt, and the result normalised by calling subroutine Norm.
        CALL    MULT
        CALL    NORM
        LD      A,(MLTSGN)
        OR      A
        JR      NZ,MULT5
        RES     7,(IX+15)
; Insert the sign bit into the result.
MULT5   POP     HL
        LD      IX,MLTBUF+12
        LD      B,4
; Move the result to the location pointed to by HL.
MULT6   LD      A,(IX)
        LD      (HL),A
        INC     HL
        INC     IX
        DJNZ    MULT6
        LD      A,(MULTE)
; Store exponent byte also.
        LD      (HL),A
        CALL    REGLD
        RET
MULT7   LD      B,4
; Subroutine Mult7 is used to transfer the two numbers into space at Mltbuf.
MULT8   LD      A,(DE)
        LD      (IX),A
        INC     DE
        INC     IX
        DJNZ    MULT8
        LD      A,(DE)
        RET
 
Mlt
Listing index
Norm