WikiLeaks - Vault 7: Projects

# Vault 7: Projects

This publication series is about specific projects related to the Vault 7 main publication.

### Athena

# nasm-2-doc_internal

- 1
- 2
- 3
- 4
- 5

This contains a source-line parser. It parses `canonical' assembly
source lines, containing some combination of the `label', `opcode',
`operand' and `comment' fields: it does not process directives or
macros. It exports two functions: `parse_line' and `cleanup_insn'.
`parse_line' is the main parser function: you pass it a source line
in ASCII text form, and it returns you an `insn' structure
containing all the details of the instruction on that line. The
parameters it requires are:
- The location (segment, offset) where the instruction on this line
will eventually be placed. This is necessary in order to evaluate
expressions containing the Here token, `$'.
- A function which can be called to retrieve the value of any
symbols the source line references.
- Which pass the assembler is on: an undefined symbol only causes an
error condition on pass two.
- The source line to be parsed.
- A structure to fill with the results of the parse.
- A function which can be called to report errors.
Some instructions (DB, DW, DD for example) can require an arbitrary
amount of storage, and so some of the members of the resulting
`insn' structure will be dynamically allocated. The other function
exported by `parser.c' is `cleanup_insn', which can be called to
deallocate any dynamic storage associated with the results of a
parse.
names.c
-------
This doesn't count as a module - it defines a few arrays which are
shared between NASM and NDISASM, so it's a separate file which is
#included by both parser.c and disasm.c.
float.c
-------
This is essentially a library module: it exports one function,
`float_const', which converts an ASCII representation of a
floating-point number into an x86-compatible binary representation,
without using any built-in floating-point arithmetic (so it will run
on any platform, portably). It calls nothing, and is called only by
`parser.c'. Note that the function `float_const' must be passed an
error reporting routine.
assemble.c
----------
This module contains the code generator: it translates `insn'
structures as returned from the parser module into actual generated
code which can be placed in an output file. It exports two
functions, `assemble' and `insn_size'.

- 1
- 2
- 3
- 4
- 5