diff --git a/README.mdown b/README.mdown index 0076430..75bf769 100644 --- a/README.mdown +++ b/README.mdown @@ -12,9 +12,9 @@ It's meant to be used interactively via the Python REPL as well as programmatica An example of a Python REPL session: - >>> from dcpu_16 import CPU + >>> from dcpu_16 import CPU, spec_demo >>> c = CPU(debug=True) - >>> c.load_m() # loads demo program + >>> c.load_m(spec_demo) # loads demo program >>> c.step() # step by one instruction << SET << c.r[0x0] diff --git a/dcpu_16.py b/dcpu_16.py index 98acddd..89a2189 100644 --- a/dcpu_16.py +++ b/dcpu_16.py @@ -364,7 +364,8 @@ class CPU(object): def j(c, val): c.r[7] = val - + def _op(c, word): + """dispatch to op""" def _pointer(c, code): """get pointer to valcode""" @@ -430,3 +431,9 @@ class CPU(object): pass +spec_demo = [ + 0x7c01, 0x0030, 0x7de1, 0x1000, 0x0020, 0x7803, 0x1000, 0xc00d, + 0x7dc1, 0x001a, 0xa861, 0x7c01, 0x2000, 0x2161, 0x2000, 0x8463, + 0x806d, 0x7dc1, 0x000d, 0x9031, 0x7c10, 0x0018, 0x7dc1, 0x001a, + 0x9037, 0x61c1, 0x7dc1, 0x001a, 0x0000, 0x0000, 0x0000, 0x0000, +]