1 #ifndef __S390_DIV64 2 #define __S390_DIV64 3 4 /* for do_div "base" needs to be smaller than 2^31-1 */ 5 6 #define do_div(n, base) ({ \ 7 unsigned long long __n = (n); \ 8 unsigned long __r; \ 9 \ 10 asm (" slr 0,0\n" \ 11 " l 1,%1\n" \ 12 " srdl 0,1\n" \ 13 " dr 0,%2\n" \ 14 " alr 1,1\n" \ 15 " alr 0,0\n" \ 16 " lhi 2,1\n" \ 17 " n 2,%1\n" \ 18 " alr 0,2\n" \ 19 " clr 0,%2\n" \ 20 " jl 0f\n" \ 21 " slr 0,%2\n" \ 22 " ahi 1,1\n" \ 23 "0: st 1,%1\n" \ 24 " l 1,4+%1\n" \ 25 " srdl 0,1\n" \ 26 " dr 0,%2\n" \ 27 " alr 1,1\n" \ 28 " alr 0,0\n" \ 29 " lhi 2,1\n" \ 30 " n 2,4+%1\n" \ 31 " alr 0,2\n" \ 32 " clr 0,%2\n" \ 33 " jl 1f\n" \ 34 " slr 0,%2\n" \ 35 " ahi 1,1\n" \ 36 "1: st 1,4+%1\n" \ 37 " lr %0,0" \ 38 : "=d" (__r), "+m" (__n) \ 39 : "d" (base) : "0", "1", "2", "cc" ); \ 40 (n) = (__n); \ 41 __r; \ 42 }) 43 44 #endif 45