[Freemint-list] Broken udelay() for m68000

Miro Kropáček miro.kropacek at gmail.com
Mon Oct 16 05:57:20 MSD 2017


After some study, it seems it isn't that bad (I think most of you were
aware of it): the delay functions *are* calibrated, quite precisely
actually. That loops_per_sec variable is actually a result of such
calibration.

So the problem is that m68000 code ignores it. I think David is right,
the magic
formula used in the linux kernel
<https://github.com/torvalds/linux/blob/master/arch/m68k/include/asm/delay.h#L48>
is
supposed to work on all m68ks, not only ColdFire (see the comment, "simpler
m68k").

On m68000, the code is quite chatty:

     3a4:       206a 001c       moveal %a2@(28),%a0
     3a8:       4878 00c8       pea c8 <oldSR-0x1c>
     3ac:       2f10            movel %a0@,%sp at -
     3ae:       4e93            jsr %a3@
     3b0:       508f            addql #8,%sp
     3b2:       720b            moveq #11,%d1
     3b4:       e2a8            lsrl %d1,%d0
     3b6:       2200            movel %d0,%d1
     3b8:       d280            addl %d0,%d1
     3ba:       d280            addl %d0,%d1
     3bc:       2801            movel %d1,%d4
     3be:       e98c            lsll #4,%d4
     3c0:       d284            addl %d4,%d1
     3c2:       2801            movel %d1,%d4
     3c4:       e18c            lsll #8,%d4
     3c6:       d284            addl %d4,%d1
     3c8:       e789            lsll #3,%d1
     3ca:       d081            addl %d1,%d0
     3cc:       ec88            lsrl #6,%d0

(a3 points to ___udivsi3)

However we should use this code also for 68060 and not only for CF as mul
ea,dr:dq is not implemented on 060 (leading to a huge performance
bottleneck I imagine).

-- 
MiKRO / Mystic Bytes
http://mikro.atari.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.atariforge.org/pipermail/freemint-list/attachments/20171016/a9d78789/attachment-0001.html 


More information about the Freemint-list mailing list