c8dasm 0.99.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +16 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +3 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +15 -0
  7. data/README.md +109 -0
  8. data/Rakefile +7 -0
  9. data/bin/c8dasm +13 -0
  10. data/c8dasm.gemspec +24 -0
  11. data/lib/c8dasm.rb +11 -0
  12. data/lib/c8dasm/assemblies.rb +18 -0
  13. data/lib/c8dasm/assemblies/asm0.rb +15 -0
  14. data/lib/c8dasm/assemblies/asm1.rb +10 -0
  15. data/lib/c8dasm/assemblies/asm2.rb +10 -0
  16. data/lib/c8dasm/assemblies/asm3.rb +10 -0
  17. data/lib/c8dasm/assemblies/asm4.rb +9 -0
  18. data/lib/c8dasm/assemblies/asm5.rb +12 -0
  19. data/lib/c8dasm/assemblies/asm6.rb +9 -0
  20. data/lib/c8dasm/assemblies/asm7.rb +9 -0
  21. data/lib/c8dasm/assemblies/asm8.rb +23 -0
  22. data/lib/c8dasm/assemblies/asm9.rb +11 -0
  23. data/lib/c8dasm/assemblies/asm_base.rb +26 -0
  24. data/lib/c8dasm/assemblies/asma.rb +11 -0
  25. data/lib/c8dasm/assemblies/asmb.rb +12 -0
  26. data/lib/c8dasm/assemblies/asmc.rb +11 -0
  27. data/lib/c8dasm/assemblies/asmd.rb +11 -0
  28. data/lib/c8dasm/assemblies/asme.rb +16 -0
  29. data/lib/c8dasm/assemblies/asmf.rb +20 -0
  30. data/lib/c8dasm/assembly.rb +22 -0
  31. data/lib/c8dasm/chip8_reader.rb +38 -0
  32. data/lib/c8dasm/comment.rb +23 -0
  33. data/lib/c8dasm/comments.rb +17 -0
  34. data/lib/c8dasm/comments/comment0.rb +14 -0
  35. data/lib/c8dasm/comments/comment1.rb +10 -0
  36. data/lib/c8dasm/comments/comment2.rb +11 -0
  37. data/lib/c8dasm/comments/comment3.rb +11 -0
  38. data/lib/c8dasm/comments/comment4.rb +11 -0
  39. data/lib/c8dasm/comments/comment5.rb +12 -0
  40. data/lib/c8dasm/comments/comment6.rb +11 -0
  41. data/lib/c8dasm/comments/comment7.rb +11 -0
  42. data/lib/c8dasm/comments/comment8.rb +25 -0
  43. data/lib/c8dasm/comments/comment9.rb +11 -0
  44. data/lib/c8dasm/comments/comment_base.rb +26 -0
  45. data/lib/c8dasm/comments/commenta.rb +11 -0
  46. data/lib/c8dasm/comments/commentb.rb +12 -0
  47. data/lib/c8dasm/comments/commentc.rb +11 -0
  48. data/lib/c8dasm/comments/commentd.rb +11 -0
  49. data/lib/c8dasm/comments/commente.rb +15 -0
  50. data/lib/c8dasm/comments/commentf.rb +30 -0
  51. data/lib/c8dasm/opcode.rb +34 -0
  52. data/lib/c8dasm/version.rb +3 -0
  53. data/spec/15-puzzle.ch8 +0 -0
  54. data/spec/MAZE +0 -0
  55. data/spec/c8dasm_spec.rb +7 -0
  56. data/spec/chip8_reader_spec.rb +27 -0
  57. data/spec/opcode_0_spec.rb +39 -0
  58. data/spec/opcode_1_spec.rb +23 -0
  59. data/spec/opcode_2_spec.rb +23 -0
  60. data/spec/opcode_3_spec.rb +23 -0
  61. data/spec/opcode_4_spec.rb +23 -0
  62. data/spec/opcode_5_spec.rb +25 -0
  63. data/spec/opcode_6_spec.rb +23 -0
  64. data/spec/opcode_7_spec.rb +23 -0
  65. data/spec/opcode_8_spec.rb +119 -0
  66. data/spec/opcode_9_spec.rb +24 -0
  67. data/spec/opcode_a_spec.rb +23 -0
  68. data/spec/opcode_b_spec.rb +24 -0
  69. data/spec/opcode_c_spec.rb +23 -0
  70. data/spec/opcode_d_spec.rb +23 -0
  71. data/spec/opcode_e_spec.rb +39 -0
  72. data/spec/opcode_f_spec.rb +151 -0
  73. data/spec/opcode_spec.rb +45 -0
  74. data/spec/spec_helper.rb +2 -0
  75. metadata +183 -0
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ include C8dasm
4
+
5
+ describe Opcode do
6
+
7
+ describe 'c201' do
8
+ before { @opcode = Opcode.new('c201') }
9
+
10
+ it 'returns the opcode' do
11
+ expect(@opcode.opcode).to eq 'c201'
12
+ end
13
+
14
+ it 'returns the assembly' do
15
+ expect(@opcode.assembly).to eq 'RND V2, 01'
16
+ end
17
+
18
+ it 'returns a comment' do
19
+ expect(@opcode.comment).to eq 'Puts random byte AND 01 into register V2.'
20
+ end
21
+ end
22
+
23
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ include C8dasm
4
+
5
+ describe Opcode do
6
+
7
+ describe 'd014' do
8
+ before { @opcode = Opcode.new('d014') }
9
+
10
+ it 'returns the opcode' do
11
+ expect(@opcode.opcode).to eq 'd014'
12
+ end
13
+
14
+ it 'returns the assembly' do
15
+ expect(@opcode.assembly).to eq 'DRW V0, V1, 4'
16
+ end
17
+
18
+ it 'returns a comment' do
19
+ expect(@opcode.comment).to eq 'Draws 4-byte sprite from I at (V0, V1)'
20
+ end
21
+ end
22
+
23
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ include C8dasm
4
+
5
+ describe Opcode do
6
+
7
+ describe 'e29e' do
8
+ before { @opcode = Opcode.new('e29e') }
9
+
10
+ it 'returns the opcode' do
11
+ expect(@opcode.opcode).to eq 'e29e'
12
+ end
13
+
14
+ it 'returns the assembly' do
15
+ expect(@opcode.assembly).to eq 'SKP V2'
16
+ end
17
+
18
+ it 'returns a comment' do
19
+ expect(@opcode.comment).to eq 'Skip next inst. if V2 key is pressed.'
20
+ end
21
+ end
22
+
23
+ describe 'eda1' do
24
+ before { @opcode = Opcode.new('eda1') }
25
+
26
+ it 'returns the opcode' do
27
+ expect(@opcode.opcode).to eq 'eda1'
28
+ end
29
+
30
+ it 'returns the assembly' do
31
+ expect(@opcode.assembly).to eq 'SKNP Vd'
32
+ end
33
+
34
+ it 'returns a comment' do
35
+ expect(@opcode.comment).to eq 'Skip next inst. if Vd key is not pressed.'
36
+ end
37
+ end
38
+
39
+ end
@@ -0,0 +1,151 @@
1
+ require 'spec_helper'
2
+
3
+ include C8dasm
4
+
5
+ describe Opcode do
6
+
7
+ describe 'f607' do
8
+ before { @opcode = Opcode.new('f607') }
9
+
10
+ it 'returns the opcode' do
11
+ expect(@opcode.opcode).to eq 'f607'
12
+ end
13
+
14
+ it 'returns the assembly' do
15
+ expect(@opcode.assembly).to eq 'LD V6, DT'
16
+ end
17
+
18
+ it 'returns a comment' do
19
+ expect(@opcode.comment).to eq 'Set V6 = delay timer value.'
20
+ end
21
+ end
22
+
23
+ describe 'f00a' do
24
+ before { @opcode = Opcode.new('f00a') }
25
+
26
+ it 'returns the opcode' do
27
+ expect(@opcode.opcode).to eq 'f00a'
28
+ end
29
+
30
+ it 'returns the assembly' do
31
+ expect(@opcode.assembly).to eq 'LD V0, KEY'
32
+ end
33
+
34
+ it 'returns a comment' do
35
+ expect(@opcode.comment).to eq 'Wait key press, store its value in V0.'
36
+ end
37
+ end
38
+
39
+ describe 'f515' do
40
+ before { @opcode = Opcode.new('f515') }
41
+
42
+ it 'returns the opcode' do
43
+ expect(@opcode.opcode).to eq 'f515'
44
+ end
45
+
46
+ it 'returns the assembly' do
47
+ expect(@opcode.assembly).to eq 'LD DT, V5'
48
+ end
49
+
50
+ it 'returns a comment' do
51
+ expect(@opcode.comment).to eq 'Set delay timer = V5.'
52
+ end
53
+ end
54
+
55
+ describe 'fd18' do
56
+ before { @opcode = Opcode.new('fd18') }
57
+
58
+ it 'returns the opcode' do
59
+ expect(@opcode.opcode).to eq 'fd18'
60
+ end
61
+
62
+ it 'returns the assembly' do
63
+ expect(@opcode.assembly).to eq 'LD ST, Vd'
64
+ end
65
+
66
+ it 'returns a comment' do
67
+ expect(@opcode.comment).to eq 'Set sound timer = Vd.'
68
+ end
69
+ end
70
+
71
+ describe 'f61e' do
72
+ before { @opcode = Opcode.new('f61e') }
73
+
74
+ it 'returns the opcode' do
75
+ expect(@opcode.opcode).to eq 'f61e'
76
+ end
77
+
78
+ it 'returns the assembly' do
79
+ expect(@opcode.assembly).to eq 'ADD I, V6'
80
+ end
81
+
82
+ it 'returns a comment' do
83
+ expect(@opcode.comment).to eq 'Set I = I + V6.'
84
+ end
85
+ end
86
+
87
+ describe 'f029' do
88
+ before { @opcode = Opcode.new('f029') }
89
+
90
+ it 'returns the opcode' do
91
+ expect(@opcode.opcode).to eq 'f029'
92
+ end
93
+
94
+ it 'returns the assembly' do
95
+ expect(@opcode.assembly).to eq 'LD F, V0'
96
+ end
97
+
98
+ it 'returns a comment' do
99
+ expect(@opcode.comment).to eq 'Set I = location of sprite for digit V0.'
100
+ end
101
+ end
102
+
103
+ describe 'f733' do
104
+ before { @opcode = Opcode.new('f733') }
105
+
106
+ it 'returns the opcode' do
107
+ expect(@opcode.opcode).to eq 'f733'
108
+ end
109
+
110
+ it 'returns the assembly' do
111
+ expect(@opcode.assembly).to eq 'LD B, V7'
112
+ end
113
+
114
+ it 'returns a comment' do
115
+ expect(@opcode.comment).to eq 'Store BCD of V7 at I, I+1, and I+2.'
116
+ end
117
+ end
118
+
119
+ describe 'f265' do
120
+ before { @opcode = Opcode.new('f265') }
121
+
122
+ it 'returns the opcode' do
123
+ expect(@opcode.opcode).to eq 'f265'
124
+ end
125
+
126
+ it 'returns the assembly' do
127
+ expect(@opcode.assembly).to eq 'LD V2, [I]'
128
+ end
129
+
130
+ it 'returns a comment' do
131
+ expect(@opcode.comment).to eq 'Load registers V0..V2 starting from I.'
132
+ end
133
+ end
134
+
135
+ describe 'f055' do
136
+ before { @opcode = Opcode.new('f055') }
137
+
138
+ it 'returns the opcode' do
139
+ expect(@opcode.opcode).to eq 'f055'
140
+ end
141
+
142
+ it 'returns the assembly' do
143
+ expect(@opcode.assembly).to eq 'LD [I], V0'
144
+ end
145
+
146
+ it 'returns a comment' do
147
+ expect(@opcode.comment).to eq 'Store registers V0..V0 starting at I.'
148
+ end
149
+ end
150
+
151
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ include C8dasm
4
+
5
+ describe Opcode do
6
+
7
+ context 'with an explicit address' do
8
+ it 'returns the address in hexadecimal' do
9
+ opcode = Opcode.new('a21e', address: 1024)
10
+ expect(opcode.address).to eq '400'
11
+ end
12
+ end
13
+
14
+ context 'without an explicit address' do
15
+ it 'returns the default address in hexadecimal' do
16
+ opcode = Opcode.new('a21e')
17
+ expect(opcode.address).to eq '200'
18
+ end
19
+ end
20
+
21
+ describe '#line' do
22
+ it 'returns a fully formated line for the desassembly' do
23
+ opcode = Opcode.new('a21e', address: 1024)
24
+ expected = '400:a21e LD I, 21e ;Puts 21e into register I.'
25
+ expect(opcode.line).to eq expected
26
+ end
27
+ end
28
+
29
+ context 'with opcode 0000' do
30
+ before { @opcode = Opcode.new('0000') }
31
+
32
+ it 'returns the opcode' do
33
+ expect(@opcode.opcode).to eq '0000'
34
+ end
35
+
36
+ it 'returns no assembly' do
37
+ expect(@opcode.assembly).to eq ''
38
+ end
39
+
40
+ it 'returns special comment' do
41
+ expect(@opcode.comment).to eq '***WARNING*** UNKNOWN INSTRUCTION!'
42
+ end
43
+ end
44
+
45
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'c8dasm'
metadata ADDED
@@ -0,0 +1,183 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: c8dasm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.99.0
5
+ platform: ruby
6
+ authors:
7
+ - lkdjiin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: c8dasm is a utility to disassemble a Chip8 binary file.
56
+ email:
57
+ - xavier.nayrac@gmail.com
58
+ executables:
59
+ - c8dasm
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - ".travis.yml"
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - bin/c8dasm
71
+ - c8dasm.gemspec
72
+ - lib/c8dasm.rb
73
+ - lib/c8dasm/assemblies.rb
74
+ - lib/c8dasm/assemblies/asm0.rb
75
+ - lib/c8dasm/assemblies/asm1.rb
76
+ - lib/c8dasm/assemblies/asm2.rb
77
+ - lib/c8dasm/assemblies/asm3.rb
78
+ - lib/c8dasm/assemblies/asm4.rb
79
+ - lib/c8dasm/assemblies/asm5.rb
80
+ - lib/c8dasm/assemblies/asm6.rb
81
+ - lib/c8dasm/assemblies/asm7.rb
82
+ - lib/c8dasm/assemblies/asm8.rb
83
+ - lib/c8dasm/assemblies/asm9.rb
84
+ - lib/c8dasm/assemblies/asm_base.rb
85
+ - lib/c8dasm/assemblies/asma.rb
86
+ - lib/c8dasm/assemblies/asmb.rb
87
+ - lib/c8dasm/assemblies/asmc.rb
88
+ - lib/c8dasm/assemblies/asmd.rb
89
+ - lib/c8dasm/assemblies/asme.rb
90
+ - lib/c8dasm/assemblies/asmf.rb
91
+ - lib/c8dasm/assembly.rb
92
+ - lib/c8dasm/chip8_reader.rb
93
+ - lib/c8dasm/comment.rb
94
+ - lib/c8dasm/comments.rb
95
+ - lib/c8dasm/comments/comment0.rb
96
+ - lib/c8dasm/comments/comment1.rb
97
+ - lib/c8dasm/comments/comment2.rb
98
+ - lib/c8dasm/comments/comment3.rb
99
+ - lib/c8dasm/comments/comment4.rb
100
+ - lib/c8dasm/comments/comment5.rb
101
+ - lib/c8dasm/comments/comment6.rb
102
+ - lib/c8dasm/comments/comment7.rb
103
+ - lib/c8dasm/comments/comment8.rb
104
+ - lib/c8dasm/comments/comment9.rb
105
+ - lib/c8dasm/comments/comment_base.rb
106
+ - lib/c8dasm/comments/commenta.rb
107
+ - lib/c8dasm/comments/commentb.rb
108
+ - lib/c8dasm/comments/commentc.rb
109
+ - lib/c8dasm/comments/commentd.rb
110
+ - lib/c8dasm/comments/commente.rb
111
+ - lib/c8dasm/comments/commentf.rb
112
+ - lib/c8dasm/opcode.rb
113
+ - lib/c8dasm/version.rb
114
+ - spec/15-puzzle.ch8
115
+ - spec/MAZE
116
+ - spec/c8dasm_spec.rb
117
+ - spec/chip8_reader_spec.rb
118
+ - spec/opcode_0_spec.rb
119
+ - spec/opcode_1_spec.rb
120
+ - spec/opcode_2_spec.rb
121
+ - spec/opcode_3_spec.rb
122
+ - spec/opcode_4_spec.rb
123
+ - spec/opcode_5_spec.rb
124
+ - spec/opcode_6_spec.rb
125
+ - spec/opcode_7_spec.rb
126
+ - spec/opcode_8_spec.rb
127
+ - spec/opcode_9_spec.rb
128
+ - spec/opcode_a_spec.rb
129
+ - spec/opcode_b_spec.rb
130
+ - spec/opcode_c_spec.rb
131
+ - spec/opcode_d_spec.rb
132
+ - spec/opcode_e_spec.rb
133
+ - spec/opcode_f_spec.rb
134
+ - spec/opcode_spec.rb
135
+ - spec/spec_helper.rb
136
+ homepage: ''
137
+ licenses:
138
+ - GPLv3
139
+ metadata: {}
140
+ post_install_message:
141
+ rdoc_options: []
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ requirements: []
155
+ rubyforge_project:
156
+ rubygems_version: 2.4.5
157
+ signing_key:
158
+ specification_version: 4
159
+ summary: Disassembler for Chip8 binaries.
160
+ test_files:
161
+ - spec/15-puzzle.ch8
162
+ - spec/MAZE
163
+ - spec/c8dasm_spec.rb
164
+ - spec/chip8_reader_spec.rb
165
+ - spec/opcode_0_spec.rb
166
+ - spec/opcode_1_spec.rb
167
+ - spec/opcode_2_spec.rb
168
+ - spec/opcode_3_spec.rb
169
+ - spec/opcode_4_spec.rb
170
+ - spec/opcode_5_spec.rb
171
+ - spec/opcode_6_spec.rb
172
+ - spec/opcode_7_spec.rb
173
+ - spec/opcode_8_spec.rb
174
+ - spec/opcode_9_spec.rb
175
+ - spec/opcode_a_spec.rb
176
+ - spec/opcode_b_spec.rb
177
+ - spec/opcode_c_spec.rb
178
+ - spec/opcode_d_spec.rb
179
+ - spec/opcode_e_spec.rb
180
+ - spec/opcode_f_spec.rb
181
+ - spec/opcode_spec.rb
182
+ - spec/spec_helper.rb
183
+ has_rdoc: