Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Why don't you code in assembly?

Name: Anonymous 2012-12-30 1:55

 

Name: Anonymous 2013-01-01 23:31

>>30
Ok, here is an O(log n) implementation in Assembly. I don't have much exp with asm, so this may not be very pretty.


fib:
        mov     eax, [esp+4]
        test    eax, eax
        jnz     .impl
        mov     eax, 0
        mov     edx, 1
        ret
.impl:
        push    eax
        sar     eax, 1
        push    eax
        call    fib

        mov     ecx, eax
        imul    ecx, edx
        sal     ecx, 1

        imul    eax, eax
        imul    edx, edx

        pop     ebx
        pop     ebx
        test    ebx, 1
        jz      .even
.odd:
        add     eax, edx
        add     edx, ecx
        ret
.even:
        add     edx, eax
        neg     eax
        add     eax, ecx
        ret

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List