In a message dated 28/09/04 18:41:44 GMT Daylight Time, 
[EMAIL PROTECTED] writes:

> 
> George Gwilt writes:
> 
> <>
> >Another place where using 68020+ instructions reduces the number of
> >instructions is in the conversion of long integers to Qdos floating point.
> <>
> 
> Demonstration, please!
> 
> Per
> 
> 

To set the long integer in D5 to QDOS fp format in D4.W and D5.L (exponent 
and mantissa) the normal 68000/8 way is given in the follwing subroutine.

se_3      move.w d5,d4
             move.l   d5,d1
             beq       se_5
             move.w  #$81f,d4
             add.l      d1,d1
             bvs        se_5
             subq.w   #1,d4
             move.l    d1,d5
             moveq    #16,d0
se_6      move.l    d5,d1
             asl.l      d0,d1
             bvs        se_7
             sub.w    d0,d4
             move.l   d1,d5
se_7      asr.w     #1,d0
             bne       se_6
se_5      rts

By using the 68020+ instruction BFFFO, which returns the first non zero bit 
in the range indicated) a good reduction is obtained. Not only is the number of 
instructions reduced but also the looping is eliminated.

t1           move.l     d5,d4
              beq         m1
              bpl          m2
              neg.l       d5
m2          bfffo        d5{1:31},d0
              subq.l     #1,d0
              lsl.l         d0,d5
              move.w   #$81f,d4
              sub.w     d0,d4
              tst.l        d4
              bpl         m1
              neg.l      d5
m1          rts


George


              
_______________________________________________
QL-Users Mailing List
http://www.quanta.org.uk/mailing.htm

Reply via email to