Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
46 lines (37 sloc) 2.47 KB


The emulator executes the bitcode generated by the assembler.


The emulator works in ticks. Each tick() executes one instruction, which is fetched from the rom. Ticks executed by the tickWrapper(), which is invoked by a simple setTimeout. Because there is a limit on how frequent setTimeout can fire, a number of ticks is executed in each tickWrapper()-call.

  1. tickWrapper()
  2. check if the emulator is running, if not, exit
  3. check if the number of instructions to be executed has been executed, if yes, exit (see CONTINUE-Message)
  4. check if the emulator should be waiting (PAUSE or DELAY executed), if yes, set a timeout of the desired time and exit. This is skipped if the emulator is stepping.
  5. tick()
  6. check for interrupts
  7. fetch the next instruction from the ROM
  8. check if the instruction is cached, if not disassemble and cache
  9. fetch instruction from the cache
  10. load needed values for parameters
  11. call the exec()-function of the instruction
  12. check and set the zero-flag, if specified in instruction-file
  13. setTickWrapperTimeout()

The timeout which is set by setTickWrapperTimeout() can be interrupted by a number of things:

  • CONTINUE-message (to allow faster stepping)
  • Hardware-Interrupt

In addition the timeout will be longer when the emulator.waitTime (see DELAY-instruction) is set.


The emulator pins and their state are handled by a IOBank instance. Please refer to the documentation for more information on this. The setIO and getIO function of the emulator api are essentially wrapper functions for the actual pin objects.


The is located in the RAM, beginning from 0x50. The sp gets increment before the byte is pushed (pre-increment), so the sp always points to the last byte. Words are pushed with the least significant byte first. An example can be found in the tutorial.


Data structures which are used inside the emulator and its messages and broadcasts.


Details about the Communicator-Implementation for the emulator, including the messages and broadcasts.