retflt


* Do whats necessary to return float to S*Basic
* ©pjwitte 2oo6

        section code

        xdef retflt

        xref resrir

        include dev8_keys_sbasic

*
retflt
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Reserve room, convert long to float and return it to S*Basic
* input :
*       d1.l = return value
*       stack must be in a tidy ("empty") state prior to this call
*
* return: cc = set
*       errors: returns directly to BASIC with d0 = 0 (Qdos) or OM (Smsq/e)
*
        move.l d1,d4            save return value
        moveq #6,d1             we need 6 bytes
        bsr resrir

*
lin2flt
*
* Convert a long integer in d1 to a floating point number on a stack
*
* input :
*        d4.l = long integer to convert
*        a1  -> six free bytes on stack
*
* return :   cc set
*        a1  -> floating point number on stack
*        d4   = ???
*        errors: always 0
*
        moveq   #0,d0
        tst.l   d4              if 0 skip all this
        beq.s   l2f_ret

        move.w  #$81F,d0        exponent bias
*
lin_loop
        add.l   d4,d4           normalise: loop until
        dbvs    d0,lin_loop       sign changes (fiddling exp all the while)

        roxr.l  #1,d4           back one restoring last bit shifted out

l2f_ret
        move.w  d0,0(a6,a1.l)   that's exponent done
        move.l  d4,2(a6,a1.l)   that's the mantissa done

        moveq #ar.float,d4      return code = float

        moveq #0,d0
        rts

*
        end

Back to Index
HTML generated by the amazing asm2htm !
2006 Sep 30 16:55:02