# Code analyser

The code analyser analyses the memory of the simulated microprocessor and tries to figure out which address contains valid instruction.

The analyser starts from the known hardware vectors (reset, IRQs etc.) and follows the possible execution paths through jumps, branches and calls marking data as code and adding variables as necessary. Execution paths that are indirect, indexed or otherwise computed are not followed initially but will be analysed when, or if, execution reaches them.

If code is known to exist elsewhere in memory and is not reachable without being run explicitly (such as by the "`run addr`" command) you can use "`analyse addr`" to ask the analyser to look there. This is not persistent however. Whenever data is loaded or "`analyse`" run with no addr argument all the analyser state is reset and recreated from the known vectors so any explicit "`analyse addr`" needs to be rerun if required.

Variables created by the analyser always start with a dot. Such variables cannot be created by the "`var`" command and are not listed by "`info var`" (although can be using "`info var .`") but otherwise work like any other variable with one exception. If you create a new variable for the exact same memory location the analyser's variable will be silently removed.

    0> dump .loop$21

    0x081f8    <.loop$21>:
    0x081f8    d6 81 da       ld     A,(0x81da <.bit0_isset$19>,X)
    0x081fb    d7 00 3d       ld     (0x003d,X),A
    0x081fe    5a             decw   X
    0x081ff    26 f7          jrne   0x81f8 <.loop$21>

    0> var copy_data .loop$21

    0> dump .loop$21
    dump [/format] memory_type [start [stop [bytes_per_line]]] | dump bit...
                        Dump memory of specified type or bit(s)

    0> dump copy_data

    0x081f8    <copy_data>:
    0x081f8    d6 81 da       ld     A,(0x81da <.bit0_isset$19>,X)
    0x081fb    d7 00 3d       ld     (0x003d,X),A
    0x081fe    5a             decw   X
    0x081ff    26 f7          jrne   0x81f8 <copy_data>