remian 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -3,3 +3,4 @@ log/
3
3
  tmp/
4
4
  .sass-cache/
5
5
  .DS_Store
6
+ *.gem
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- remian (0.1.0)
4
+ remian (0.1.1)
5
5
  term-ansicolor (~> 1.0.7)
6
6
  thor (~> 0.16.0)
7
7
 
data/bin/remian CHANGED
@@ -5,6 +5,14 @@ require "remian"
5
5
 
6
6
  module Remian
7
7
  class Thorian < Thor
8
+ map "-v" => :version
9
+
10
+ desc "version", "Get Remian version."
11
+
12
+ def version
13
+ puts "v#{Remian::VERSION}"
14
+ end
15
+
8
16
  desc "execute FILEPATH", "Runs given .rem file."
9
17
 
10
18
  method_option :clock_speed, default: 30, aliases: "-c", desc: "Machine clock speed in Hz (default 50)."
@@ -1,5 +1,6 @@
1
1
  require "term/ansicolor"
2
- require "./lib/remian/control"
2
+ require "remian/version"
3
+ require "remian/control"
3
4
 
4
5
  module Remian
5
6
  def self.say message, colour_hash
@@ -48,9 +48,11 @@ module Remian
48
48
  @registers[:address] = @registers[:address] + 1
49
49
 
50
50
  instruction = @decoder.parse address_contents
51
+ return if instruction[:skip]
52
+
51
53
  if not instruction[:opcode].nil? and @instruction_set.respond_to? instruction[:opcode]
52
54
  Remian.say "> #{address_contents}", :green
53
- @instruction_set.send(instruction[:opcode], instruction[:data])
55
+ @instruction_set.send(instruction[:opcode], instruction[:operands])
54
56
  else
55
57
  Remian.say "Instruction '#{instruction[:opcode]}' is not defined.", :red
56
58
  end
@@ -1,10 +1,12 @@
1
1
  class Decoder
2
2
  def parse instruction
3
+ instruction = instruction.to_s
3
4
  components = instruction.to_s.split " "
4
5
 
5
6
  return {
7
+ skip: instruction[0] == "#",
6
8
  opcode: components.shift,
7
- data: components
9
+ operands: components
8
10
  }
9
11
  end
10
12
  end
@@ -0,0 +1,3 @@
1
+ module Remian
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "remian/version"
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "remian"
8
+ gem.version = Remian::VERSION
9
+ gem.authors = ["Michael Mokrysz"]
10
+ gem.email = ["hi@46bit.com"]
11
+ gem.description = "A baby virtual machine built in Ruby."
12
+ gem.summary = "Remian is a small virtual machine, designed to a Von Neumann architecture with a RISC mindset."
13
+ gem.homepage = "https://github.com/46Bit/remian"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = ["remian"]
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency "thor", "~> 0.16.0"
21
+ gem.add_dependency "term-ansicolor", "~> 1.0.7"
22
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remian
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -81,6 +81,8 @@ files:
81
81
  - lib/remian/instruction_set/set.rb
82
82
  - lib/remian/instruction_set/zero.rb
83
83
  - lib/remian/memory.rb
84
+ - lib/remian/version.rb
85
+ - remian.gemspec
84
86
  homepage: https://github.com/46Bit/remian
85
87
  licenses: []
86
88
  post_install_message: