Commit Graph

22 Commits

Author SHA1 Message Date
2b8663037f First part of libvm transition
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-03-03 19:05:50 -05:00
ef03ea9137 Update assembler infrastructure to be more modular
Assembler has more discrete passes now, but things are kind of bare on
the error message front. But, everything is working as it did
previously, so we can move on to more interesting things.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-03-03 18:10:08 -05:00
4b96902831 Scrap preprocessor, add .include directive instead
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-02-27 15:52:17 -05:00
381a59f5fe Clean up main.rs some, add preprocessor
* Preprocessor uses an LRPAR generated lexer and a custom parser to
  filter comments and set defines. Includes and conditional compilation
  will come next.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-02-26 14:24:30 -05:00
bd34cdad63 Add compile and compile_out options, and extended input/output options
* compile flag and compile_out argument to the driver allow the program
  to be compiled only
* if '-' is supplied to compile_out, it will output to STDOUT instead
* if '-' is supplied to input, it will read from STDIN instead

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-02-25 18:12:28 -05:00
ef83cf7ef3 Add max_mem and size parsing for arg parsing
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-02-25 14:55:14 -05:00
b4637e2070 Comments in main.rs
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-02-25 14:21:39 -05:00
07abfc96b5 Add structopt for arg parsing
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-02-25 14:19:12 -05:00
1c05b3bb44 Update main to return the given status instead of printing the status out when halted
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-02-25 13:45:04 -05:00
5619c9dc87 Add address deref, syntax, and deref sizes
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-02-25 12:07:24 -05:00
b0ef49bc2a Add assembler and execution logic
Most everything works, but there's one small bug with the execution
involving jumps - still have to figure that one out.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-02-18 17:44:41 -05:00
2c4b56e362 Use lrpar for parsing, big 'ol syntax overhaul
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-02-17 16:15:06 -05:00
cf9ba376aa Add value directives and strings
.string, .zstring, .u64, .u32, .u16, .u8 are used before an ImmValue to
determine how the memory should be laid out for that value.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-02-11 17:49:17 -05:00
7504b81b2d Require assembler sections to specify where in virtual memory they begin
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-02-10 18:02:44 -05:00
a4a37b5a27 Add Disassemble, fix bug in position calculation
* Disassemble structure can be used for dumping an object section
* Assembler position calculation was messing up, causing jump addresses
  to be wrong. This is fixed.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-02-10 16:31:08 -05:00
c982be553f Add execution to VM via file, starting to iron out bugs
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-02-09 15:43:07 -05:00
f1ed41f98b Rustfmt
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-02-09 13:13:26 -05:00
e198da5825 Finish up parser and assembler with more-or-less complete syntax
Major changes inlude:

* Bit the bullet and now instructions have their length hard-coded
* Move from_utf8 object parsing to be done by their objects (instead of
  a Parser god object)
* A list of AST sections are assembled into an Object using the new
  vm::obj::assemble module.
* Changed the object layout some in the spec, and adjusted code to match
  this.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-02-09 13:04:56 -05:00
214f0b8aed Add object layout, object parsing, instruction layout
* Object layout and parsing are done in the vm::obj module
* Add MemCursor, a wrapper around the std::io::Cursor type for walking
  through VM memory
* Add vm::tick module for containing the Vm::tick() method
  implementation, since it's pretty big
* Instructions are now variable-sized, and are read lazily,
  one-at-a-time directly from memory.
* Add VM runtime error structure
* Probably some other stuff I forgot

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-02-03 17:56:32 -05:00
f98a53654e Update/add instructions in parser
* StoreImm just uses a u64 instead of u32 - we'll figure out the layout
  later
* Jmp implementation added (can't believe I forgot this)
* Add Inst AST item, whose immediates don't have to be a u64 right away

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-01-28 18:35:41 -05:00
c4c196a136 Add lexer dump to main and fix a couple of bugs
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-01-28 18:35:41 -05:00
ddfcec0427 Initial commit
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
2020-01-25 19:17:39 -05:00