#compdef asmline

_arguments -S -s \
    '(H --rand)--rand[runs the code and initializes memory with random data _rdi--r9 can be dereferenced_.]:random heap:' \
    '(H -r --return)'{-r=-,--return=-}'[runs assembled code]:number of elements:' \
    '(H -p --print)'{-p,--print}'[print to stdout in ASCII-hex.]' \
    '(H -P --printfile -o --object)'{-P+,--printfile+}'[write raw binary into FILE]:filename:_files' \
    '(H -P --printfile -o --object)'{-o+,--object+}'[write raw binary machinecode to FILE.bin]:filename:_files' \
    '(H -c --chunk)'{-c+,--chunk+}'[set (write) chunk size. Will NOP-pad every chunk]:size of chunks to pad to:' \
    '(H -b --breaks)'{-b+,--breaks+}'[set (read) chunk size. Counts how many chunks break a boundary.]' \
    + '(mov)' \
    "(H)--nasm-mov-imm[nasm   mov imm: mov to 32-bit reg if possible.]" \
    "(H)--smart-mov-imm[smart  mov imm: if 64-bit padded, mov to 64-bit reg, to 32-bit otherwise.]" \
    "(H)--strict-mov-imm[strict mov imm: always mov to 64-bit reg.]" \
    + '(sib_index)' \
    "(H)--nasm-sib-index-base-swap[nasm swap sib; 'lea r15, \[rax+rsp\]' -> 'lea r15, \[rsp+rax\]']" \
    "(H)--strict-sib-index-base-swap[no swap sib; 'lea r15, \[rax+rsp\]' as is.]" \
    + '(sib_nobase)' \
    "(H)--nasm-sib-no-base[nasm scale sib; 'lea r15, \[2*rax\]' -> 'lea r15, \[rax+1*rax\]']" \
    "(H)--strict-sib-no-base[no scale sib; 'lea r15, \[2*rax\]' as is.]" \
    + '(sib_total)' \
    "(H sib_index sib_nobase)--nasm-sib[implies --nasm-sib-{no-base,index-base-swap}]" \
    "(H sib_index sib_nobase)--strict-sib[implies --strict-sib-{no-base,index-base-swap}]" \
    + '(mode_total)' \
    "(H sib_total mov)"{--nasm,-n}'[implies --nasm-{mov-imm,sib-{no-base,index-base-swap}}]' \
    "(H sib_total mov)"{--strict,-t}'[implies --strict-{mov-imm,-{no-base,index-base-swap}}]' \
    + '(H)' \
    '(* - input)'{-v,--version}'[Prints version information to stdout and exits.]' \
    '(* - input)'{-h,--help}'[Prints usage information to stdout and exits.]' \
    + '(input)' \
    ':assembly file:_files -g \*.\(asm\|s\|S\)' && ret=0
