Permalink
Browse files

Initial commit.

  • Loading branch information...
Textmode committed Feb 27, 2011
0 parents commit b56116f9248434ac0608b1ab526b482fa10cbeeb
Showing with 864 additions and 0 deletions.
  1. +9 −0 .gitignore
  2. +28 −0 COPYING
  3. +97 −0 README
  4. +316 −0 asm.lua
  5. +5 −0 examples/COPYING
  6. +35 −0 examples/count10.asm
  7. +26 −0 examples/jump.asm
  8. +7 −0 examples/show.asm
  9. +8 −0 examples/test.asm
  10. +333 −0 machine.lua
@@ -0,0 +1,9 @@
+*~
+*.crap
+*.bin
+*.o
+*.tmp
+*.page
+*.seg
+*.luac
+
28 COPYING
@@ -0,0 +1,28 @@
+TMVM is licenced under the Zlib licence, a copy of which is provided below.
+
+-----
+
+Copyright (c) 2011 Textmode (D. M. Brownrigg)
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any damages
+arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not
+claim that you wrote the original software. If you use this software
+in a product, an acknowledgment in the product documentation would be
+appreciated but is not required.
+
+2. Altered source versions must be plainly marked as such, and must not be
+misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source
+distribution.
+
+(End of Licence)
+-----
+
97 README
@@ -0,0 +1,97 @@
+Textmode Virtual Macaroni, or TMVM, is a simple, poorly-designed,
+simulation of a register-based system.
+It currently has an addressable memory space of 256 bytes (00..ff)
+(Segments are planned, but not yet implemented). It runs at a nominal
+speed of 1MHz.
+
+Its not presently useful for much of anything, it also likely to be
+unstable and unreliable, so have fun! :D
+
+Note: TMVM is still under development, expect fundamental design and API
+changes.
+
+TMVM is cop
+
+== Requirements
+ Lua 5.1 or better.
+ A sense of humor.
+
+
+
+
+== Usage
+
+=== Machine
+
+machine.lua can be required. asm.lua can be required, or run as script
+(eg. 'lua asm.lua file.asm').
+
+machine exposes the following functions:
+ module:new(opt_name)
+ returns: machine
+ creates a new machine with the given name.
+ if no name is given, a default name will be provided.
+
+
+ (VM):signal(opt_signal)
+ returns: signal, description
+ if given no parms, returns the current signal, and a (short) textual
+ description.
+ otherwise it triggers the given signal.
+ if another signal has yet to be cleared, it will trigger a double
+ fault.
+ if a double-fault is uncleared, a triple-fault.
+ triggering a signal NONE will clear the signal.
+
+
+ (VM):load(opt_start, data_string_or_table)
+ returns: (nothing)
+ attempts to load the given data into the machine's memory.
+ if start is omitted, it will load at address 0, segment 0.
+
+
+ (VM):cycle(opt_num)
+ returns: machine_state
+ completes num instruction cycles. if num is omitted, it will assume
+ 1 cycle.
+
+
+ (VM):run(bool_show_status_dumps) -- Broken!
+ returns: (nothing)
+ attempts to run the machine at its base speed.
+ if passed true, it will call VM:dump() roughly 1/s
+
+
+ (VM):dump()
+ returns: (nothing)
+ prints state information on the current machine
+
+=== ASM
+
+asm.lua can be required normally. additionally, it is a valid script and
+ can be directly run.
+ as a program, asm.lua takes the name of a source file, and optionally the
+ name of an output file. if no output file is given, it outputs to the
+ same filename with the ".crap" replacing its original extension: thus
+ 'test.asm' outputs to 'test.crap'. regardless, it also prints a
+ lua-formatted table of hex digits representing the assembled binary.
+
+asm.lua exposes the following functions:
+
+ asm.load(filename)
+ returns: preparsed_chunk
+ loads the given file and returns a normalised chunk, suitable for
+ further parsing.
+
+
+ asm.scrub(string)
+ returns: preparsed_chunk
+ processes the given string into a pre-parsed chunk, suitable for further
+ parsing.
+
+ asm.parse(chunk)
+ returns: final_bytestring
+ takes a pre-parsed chunk, and returns a fully-assembled chunk as a
+ string, suitable for saving or loading into a machine.
+
+
Oops, something went wrong.

0 comments on commit b56116f

Please sign in to comment.