; > quotient.arm.s ; Copyright: Robert J. Harley, 02-Feb-1998 ; Contact: Robert.Harley@inria.fr ; Legalese: You can do what you want with this code as long as this ; comment stays attached in a prominent position in ; human-readable form, any distribution of this or ; derived products is made without profit and includes ; full source and is subject to the same conditions. ; ; To use this with ecdl32bit.c, declare ; ; extern void quotientNew(u96 *pz, u96 *px, u96 *py); ; ; then delete inverse() and replace quotient() with: ; : static INLINE u96 quotient(u96 x, u96 y) { ; u96 z; ; ; quotientNew(&z, &x, &y); ; ; return z; ; } /* end quotient */ ; ; You might have to munge the syntax a little depending on your assembler. vh = r0 bh = r1 bm = r2 bl = r3 uh = r4 um = r5 ul = r6 ah = r7 am = r8 al = r9 sl = r10 fp = r11 ip = r12 vm = ip sp = r13 lr = r14 vl = lr pc = r15 .text .align 4 .global quotientNew ; Compute u/a modulo 1+x^38+x^89, degree a,u < 89, a != 0. ; Is the ARM a beautiful chip or what? quotientNew: mov ip, sp stmfd sp!, { r0, r4-r9, fp, ip, lr, pc } sub fp, ip, #4 ldmia r1, { uh, um, ul } ldmia r2, { ah, am, al } mov bh, #33554432 mov bm, #64 mov bl, #1 mov vh, #0 mov vm, #0 mov vl, #0 tst al, #1 beq loop4 mov r0, r0 ; align main loop mov r0, r0 mov r0, r0 loop1: eor bh, bh, ah eor bm, bm, am eor bl, bl, al eor vh, vh, uh eor vm, vm, um eor vl, vl, ul loop2: movs bh, bh, lsr #1 movs bm, bm, rrx mov bl, bl, rrx movs vh, vh, lsr #1 movs vm, vm, rrx movs vl, vl, rrx eorcs vh, vh, #16777216 eorcs vm, vm, #32 tst bl, #1 beq loop2 cmp ah, bh cmpeq am, bm cmpeq al, bl blo loop1 beq out loop3: eor ah, ah, bh eor am, am, bm eor al, al, bl eor uh, uh, vh eor um, um, vm eor ul, ul, vl loop4: movs ah, ah, lsr #1 movs am, am, rrx mov al, al, rrx movs uh, uh, lsr #1 movs um, um, rrx movs ul, ul, rrx eorcs uh, uh, #16777216 eorcs um, um, #32 tst al, #1 beq loop4 cmp ah, bh cmpeq am, bm cmpeq al, bl blo loop1 bhi loop3 out: ldr r0, [fp, #-40] str uh, [r0, #0] str um, [r0, #4] str ul, [r0, #8] ldmea fp, { r4-r9, fp, sp, pc }^ ; end quotient.arm.s