Packages and Binaries:

nasm

Netwide Assembler. NASM will currently output flat-form binary files, a.out, COFF and ELF Unix object files, and Microsoft 16-bit DOS and Win32 object files.

Also included is NDISASM, a prototype x86 binary-file disassembler which uses the same instruction table as NASM.

NASM is released under the GNU Lesser General Public License (LGPL).

Installed size: 3.26 MB
How to install: sudo apt install nasm

Dependencies:
  • dpkg | install-info
  • libc6
nasm

The Netwide Assembler, a portable 80x86 assembler

root@kali:~# nasm -h
Usage: nasm [-@ response_file] [options...] [--] filename
       nasm -v (or --v)

Options (values in brackets indicate defaults):

    -h            show this text and exit (also --help)
    -v (or --v)   print the NASM version number and exit
    -@ file       response file; one command line option per line

    -o outfile    write output to outfile
    --keep-all    output files will not be removed even if an error happens

    -Xformat      specify error reporting format (gnu or vc)
    -s            redirect error messages to stdout
    -Zfile        redirect error messages to file

    -M            generate Makefile dependencies on stdout
    -MG           d:o, missing files assumed generated
    -MF file      set Makefile dependency file
    -MD file      assemble and generate dependencies
    -MT file      dependency target name
    -MQ file      dependency target name (quoted)
    -MP           emit phony targets

    -f format     select output file format
       bin                  Flat raw binary (MS-DOS, embedded, ...) [default]
       ith                  Intel Hex encoded flat binary
       srec                 Motorola S-records encoded flat binary
       aout                 Linux a.out
       aoutb                NetBSD/FreeBSD a.out
       coff                 COFF (i386) (DJGPP, some Unix variants)
       elf32                ELF32 (i386) (Linux, most Unix variants)
       elf64                ELF64 (x86-64) (Linux, most Unix variants)
       elfx32               ELFx32 (ELF32 for x86-64) (Linux)
       as86                 as86 (bin86/dev86 toolchain)
       obj                  Intel/Microsoft OMF (MS-DOS, OS/2, Win16)
       win32                Microsoft extended COFF for Win32 (i386)
       win64                Microsoft extended COFF for Win64 (x86-64)
       ieee                 IEEE-695 (LADsoft variant) object file format
       macho32              Mach-O i386 (Mach, including MacOS X and variants)
       macho64              Mach-O x86-64 (Mach, including MacOS X and variants)
       dbg                  Trace of all info passed to output stage
       elf                  Legacy alias for "elf32"
       macho                Legacy alias for "macho32"
       win                  Legacy alias for "win32"

    -g            generate debugging information
    -F format     select a debugging format (output format dependent)
    -gformat      same as -g -F format
       elf32:     dwarf     ELF32 (i386) dwarf (newer) [default]
                  stabs     ELF32 (i386) stabs (older)
       elf64:     dwarf     ELF64 (x86-64) dwarf (newer) [default]
                  stabs     ELF64 (x86-64) stabs (older)
       elfx32:    dwarf     ELFx32 (x86-64) dwarf (newer) [default]
                  stabs     ELFx32 (x86-64) stabs (older)
       obj:       borland   Borland Debug Records [default]
       win32:     cv8       Codeview 8+ [default]
       win64:     cv8       Codeview 8+ [default]
       ieee:      ladsoft   LADsoft Debug Records [default]
       macho32:   dwarf     Mach-O i386 dwarf for Darwin/MacOS [default]
       macho64:   dwarf     Mach-O x86-64 dwarf for Darwin/MacOS [default]
       dbg:       debug     Trace of all info passed to debug stage [default]

    -l listfile   write listing to a list file
    -Lflags...    add optional information to the list file
       -Lb        show builtin macro packages (standard and %use)
       -Ld        show byte and repeat counts in decimal, not hex
       -Le        show the preprocessed output
       -Lf        ignore .nolist (force output)
       -Lm        show multi-line macro calls with expanded parameters
       -Lp        output a list file every pass, in case of errors
       -Ls        show all single-line macro definitions
       -Lw        flush the output after every line (very slow!)
       -L+        enable all listing options except -Lw (very verbose!)

    -Oflags...    optimize opcodes, immediates and branch offsets
       -O0        no optimization
       -O1        minimal optimization
       -Ox        multipass optimization (default)
       -Ov        display the number of passes executed at the end
    -t            assemble in limited SciTech TASM compatible mode

    -E (or -e)    preprocess only (writes output to stdout by default)
    -a            don't preprocess (assemble only)
    -Ipath        add a pathname to the include file path
    -Pfile        pre-include a file (also --include)
    -Dmacro[=str] pre-define a macro
    -Umacro       undefine a macro
   --pragma str   pre-executes a specific %%pragma
   --before str   add line (usually a preprocessor statement) before the input
   --no-line      ignore %line directives in input

   --prefix str   prepend the given string to the names of all extern,
                  common and global symbols (also --gprefix)
   --suffix str   append the given string to the names of all extern,
                  common and global symbols (also --gprefix)
   --lprefix str  prepend the given string to local symbols
   --lpostfix str append the given string to local symbols

   --reproducible attempt to produce run-to-run identical output

    -w+x          enable warning x (also -Wx)
    -w-x          disable warning x (also -Wno-x)
    -w[+-]error   promote all warnings to errors (also -Werror)
    -w[+-]error=x promote warning x to errors (also -Werror=x)
       all                  all possible warnings
       db-empty             no operand for data declaration [on]
       ea                   all warnings prefixed with "ea-"
       ea-absolute          absolute address cannot be RIP-relative [on]
       ea-dispsize          displacement size ignored on absolute address [on]
       float                all warnings prefixed with "float-"
       float-denorm         floating point denormal [off]
       float-overflow       floating point overflow [on]
       float-toolong        too many digits in floating-point number [on]
       float-underflow      floating point underflow [off]
       forward              forward reference may have unpredictable results [on]
       label                all warnings prefixed with "label-"
       label-orphan         labels alone on lines without trailing `:' [on]
       label-redef          label redefined to an identical value [off]
       label-redef-late     label (re)defined during code generation [error]
       number-overflow      numeric constant does not fit [on]
       obsolete             all warnings prefixed with "obsolete-"
       obsolete-nop         instruction obsolete and is a noop on the target CPU [on]
       obsolete-removed     instruction obsolete and removed on the target CPU [on]
       obsolete-valid       instruction obsolete but valid on the target CPU [on]
       phase                phase error during stabilization [off]
       pp                   all warnings prefixed with "pp-"
       pp-else              all warnings prefixed with "pp-else-"
       pp-else-elif         %elif after %else [on]
       pp-else-else         %else after %else [on]
       pp-empty-braces      empty %{} construct [on]
       pp-environment       nonexistent environment variable [on]
       pp-macro             all warnings prefixed with "pp-macro-"
       pp-macro-def         all warnings prefixed with "pp-macro-def-"
       pp-macro-def-case-single single-line macro defined both case sensitive and insensitive [on]
       pp-macro-def-greedy-single single-line macro [on]
       pp-macro-def-param-single single-line macro defined with and without parameters [error]
       pp-macro-defaults    macros with more default than optional parameters [on]
       pp-macro-params      all warnings prefixed with "pp-macro-params-"
       pp-macro-params-legacy improperly calling multi-line macro for legacy support [on]
       pp-macro-params-multi multi-line macro calls with wrong parameter count [on]
       pp-macro-params-single single-line macro calls with wrong parameter count [on]
       pp-macro-redef-multi redefining multi-line macro [on]
       pp-open              all warnings prefixed with "pp-open-"
       pp-open-braces       unterminated %{...} [on]
       pp-open-brackets     unterminated %[...] [on]
       pp-open-string       unterminated string [on]
       pp-rep-negative      regative %rep count [on]
       pp-sel-range         %sel() argument out of range [on]
       pp-trailing          trailing garbage ignored [on]
       pragma               all warnings prefixed with "pragma-"
       pragma-bad           malformed %pragma [off]
       pragma-empty         empty %pragma directive [off]
       pragma-na            %pragma not applicable to this compilation [off]
       pragma-unknown       unknown %pragma facility or directive [off]
       prefix               all warnings prefixed with "prefix-"
       prefix-bnd           invalid BND prefix [on]
       prefix-hle           invalid HLE prefix [on]
       prefix-lock          LOCK prefix on unlockable instructions [on]
       prefix-opsize        invalid operand size prefix [on]
       prefix-seg           segment prefix ignored in 64-bit mode [on]
       ptr                  non-NASM keyword used in other assemblers [on]
       regsize              register size specification ignored [on]
       unknown-warning      unknown warning in -W/-w or warning directive [off]
       user                 %warning directives [on]
       warn-stack-empty     warning stack empty [on]
       zeroing              RESx in initialized section becomes zero [on]
       zext-reloc           relocation zero-extended to match output format [on]
       other                any warning not specifically mentioned above [on]

   --limit-X val  set execution limit X
       passes               total number of passes [unlimited]
       stalled-passes       number of passes without forward progress [1000]
       macro-levels         levels of macro expansion [10000]
       macro-tokens         tokens processed during single-lime macro expansion [10000000]
       mmacros              multi-line macros before final return [100000]
       rep                  %rep count [1000000]
       eval                 expression evaluation descent [8192]
       lines                total source lines processed [2000000000]

ndisasm

The Netwide Disassembler, an 80x86 binary file disassembler

root@kali:~# ndisasm -h
usage: ndisasm [-a] [-i] [-h] [-r] [-u] [-b bits] [-o origin] [-s sync...]
               [-e bytes] [-k start,bytes] [-p vendor] file
   -a or -i activates auto (intelligent) sync
   -u same as -b 32
   -b 16, -b 32 or -b 64 sets the processor mode
   -h displays this text
   -r or -v displays the version number
   -e skips <bytes> bytes of header
   -k avoids disassembling <bytes> bytes from position <start>
   -p selects the preferred vendor instruction set (intel, amd, cyrix, idt)

Updated on: 2023-Nov-24