µCsim: Code Analyzer

# Code analyzer

This feature is included into both DOS and UNIX versions. Code analyzer analyzes the code of the simulated program and tries to figure out which address contains valid instruction. Analyzer starts analyzing of the code with address 0 which always must contain an instruction because reset of the device sets zero into program counter. So, analyzer marks address 0 that it contains an instruction. Then it marks the address of the next instruction and so on. If the analyzer finds a jump instruction it continues with destination address of the jump instruction. If it finds a call instruction, it recursively analyzes destination address as well as next instruction follows the call one. Analyzator stops if it finds an address which is already marked or if it finds a return instruction or an indirect jump which is impossible to follow. All these mean that it is impossible to discover all instructions of the program.

This problem is solved in very simple way in UNIX version. If the execution reaches an umarked address, the analyzer is called to analyze the code starting at actual address pointed by the PC. This method is not included into DOS version but this re-analyzation can be requested by pressing Ctrl-F7 at any time.