rips 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rips/assembler.rb +37 -0
- data/lib/rips/error.rb +15 -0
- data/lib/rips/formats/format.rb +15 -0
- data/lib/rips/formats.rb +0 -0
- data/lib/rips/instructions/instruction.rb +17 -0
- data/lib/rips/instructions/set.rb +6 -0
- data/lib/rips/instructions.rb +0 -0
- data/lib/rips/variables/variable.rb +14 -0
- data/lib/rips/variables.rb +0 -0
- data/lib/rips/version.rb +1 -1
- data/lib/rips.rb +21 -1
- metadata +11 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15d47ea6c151a478f9748664cb04398ef56a6c25
|
4
|
+
data.tar.gz: 0bca77b30fa8ab05d24f04dbeb0459ba0ba8b790
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b00d78c5c59e542dec762108d82b665bacf262a813e747761a6e2c9618e49f43fecd667c354190e9bf00df26e9acc8aa4115ff527615fc405382054aa631c7a2
|
7
|
+
data.tar.gz: 44bbf9d40c80f076e3c7a08b6a24f1d1ee4288cce5bc477d7020af0f22b2d968b7f6143f68541a3a95acfc46432296342bdbbef3cf7dcff052beca998dd84d47
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "rips/instructions"
|
2
|
+
|
3
|
+
module Rips
|
4
|
+
class Assembler
|
5
|
+
|
6
|
+
# @input: array with assembly instructions
|
7
|
+
# @output: array with coded instructions
|
8
|
+
# @cmd: line split on tokens (name + arguments)
|
9
|
+
# @instruction: instruction instance
|
10
|
+
# @line: number of file's line
|
11
|
+
def initialize
|
12
|
+
@input = []
|
13
|
+
@output = []
|
14
|
+
@cmd
|
15
|
+
@instruction
|
16
|
+
@line = 1
|
17
|
+
end
|
18
|
+
|
19
|
+
# Stores each new line of file
|
20
|
+
def << (value)
|
21
|
+
@input << value.strip
|
22
|
+
end
|
23
|
+
|
24
|
+
# Analyze and translate each instruction
|
25
|
+
def run
|
26
|
+
end
|
27
|
+
|
28
|
+
# Codification log of instruction
|
29
|
+
def show
|
30
|
+
end
|
31
|
+
|
32
|
+
# Generate output in "progfile.dat"
|
33
|
+
def generate
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
data/lib/rips/error.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module Rips
|
2
|
+
module Error
|
3
|
+
|
4
|
+
MESSAGES =
|
5
|
+
[ "RIPS ERROR (0). Unknown problem.",
|
6
|
+
"RIPS ERROR (1). No input file (try `rips file.rips`).",
|
7
|
+
"RIPS ERROR (2). Doesn't exist file or directory.",
|
8
|
+
"RIPS ERROR (3). Permission denied to read file." ]
|
9
|
+
|
10
|
+
def self.message (num, *args)
|
11
|
+
puts MESSAGES[num] % args
|
12
|
+
exit
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Rips
|
2
|
+
module Formats
|
3
|
+
|
4
|
+
class Format
|
5
|
+
|
6
|
+
attr_reader :opcode, :args_number
|
7
|
+
|
8
|
+
# @opcode = operation code in binary
|
9
|
+
# @args_number = number of format's arguments
|
10
|
+
def initialize (opcode, args_number)
|
11
|
+
@opcode, @args_number = opcode, args_number
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/rips/formats.rb
ADDED
File without changes
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "rips/instructions/set"
|
2
|
+
require "rips/formats"
|
3
|
+
require "rips/variables"
|
4
|
+
|
5
|
+
module Rips
|
6
|
+
module Instructions
|
7
|
+
|
8
|
+
class Instruction
|
9
|
+
|
10
|
+
# @name: mnemonic name
|
11
|
+
# @type: instruction format
|
12
|
+
def initialize (name, type)
|
13
|
+
@name,@type = name,type
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
File without changes
|
File without changes
|
data/lib/rips/version.rb
CHANGED
data/lib/rips.rb
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
require "rips/version"
|
2
|
+
require "rips/assembler"
|
3
|
+
require "rips/error"
|
2
4
|
|
3
5
|
module Rips
|
4
|
-
|
6
|
+
|
7
|
+
# Check for a valid file
|
8
|
+
if ARGV.empty?
|
9
|
+
Error::message(1)
|
10
|
+
elsif !File.exist? ARGV[0]
|
11
|
+
Error::message(2)
|
12
|
+
elsif !File.readable? ARGV[0]
|
13
|
+
Error::message(3)
|
14
|
+
end
|
15
|
+
|
16
|
+
rips = Assembler.new
|
17
|
+
|
18
|
+
File.open(ARGV[0], "r") do |f|
|
19
|
+
f.each_line do |line|
|
20
|
+
rips << line
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
rips.run
|
5
25
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rips
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Madh93
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -68,6 +68,15 @@ files:
|
|
68
68
|
- Rakefile
|
69
69
|
- bin/rips
|
70
70
|
- lib/rips.rb
|
71
|
+
- lib/rips/assembler.rb
|
72
|
+
- lib/rips/error.rb
|
73
|
+
- lib/rips/formats.rb
|
74
|
+
- lib/rips/formats/format.rb
|
75
|
+
- lib/rips/instructions.rb
|
76
|
+
- lib/rips/instructions/instruction.rb
|
77
|
+
- lib/rips/instructions/set.rb
|
78
|
+
- lib/rips/variables.rb
|
79
|
+
- lib/rips/variables/variable.rb
|
71
80
|
- lib/rips/version.rb
|
72
81
|
- rips.gemspec
|
73
82
|
- spec/rips_spec.rb
|