rips 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3fff3963bd941c448681cc84b7866aef618c72d9
4
- data.tar.gz: 1f77e7972c43bcc523a10f749b4cfc7c3bc04d67
3
+ metadata.gz: bffe0b0ca1c5cbe5e05162277e630d89de27b477
4
+ data.tar.gz: f39d68d702a970ffcd69fbab041249a326bebffe
5
5
  SHA512:
6
- metadata.gz: d0bb9c555874d3bdfac873b7cec8add0b1f05007684f5406158420cb76e2ca84352b3d2f2c258faadfc466b62a09d18c31173b65c75a9970fe427b182b1040b2
7
- data.tar.gz: febd89dee2a4629452838ade172abde29357d6c1f14bad915cdcc9dcaccd15ea92452ff617f3c2d11ffef5ab8aaf37a655454ea21b77a5063310bab2183f525e
6
+ metadata.gz: 1c9b72194361c1eb3fd7892099746df3ff93b66063df762cef08423d1847edbd5f7a2599abeb96a2ae51c5d0bbcf6456b9a538ac45d33e57ece6a2af602ccb60
7
+ data.tar.gz: 076a4e329bf523e3a7634d416ba2a3b7b0d90055eccc1a0719621ea66930292cf06306b4149bb5ded012e97cd8e133a683f393048d5ff1884da2494461127ff6
data/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
  [![Gem Version](https://badge.fury.io/rb/rips.svg)](http://badge.fury.io/rb/rips)
3
3
  [![Dependency Status](https://gemnasium.com/Madh93/rips.svg)](https://gemnasium.com/Madh93/rips)
4
4
 
5
- Simple assembler written in Ruby for a simple 16-bit CPU written in Verilog. Based in MIPS syntax with next features:
5
+ Simple assembler written in Ruby for a [simple 16-bit CPU written in Verilog](https://github.com/Madh93/scpu/). Based in MIPS syntax with next features:
6
6
 
7
- - 18 basic instructions
7
+ - 19 basic instructions
8
8
  - 16 registers ($0-$15)
9
9
  - 4 I/O ports (@0-@3)
10
10
  - Support labels
@@ -38,27 +38,28 @@ Examples:
38
38
 
39
39
  ## Instruction Set
40
40
 
41
- | Name | MNENOMIC | FORMAT | OPERATION | OPCODE |
42
- |--------------------|----------|--------|----------------|--------|
43
- | Move | move | C | move $1, $0 | 0000 |
44
- | Not | not | C | not $1, $0 | 0001 |
45
- | Add | add | D | add $2, $0, $1 | 0010 |
46
- | Subtract | sub | D | sub $2, $0, $1 | 0011 |
47
- | And | and | D | and $2, $0, $1 | 0100 |
48
- | Or | or | D | or $2, $0, $1 | 0101 |
49
- | Sign negation | neg | C | neg $1, $0 | 0110 |
50
- | Jump | j | B | j label | 1001 |
51
- | Load Inmediate | li | C | li $0, 10 | 1010 |
52
- | Load from I/O | lesr | C | lesr $0, @0 | 1011 |
53
- | Store I/O from Reg | sesr | C | sesr @0, $0 | 1101 |
54
- | Store I/O from Mem | sesm | C | sesm @0, 10 | 1110 |
55
- | Relative Jump | ji | B | ji 10 | 011000 |
56
- | Jump and Link | jal | B | jal label | 101000 |
57
- | Jump Register | jr | A | jr | 111000 |
58
- | Branch z!=0 | bnez | B | bnez label | 001111 |
59
- | Branch z==0 | beqz | B | beqz label | 011111 |
60
- | No Operation | nop | A | nop | 111111 |
61
-
41
+ | Name | MNENOMIC | FORMAT | OPERATION | OPCODE |
42
+ |--------------------------|----------|--------|------------------|--------|
43
+ | Move | move | C | move $1, $0 | 0000 |
44
+ | Not | not | C | not $1, $0 | 0001 |
45
+ | Add | add | D | add $2, $0, $1 | 0010 |
46
+ | Subtract | sub | D | sub $2, $0, $1 | 0011 |
47
+ | And | and | D | and $2, $0, $1 | 0100 |
48
+ | Or | or | D | or $2, $0, $1 | 0101 |
49
+ | Shift right logical | srl | D | srl $2, $3, $1 | 0110 |
50
+ | Less than | lest | D | lest $0, $2, $1 | 0111 |
51
+ | Jump | j | B | j label | 1001 |
52
+ | Load Inmediate | li | C | li $0, 10 | 1010 |
53
+ | Load from I/O | lesr | C | lesr $0, @0 | 1011 |
54
+ | Store I/O from Reg | sesr | C | sesr @0, $0 | 1101 |
55
+ | Store I/O from Mem | sesm | C | sesm @0, 10 | 1110 |
56
+ | Relative Jump | ji | B | ji 10 | 011000 |
57
+ | Jump and Link | jal | B | jal label | 101000 |
58
+ | Jump Register | jr | A | jr | 111000 |
59
+ | Branch z!=0 | bnez | B | bnez label | 001111 |
60
+ | Branch z==0 | beqz | B | beqz label | 011111 |
61
+ | No Operation | nop | A | nop | 111111 |
62
+
62
63
  ## Contributing
63
64
 
64
65
  1. Fork it ( https://github.com/Madh93/rips/fork )
@@ -62,7 +62,7 @@ module Rips
62
62
  @cmd[:comments] = line
63
63
  else
64
64
  @cmd[:name] = line.instruction_name
65
- if (@cmd[:name] == "jr ") || (@cmd[:name] == "nop ")
65
+ if (@cmd[:name] == "jr") || (@cmd[:name] == "nop")
66
66
  @cmd[:arguments] = []
67
67
  else
68
68
  @cmd[:arguments] = line.instruction_arguments(@cmd[:name])
@@ -12,6 +12,10 @@ module Rips
12
12
  super(opcode,0)
13
13
  @args = {}
14
14
  end
15
+
16
+ # Pass all arguments at once
17
+ def set_arguments (args)
18
+ end
15
19
 
16
20
  end
17
21
  end
@@ -7,12 +7,15 @@ require "rips/instructions/jal"
7
7
  require "rips/instructions/ji"
8
8
  require "rips/instructions/jr"
9
9
  require "rips/instructions/lesr"
10
+ require "rips/instructions/lest"
10
11
  require "rips/instructions/li"
11
12
  require "rips/instructions/move"
12
13
  require "rips/instructions/nop"
13
14
  require "rips/instructions/neg"
14
15
  require "rips/instructions/not"
15
16
  require "rips/instructions/or"
17
+ require "rips/instructions/print"
16
18
  require "rips/instructions/sesm"
17
19
  require "rips/instructions/sesr"
20
+ require "rips/instructions/srl"
18
21
  require "rips/instructions/sub"
@@ -0,0 +1,19 @@
1
+ require "rips/instructions/instruction"
2
+
3
+ module Rips
4
+ module Instructions
5
+
6
+ class Lest < Instruction
7
+
8
+ attr_reader :variables, :length
9
+
10
+ # @variables: types of instruction's variables
11
+ # @length: length in bits for each variable
12
+ def initialize
13
+ super("lest",Formats::DFormat.new(0b0111))
14
+ @variables = [Variables::Register.new, Variables::Register.new, Variables::Register.new]
15
+ @length = {r3:4, r2:4, r1:4, op:4}
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ require "rips/instructions/instruction"
2
+
3
+ module Rips
4
+ module Instructions
5
+
6
+ class Print < Instruction
7
+
8
+ attr_reader :variables, :length
9
+
10
+ # @variables: types of instruction's variables
11
+ # @length: length in bits for each variable
12
+ def initialize
13
+ super("print",Formats::BFormat.new(0b1100))
14
+ @variables = [Variables::Register.new]
15
+ @length = {r1:4, op:4, blank:8}
16
+ end
17
+ end
18
+ end
19
+ end
@@ -11,14 +11,17 @@ module Rips
11
11
  "beqz",
12
12
  "bnez",
13
13
  "lesr",
14
+ "lest",
14
15
  "li",
15
16
  "move",
16
17
  "nop",
17
18
  "neg",
18
19
  "not",
19
20
  "or",
21
+ "print",
20
22
  "sesm",
21
23
  "sesr",
24
+ "srl",
22
25
  "sub" ]
23
26
  end
24
27
  end
@@ -0,0 +1,19 @@
1
+ require "rips/instructions/instruction"
2
+
3
+ module Rips
4
+ module Instructions
5
+
6
+ class Srl < Instruction
7
+
8
+ attr_reader :variables, :length
9
+
10
+ # @variables: types of instruction's variables
11
+ # @length: length in bits for each variable
12
+ def initialize
13
+ super("srl",Formats::DFormat.new(0b0110))
14
+ @variables = [Variables::Register.new, Variables::Register.new, Variables::Register.new]
15
+ @length = {r3:4, r2:4, r1:4, op:4}
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module Rips
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  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.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Madh93
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-26 00:00:00.000000000 Z
11
+ date: 2015-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -89,15 +89,18 @@ files:
89
89
  - lib/rips/instructions/ji.rb
90
90
  - lib/rips/instructions/jr.rb
91
91
  - lib/rips/instructions/lesr.rb
92
+ - lib/rips/instructions/lest.rb
92
93
  - lib/rips/instructions/li.rb
93
94
  - lib/rips/instructions/move.rb
94
95
  - lib/rips/instructions/neg.rb
95
96
  - lib/rips/instructions/nop.rb
96
97
  - lib/rips/instructions/not.rb
97
98
  - lib/rips/instructions/or.rb
99
+ - lib/rips/instructions/print.rb
98
100
  - lib/rips/instructions/sesm.rb
99
101
  - lib/rips/instructions/sesr.rb
100
102
  - lib/rips/instructions/set.rb
103
+ - lib/rips/instructions/srl.rb
101
104
  - lib/rips/instructions/sub.rb
102
105
  - lib/rips/utils.rb
103
106
  - lib/rips/utils/array.rb
@@ -134,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
137
  version: '0'
135
138
  requirements: []
136
139
  rubyforge_project:
137
- rubygems_version: 2.4.2
140
+ rubygems_version: 2.4.8
138
141
  signing_key:
139
142
  specification_version: 4
140
143
  summary: Simple assembler for a simple 16-bit CPU.