Linux 0.11的get_free_page分析

unsigned long get_free_page(void)
{
register unsigned long __res asm("ax");

__asm__("std ; repne ; scasb\n\t"
    "jne 1f\n\t"
    "movb $1,1(%%edi)\n\t"
    "sall $12,%%ecx\n\t"
    "addl %2,%%ecx\n\t"
    "movl %%ecx,%%edx\n\t"
    "movl $1024,%%ecx\n\t"
    "leal 4092(%%edx),%%edi\n\t"
    "rep ; stosl\n\t"
    "movl %%edx,%%eax\n"
    "1:"
    :"=a" (__res)
    :"0" (0),"i" (LOW_MEM),"c" (PAGING_PAGES),
    "D" (mem_map+PAGING_PAGES-1)
    );
return __res;
}

 

00000880 <_get_free_page>:
880:    57                       push   %edi
881:    b8 00 00 00 00           mov    $0x0,%eax
886:    b9 00 0f 00 00           mov    $0xf00,%ecx
88b:    bf 1f 0f 00 00           mov    $0xf1f,%edi
890:    fd                       std   
891:    f2 ae                    repnz scas %es:(%edi),%al
893:    75 1e                    jne    8b3 <_get_free_page+0x33>
895:    c6 47 01 01              movb   $0x1,0x1(%edi)
899:    c1 e1 0c                 shl    $0xc,%ecx
89c:    81 c1 00 00 10 00        add    $0x100000,%ecx
8a2:    89 ca                    mov    %ecx,%edx
8a4:    b9 00 04 00 00           mov    $0x400,%ecx
8a9:    8d ba fc 0f 00 00        lea    0xffc(%edx),%edi
8af:    f3 ab                    rep stos %eax,%es:(%edi)
8b1:    89 d0                    mov    %edx,%eax
8b3:    5f                       pop    %edi
8b4:    c3                       ret   

转载于:https://www.cnblogs.com/fanzi2009/archive/2012/07/31/2617559.html

你可能感兴趣的:(Linux 0.11的get_free_page分析)