Bill Allombert on Sun, 26 Mar 2006 13:54:14 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

m68k inline assembly kernel


Hello PARI-dev,

I have just commited a inline level 0 assembly kernel for
Motorola 68k processors to PARI CVS.

For the nostalgic among you, I join the core of the files below.

I hope that, like me, you will feel much youger!

Cheers,
Bill.


#define LOCAL_HIREMAINDER  register ulong hiremainder
#define LOCAL_OVERFLOW     register ulong overflow

#define addll(a,b)                                              \
({ ulong __value, __arg1 = (a), __arg2 = (b);                   \
   __asm__ ("add.l %2,%0 ; addx.l %1,%1"                        \
        : "=&d" (__value), "=d" (overflow)                      \
        : "rm" (__arg1), "0" (__arg2), "1" (0UL)                \
        : "cc");                                                \
  __value;                                                      \
})

#define addllx(a,b)                                             \
({ ulong __value, __arg1 = (a), __arg2 = (b), __temp;           \
   __asm__ ("neg.l %2 ; addx.l %4,%0 ; addx.l %1,%1"            \
        : "=d" (__value), "=d" (overflow), "=d" (__temp)        \
        : "0" (__arg1), "d" (__arg2), "2" (overflow), "1" (0UL) \
        : "cc");                                                \
  __value;                                                      \
})

#define subll(a,b)                                              \
({ ulong __value, __arg1 = (a), __arg2 = (b);                   \
   __asm__ ("sub.l %3,%0 ; addx.l %1,%1"                        \
        : "=&d" (__value), "=d" (overflow)                      \
        : "0" (__arg1), "rm" (__arg2), "1" (0UL)                \
        : "cc");                                                \
  __value;                                                      \
})

#define subllx(a,b)                                             \
({ ulong __value, __arg1 = (a), __arg2 = (b), __temp;           \
   __asm__ ("neg.l %2 ; subx.l %4,%0 ; addx.l %1,%1"            \
        : "=d" (__value), "=d" (overflow), "=d" (__temp)        \
        : "0" (__arg1), "d" (__arg2), "2" (overflow), "1" (0UL) \
        : "cc");                                                \
  __value;                                                      \
})

#define mulll(a, b)                                                     \
({                                                                      \
  ulong __arg1 = (a), __arg2 = (b), __value;                            \
  __asm__ ("mulu.l %2, %0:%1"                                           \
           : "=d" (hiremainder), "=d" (__value)                         \
           : "md" (__arg1) , "1" (__arg2)                               \
           : "cc");                                                     \
  __value;                                                              \
})

#define addmul(a, b)                                                    \
({                                                                      \
  ulong __arg1 = (a), __arg2 = (b), __value;                            \
  __asm__ ("mulu.l %2, %0:%1; add.l %4,%1; addx.l %5,%0"                \
           : "=&d" (hiremainder), "=&d" (__value)                       \
           : "md" (__arg1), "1" (__arg2), "d" (hiremainder), "d" (0UL)  \
           : "cc" );                                                    \
  __value;                                                              \
})

#define bfffo(a)                                                        \
({                                                                      \
  ulong __arg1 = (a), __value;                                          \
  __asm__ ("bfffo %1{#0:#0}, %0"                                        \
           : "=d" (__value)                                             \
           : "md" (__arg1)                                              \
           : "cc" );                                                    \
  __value;                                                              \
})

#define divll(a, b)                                                     \
({                                                                      \
  ulong __arg2 = (b), __value =(a);                                     \
  __asm__ ("divu.l %2, %0:%1"                                           \
           : "+d" (hiremainder), "+d" (__value)                         \
           : "md" (__arg2)                                              \
           : "cc");                                                     \
  __value;                                                              \
})