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

`insn_size' is designed to be called on pass one of assembly: it
takes an `insn' structure as input, and returns the amount of space
that would be taken up if the instruction described in the structure
were to be converted to real machine code. `insn_size' also requires
to be told the location (as a segment/offset pair) where the
instruction would be assembled, the mode of assembly (16/32 bit
default), and a function it can call to report errors.
`assemble' is designed to be called on pass two: it takes all the
parameters that `insn_size' does, but has an extra parameter which
is an output driver. `assemble' actually converts the input
instruction into machine code, and outputs the machine code by means
of calling the `output' function of the driver.
insnsa.c
--------
This is another library module: it exports one very big array of
instruction translations. It is generated automatically from the
insns.dat file by the insns.pl script.
labels.c
--------
This module contains a label manager. It exports six functions:
`init_labels' should be called before any other function in the
module. `cleanup_labels' may be called after all other use of the
module has finished, to deallocate storage.
`define_label' is called to define new labels: you pass it the name
of the label to be defined, and the (segment,offset) pair giving the
value of the label. It is also passed an error-reporting function,
and an output driver structure (so that it can call the output
driver's label-definition function). `define_label' mentally
prepends the name of the most recently defined non-local label to
any label beginning with a period.
`define_label_stub' is designed to be called in pass two, once all
the labels have already been defined: it does nothing except to
update the "most-recently-defined-non-local-label" status, so that
references to local labels in pass two will work correctly.
`declare_as_global' is used to declare that a label should be
global. It must be called _before_ the label in question is defined.
Finally, `lookup_label' attempts to translate a label name into a
(segment,offset) pair. It returns non-zero on success.
The label manager module is (theoretically :) restartable: after
calling `cleanup_labels', you can call `init_labels' again, and
start a new assembly with a new set of symbols.
listing.c
---------
This file contains the listing file generator. The interface to the

- 1
- 2
- 3
- 4
- 5