voodoo 0.5.0 → 0.6.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.
@@ -8,12 +8,17 @@ module Voodoo
8
8
  def initialize nasmgenerator, nasm_extra_args
9
9
  @nasmgenerator = nasmgenerator
10
10
  @nasm_extra_args = nasm_extra_args
11
+ @output_file_suffix = '.o'
11
12
  end
12
13
 
13
14
  include CommandPostProcessor
14
15
 
15
16
  def output_file_name input_name
16
- input_name.sub(/\.voo$/, '') + '.o'
17
+ input_name.sub(/\.voo$/, '') + @output_file_suffix
18
+ end
19
+
20
+ def output_file_suffix
21
+ @output_file_suffix
17
22
  end
18
23
 
19
24
  # Writes the generated code to the given IO handle
@@ -26,18 +26,13 @@ module Voodoo
26
26
  def initialize params = {}
27
27
  super params
28
28
  @if_labels = []
29
+ @output_file_suffix = '.asm'
29
30
  end
30
31
 
31
32
  #
32
33
  # == Information About the Generator
33
34
  #
34
35
 
35
- # Given an input file name, returns the canonical output file name
36
- # for this code generator.
37
- def output_file_name input_name
38
- input_name.sub(/\.voo$/, '') + '.asm'
39
- end
40
-
41
36
  # Returns the number of bits per word for this code generator.
42
37
  def wordsize
43
38
  @WORDSIZE * 8
@@ -468,7 +463,8 @@ module Voodoo
468
463
  def eval_div x, y
469
464
  x_ref = load_value_into_register x, @AX
470
465
  y_ref = load_value y, @SCRATCH_REG
471
- set_register @DX, 0
466
+ emit "mov #{@DX}, #{@AX}\n"
467
+ emit "sar #{@DX}, #{@WORDSIZE * 8 - 1}\n"
472
468
  if immediate_operand?(y_ref)
473
469
  set_register @BX, y_ref
474
470
  emit "idiv #{@BX}\n"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: voodoo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robbert Haarman
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-10 00:00:00 +01:00
12
+ date: 2010-04-15 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -39,12 +39,13 @@ files:
39
39
  - lib/voodoo/generators/amd64_elf_generator.rb
40
40
  - lib/voodoo/generators/common_code_generator.rb
41
41
  - lib/voodoo/generators/nasm_generator.rb
42
+ - lib/voodoo/generators/mips_elf_generator.rb
43
+ - lib/voodoo/generators/gas_elf_generator.rb
42
44
  - lib/voodoo/generators/amd64_nasm_generator.rb
43
45
  - lib/voodoo/generators/mips_gas_generator.rb
44
46
  - lib/voodoo/generators/generator_api1.rb
45
47
  - lib/voodoo/generators/i386_nasm_generator.rb
46
48
  - lib/voodoo/generators/command_postprocessor.rb
47
- - lib/voodoo/generators/gas_generator.rb
48
49
  - lib/voodoo/generators/nasm_elf_generator.rb
49
50
  - lib/voodoo/generators/i386_elf_generator.rb
50
51
  has_rdoc: true
@@ -1,91 +0,0 @@
1
- require 'voodoo/generators/common_code_generator'
2
-
3
- module Voodoo
4
- # Common base class for code generators that target the GNU assembler
5
- class GasGenerator < CommonCodeGenerator
6
- def initialize params
7
- super params
8
- end
9
-
10
- #
11
- # == Alignment
12
- #
13
-
14
- # Align data on the next _alignment_-byte boundary.
15
- # If _alignment_ is not specified, the default data alignment
16
- # is used.
17
- def align_data alignment = @DATA_ALIGNMENT
18
- in_section(:data) { emit ".align #{alignment}" }
19
- end
20
-
21
- # Align code on the next _alignment_-byte boundary.
22
- # If _alignment_ is not specified, the default code alignment
23
- # is used.
24
- def align_code alignment = @CODE_ALIGNMENT
25
- in_section(:code) { emit ".align #{alignment}" }
26
- end
27
-
28
- # Align function on the next _alignment_-byte boundary.
29
- # If _alignment_ is not specified, the default function alignment
30
- # is used.
31
- def align_function alignment = @FUNCTION_ALIGNMENT
32
- in_section(:code) { emit ".align #{alignment}" }
33
- end
34
-
35
- #
36
- # == Data Definition
37
- #
38
-
39
- # Define a byte with the given value
40
- def byte value
41
- emit ".byte #{value}\n"
42
- end
43
-
44
- # Define a string with the given value
45
- def string value
46
- code = ''
47
- value.each_byte do |b|
48
- if b >= 32 && b < 128
49
- code << b.chr
50
- else
51
- code << sprintf('\%02x', b)
52
- end
53
- end
54
- emit ".ascii \"#{code}\"\n"
55
- end
56
-
57
- # Define a machine word with the given value
58
- def word value
59
- emit ".word #{value}\n"
60
- end
61
-
62
- #
63
- # == Information About the Generator
64
- #
65
-
66
- # Returns the number of bits per word for this code generator.
67
- def wordsize
68
- @WORDSIZE * 8
69
- end
70
-
71
- #
72
- # == Labels
73
- #
74
-
75
- # Export symbols from the current section
76
- def export *symbols
77
- symbols.each { |sym| emit ".globl #{sym}\n" }
78
- end
79
-
80
- # Import labels into the current section
81
- def import *symbols
82
- # nothing
83
- end
84
-
85
- # Define a label in the current section
86
- def label name
87
- emit "#{name}:\n"
88
- end
89
-
90
- end
91
- end