Grain of Salt - February 22nd, 2010 [entries|archive|friends|userinfo]
snauts

[ userinfo | sc userinfo ]
[ archive | journal archive ]

February 22nd, 2010

[Feb. 22nd, 2010|08:31 pm]
Ew, ARM arhitektūrai nav dalīšanas.
int div(int x, int y) {
    return x / y;
}

Ar gcc -O3 nokompilējas par:
000081ec <div>:
    81ec:       e52de004        push    {lr}
    81f0:       e24dd004        sub     sp, sp, #4      ; 0x4
    81f4:       eb000001        bl      8200 <__aeabi_idiv>
    81f8:       e28dd004        add     sp, sp, #4      ; 0x4
    81fc:       e8bd8000        pop     {pc}

00008200 <__aeabi_idiv>:
    8200:       e3510000        cmp     r1, #0		; 0x0
    8204:       e020c001        eor     ip, r0, r1
    8208:       0a00002f        beq     82cc <__aeabi_idiv+0xcc>
    820c:       42611000        rsbmi   r1, r1, #0      ; 0x0
    8210:       e2512001        subs    r2, r1, #1      ; 0x1
    8214:       0a00001f        beq     8298 <__aeabi_idiv+0x98>
    8218:       e1b03000        movs    r3, r0
    821c:       42603000        rsbmi   r3, r0, #0      ; 0x0
    8220:       e1530001        cmp     r3, r1
    8224:       9a00001e        bls     82a4 <__aeabi_idiv+0xa4>
    8228:       e1110002        tst     r1, r2
    822c:       0a000020        beq     82b4 <__aeabi_idiv+0xb4>
    8230:       e16f2f11        clz     r2, r1
    8234:       e16f0f13        clz     r0, r3
    8238:       e0420000        sub     r0, r2, r0
    823c:       e3a02001        mov     r2, #1		; 0x1
    8240:       e1a01011        lsl     r1, r1, r0
    8244:       e1a02012        lsl     r2, r2, r0
    8248:       e3a00000        mov     r0, #0		; 0x0
    824c:       e1530001        cmp     r3, r1
    8250:       20433001        subcs   r3, r3, r1
    8254:       21800002        orrcs   r0, r0, r2
    8258:       e15300a1        cmp     r3, r1, lsr #1
    825c:       204330a1        subcs   r3, r3, r1, lsr #1
    8260:       218000a2        orrcs   r0, r0, r2, lsr #1
    8264:       e1530121        cmp     r3, r1, lsr #2
    8268:       20433121        subcs   r3, r3, r1, lsr #2
    826c:       21800122        orrcs   r0, r0, r2, lsr #2
    8270:       e15301a1        cmp     r3, r1, lsr #3
    8274:       204331a1        subcs   r3, r3, r1, lsr #3
    8278:       218001a2        orrcs   r0, r0, r2, lsr #3
    827c:       e3530000        cmp     r3, #0		; 0x0
    8280:       11b02222        lsrsne  r2, r2, #4
    8284:       11a01221        lsrne   r1, r1, #4
    8288:       1affffef        bne     824c <__aeabi_idiv+0x4c>
    828c:       e35c0000        cmp     ip, #0		; 0x0
    8290:       42600000        rsbmi   r0, r0, #0      ; 0x0
    8294:       e12fff1e        bx      lr
    8298:       e13c0000        teq     ip, r0
    829c:       42600000        rsbmi   r0, r0, #0      ; 0x0
    82a0:       e12fff1e        bx      lr
    82a4:       33a00000        movcc   r0, #0		; 0x0
    82a8:       01a00fcc        asreq   r0, ip, #31
    82ac:       03800001        orreq   r0, r0, #1      ; 0x1
    82b0:       e12fff1e        bx      lr
    82b4:       e16f2f11        clz     r2, r1
    82b8:       e262201f        rsb     r2, r2, #31     ; 0x1f
    82bc:       e35c0000        cmp     ip, #0		; 0x0
    82c0:       e1a00233        lsr     r0, r3, r2
    82c4:       42600000        rsbmi   r0, r0, #0      ; 0x0
    82c8:       e12fff1e        bx      lr
    82cc:       e52de008        str     lr, [sp, #-8]!
    82d0:       eb000007        bl      82f4 <__div0>
    82d4:       e3a00000        mov     r0, #0		; 0x0
    82d8:       e49df008        ldr     pc, [sp], #8
link3 comments|post comment

navigation
[ viewing | February 22nd, 2010 ]
[ go | Previous Day|Next Day ]