Skip to content

Minimize the assembly code #1

@vmmon

Description

@vmmon

There are some but not all possible size optimizations applied to the assembly code.

One can:

  • only work on 32-bit registers - they are automatically zero-extended to 64-bit
  • update only parts of the lower registers
  • assume the output of the syscall

With them the code boils down to 23 bytes:

  401000:       31 c0                   xor    %eax,%eax
  401002:       b0 01                   mov    $0x1,%al
  401004:       89 c7                   mov    %eax,%edi
  401006:       be 00 10 40 00          mov    $0x401000,%esi
  40100b:       31 d2                   xor    %edx,%edx
  40100d:       b2 07                   mov    $0x7,%dl
  40100f:       0f 05                   syscall
  401011:       31 ff                   xor    %edi,%edi
  401013:       b0 3c                   mov    $0x3c,%al
  401015:       0f 05                   syscall

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions