rips 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +24 -23
- data/lib/rips/assembler.rb +1 -1
- data/lib/rips/formats/aformat.rb +4 -0
- data/lib/rips/instructions.rb +3 -0
- data/lib/rips/instructions/lest.rb +19 -0
- data/lib/rips/instructions/print.rb +19 -0
- data/lib/rips/instructions/set.rb +3 -0
- data/lib/rips/instructions/srl.rb +19 -0
- data/lib/rips/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bffe0b0ca1c5cbe5e05162277e630d89de27b477
|
4
|
+
data.tar.gz: f39d68d702a970ffcd69fbab041249a326bebffe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
-
|
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
|
42
|
-
|
43
|
-
| Move
|
44
|
-
| Not
|
45
|
-
| Add
|
46
|
-
| Subtract
|
47
|
-
| And
|
48
|
-
| Or
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
| Load
|
53
|
-
|
|
54
|
-
| Store I/O from
|
55
|
-
|
|
56
|
-
| Jump
|
57
|
-
| Jump
|
58
|
-
|
|
59
|
-
| Branch z
|
60
|
-
|
|
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 )
|
data/lib/rips/assembler.rb
CHANGED
@@ -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
|
65
|
+
if (@cmd[:name] == "jr") || (@cmd[:name] == "nop")
|
66
66
|
@cmd[:arguments] = []
|
67
67
|
else
|
68
68
|
@cmd[:arguments] = line.instruction_arguments(@cmd[:name])
|
data/lib/rips/formats/aformat.rb
CHANGED
data/lib/rips/instructions.rb
CHANGED
@@ -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
|
@@ -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
|
data/lib/rips/version.rb
CHANGED
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.
|
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-
|
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.
|
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.
|