Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

_aullrem

aullrem._aullrem
pub fn _aullrem() callconv(.naked) void

File

lib/compiler_rt/aullrem.zig:29

Code

pub fn _aullrem() callconv(.naked) void {
    @setRuntimeSafety(false);

    // The stack layout is:
    // ESP+16 divisor (hi)
    // ESP+12 divisor (low)
    // ESP+8 dividend (hi)
    // ESP+4 dividend (low)
    // ESP   return address

    asm volatile (
        \\  push   %%ebx
        \\  mov    0x14(%%esp),%%eax
        \\  or     %%eax,%%eax
        \\  jne    1f
        \\  mov    0x10(%%esp),%%ecx
        \\  mov    0xc(%%esp),%%eax
        \\  xor    %%edx,%%edx
        \\  div    %%ecx
        \\  mov    0x8(%%esp),%%eax
        \\  div    %%ecx
        \\  mov    %%edx,%%eax
        \\  xor    %%edx,%%edx
        \\  jmp    6f
        \\ 1:
        \\  mov    %%eax,%%ecx
        \\  mov    0x10(%%esp),%%ebx
        \\  mov    0xc(%%esp),%%edx
        \\  mov    0x8(%%esp),%%eax
        \\ 2:
        \\  shr    %%ecx
        \\  rcr    %%ebx
        \\  shr    %%edx
        \\  rcr    %%eax
        \\  or     %%ecx,%%ecx
        \\  jne    2b
        \\  div    %%ebx
        \\  mov    %%eax,%%ecx
        \\  mull   0x14(%%esp)
        \\  xchg   %%eax,%%ecx
        \\  mull   0x10(%%esp)
        \\  add    %%ecx,%%edx
        \\  jb     3f
        \\  cmp    0xc(%%esp),%%edx
        \\  ja     3f
        \\  jb     4f
        \\  cmp    0x8(%%esp),%%eax
        \\  jbe    4f
        \\ 3:
        \\  sub    0x10(%%esp),%%eax
        \\  sbb    0x14(%%esp),%%edx
        \\ 4:
        \\  sub    0x8(%%esp),%%eax
        \\  sbb    0xc(%%esp),%%edx
        \\  neg    %%edx
        \\  neg    %%eax
        \\  sbb    $0x0,%%edx
        \\ 6:
        \\  pop    %%ebx
        \\  ret    $0x10
    );
}