ADDED: tm simulator and source
ADDED: a naive runable version
ADDED: input/output
FIXED: funciton return offset