diff --git a/.travis.yml b/.travis.yml index 83880550..3a5791da 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,6 @@ before_install: + - git fetch origin master:master + - git fetch origin v2.0.0:v2.0.0 - sudo apt-get install libicu-dev -y - gem update --system 2.1.11 rvm: diff --git a/README.md b/README.md index 660ac00c..d497e8c2 100644 --- a/README.md +++ b/README.md @@ -152,4 +152,4 @@ If you are the current maintainer of this gem: 0. Test behavior locally, branch deploy, whatever needs to happen 0. Merge github/linguist PR 0. Tag and push: `git tag vx.xx.xx; git push --tags` - 0. Push to rubygems.org -- `gem push github-linguist-2.10.12.gem` + 0. Push to rubygems.org -- `gem push github-linguist-3.0.0.gem` diff --git a/bin/linguist b/bin/linguist index 2cfa8064..e086dcea 100755 --- a/bin/linguist +++ b/bin/linguist @@ -5,6 +5,7 @@ require 'linguist/file_blob' require 'linguist/repository' +require 'rugged' path = ARGV[0] || Dir.pwd @@ -18,7 +19,8 @@ ARGV.shift breakdown = true if ARGV[0] == "--breakdown" if File.directory?(path) - repo = Linguist::Repository.from_directory(path) + rugged = Rugged::Repository.new(path) + repo = Linguist::Repository.new(rugged, rugged.head.target_id) repo.languages.sort_by { |_, size| size }.reverse.each do |language, size| percentage = ((size / repo.size.to_f) * 100) percentage = sprintf '%.2f' % percentage diff --git a/github-linguist.gemspec b/github-linguist.gemspec index d4c2337a..936550f3 100644 --- a/github-linguist.gemspec +++ b/github-linguist.gemspec @@ -17,6 +17,7 @@ Gem::Specification.new do |s| s.add_dependency 'escape_utils', '~> 1.0.1' s.add_dependency 'mime-types', '~> 1.19' s.add_dependency 'pygments.rb', '~> 0.6.0' + s.add_dependency 'rugged', '~> 0.21.0' s.add_development_dependency 'json' s.add_development_dependency 'mocha' diff --git a/lib/linguist/blob_helper.rb b/lib/linguist/blob_helper.rb index 15ab2d9f..27c4b3dd 100644 --- a/lib/linguist/blob_helper.rb +++ b/lib/linguist/blob_helper.rb @@ -313,15 +313,7 @@ module Linguist # # Returns a Language or nil if none is detected def language - return @language if defined? @language - - if defined?(@data) && @data.is_a?(String) - data = @data - else - data = lambda { (binary_mime_type? || binary?) ? "" : self.data } - end - - @language = Language.detect(name.to_s, data, mode) + @language ||= Language.detect(self) end # Internal: Get the lexer of the blob. diff --git a/lib/linguist/file_blob.rb b/lib/linguist/file_blob.rb index 7e7f1acd..bc475023 100644 --- a/lib/linguist/file_blob.rb +++ b/lib/linguist/file_blob.rb @@ -52,5 +52,20 @@ module Linguist def size File.size(@path) end + + # Public: Get file extension. + # + # Returns a String. + def extension + # File.extname returns nil if the filename is an extension. + extension = File.extname(name) + basename = File.basename(name) + # Checks if the filename is an extension. + if extension.empty? && basename[0] == "." + basename + else + extension + end + end end end diff --git a/lib/linguist/language.rb b/lib/linguist/language.rb index a8e7a33c..b2245b87 100644 --- a/lib/linguist/language.rb +++ b/lib/linguist/language.rb @@ -92,18 +92,25 @@ module Linguist # Public: Detects the Language of the blob. # - # name - String filename - # data - String blob data. A block also maybe passed in for lazy - # loading. This behavior is deprecated and you should always - # pass in a String. - # mode - Optional String mode (defaults to nil) + # blob - an object that includes the Linguist `BlobHelper` interface; + # see Linguist::LazyBlob and Linguist::FileBlob for examples # # Returns Language or nil. - def self.detect(name, data, mode = nil) + def self.detect(blob) + name = blob.name.to_s + + # Check if the blob is possibly binary and bail early; this is a cheap + # test that uses the extension name to guess a binary binary mime type. + # + # We'll perform a more comprehensive test later which actually involves + # looking for binary characters in the blob + return nil if blob.likely_binary? || blob.binary? + # A bit of an elegant hack. If the file is executable but extensionless, # append a "magic" extension so it can be classified with other # languages that have shebang scripts. - if File.extname(name).empty? && mode && (mode.to_i(8) & 05) == 05 + extension = FileBlob.new(name).extension + if extension.empty? && blob.mode && (blob.mode.to_i(8) & 05) == 05 name += ".script!" end @@ -114,10 +121,10 @@ module Linguist # extension at all, in the case of extensionless scripts), we need to continue # our detection work if possible_languages.length > 1 - data = data.call() if data.respond_to?(:call) + data = blob.data possible_language_names = possible_languages.map(&:name) - # Don't bother with emptiness + # Don't bother with binary contents or an empty file if data.nil? || data == "" nil # Check if there's a shebang line and use that as authoritative @@ -183,7 +190,8 @@ module Linguist # # Returns all matching Languages or [] if none were found. def self.find_by_filename(filename) - basename, extname = File.basename(filename), File.extname(filename) + basename = File.basename(filename) + extname = FileBlob.new(filename).extension langs = @filename_index[basename] + @extension_index[extname] langs.compact.uniq @@ -395,7 +403,7 @@ module Linguist # # Returns the extensions Array attr_reader :filenames - + # Public: Return all possible extensions for language def all_extensions (extensions + [primary_extension]).uniq diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 1038cc7a..5b126270 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -89,7 +89,7 @@ Agda: Alloy: type: programming # 'modeling' would be more appropiate - lexer: Text only + lexer: Alloy color: "#cc5c24" extensions: - .als @@ -157,7 +157,6 @@ Assembly: - nasm extensions: - .asm - - .inc Augeas: type: programming @@ -222,6 +221,8 @@ BlitzBasic: - .decls BlitzMax: + type: programming + color: "#cd6400" extensions: - .bmx @@ -800,6 +801,12 @@ Gosu: extensions: - .gs +Grace: + type: programming + lexer: Text only + extensions: + - .grace + Grammatical Framework: type: programming lexer: Haskell @@ -1397,6 +1404,13 @@ Nimrod: - .nim - .nimrod +Nit: + type: programming + lexer: Text only + color: "#0d8921" + extensions: + - .nit + Nix: type: programming lexer: Nix @@ -1538,6 +1552,8 @@ PHP: - .phpt filenames: - Phakefile + interpreters: + - php Pan: type: programming @@ -1890,6 +1906,7 @@ Ruby: - Jarfile - Mavenfile - Podfile + - Puppetfile - Thorfile - Vagrantfile - buildfile diff --git a/lib/linguist/lazy_blob.rb b/lib/linguist/lazy_blob.rb new file mode 100644 index 00000000..bb262241 --- /dev/null +++ b/lib/linguist/lazy_blob.rb @@ -0,0 +1,37 @@ +require 'linguist/blob_helper' +require 'rugged' + +module Linguist + class LazyBlob + include BlobHelper + + MAX_SIZE = 128 * 1024 + + attr_reader :repository + attr_reader :oid + attr_reader :name + attr_reader :mode + + def initialize(repo, oid, name, mode = nil) + @repository = repo + @oid = oid + @name = name + @mode = mode + end + + def data + load_blob! + @data + end + + def size + load_blob! + @size + end + + protected + def load_blob! + @data, @size = Rugged::Blob.to_buffer(repository, oid, MAX_SIZE) if @data.nil? + end + end +end diff --git a/lib/linguist/repository.rb b/lib/linguist/repository.rb index a62bf281..a89c81e6 100644 --- a/lib/linguist/repository.rb +++ b/lib/linguist/repository.rb @@ -1,4 +1,5 @@ -require 'linguist/file_blob' +require 'linguist/lazy_blob' +require 'rugged' module Linguist # A Repository is an abstraction of a Grit::Repo or a basic file @@ -7,100 +8,146 @@ module Linguist # Its primary purpose is for gathering language statistics across # the entire project. class Repository - # Public: Initialize a new Repository from a File directory - # - # base_path - A path String - # - # Returns a Repository - def self.from_directory(base_path) - new Dir["#{base_path}/**/*"]. - select { |f| File.file?(f) }. - map { |path| FileBlob.new(path, base_path) } + attr_reader :repository + + # Public: Create a new Repository based on the stats of + # an existing one + def self.incremental(repo, commit_oid, old_commit_oid, old_stats) + repo = self.new(repo, commit_oid) + repo.load_existing_stats(old_commit_oid, old_stats) + repo end - # Public: Initialize a new Repository + # Public: Initialize a new Repository to be analyzed for language + # data # - # enum - Enumerator that responds to `each` and - # yields Blob objects + # repo - a Rugged::Repository object + # commit_oid - the sha1 of the commit that will be analyzed; + # this is usually the master branch # # Returns a Repository - def initialize(enum) - @enum = enum - @computed_stats = false - @language = @size = nil - @sizes = Hash.new { 0 } - @file_breakdown = Hash.new { |h,k| h[k] = Array.new } + def initialize(repo, commit_oid) + @repository = repo + @commit_oid = commit_oid + + raise TypeError, 'commit_oid must be a commit SHA1' unless commit_oid.is_a?(String) + end + + # Public: Load the results of a previous analysis on this repository + # to speed up the new scan. + # + # The new analysis will be performed incrementally as to only take + # into account the file changes since the last time the repository + # was scanned + # + # old_commit_oid - the sha1 of the commit that was previously analyzed + # old_stats - the result of the previous analysis, obtained by calling + # Repository#cache on the old repository + # + # Returns nothing + def load_existing_stats(old_commit_oid, old_stats) + @old_commit_oid = old_commit_oid + @old_stats = old_stats + nil end # Public: Returns a breakdown of language stats. # # Examples # - # # => { Language['Ruby'] => 46319, - # Language['JavaScript'] => 258 } + # # => { 'Ruby' => 46319, + # 'JavaScript' => 258 } # - # Returns a Hash of Language keys and Integer size values. + # Returns a Hash of language names and Integer size values. def languages - compute_stats - @sizes + @sizes ||= begin + sizes = Hash.new { 0 } + cache.each do |_, (language, size)| + sizes[language] += size + end + sizes + end end # Public: Get primary Language of repository. # - # Returns a Language + # Returns a language name def language - compute_stats - @language + @language ||= begin + primary = languages.max_by { |(_, size)| size } + primary && primary[0] + end end # Public: Get the total size of the repository. # # Returns a byte size Integer def size - compute_stats - @size + @size ||= languages.inject(0) { |s,(_,v)| s + v } end # Public: Return the language breakdown of this repository by file + # + # Returns a map of language names => [filenames...] def breakdown_by_file - compute_stats - @file_breakdown + @file_breakdown ||= begin + breakdown = Hash.new { |h,k| h[k] = Array.new } + cache.each do |filename, (language, _)| + breakdown[language] << filename + end + breakdown + end end - # Internal: Compute language breakdown for each blob in the Repository. + # Public: Return the cached results of the analysis # - # Returns nothing - def compute_stats - return if @computed_stats + # This is a per-file breakdown that can be passed to other instances + # of Linguist::Repository to perform incremental scans + # + # Returns a map of filename => [language, size] + def cache + @cache ||= begin + if @old_commit_oid == @commit_oid + @old_stats + else + compute_stats(@old_commit_oid, @commit_oid, @old_stats) + end + end + end - @enum.each do |blob| - # Skip files that are likely binary - next if blob.likely_binary? + protected + def compute_stats(old_commit_oid, commit_oid, cache = nil) + file_map = cache ? cache.dup : {} + old_tree = old_commit_oid && Rugged::Commit.lookup(repository, old_commit_oid).tree + new_tree = Rugged::Commit.lookup(repository, commit_oid).tree - # Skip vendored or generated blobs - next if blob.vendored? || blob.generated? || blob.language.nil? + diff = Rugged::Tree.diff(repository, old_tree, new_tree) - # Only include programming languages and acceptable markup languages - if blob.language.type == :programming || Language.detectable_markup.include?(blob.language.name) + diff.each_delta do |delta| + old = delta.old_file[:path] + new = delta.new_file[:path] - # Build up the per-file breakdown stats - @file_breakdown[blob.language.group.name] << blob.name + file_map.delete(old) + next if delta.binary - @sizes[blob.language.group] += blob.size + if [:added, :modified].include? delta.status + # Skip submodules + mode = delta.new_file[:mode] + next if (mode & 040000) != 0 + + blob = Linguist::LazyBlob.new(repository, delta.new_file[:oid], new, mode.to_s(8)) + + # Skip vendored or generated blobs + next if blob.vendored? || blob.generated? || blob.language.nil? + + # Only include programming languages and acceptable markup languages + if blob.language.type == :programming || Language.detectable_markup.include?(blob.language.name) + file_map[new] = [blob.language.group.name, blob.size] + end end end - # Compute total size - @size = @sizes.inject(0) { |s,(_,v)| s + v } - - # Get primary language - if primary = @sizes.max_by { |(_, size)| size } - @language = primary[0] - end - - @computed_stats = true - - nil + file_map end end end diff --git a/lib/linguist/samples.json b/lib/linguist/samples.json index 9815310d..bde32dac 100644 --- a/lib/linguist/samples.json +++ b/lib/linguist/samples.json @@ -33,8 +33,7 @@ ".aj" ], "Assembly": [ - ".asm", - ".inc" + ".asm" ], "AutoHotkey": [ ".ahk" @@ -45,6 +44,9 @@ "BlitzBasic": [ ".bb" ], + "BlitzMax": [ + ".bmx" + ], "Bluespec": [ ".bsv" ], @@ -189,6 +191,9 @@ ".gsx", ".vark" ], + "Grace": [ + ".grace" + ], "Grammatical Framework": [ ".gf" ], @@ -366,6 +371,9 @@ "Nimrod": [ ".nim" ], + "Nit": [ + ".nit" + ], "Nix": [ ".nix" ], @@ -734,6 +742,9 @@ "Nginx": [ "nginx.conf" ], + "PHP": [ + ".php" + ], "Perl": [ "ack" ], @@ -776,6 +787,9 @@ ".gvimrc", ".vimrc" ], + "XML": [ + ".cproject" + ], "YAML": [ ".gemrc" ], @@ -785,8 +799,8 @@ "exception.zep.php" ] }, - "tokens_total": 650833, - "languages_total": 855, + "tokens_total": 637738, + "languages_total": 879, "tokens": { "ABAP": { "*/**": 1, @@ -3157,1134 +3171,22 @@ "WeakHashMap": 1 }, "Assembly": { - ";": 20, - "flat": 4, - "assembler": 6, - "core": 2, - "Copyright": 4, - "(": 13, - "c": 4, - ")": 6, - "-": 87, - "Tomasz": 4, - "Grysztar.": 4, - "All": 4, - "rights": 4, - "reserved.": 4, - "xor": 52, - "eax": 510, - "mov": 1253, - "[": 2026, - "stub_size": 1, - "]": 2026, - "current_pass": 16, - "ax": 87, - "resolver_flags": 1, - "number_of_sections": 1, - "actual_fixups_size": 1, - "assembler_loop": 2, - "labels_list": 3, - "tagged_blocks": 23, - "additional_memory": 6, - "free_additional_memory": 2, - "additional_memory_end": 9, - "structures_buffer": 9, - "esi": 619, - "source_start": 1, - "edi": 250, - "code_start": 2, - "dword": 87, - "adjustment": 4, - "+": 232, - "addressing_space": 17, - "error_line": 16, - "counter": 13, - "format_flags": 2, - "number_of_relocations": 1, - "undefined_data_end": 4, - "file_extension": 1, - "next_pass_needed": 16, - "al": 1174, - "output_format": 3, - "adjustment_sign": 2, - "code_type": 106, - "call": 845, - "init_addressing_space": 6, - "pass_loop": 2, - "assemble_line": 3, - "jnc": 11, - "cmp": 1088, - "je": 485, - "pass_done": 2, - "sub": 64, - "h": 376, - "current_line": 24, - "jmp": 450, - "missing_end_directive": 7, - "close_pass": 1, - "check_symbols": 2, - "memory_end": 7, - "jae": 34, - "symbols_checked": 2, - "test": 95, - "byte": 549, - "jz": 107, - "symbol_defined_ok": 5, - "cx": 42, - "jne": 485, - "and": 50, - "not": 42, - "or": 194, - "use_prediction_ok": 5, - "jnz": 125, - "check_use_prediction": 2, - "use_misprediction": 3, - "check_next_symbol": 5, - "define_misprediction": 4, - "check_define_prediction": 2, - "add": 76, - "LABEL_STRUCTURE_SIZE": 1, - "next_pass": 3, - "assemble_ok": 2, - "error": 7, - "undefined_symbol": 2, - "error_confirmed": 3, - "error_info": 2, - "error_handler": 3, - "esp": 14, - "ret": 70, - "inc": 87, - "passes_limit": 3, - "code_cannot_be_generated": 1, - "create_addressing_space": 1, - "ebx": 336, - "Ah": 25, - "illegal_instruction": 48, - "Ch": 11, - "jbe": 11, - "out_of_memory": 19, - "ja": 28, - "lods": 366, - "assemble_instruction": 2, - "jb": 34, - "source_end": 2, - "define_label": 2, - "define_constant": 2, - "label_addressing_space": 2, - "Fh": 73, - "new_line": 2, - "code_type_setting": 2, - "segment_prefix": 2, - "instruction_assembled": 138, - "prefixed_instruction": 11, - "symbols_file": 4, - "continue_line": 8, - "line_assembled": 3, - "invalid_use_of_symbol": 17, - "reserved_word_used_as_symbol": 6, - "label_size": 5, - "make_label": 3, - "edx": 219, - "cl": 42, - "ebp": 49, - "ds": 21, - "sbb": 9, - "jp": 2, - "label_value_ok": 2, - "recoverable_overflow": 4, - "address_sign": 4, - "make_virtual_label": 2, - "xchg": 31, - "ch": 55, - "shr": 30, - "neg": 4, - "setnz": 5, - "ah": 229, - "finish_label": 2, - "setne": 14, - "finish_label_symbol": 2, - "b": 30, - "label_symbol_ok": 2, - "new_label": 2, - "symbol_already_defined": 3, - "btr": 2, - "jc": 28, - "requalified_label": 2, - "label_made": 4, - "push": 150, - "get_constant_value": 4, - "dl": 58, - "size_override": 7, - "get_value": 2, - "pop": 99, - "bl": 124, - "ecx": 153, - "constant_referencing_mode_ok": 2, - "value_type": 42, - "make_constant": 2, - "value_sign": 3, - "constant_symbol_ok": 2, - "symbol_identifier": 4, - "new_constant": 2, - "redeclare_constant": 2, - "requalified_constant": 2, - "make_addressing_space_label": 3, - "dx": 27, - "operand_size": 121, - "operand_prefix": 9, - "opcode_prefix": 30, - "rex_prefix": 9, - "vex_required": 2, - "vex_register": 1, - "immediate_size": 9, - "instruction_handler": 32, - "movzx": 13, - "word": 79, - "extra_characters_on_line": 8, - "clc": 11, - "dec": 30, - "stc": 9, - "org_directive": 1, - "invalid_argument": 28, - "invalid_value": 21, - "get_qword_value": 5, - "in_virtual": 2, - "org_space_ok": 2, - "close_virtual_addressing_space": 3, - "org_value_ok": 2, - "bts": 1, - "label_directive": 1, - "get_label_size": 2, - "label_size_ok": 2, - "get_free_label_value": 2, - "get_address_value": 3, - "bh": 34, - "bp": 2, - "shl": 17, - "bx": 8, - "make_free_label": 1, - "address_symbol": 2, - "load_directive": 1, - "load_size_ok": 2, - "value": 38, - "get_data_point": 3, - "value_loaded": 2, - "rep": 7, - "movs": 8, - "get_data_address": 5, - "addressing_space_unavailable": 3, - "symbol_out_of_scope": 1, - "get_addressing_space": 3, - "store_label_reference": 1, - "calculate_relative_offset": 2, - "data_address_type_ok": 2, - "adc": 9, - "bad_data_address": 3, - "store_directive": 1, - "sized_store": 2, - "get_byte_value": 23, - "store_value_ok": 2, - "undefined_data_start": 3, - "display_directive": 2, - "display_byte": 2, - "stos": 107, - "display_next": 2, - "show_display_buffer": 2, - "display_done": 3, - "display_messages": 2, - "skip_block": 2, - "display_block": 4, - "times_directive": 1, - "get_count_value": 6, - "zero_times": 3, - "times_argument_ok": 2, - "counter_limit": 7, - "times_loop": 2, - "stack_overflow": 2, - "stack_limit": 2, - "times_done": 2, - "skip_symbol": 5, - "virtual_directive": 3, - "virtual_at_current": 2, - "set_virtual": 2, - "allocate_structure_data": 5, - "find_structure_data": 6, - "scan_structures": 2, - "no_such_structure": 2, - "structure_data_found": 2, - "end_virtual": 2, - "unexpected_instruction": 18, - "remove_structure_data": 7, - "lea": 8, - "std": 2, - "cld": 2, - "addressing_space_closed": 2, - "virtual_byte_ok": 2, - "virtual_word_ok": 2, - "repeat_directive": 7, - "zero_repeat": 2, - "end_repeat": 2, - "continue_repeating": 2, - "stop_repeat": 2, - "find_end_repeat": 4, - "find_structure_end": 5, - "while_directive": 7, - "do_while": 2, - "calculate_logical_expression": 3, - "while_true": 2, - "stop_while": 2, - "find_end_while": 3, - "end_while": 2, - "too_many_repeats": 1, - "if_directive": 13, - "if_true": 2, - "find_else": 4, - "else_true": 3, - "make_if_structure": 2, - "else_directive": 3, - "found_else": 2, - "skip_else": 3, - "find_end_if": 3, - "end_if": 2, - "else_found": 2, - "find_end_directive": 10, - "no_end_directive": 2, - "skip_labels": 2, - "labels_ok": 2, - "prefix_instruction": 2, - "skip_repeat": 2, - "skip_while": 2, - "skip_if": 2, - "structure_end": 4, - "end_directive": 2, - "skip_if_block": 4, - "if_block_skipped": 2, - "skip_after_else": 3, - "data_directive": 1, - "end_data": 1, - "break_directive": 1, - "find_breakable_structure": 4, - "break_repeat": 2, - "break_while": 2, - "break_if": 2, - "data_bytes": 1, - "define_data": 8, - "get_byte": 2, - "undefined_data": 7, - "get_string": 2, - "mark_undefined_data": 2, - "undefined_data_ok": 2, - "simple_data_value": 3, - "skip_expression": 1, - "duplicate_zero_times": 2, - "duplicate_single_data_value": 3, - "duplicate_data": 2, - "duplicated_values": 2, - "near": 3, - "data_defined": 5, - "skip_single_data_value": 2, - "skip_data_value": 2, - "data_unicode": 1, - "base_code": 195, - "define_words": 2, - "data_words": 1, - "get_word": 2, - "scas": 10, - "word_data_value": 2, - "word_string": 2, - "get_word_value": 19, - "mark_relocation": 26, - "jecxz": 1, - "word_string_ok": 2, - "ecx*2": 1, - "copy_word_string": 2, - "loop": 2, - "data_dwords": 1, - "get_dword": 2, - "get_dword_value": 13, - "complex_dword": 2, - "invalid_operand": 239, - "data_pwords": 1, - "get_pword": 2, - "get_pword_value": 1, - "complex_pword": 2, - "data_qwords": 1, - "get_qword": 2, - "data_twords": 1, - "get_tword": 2, - "complex_tword": 2, - "fp_zero_tword": 2, - "FFFh": 3, - "jo": 2, - "value_out_of_range": 10, - "jge": 5, - "jg": 1, - "tword_exp_ok": 3, - "large_shift": 2, - "shrd": 1, - "tword_mantissa_shift_done": 2, - "store_shifted_mantissa": 2, - "data_file": 2, - "open_binary_file": 2, - "lseek": 5, - "position_ok": 2, - "size_ok": 2, - "read": 3, - "error_reading_file": 1, - "close": 3, - "find_current_source_path": 2, - "get_current_path": 3, - "lodsb": 12, - "stosb": 6, - "cut_current_path": 1, - "current_path_ok": 1, - "/": 1, - ".": 7, - "invalid_align_value": 3, - "section_not_aligned_enough": 4, - "make_alignment": 3, - "pe_alignment": 2, - "nops": 2, - "reserved_data": 2, - "nops_stosb_ok": 2, - "nops_stosw_ok": 2, - "err_directive": 1, - "invoked_error": 2, - "assert_directive": 1, - "assertion_failed": 1, - "simple_instruction_except64": 1, - "simple_instruction": 6, - "simple_instruction_only64": 1, - "simple_instruction_16bit_except64": 1, - "simple_instruction_16bit": 2, - "size_prefix": 3, - "simple_instruction_32bit_except64": 1, - "simple_instruction_32bit": 6, - "iret_instruction": 1, - "simple_instruction_64bit": 2, - "simple_extended_instruction_64bit": 1, - "simple_extended_instruction": 1, - "segment_register": 7, - "store_segment_prefix": 1, - "int_instruction": 1, - "get_size_operator": 137, - "invalid_operand_size": 131, - "jns": 1, - "int_imm_ok": 2, - "CDh": 1, - "aa_instruction": 1, - "aa_store": 2, - "basic_instruction": 1, - "basic_reg": 2, - "basic_mem": 1, - "get_address": 62, - "basic_mem_imm": 2, - "basic_mem_reg": 1, - "convert_register": 60, - "postbyte_register": 137, - "instruction_ready": 72, - "operand_autodetect": 47, - "store_instruction": 3, - "basic_mem_imm_nosize": 2, - "basic_mem_imm_8bit": 2, - "basic_mem_imm_16bit": 2, - "basic_mem_imm_32bit": 2, - "basic_mem_imm_64bit": 1, - "size_declared": 17, - "long_immediate_not_encodable": 14, - "operand_64bit": 18, - "get_simm32": 10, - "basic_mem_imm_32bit_ok": 2, - "recoverable_unknown_size": 19, - "store_instruction_with_imm8": 11, - "operand_16bit": 25, - "basic_mem_imm_16bit_store": 3, - "basic_mem_simm_8bit": 5, - "store_instruction_with_imm16": 4, - "operand_32bit": 27, - "basic_mem_imm_32bit_store": 3, - "store_instruction_with_imm32": 4, - "cdq": 11, - "get_simm32_ok": 2, - "basic_reg_reg": 2, - "basic_reg_imm": 2, - "basic_reg_mem": 1, - "basic_reg_mem_8bit": 2, - "nomem_instruction_ready": 53, - "store_nomem_instruction": 19, - "basic_reg_imm_8bit": 2, - "basic_reg_imm_16bit": 2, - "basic_reg_imm_32bit": 2, - "basic_reg_imm_64bit": 1, - "basic_reg_imm_32bit_ok": 2, - "basic_al_imm": 2, - "basic_reg_imm_16bit_store": 3, - "basic_reg_simm_8bit": 5, - "basic_ax_imm": 2, - "basic_store_imm_16bit": 2, - "store_instruction_code": 26, - "basic_reg_imm_32bit_store": 3, - "basic_eax_imm": 2, - "basic_store_imm_32bit": 2, - "ignore_unknown_size": 2, - "operand_size_not_specified": 1, - "single_operand_instruction": 1, - "F6h": 4, - "single_reg": 2, - "single_mem": 1, - "single_mem_8bit": 2, - "single_mem_nosize": 2, - "single_reg_8bit": 2, - "mov_instruction": 1, - "mov_reg": 2, - "mov_mem": 1, - "mov_mem_imm": 2, - "mov_mem_reg": 1, - "mov_mem_general_reg": 2, - "mov_mem_sreg": 2, - "mov_mem_reg_8bit": 2, - "mov_mem_ax": 2, - "mov_mem_al": 1, - "mov_mem_address16_al": 3, - "mov_mem_address32_al": 3, - "mov_mem_address64_al": 3, - "invalid_address_size": 18, - "store_segment_prefix_if_necessary": 17, - "address_32bit_prefix": 11, - "A2h": 3, - "store_mov_address32": 4, - "store_address_32bit_value": 1, - "address_16bit_prefix": 11, - "store_mov_address16": 4, - "invalid_address": 32, - "store_mov_address64": 4, - "store_address_64bit_value": 1, - "mov_mem_address16_ax": 3, - "mov_mem_address32_ax": 3, - "mov_mem_address64_ax": 3, - "A3h": 3, - "mov_mem_sreg_store": 2, - "mov_mem_imm_nosize": 2, - "mov_mem_imm_8bit": 2, - "mov_mem_imm_16bit": 2, - "mov_mem_imm_32bit": 2, - "mov_mem_imm_64bit": 1, - "mov_mem_imm_32bit_store": 2, - "C6h": 1, - "C7h": 4, - "F0h": 7, - "mov_sreg": 2, - "mov_reg_mem": 2, - "mov_reg_imm": 2, - "mov_reg_reg": 1, - "mov_reg_sreg": 2, - "mov_reg_reg_8bit": 2, - "mov_reg_creg": 2, - "mov_reg_dreg": 2, - "mov_reg_treg": 2, - "mov_reg_sreg64": 2, - "mov_reg_sreg32": 2, - "mov_reg_sreg_store": 3, - "extended_code": 73, - "mov_reg_xrx": 3, - "mov_reg_xrx_64bit": 2, - "mov_reg_xrx_store": 3, - "mov_reg_mem_8bit": 2, - "mov_ax_mem": 2, - "mov_al_mem": 2, - "mov_al_mem_address16": 3, - "mov_al_mem_address32": 3, - "mov_al_mem_address64": 3, - "A0h": 4, - "mov_ax_mem_address16": 3, - "mov_ax_mem_address32": 3, - "mov_ax_mem_address64": 3, - "A1h": 4, - "mov_reg_imm_8bit": 2, - "mov_reg_imm_16bit": 2, - "mov_reg_imm_32bit": 2, - "mov_reg_imm_64bit": 1, - "mov_reg_imm_64bit_store": 3, - "mov_reg_64bit_imm_32bit": 2, - "B8h": 3, - "store_mov_reg_imm_code": 5, - "B0h": 5, - "mov_store_imm_32bit": 2, - "mov_reg_imm_prefix_ok": 2, - "mov_creg": 2, - "mov_dreg": 2, - "mov_treg": 2, - "mov_sreg_mem": 2, - "mov_sreg_reg": 1, - "mov_sreg_reg_size_ok": 2, - "Eh": 8, - "mov_sreg_mem_size_ok": 2, - "mov_xrx": 3, - "mov_xrx_64bit": 2, - "mov_xrx_store": 4, - "test_instruction": 1, - "test_reg": 2, - "test_mem": 1, - "test_mem_imm": 2, - "test_mem_reg": 2, - "test_mem_reg_8bit": 2, - "test_mem_imm_nosize": 2, - "test_mem_imm_8bit": 2, - "test_mem_imm_16bit": 2, - "test_mem_imm_32bit": 2, - "test_mem_imm_64bit": 1, - "test_mem_imm_32bit_store": 2, - "F7h": 5, - "test_reg_mem": 3, - "test_reg_imm": 2, - "test_reg_reg": 1, - "test_reg_reg_8bit": 2, - "test_reg_imm_8bit": 2, - "test_reg_imm_16bit": 2, - "test_reg_imm_32bit": 2, - "test_reg_imm_64bit": 1, - "test_reg_imm_32bit_store": 2, - "test_al_imm": 2, - "A8h": 1, - "test_ax_imm": 2, - "A9h": 2, - "test_eax_imm": 2, - "test_reg_mem_8bit": 2, - "xchg_instruction": 1, - "xchg_reg": 2, - "xchg_mem": 1, - "xchg_reg_reg": 1, - "xchg_reg_reg_8bit": 2, - "xchg_ax_reg": 2, - "xchg_reg_reg_store": 3, - "xchg_ax_reg_ok": 3, - "xchg_ax_reg_store": 2, - "push_instruction": 1, - "push_size": 9, - "push_next": 2, - "push_reg": 2, - "push_imm": 2, - "push_mem": 1, - "push_mem_16bit": 3, - "push_mem_32bit": 3, - "push_mem_64bit": 3, - "push_mem_store": 4, - "FFh": 4, - "push_done": 5, - "push_sreg": 2, - "push_reg_ok": 2, - "push_reg_16bit": 2, - "push_reg_32bit": 2, - "push_reg_64bit": 1, - "push_reg_store": 5, - "dh": 37, - "push_sreg16": 3, - "push_sreg32": 3, - "push_sreg64": 3, - "push_sreg_store": 4, - "push_sreg_386": 2, - "push_imm_size_ok": 3, - "push_imm_16bit": 2, - "push_imm_32bit": 2, - "push_imm_64bit": 2, - "push_imm_optimized_16bit": 3, - "push_imm_optimized_32bit": 3, - "push_imm_optimized_64bit": 2, - "push_imm_32bit_store": 8, - "jl": 13, - "push_imm_8bit": 3, - "push_imm_16bit_store": 4, - "pop_instruction": 1, - "pop_next": 2, - "pop_reg": 2, - "pop_mem": 1, - "pop_mem_16bit": 3, - "pop_mem_32bit": 3, - "pop_mem_64bit": 3, - "pop_mem_store": 4, - "pop_done": 3, - "pop_sreg": 2, - "pop_reg_ok": 2, - "pop_reg_16bit": 2, - "pop_reg_32bit": 2, - "pop_reg_64bit": 2, - "pop_reg_store": 5, - "pop_cs": 2, - "pop_sreg16": 3, - "pop_sreg32": 3, - "pop_sreg64": 3, - "pop_sreg_store": 4, - "pop_sreg_386": 2, - "pop_cs_store": 3, - "inc_instruction": 1, - "inc_reg": 2, - "inc_mem": 2, - "inc_mem_8bit": 2, - "inc_mem_nosize": 2, - "FEh": 2, - "inc_reg_8bit": 2, - "inc_reg_long_form": 2, - "set_instruction": 1, - "set_reg": 2, - "set_mem": 1, - "arpl_instruction": 1, - "arpl_reg": 2, - "bound_instruction": 1, - "bound_store": 2, - "enter_instruction": 1, - "enter_imm16_size_ok": 2, - "enter_imm16_ok": 2, - "js": 3, - "enter_imm8_size_ok": 2, - "enter_imm8_ok": 2, - "C8h": 2, - "ret_instruction_only64": 1, - "ret_instruction": 5, - "ret_instruction_32bit_except64": 1, - "ret_instruction_32bit": 1, - "ret_instruction_16bit": 1, - "retf_instruction": 1, - "ret_instruction_64bit": 1, - "simple_ret": 4, - "ret_imm": 3, - "ret_imm_ok": 2, - "ret_imm_store": 2, - "lea_instruction": 1, - "Dh": 19, - "ls_instruction": 1, - "les_instruction": 2, - "lds_instruction": 2, - "ls_code_ok": 2, - "C4h": 1, - "ls_short_code": 2, - "C5h": 2, - "ls_16bit": 2, - "ls_32bit": 2, - "ls_64bit": 2, - "sh_instruction": 1, - "sh_reg": 2, - "sh_mem": 1, - "sh_mem_imm": 2, - "sh_mem_reg": 1, - "sh_mem_cl_8bit": 2, - "sh_mem_cl_nosize": 2, - "D3h": 2, - "D2h": 2, - "sh_mem_imm_size_ok": 2, - "sh_mem_imm_8bit": 2, - "sh_mem_imm_nosize": 2, - "sh_mem_1": 2, - "C1h": 2, - "D1h": 2, - "sh_mem_1_8bit": 2, - "C0h": 2, - "D0h": 2, - "sh_reg_imm": 2, - "sh_reg_reg": 1, - "sh_reg_cl_8bit": 2, - "sh_reg_imm_size_ok": 2, - "sh_reg_imm_8bit": 2, - "sh_reg_1": 2, - "sh_reg_1_8bit": 2, - "shd_instruction": 1, - "shd_reg": 2, - "shd_mem": 1, - "shd_mem_reg_imm": 2, - "shd_mem_reg_imm_size_ok": 2, - "shd_reg_reg_imm": 2, - "shd_reg_reg_imm_size_ok": 2, - "movx_instruction": 1, - "movx_reg": 2, - "movx_unknown_size": 2, - "movx_mem_store": 3, - "movx_reg_8bit": 2, - "movx_reg_16bit": 2, - "movsxd_instruction": 1, - "movsxd_reg": 2, - "movsxd_mem_store": 2, - "bt_instruction": 1, - "bt_reg": 2, - "bt_mem_imm": 3, - "bt_mem_reg": 2, - "bt_mem_imm_size_ok": 2, - "bt_mem_imm_nosize": 2, - "bt_mem_imm_store": 2, - "BAh": 2, - "bt_reg_imm": 3, - "bt_reg_reg": 2, - "bt_reg_imm_size_ok": 2, - "bt_reg_imm_store": 1, - "bs_instruction": 1, - "get_reg_mem": 2, - "bs_reg_reg": 2, - "get_reg_reg": 2, - "imul_instruction": 1, - "imul_reg": 2, - "imul_mem": 1, - "imul_mem_8bit": 2, - "imul_mem_nosize": 2, - "imul_reg_": 2, - "imul_reg_8bit": 2, - "imul_reg_imm": 3, - "imul_reg_noimm": 2, - "imul_reg_reg": 2, - "imul_reg_mem": 1, - "imul_reg_mem_imm": 2, - "AFh": 2, - "imul_reg_mem_imm_16bit": 2, - "imul_reg_mem_imm_32bit": 2, - "imul_reg_mem_imm_64bit": 1, - "imul_reg_mem_imm_32bit_ok": 2, - "imul_reg_mem_imm_16bit_store": 4, - "imul_reg_mem_imm_8bit_store": 3, - "imul_reg_mem_imm_32bit_store": 4, - "Bh": 11, - "imul_reg_reg_imm": 3, - "imul_reg_reg_imm_16bit": 2, - "imul_reg_reg_imm_32bit": 2, - "imul_reg_reg_imm_64bit": 1, - "imul_reg_reg_imm_32bit_ok": 2, - "imul_reg_reg_imm_16bit_store": 4, - "imul_reg_reg_imm_8bit_store": 3, - "imul_reg_reg_imm_32bit_store": 4, - "in_instruction": 1, - "in_imm": 2, - "in_reg": 2, - "in_al_dx": 2, - "in_ax_dx": 2, - "EDh": 1, - "ECh": 1, - "in_imm_size_ok": 2, - "in_al_imm": 2, - "in_ax_imm": 2, - "E5h": 1, - "E4h": 1, - "out_instruction": 1, - "out_imm": 2, - "out_dx_al": 2, - "out_dx_ax": 2, - "EFh": 1, - "EEh": 1, - "out_imm_size_ok": 2, - "out_imm_al": 2, - "out_imm_ax": 2, - "E7h": 1, - "E6h": 1, - "call_instruction": 1, - "E8h": 3, - "process_jmp": 2, - "jmp_instruction": 1, - "E9h": 1, - "EAh": 1, - "get_jump_operator": 3, - "jmp_imm": 2, - "jmp_reg": 2, - "jmp_mem": 1, - "jump_type": 14, - "jmp_mem_size_not_specified": 2, - "jmp_mem_16bit": 3, - "jmp_mem_32bit": 2, - "jmp_mem_48bit": 2, - "jmp_mem_64bit": 2, - "jmp_mem_80bit": 2, - "jmp_mem_far": 2, - "jmp_mem_near": 2, - "jmp_mem_near_32bit": 3, - "jmp_mem_far_32bit": 4, - "jmp_mem_far_store": 3, - "jmp_reg_16bit": 2, - "jmp_reg_32bit": 2, - "jmp_reg_64bit": 1, - "jmp_far": 2, - "jmp_near": 1, - "jmp_imm_16bit": 3, - "jmp_imm_32bit": 2, - "jmp_imm_64bit": 3, - "get_address_dword_value": 3, - "jmp_imm_32bit_prefix_ok": 2, - "calculate_jump_offset": 10, - "check_for_short_jump": 8, - "jmp_short": 3, - "jmp_imm_32bit_store": 2, - "jno": 2, - "jmp_imm_32bit_ok": 2, - "relative_jump_out_of_range": 6, - "get_address_qword_value": 3, - "EBh": 1, - "get_address_word_value": 3, - "jmp_imm_16bit_prefix_ok": 2, - "cwde": 3, - "forced_short": 2, - "no_short_jump": 4, - "short_jump": 4, - "jmp_short_value_type_ok": 2, - "jump_out_of_range": 3, - "jmp_far_16bit": 2, - "jmp_far_32bit": 3, - "jmp_far_segment": 2, - "conditional_jump": 1, - "conditional_jump_16bit": 3, - "conditional_jump_32bit": 2, - "conditional_jump_64bit": 3, - "conditional_jump_32bit_prefix_ok": 2, - "conditional_jump_short": 4, - "conditional_jump_32bit_store": 2, - "conditional_jump_32bit_range_ok": 2, - "conditional_jump_16bit_prefix_ok": 2, - "loop_instruction_16bit": 1, - "loop_instruction": 5, - "loop_instruction_32bit": 1, - "loop_instruction_64bit": 1, - "loop_jump_16bit": 3, - "loop_jump_32bit": 2, - "loop_jump_64bit": 3, - "loop_jump_32bit_prefix_ok": 2, - "loop_counter_size": 4, - "make_loop_jump": 3, - "loop_counter_size_ok": 2, - "loop_jump_16bit_prefix_ok": 2, - "movs_instruction": 1, - "address_sizes_do_not_agree": 2, - "movs_address_16bit": 2, - "movs_address_32bit": 2, - "movs_store": 3, - "A4h": 1, - "movs_check_size": 5, - "lods_instruction": 1, - "lods_address_16bit": 2, - "lods_address_32bit": 2, - "lods_store": 3, - "ACh": 1, - "stos_instruction": 1, - "stos_address_16bit": 2, - "stos_address_32bit": 2, - "stos_store": 3, - "cmps_instruction": 1, - "cmps_address_16bit": 2, - "cmps_address_32bit": 2, - "cmps_store": 3, - "A6h": 1, - "ins_instruction": 1, - "ins_address_16bit": 2, - "ins_address_32bit": 2, - "ins_store": 3, - "ins_check_size": 2, - "outs_instruction": 1, - "outs_address_16bit": 2, - "outs_address_32bit": 2, - "outs_store": 3, - "xlat_instruction": 1, - "xlat_address_16bit": 2, - "xlat_address_32bit": 2, - "xlat_store": 3, - "D7h": 1, - "pm_word_instruction": 1, - "pm_reg": 2, - "pm_mem": 2, - "pm_mem_store": 2, - "pm_store_word_instruction": 1, - "lgdt_instruction": 1, - "lgdt_mem_48bit": 2, - "lgdt_mem_80bit": 2, - "lgdt_mem_store": 4, - "lar_instruction": 1, - "lar_reg_reg": 2, - "lar_reg_mem": 2, - "invlpg_instruction": 1, - "swapgs_instruction": 1, - "rdtscp_instruction": 1, - "basic_486_instruction": 1, - "basic_486_reg": 2, - "basic_486_mem_reg_8bit": 2, - "basic_486_reg_reg_8bit": 2, - "bswap_instruction": 1, - "bswap_reg_code_ok": 2, - "bswap_reg64": 2, - "cmpxchgx_instruction": 1, - "cmpxchgx_size_ok": 2, - "cmpxchgx_store": 2, - "nop_instruction": 1, - "extended_nop": 4, - "extended_nop_reg": 2, - "extended_nop_store": 2, - "basic_fpu_instruction": 1, - "D8h": 2, - "basic_fpu_streg": 2, - "basic_fpu_mem": 2, - "basic_fpu_mem_32bit": 2, - "basic_fpu_mem_64bit": 2, - "DCh": 2, - "convert_fpu_register": 9, - "basic_fpu_single_streg": 3, - "basic_fpu_st0": 2, - "basic_fpu_streg_st0": 2, - "simple_fpu_instruction": 1, - "D9h": 6, - "fi_instruction": 1, - "fi_mem_16bit": 2, - "fi_mem_32bit": 2, - "DAh": 2, - "DEh": 2, - "fld_instruction": 1, - "fld_streg": 2, - "fld_mem_32bit": 2, - "fld_mem_64bit": 2, - "fld_mem_80bit": 2, - "DDh": 6, - "fld_mem_80bit_store": 3, - "DBh": 4, - "fst_streg": 2, - "fild_instruction": 1, - "fild_mem_16bit": 2, - "fild_mem_32bit": 2, - "fild_mem_64bit": 2, - "DFh": 5, - "fisttp_64bit_store": 2, - "fild_mem_64bit_store": 3, - "fbld_instruction": 1, - "fbld_mem_80bit": 3, - "faddp_instruction": 1, - "faddp_streg": 2, - "fcompp_instruction": 1, - "D9DEh": 1, - "fucompp_instruction": 1, - "E9DAh": 1, - "fxch_instruction": 1, - "fpu_single_operand": 3, - "ffreep_instruction": 1, - "ffree_instruction": 1, - "fpu_streg": 2, - "fstenv_instruction": 1, - "fldenv_instruction": 3, - "fpu_mem": 2, - "fstenv_instruction_16bit": 1, - "fldenv_instruction_16bit": 1, - "fstenv_instruction_32bit": 1, - "fldenv_instruction_32bit": 1, - "fsave_instruction_32bit": 1, - "fnsave_instruction_32bit": 1, - "fnsave_instruction": 3, - "fsave_instruction_16bit": 1, - "fnsave_instruction_16bit": 1, - "fsave_instruction": 1, - "fstcw_instruction": 1, - "fldcw_instruction": 1, - "fldcw_mem_16bit": 3, - "fstsw_instruction": 1, - "fnstsw_instruction": 1, - "fstsw_reg": 2, - "fstsw_mem_16bit": 3, - "E0DFh": 1, - "finit_instruction": 1, - "fninit_instruction": 1, - "fcmov_instruction": 1, - "fcomi_streg": 3, - "fcomi_instruction": 1, - "fcomip_instruction": 1, - "fcomi_st0_streg": 2, - "basic_mmx_instruction": 1, - "mmx_instruction": 1, - "convert_mmx_register": 18, - "make_mmx_prefix": 9, - "mmx_mmreg_mmreg": 3, - "mmx_mmreg_mem": 2, - "mmx_bit_shift_instruction": 1, - "mmx_ps_mmreg_imm8": 2, - "pmovmskb_instruction": 1, - "pmovmskb_reg_size_ok": 2, - "mmx_nomem_imm8": 7, - "mmx_imm8": 6, - "append_imm8": 2, - "pinsrw_instruction": 1, - "pinsrw_mmreg_reg": 2, - "pshufw_instruction": 1, - "mmx_size": 30, - "pshuf_instruction": 2, - "pshufd_instruction": 1, - "pshuf_mmreg_mmreg": 2, - "movd_instruction": 1, - "movd_reg": 2, - "movd_mmreg": 2, - "movd_mmreg_reg": 2, - "mmx_prefix_for_vex": 2, - "no_mmx_prefix": 2, - "movq_instruction": 1, - "movq_reg": 2, - "movq_mem_xmmreg": 2, - "D6h": 2, - "movq_mmreg": 2, - "movq_mmreg_": 2, - "F3h": 7, - "movq_mmreg_reg": 2, - "movq_mmreg_mmreg": 2, - "movq_mmreg_reg_store": 2, - "movdq_instruction": 1, - "movdq_mmreg": 2, - "convert_xmm_register": 12, - "movdq_mmreg_mmreg": 2, - "lddqu_instruction": 1, - "F2h": 6, - "movdq2q_instruction": 1, - "movq2dq_": 2, - "movq2dq_instruction": 1, - "sse_ps_instruction_imm8": 1, - "sse_ps_instruction": 1, - "sse_instruction": 11, - "sse_pd_instruction_imm8": 1, - "sse_pd_instruction": 1, - "sse_ss_instruction": 1, - "sse_sd_instruction": 1, - "cmp_pd_instruction": 1, - "cmp_ps_instruction": 1, - "C2h": 4, - "cmp_ss_instruction": 1, - "cmp_sx_instruction": 2, - "cmpsd_instruction": 1, - "A7h": 1, - "cmp_sd_instruction": 1, - "comiss_instruction": 1, - "comisd_instruction": 1, - "cvtdq2pd_instruction": 1, - "cvtps2pd_instruction": 1, - "cvtpd2dq_instruction": 1, - "movshdup_instruction": 1, - "sse_xmmreg": 2, - "sse_reg": 1, - "sse_xmmreg_xmmreg": 2, - "sse_reg_mem": 2, - "sse_mem_size_ok": 2, - "supplemental_code": 2, - "sse_cmp_mem_ok": 3, - "sse_ok": 2, - "take_additional_xmm0": 3, - "sse_xmmreg_xmmreg_ok": 4, - "sse_cmp_nomem_ok": 3, - "sse_nomem_ok": 2, - "additional_xmm0_ok": 2, - "pslldq_instruction": 1, - "movpd_instruction": 1, - "movps_instruction": 1, - "sse_mov_instruction": 3, - "movss_instruction": 1, - "sse_movs": 2, - "movsd_instruction": 1, - "A5h": 1, - "sse_mem": 2, - "sse_mem_xmmreg": 2, - "movlpd_instruction": 1, - "movlps_instruction": 1, - "movhlps_instruction": 1, - "maskmovq_instruction": 1, - "maskmov_instruction": 2, - "maskmovdqu_instruction": 1, - "movmskpd_instruction": 1, - "movmskps_instruction": 1, - "movmskps_reg_ok": 2, - "cvtpi2pd_instruction": 1, - "cvtpi2ps_instruction": 1, - "interface": 2, - "for": 2, - "Win32": 2, + ";": 3, + "flat": 1, + "assembler": 2, + "interface": 1, + "for": 1, + "Win32": 1, + "Copyright": 1, + "(": 2, + "c": 1, + ")": 2, + "-": 2, + "Tomasz": 1, + "Grysztar.": 1, + "All": 1, + "rights": 1, + "reserved.": 1, "format": 1, "PE": 1, "console": 1, @@ -4293,185 +3195,154 @@ "readable": 4, "executable": 1, "start": 1, - "con_handle": 8, - "STD_OUTPUT_HANDLE": 2, + "mov": 28, + "[": 25, + "con_handle": 2, + "]": 25, + "STD_OUTPUT_HANDLE": 1, + "esi": 12, "_logo": 2, - "display_string": 19, + "call": 25, + "display_string": 7, "get_params": 2, + "jc": 3, "information": 2, - "init_memory": 2, + "init_memory": 1, "_memory_prefix": 2, - "memory_start": 4, - "display_number": 8, + "eax": 18, + "memory_end": 1, + "sub": 4, + "memory_start": 1, + "add": 2, + "additional_memory_end": 1, + "additional_memory": 1, + "shr": 1, + "display_number": 5, "_memory_suffix": 2, "GetTickCount": 3, "start_time": 3, "preprocessor": 1, "parser": 1, "formatter": 1, - "display_user_messages": 3, + "display_user_messages": 1, + "movzx": 1, + "current_pass": 1, + "inc": 1, "_passes_suffix": 2, - "div": 8, + "xor": 5, + "edx": 15, + "ebx": 4, + "div": 2, + "or": 11, + "jz": 11, "display_bytes_count": 2, - "display_character": 6, + "push": 1, + "dl": 1, + "display_character": 1, + "pop": 1, "_seconds_suffix": 2, "written_size": 1, "_bytes_suffix": 2, - "exit_program": 5, + "al": 48, + "jmp": 12, + "exit_program": 2, "_usage": 2, "input_file": 4, "output_file": 3, - "memory_setting": 4, + "symbols_file": 2, + "memory_setting": 3, + "passes_limit": 2, "GetCommandLine": 2, + "edi": 4, "params": 2, "find_command_start": 2, + "lodsb": 11, + "cmp": 31, + "h": 18, + "je": 25, "skip_quoted_name": 3, "skip_name": 2, "find_param": 7, "all_params": 5, "option_param": 2, + "Dh": 15, + "jne": 3, "get_output_file": 2, "process_param": 3, "bad_params": 11, "string_param": 3, "copy_param": 2, + "stosb": 3, "param_end": 6, "string_param_end": 2, "memory_option": 4, "passes_option": 4, "symbols_option": 3, + "stc": 2, + "ret": 4, "get_option_value": 3, "get_option_digit": 2, "option_value_ok": 4, "invalid_option_value": 5, + "ja": 2, "imul": 1, + "jo": 1, + "dec": 4, + "clc": 2, + "shl": 1, + "jae": 1, + "dx": 1, "find_symbols_file_name": 2, "include": 15, "data": 3, "writeable": 2, "_copyright": 1, - "db": 35, + "db": 30, + "Ah": 9, "VERSION_STRING": 1, "align": 1, "dd": 22, - "bytes_count": 8, - "displayed_count": 4, - "character": 3, - "last_displayed": 5, + "bytes_count": 1, + "displayed_count": 1, + "character": 1, + "last_displayed": 1, "rb": 4, "options": 1, - "buffer": 14, + "buffer": 1, "stack": 1, "import": 1, "rva": 16, "kernel_name": 2, "kernel_table": 2, - "ExitProcess": 2, + "ExitProcess": 1, "_ExitProcess": 2, - "CreateFile": 3, + "CreateFile": 1, "_CreateFileA": 2, - "ReadFile": 2, + "ReadFile": 1, "_ReadFile": 2, - "WriteFile": 6, + "WriteFile": 1, "_WriteFile": 2, - "CloseHandle": 2, + "CloseHandle": 1, "_CloseHandle": 2, - "SetFilePointer": 2, + "SetFilePointer": 1, "_SetFilePointer": 2, "_GetCommandLineA": 2, - "GetEnvironmentVariable": 2, + "GetEnvironmentVariable": 1, "_GetEnvironmentVariable": 2, - "GetStdHandle": 5, + "GetStdHandle": 1, "_GetStdHandle": 2, - "VirtualAlloc": 2, + "VirtualAlloc": 1, "_VirtualAlloc": 2, - "VirtualFree": 2, + "VirtualFree": 1, "_VirtualFree": 2, "_GetTickCount": 2, - "GetSystemTime": 2, + "GetSystemTime": 1, "_GetSystemTime": 2, - "GlobalMemoryStatus": 2, + "GlobalMemoryStatus": 1, "_GlobalMemoryStatus": 2, "dw": 14, "fixups": 1, - "discardable": 1, - "CREATE_NEW": 1, - "CREATE_ALWAYS": 2, - "OPEN_EXISTING": 2, - "OPEN_ALWAYS": 1, - "TRUNCATE_EXISTING": 1, - "FILE_SHARE_READ": 3, - "FILE_SHARE_WRITE": 1, - "FILE_SHARE_DELETE": 1, - "GENERIC_READ": 2, - "GENERIC_WRITE": 2, - "STD_INPUT_HANDLE": 1, - "FFFFFFF6h": 1, - "FFFFFFF5h": 1, - "STD_ERROR_HANDLE": 3, - "FFFFFFF4h": 1, - "MEM_COMMIT": 2, - "MEM_RESERVE": 1, - "MEM_DECOMMIT": 1, - "MEM_RELEASE": 2, - "MEM_FREE": 1, - "MEM_PRIVATE": 1, - "MEM_MAPPED": 1, - "MEM_RESET": 1, - "MEM_TOP_DOWN": 1, - "PAGE_NOACCESS": 1, - "PAGE_READONLY": 1, - "PAGE_READWRITE": 2, - "PAGE_WRITECOPY": 1, - "PAGE_EXECUTE": 1, - "PAGE_EXECUTE_READ": 1, - "PAGE_EXECUTE_READWRITE": 1, - "PAGE_EXECUTE_WRITECOPY": 1, - "PAGE_GUARD": 1, - "PAGE_NOCACHE": 1, - "allocate_memory": 4, - "large_memory": 3, - "not_enough_memory": 2, - "do_exit": 2, - "get_environment_variable": 1, - "buffer_for_variable_ok": 2, - "open": 2, - "file_error": 6, - "create": 1, - "write": 1, - "repne": 1, - "scasb": 1, - "display_loop": 2, - "display_digit": 3, - "digit_ok": 2, - "line_break_ok": 4, - "make_line_break": 2, - "A0Dh": 2, - "D0Ah": 1, - "take_last_two_characters": 2, - "block_displayed": 2, - "block_ok": 2, - "fatal_error": 1, - "error_prefix": 3, - "error_suffix": 3, - "assembler_error": 1, - "get_error_lines": 2, - "get_next_error_line": 2, - "display_error_line": 3, - "find_definition_origin": 2, - "line_number_start": 3, - "FFFFFFFh": 2, - "line_number_ok": 2, - "line_data_start": 2, - "line_data_displayed": 2, - "get_line_data": 2, - "display_line_data": 5, - "cr_lf": 2, - "make_timestamp": 1, - "mul": 5, - "months_correction": 2, - "day_correction_ok": 4, - "day_correction": 2 + "discardable": 1 }, "AutoHotkey": { "MsgBox": 1, @@ -4944,6 +3815,32 @@ "DoubleGT": 1, "F#1A#20#2F": 1 }, + "BlitzMax": { + "SuperStrict": 1, + "Framework": 1, + "Brl.StandardIO": 1, + "Type": 2, + "TMyType": 3, + "Field": 1, + "property": 1, + "int": 3, + "Function": 1, + "A": 1, + "(": 5, + "param": 1, + ")": 5, + "do": 1, + "nothing": 1, + "End": 2, + "Method": 1, + "Global": 1, + "my": 1, + "new": 1, + "Win32": 1, + "my.A": 2, + "my.B": 2, + "Linux": 1 + }, "Bluespec": { "package": 2, "TbTL": 1, @@ -26391,6 +25288,229 @@ "user.FirstName": 1, "user.Department": 1 }, + "Grace": { + "method": 10, + "ack": 4, + "(": 215, + "m": 5, + "Number": 4, + "n": 4, + ")": 215, + "-": 16, + "{": 61, + "print": 2, + "if": 23, + "<": 5, + "then": 24, + "+": 29, + "}": 61, + "elseif": 1, + "else": 7, + "import": 7, + "as": 7, + "gtk": 1, + "io": 1, + "collections": 1, + "button_factory": 1, + "dialog_factory": 1, + "highlighter": 1, + "aComp": 1, + "//TODO": 1, + "def": 56, + "window": 2, + "gtk.window": 3, + "gtk.GTK_WINDOW_TOPLEVEL": 3, + "window.title": 1, + "window.set_default_size": 1, + "var": 33, + "popped": 3, + "mBox": 2, + "gtk.box": 6, + "gtk.GTK_ORIENTATION_VERTICAL": 4, + "buttonBox": 2, + "gtk.GTK_ORIENTATION_HORIZONTAL": 5, + "consoleButtons": 2, + "consoleBox": 2, + "editorBox": 2, + "splitPane": 4, + "gtk.paned": 1, + "menuBox": 2, + "runButton": 2, + "button_factory.make": 10, + "clearButton": 2, + "outButton": 2, + "errorButton": 2, + "popButton": 2, + "newButton": 2, + "openButton": 2, + "saveButton": 2, + "saveAsButton": 2, + "closeButton": 2, + "tEdit": 3, + "gtk.text_view": 5, + "tEdit.set_size_request": 1, + "scrolled_main": 4, + "gtk.scrolled_window": 5, + "scrolled_main.set_size_request": 1, + "scrolled_main.add": 1, + "notebook": 8, + "gtk.notebook": 1, + "notebook.scrollable": 1, + "true": 8, + "editor_map": 8, + "collections.map.new": 4, + "editor_map.put": 1, + "scrolled_map": 6, + "scrolled_map.put": 1, + "lighter": 3, + "highlighter.Syntax_Highlighter.new": 1, + "tEdit.buffer.on": 1, + "do": 14, + "lighter.highlightLine": 1, + "completer": 1, + "aComp.Auto_Completer.new": 1, + "deleteCompileFiles": 3, + "page_num": 7, + "cur_scrolled": 9, + "scrolled_map.get": 8, + "filename": 6, + "notebook.get_tab_label_text": 3, + "filename.substringFrom": 1, + "to": 1, + "filename.size": 1, + "//Removes": 1, + ".grace": 1, + "extension": 1, + "io.system": 13, + "currentConsole": 17, + "//": 3, + "Which": 1, + "console": 1, + "is": 1, + "being": 1, + "shown": 1, + "out": 9, + "false": 9, + "outText": 4, + "errorText": 4, + "runButton.on": 1, + "clearConsoles": 4, + "cur_page_num": 15, + "notebook.current_page": 6, + "cur_page": 5, + "editor_map.get": 7, + "cur_page_label": 6, + "sIter": 9, + "gtk.text_iter": 6, + "eIter": 9, + "cur_page.buffer.get_iter_at_offset": 4, + "text": 4, + "cur_page.buffer.get_text": 2, + "file": 2, + "io.open": 4, + "file.write": 2, + "file.close": 2, + "outputFile": 1, + "errorFile": 1, + "outputFile.read": 1, + "errorFile.read": 1, + "switched": 4, + "outText.size": 2, + "&&": 4, + "switch_to_output": 3, + "errorText.size": 2, + "switch_to_errors": 3, + "populateConsoles": 4, + "clearButton.on": 1, + "outButton.on": 1, + "errorButton.on": 1, + "popButton.on": 1, + "popIn": 2, + "popOut": 2, + "newButton.on": 1, + "new_window_class": 1, + "dialog_factory.new.new": 1, + "new_window": 1, + "new_window_class.window": 1, + "new_window.show_all": 1, + "openButton.on": 1, + "open_window_class": 1, + "dialog_factory.open.new": 1, + "open_window": 1, + "open_window_class.window": 1, + "open_window.show_all": 1, + "saveButton.on": 1, + "saveAs_window_class": 2, + "dialog_factory.save.new": 2, + "saveAs_window": 2, + "saveAs_window_class.window": 2, + "saveAs_window.show_all": 2, + "saveAsButton.on": 1, + "closeButton.on": 1, + "num_pages": 3, + "notebook.n_pages": 2, + "e_map": 2, + "s_map": 2, + "x": 21, + "while": 3, + "eValue": 4, + "sValue": 4, + "e_map.put": 2, + "s_map.put": 2, + "notebook.remove_page": 1, + "notebook.show_all": 1, + "outConsole": 4, + "outScroll": 5, + "errorConsole": 4, + "errorScroll": 4, + "errorTag": 3, + "errorConsole.buffer.create_tag": 2, + "createOut": 3, + "outScroll.add": 1, + "outConsole.set_size_request": 5, + "outScroll.set_size_request": 5, + "outConsole.editable": 1, + "outConsole.buffer.set_text": 3, + "createError": 3, + "errorScroll.add": 1, + "errorConsole.set_size_request": 5, + "errorScroll.set_size_request": 5, + "errorConsole.editable": 1, + "errorConsole.buffer.set_text": 3, + "consoleBox.remove": 2, + "This": 2, + "destroys": 2, + "the": 2, + "consoleBox.add": 5, + "popped.show_all": 3, + "window.show_all": 3, + "errorConsole.buffer.get_iter_at_offset": 2, + "errorConsole.buffer.apply_tag": 1, + "popInBlock": 2, + "consoleBox.reparent": 3, + "popButton.label": 3, + "cur_page.set_size_request": 3, + "cur_scrolled.set_size_request": 3, + "popped.visible": 3, + "popped.connect": 1, + "hSeparator1": 2, + "gtk.separator": 2, + "hSeparator2": 2, + "menuBox.add": 4, + "buttonBox.add": 2, + "consoleButtons.add": 4, + "editorBox.add": 2, + "notebook.add": 1, + "notebook.set_tab_label_text": 1, + "splitPane.add1": 1, + "splitPane.add2": 1, + "mBox.add": 3, + "window.add": 1, + "exit": 2, + "gtk.main_quit": 1, + "window.connect": 1, + "gtk.main": 1 + }, "Grammatical Framework": { "-": 594, "#": 14, @@ -45573,6 +44693,908 @@ "Nimrod": { "echo": 1 }, + "Nit": { + "#": 196, + "module": 18, + "print_arguments": 1, + "for": 27, + "a": 40, + "in": 39, + "args": 9, + "do": 83, + "print": 135, + "end": 117, + "websocket_server": 1, + "import": 18, + "websocket": 1, + "var": 157, + "sock": 1, + "new": 164, + "WebSocket": 1, + "(": 448, + ")": 448, + "msg": 8, + "String": 14, + "if": 89, + "sock.listener.eof": 2, + "then": 81, + "sys.errno.strerror": 1, + "sock.accept": 2, + "while": 4, + "not": 12, + "sock.connected": 1, + "sys.stdin.poll_in": 1, + "gets": 1, + "printn": 10, + "sock.close": 1, + "sock.disconnect_client": 1, + "sock.write": 1, + "sock.can_read": 1, + "sock.read_line": 1, + "drop_privileges": 1, + "privileges": 1, + "opts": 1, + "OptionContext": 1, + "opt_ug": 2, + "OptionUserAndGroup.for_dropping_privileges": 1, + "opt_ug.mandatory": 1, + "true": 6, + "opts.add_option": 1, + "opts.parse": 1, + "opts.errors.is_empty": 1, + "opts.errors": 1, + "opts.usage": 1, + "exit": 3, + "user_group": 2, + "opt_ug.value": 1, + "assert": 24, + "null": 39, + "user_group.drop_privileges": 1, + "callback_monkey": 2, + "{": 14, + "#include": 2, + "": 1, + "": 1, + "typedef": 2, + "struct": 2, + "int": 4, + "id": 2, + ";": 34, + "age": 2, + "}": 14, + "CMonkey": 6, + "MonkeyActionCallable": 7, + "toCall": 6, + "Object": 7, + "message": 9, + "MonkeyAction": 5, + "//": 13, + "Method": 1, + "which": 4, + "reproduce": 3, + "callback": 11, + "answer": 1, + "Please": 1, + "note": 1, + "that": 2, + "function": 2, + "pointer": 2, + "is": 25, + "only": 6, + "used": 1, + "to": 18, + "the": 57, + "void": 3, + "cbMonkey": 2, + "*mkey": 2, + "callbackFunc": 2, + "CMonkey*": 1, + "MonkeyAction*": 1, + "*data": 3, + "sleep": 5, + "mkey": 2, + "data": 6, + "Back": 2, + "of": 31, + "background": 1, + "treatment": 1, + "will": 8, + "be": 9, + "redirected": 1, + "nit_monkey_callback_func": 2, + "To": 1, + "call": 3, + "your": 1, + "method": 17, + "signature": 1, + "must": 1, + "written": 2, + "like": 1, + "this": 2, + "": 1, + "Name": 1, + "_": 1, + "": 1, + "...": 1, + "MonkeyActionCallable_wokeUp": 1, + "-": 70, + "interface": 3, + "fun": 57, + "wokeUp": 4, + "sender": 3, + "Monkey": 4, + "abstract": 2, + "extern": 2, + "class": 20, + "*": 14, + "*monkey": 1, + "malloc": 2, + "sizeof": 2, + "monkey": 4, + "return": 54, + "get": 1, + "defined": 4, + "Must": 1, + "as": 1, + "Nit/C": 1, + "because": 4, + "C": 4, + "inside": 1, + "wokeUpAction": 2, + "MonkeyActionCallable.wokeUp": 1, + "Allocating": 1, + "memory": 1, + "keep": 2, + "reference": 2, + "received": 1, + "parameters": 1, + "receiver": 1, + "Message": 1, + "Incrementing": 1, + "counter": 1, + "prevent": 1, + "from": 8, + "releasing": 1, + "MonkeyActionCallable_incr_ref": 1, + "Object_incr_ref": 1, + "Calling": 1, + "by": 5, + "passing": 1, + "Receiver": 1, + "Function": 1, + "object": 2, + "Datas": 1, + "recv": 12, + "&": 1, + "socket_client": 1, + "socket": 6, + "args.length": 3, + "<": 11, + "s": 68, + "Socket.client": 1, + "[": 106, + "]": 80, + ".to_i": 2, + "s.connected": 1, + "s.write": 1, + "s.close": 1, + "extern_methods": 1, + "redef": 30, + "enum": 3, + "Int": 47, + "Returns": 1, + "self": 41, + "th": 2, + "fibonnaci": 1, + "number": 7, + "implemented": 1, + "here": 1, + "optimization": 1, + "purposes": 2, + "fib": 5, + "else": 63, + "Int_fib": 3, + "+": 39, + "System": 1, + "seconds": 1, + "Return": 4, + "atan2l": 1, + "x": 16, + "libmath": 1, + "atan_with": 2, + "Float": 3, + "atan2": 1, + "This": 1, + "Nit": 2, + "methods": 2, + "code": 3, + "It": 1, + "use": 1, + "local": 1, + "operator": 1, + "to_s": 3, + "all": 3, + "objects": 1, + "String.to_cstring": 2, + "an": 4, + "equivalent": 1, + "char*": 1, + "foo": 3, + "long": 2, + "recv_fib": 2, + "recv_plus_fib": 2, + "Int__plus": 1, + "nit_string": 2, + "Int_to_s": 1, + "char": 1, + "*c_string": 1, + "String_to_cstring": 1, + "printf": 1, + "c_string": 1, + "Equivalent": 1, + "but": 6, + "pure": 1, + "bar": 2, + "curl_mail": 1, + "curl": 11, + "Curl": 4, + "mail_request": 1, + "CurlMailRequest": 1, + "response": 5, + "mail_request.set_outgoing_server": 1, + "isa": 12, + "CurlResponseFailed": 5, + "mail_request.from": 1, + "mail_request.to": 1, + "mail_request.cc": 1, + "mail_request.bcc": 1, + "headers_body": 4, + "HeaderMap": 3, + "mail_request.headers_body": 1, + "mail_request.body": 1, + "mail_request.subject": 1, + "mail_request.verbose": 1, + "false": 8, + "mail_request.execute": 1, + "CurlMailResponseSuccess": 1, + "procedural_array": 1, + "array_sum": 2, + "Array": 12, + "sum": 12, + "i": 20, + "array_sum_alt": 2, + "a.length": 1, + "curl_http": 1, + "MyHttpFetcher": 2, + "super": 10, + "CurlCallbacks": 1, + "our_body": 1, + "init": 6, + "self.curl": 1, + "Release": 1, + "destroy": 1, + "self.curl.destroy": 1, + "Header": 1, + "header_callback": 1, + "line": 3, + "We": 1, + "silent": 1, + "testing": 1, + "#if": 1, + "line.has_prefix": 1, + "Body": 1, + "body_callback": 1, + "self.our_body": 1, + "Stream": 1, + "Cf": 1, + "No": 1, + "one": 3, + "registered": 1, + "stream_callback": 1, + "buffer": 1, + "size": 8, + "count": 2, + "url": 2, + "request": 1, + "CurlHTTPRequest": 1, + "HTTP": 3, + "Get": 2, + "Request": 3, + "request.verbose": 3, + "getResponse": 3, + "request.execute": 2, + "CurlResponseSuccess": 2, + "Post": 1, + "myHttpFetcher": 2, + "request.delegate": 1, + "postDatas": 5, + "request.datas": 1, + "postResponse": 3, + "file": 1, + "headers": 3, + "request.headers": 1, + "downloadResponse": 3, + "request.download_to_file": 1, + "CurlFileResponseSuccess": 1, + "Program": 1, + "logic": 1, + "clock": 4, + "Clock": 10, + "total": 1, + "minutes": 12, + "total_minutes": 2, + "Note": 7, + "read": 1, + "acces": 1, + "public": 1, + "write": 1, + "access": 1, + "private.": 1, + "current": 26, + "hour": 3, + "self.total_minutes": 8, + "%": 3, + "set": 2, + "hour.": 1, + "m": 5, + "or": 9, + "changed": 1, + "accordinlgy": 1, + "self.hours": 1, + "hours": 9, + "/": 4, + "updated": 1, + "h": 7, + "position": 2, + "arrow": 2, + "interval": 1, + "hour_pos": 2, + "replace": 1, + ".": 6, + "and": 10, + "updated.": 1, + "reset": 1, + "hours*60": 1, + "self.reset": 1, + "o": 5, + "nullable": 11, + "type": 2, + "test": 1, + "required": 1, + "Thanks": 1, + "adaptive": 1, + "typing": 1, + "there": 2, + "no": 1, + "downcast": 1, + "i.e.": 1, + "safe": 4, + "o.total_minutes": 2, + "c": 17, + "c.minutes": 1, + "c.hours": 1, + "c2": 2, + "c2.minutes": 1, + "callback_chimpanze": 1, + "Chimpanze": 2, + "create": 1, + "Invoking": 1, + "take": 1, + "some": 1, + "time": 1, + "compute": 1, + "back": 1, + "with": 2, + "information.": 1, + "Callback": 1, + "Interface": 1, + "monkey.wokeUpAction": 1, + "Inherit": 1, + "m.create": 1, + "circular_list": 1, + "CircularList": 6, + "E": 15, + "Like": 1, + "standard": 1, + "LinkedList": 1, + "Sequence.": 1, + "Sequence": 1, + "The": 11, + "first": 7, + "node": 10, + "list": 10, + "any": 1, + "special": 1, + "case": 1, + "empty": 1, + "handled": 1, + "private": 5, + "CLNode": 6, + "iterator": 1, + "CircularListIterator": 2, + "self.node.item": 2, + "push": 3, + "e": 4, + "new_node": 4, + "n": 16, + "self.node": 13, + "so": 4, + "attach": 1, + "nodes": 3, + "correctly.": 2, + "old_last_node": 2, + "n.prev": 4, + "new_node.next": 1, + "new_node.prev": 1, + "old_last_node.next": 1, + "pop": 2, + "prev": 3, + "n.item": 1, + "detach": 1, + "prev_prev": 2, + "prev.prev": 1, + "prev_prev.next": 1, + "prev.item": 1, + "unshift": 1, + "Circularity": 2, + "has": 3, + "benefits.": 2, + "self.node.prev": 1, + "shift": 1, + "self.node.next": 2, + "self.pop": 1, + "Move": 1, + "at": 2, + "last": 2, + "second": 1, + "etc.": 1, + "rotate": 1, + "n.next": 1, + "Sort": 1, + "using": 1, + "Josephus": 1, + "algorithm.": 1, + "josephus": 1, + "step": 2, + "res": 1, + "self.is_empty": 1, + "self.rotate": 1, + "kill": 1, + "self.shift": 1, + "res.add": 1, + "res.node": 1, + "item": 5, + "next": 9, + "circular": 3, + "list.": 4, + "Because": 2, + "circularity": 1, + "always": 1, + "default": 2, + "let": 1, + "it": 1, + "previous": 4, + "Coherence": 1, + "between": 1, + "maintained": 1, + "IndexedIterator": 1, + "index": 7, + "pointed.": 1, + "Is": 1, + "empty.": 4, + "iterated.": 1, + "is_ok": 1, + "Empty": 1, + "lists": 2, + "are": 4, + "OK.": 2, + "Pointing": 1, + "again": 1, + "self.index": 3, + "self.list.node": 1, + "list.node": 1, + "self.list": 1, + "i.add_all": 1, + "i.first": 1, + "i.join": 3, + "i.push": 1, + "i.shift": 1, + "i.pop": 1, + "i.unshift": 1, + "i.josephus": 1, + "opengles2_hello_triangle": 1, + "glesv2": 1, + "egl": 1, + "mnit_linux": 1, + "sdl": 1, + "x11": 1, + ".environ": 3, + "window_width": 2, + "window_height": 2, + "##": 6, + "SDL": 2, + "sdl_display": 1, + "SDLDisplay": 1, + "sdl_wm_info": 1, + "SDLSystemWindowManagerInfo": 1, + "x11_window_handle": 2, + "sdl_wm_info.x11_window_handle": 1, + "X11": 1, + "x_display": 3, + "x_open_default_display": 1, + "EGL": 2, + "egl_display": 6, + "EGLDisplay": 1, + "egl_display.is_valid": 2, + "egl_display.initialize": 1, + "egl_display.error": 3, + "config_chooser": 1, + "EGLConfigChooser": 1, + "#config_chooser.surface_type_egl": 1, + "config_chooser.blue_size": 1, + "config_chooser.green_size": 1, + "config_chooser.red_size": 1, + "#config_chooser.alpha_size": 1, + "#config_chooser.depth_size": 1, + "#config_chooser.stencil_size": 1, + "#config_chooser.sample_buffers": 1, + "config_chooser.close": 1, + "configs": 3, + "config_chooser.choose": 1, + "configs.is_empty": 1, + "config": 4, + "attribs": 1, + "config.attribs": 2, + "configs.first": 1, + "format": 1, + ".native_visual_id": 1, + "surface": 5, + "egl_display.create_window_surface": 1, + "surface.is_ok": 1, + "context": 9, + "egl_display.create_context": 1, + "context.is_ok": 1, + "make_current_res": 2, + "egl_display.make_current": 2, + "width": 2, + "surface.attribs": 2, + ".width": 1, + "height": 2, + ".height": 1, + "egl_bind_opengl_es_api": 1, + "GLESv2": 1, + "assert_no_gl_error": 6, + "gl_shader_compiler": 1, + "gl_error.to_s": 1, + "program": 1, + "GLProgram": 1, + "program.is_ok": 1, + "program.info_log": 1, + "abort": 2, + "vertex_shader": 2, + "GLVertexShader": 1, + "vertex_shader.is_ok": 1, + "vertex_shader.source": 1, + "vertex_shader.compile": 1, + "vertex_shader.is_compiled": 1, + "fragment_shader": 2, + "GLFragmentShader": 1, + "fragment_shader.is_ok": 1, + "fragment_shader.source": 1, + "fragment_shader.compile": 1, + "fragment_shader.is_compiled": 1, + "program.attach_shader": 2, + "program.bind_attrib_location": 1, + "program.link": 1, + "program.is_linked": 1, + "vertices": 2, + "vertex_array": 1, + "VertexArray": 1, + "vertex_array.attrib_pointer": 1, + "gl_clear_color": 1, + "gl_viewport": 1, + "gl_clear_color_buffer": 1, + "program.use": 1, + "vertex_array.enable": 1, + "vertex_array.draw_arrays_triangles": 1, + "egl_display.swap_buffers": 1, + "program.delete": 1, + "vertex_shader.delete": 1, + "fragment_shader.delete": 1, + "EGLSurface.none": 2, + "EGLContext.none": 1, + "egl_display.destroy_context": 1, + "egl_display.destroy_surface": 1, + "sdl_display.destroy": 1, + "gtk": 1, + "CalculatorContext": 7, + "result": 16, + "last_op": 4, + "Char": 7, + "after_point": 12, + "push_op": 2, + "op": 11, + "apply_last_op_if_any": 2, + "self.result": 2, + "store": 1, + "prepare": 1, + "push_digit": 1, + "digit": 1, + "digit.to_f": 2, + "pow": 1, + "after_point.to_f": 1, + "self.after_point": 1, + "self.current": 3, + "switch_to_decimals": 1, + "CalculatorGui": 2, + "GtkCallable": 1, + "win": 2, + "GtkWindow": 2, + "container": 3, + "GtkGrid": 2, + "lbl_disp": 3, + "GtkLabel": 2, + "but_eq": 3, + "GtkButton": 2, + "but_dot": 3, + "signal": 1, + "user_data": 5, + "context.after_point": 1, + "after_point.abs": 1, + "operation": 1, + "but_dot.sensitive": 2, + "context.switch_to_decimals": 4, + "lbl_disp.text": 3, + "context.push_op": 15, + "context.result.to_precision_native": 1, + "s.length.times": 1, + "chiffre": 3, + "s.chars": 2, + "s.substring": 2, + "s.length": 2, + "context.push_digit": 25, + "context.current.to_precision_native": 1, + "init_gtk": 1, + "win.add": 1, + "container.attach": 7, + "digits": 1, + "GtkButton.with_label": 5, + "n.to_s": 1, + "but.request_size": 2, + "but.signal_connect": 2, + "/3": 1, + "operators": 2, + "r": 21, + "op.to_s": 1, + "but_eq.request_size": 1, + "but_eq.signal_connect": 1, + "but_dot.request_size": 1, + "but_dot.signal_connect": 1, + "#C": 1, + "but_c": 2, + "but_c.request_size": 1, + "but_c.signal_connect": 1, + "win.show_all": 1, + "context.result.to_precision": 6, + "#test": 2, + "multiple": 1, + "decimals": 1, + "button": 1, + "app": 1, + "run_gtk": 1, + "draw_operation": 1, + "n_chars": 1, + "abs": 2, + "log10f": 1, + "float": 1, + "as_operator": 1, + "b": 10, + "override_dispc": 1, + "Bool": 2, + "lines": 7, + "Line": 53, + "P": 51, + "s/2": 23, + "y": 9, + "lines.add": 1, + "q4": 4, + "s/4": 1, + "l": 4, + "lines.append": 1, + "tl": 2, + "tr": 2, + "hack": 3, + "support": 1, + "bug": 1, + "evaluation": 1, + "software": 1, + "draw": 1, + "dispc": 2, + "gap": 1, + "w": 3, + "length": 2, + "*gap": 1, + "map": 8, + ".filled_with": 1, + "ci": 2, + "self.chars": 1, + "local_dispc": 4, + "c.override_dispc": 1, + "c.lines": 1, + "line.o.x": 1, + "ci*size": 1, + "ci*gap": 1, + "line.o.y": 1, + "line.len": 1, + "map.length": 3, + ".length": 1, + "line.step_x": 1, + "line.step_y": 1, + "step_x": 1, + "step_y": 1, + "len": 1, + "op_char": 3, + "disp_char": 6, + "disp_size": 6, + "disp_gap": 6, + "gets.to_i": 4, + "gets.chars": 2, + "op_char.as_operator": 1, + "len_a": 2, + "a.n_chars": 1, + "len_b": 2, + "b.n_chars": 1, + "len_res": 3, + "result.n_chars": 1, + "max_len": 5, + "len_a.max": 1, + "len_b.max": 1, + "d": 6, + "line_a": 3, + "a.to_s": 1, + "line_a.draw": 1, + "line_b": 3, + "op_char.to_s": 1, + "b.to_s": 1, + "line_b.draw": 1, + "disp_size*max_len": 1, + "*disp_gap": 1, + "line_res": 3, + "result.to_s": 1, + "line_res.draw": 1, + "html": 1, + "NitHomepage": 2, + "HTMLPage": 1, + "head": 5, + "add": 35, + ".attr": 17, + ".text": 27, + "body": 1, + "open": 14, + ".add_class": 4, + "add_html": 7, + "close": 14, + "page": 1, + "page.write_to": 1, + "stdout": 2, + "page.write_to_file": 1, + "int_stack": 1, + "IntStack": 2, + "Null": 1, + "means": 1, + "stack": 3, + "ISNode": 4, + "Add": 2, + "integer": 2, + "stack.": 2, + "val": 5, + "self.head": 5, + "Remove": 1, + "pushed": 1, + "integer.": 1, + "followings": 2, + "statically": 3, + "head.val": 1, + "head.next": 1, + "integers": 1, + "sumall": 1, + "cur": 3, + "condition": 1, + "cur.val": 1, + "cur.next": 1, + "attributes": 1, + "have": 1, + "value": 2, + "free": 2, + "constructor": 2, + "implicitly": 2, + "defined.": 2, + "stored": 1, + "node.": 1, + "any.": 1, + "A": 1, + "l.push": 4, + "l.sumall": 1, + "loop": 2, + "l.pop": 5, + "break": 2, + "following": 1, + "gives": 2, + "alternative": 1, + "socket_server": 1, + "args.is_empty": 1, + "Socket.server": 1, + "clients": 2, + "Socket": 1, + "max": 2, + "fs": 1, + "SocketObserver": 1, + "fs.readset.set": 2, + "fs.select": 1, + "fs.readset.is_set": 1, + "ns": 1, + "socket.accept": 1, + "ns.write": 1, + "ns.close": 1, + "fibonacci": 3, + "Calculate": 1, + "element": 1, + "sequence.": 1, + ".fibonacci": 2, + "usage": 3, + "args.first.to_i.fibonacci": 1, + "clock_more": 1, + "now": 1, + "comparable": 1, + "Comparable": 1, + "Comparaison": 1, + "make": 1, + "sense": 1, + "other": 2, + "OTHER": 1, + "Comparable.": 1, + "All": 1, + "rely": 1, + "on": 1, + "c1": 1, + "c3": 1, + "c1.minutes": 1, + "template": 1, + "###": 2, + "Here": 2, + "definition": 1, + "specific": 1, + "templates": 2, + "TmplComposers": 2, + "Template": 3, + "Short": 2, + "composers": 4, + "TmplComposer": 3, + "Detailled": 1, + "composer_details": 2, + "TmplComposerDetail": 3, + "composer": 1, + "both": 1, + "add_composer": 1, + "firstname": 5, + "lastname": 6, + "birth": 5, + "death": 5, + "composers.add": 1, + "composer_details.add": 1, + "rendering": 3, + "add_all": 2, + "name": 4, + "self.name": 1, + "self.firstname": 1, + "self.lastname": 1, + "self.birth": 1, + "self.death": 1, + "simple": 1, + "f": 1, + "f.add_composer": 3, + "f.write_to": 1 + }, "Nix": { "{": 8, "stdenv": 1, @@ -50388,9 +50410,21 @@ "Kick": 1 }, "PHP": { - "SHEBANG#!php": 3, + "SHEBANG#!php": 4, + "": 1, + "aMenuLinks": 1, + "Array": 13, + "Blog": 1, + "SITE_DIR": 4, + "Photos": 1, + "photo": 1, + "About": 1, + "me": 1, + "about": 1, + "php": 14, + "Contact": 1, + "contacts": 1, "<": 11, - "php": 12, "echo": 2, ";": 1383, "": 3, @@ -67502,9 +67536,9 @@ "return": 1 }, "XML": { - "": 11, - "version=": 17, - "encoding=": 7, + "": 12, + "version=": 21, + "encoding=": 8, "": 7, "ToolsVersion=": 6, "DefaultTargets=": 5, @@ -67581,6 +67615,94 @@ "": 10, "": 5, "": 7, + "standalone=": 1, + "": 1, + "4": 1, + "0": 2, + "": 1, + "storage_type_id=": 1, + "": 14, + "moduleId=": 14, + "": 2, + "id=": 141, + "buildSystemId=": 2, + "name=": 270, + "": 2, + "": 2, + "": 12, + "point=": 12, + "": 2, + "": 7, + "": 2, + "artifactName=": 2, + "buildArtefactType=": 2, + "buildProperties=": 2, + "cleanCommand=": 2, + "description=": 4, + "cdt": 2, + "managedbuild": 2, + "config": 2, + "gnu": 2, + "exe": 2, + "debug": 1, + "1803931088": 1, + "parent=": 2, + "": 2, + "resourcePath=": 2, + "": 2, + "superClass=": 42, + "": 2, + "": 2, + "buildPath=": 2, + "keepEnvironmentInBuildfile=": 2, + "managedBuildOn=": 2, + "": 12, + "": 4, + "": 8, + "": 8, + "defaultValue=": 2, + "": 4, + "kind=": 6, + "paths=": 4, + "": 2, + "": 2, + "": 2, + "": 2, + "": 2, + "flags=": 2, + "": 2, + "": 2, + "": 2, + "release": 1, + "32754498": 1, + "": 2, + "projectType=": 1, + "": 5, + "enabled=": 125, + "problemReportingEnabled=": 5, + "selectedProfileId=": 5, + "": 40, + "": 40, + "": 40, + "filePath=": 40, + "": 80, + "": 40, + "": 40, + "": 40, + "arguments=": 40, + "command=": 40, + "useDefault=": 40, + "": 40, + "": 40, + "": 4, + "instanceId=": 4, + "": 4, + "": 1, "": 1, "": 1, "": 2, @@ -67710,7 +67832,6 @@ "": 1, "": 1, "": 1, - "name=": 227, "compatVersion=": 1, "": 1, "FreeMedForms": 1, @@ -68690,14 +68811,12 @@ "standard": 1, "": 1, "": 1, - "value=": 1, "": 1, "": 1, "": 1, "": 1, "": 2, "visibility=": 2, - "description=": 2, "": 1, "": 1, "org=": 1, @@ -68706,7 +68825,6 @@ "junit": 2, "": 1, "": 1, - "": 1, "module.ant": 1, "optionnal": 1, "designed": 1, @@ -70100,10 +70218,11 @@ "Arduino": 20, "AsciiDoc": 103, "AspectJ": 324, - "Assembly": 21750, + "Assembly": 743, "AutoHotkey": 3, "Awk": 544, "BlitzBasic": 2065, + "BlitzMax": 40, "Bluespec": 1298, "Brightscript": 579, "C": 65970, @@ -70140,6 +70259,7 @@ "Game Maker Language": 13310, "Gnuplot": 1023, "Gosu": 410, + "Grace": 1381, "Grammatical Framework": 10607, "Groovy": 93, "Groovy Server Pages": 91, @@ -70194,6 +70314,7 @@ "NetLogo": 243, "Nginx": 179, "Nimrod": 1, + "Nit": 5282, "Nix": 188, "Nu": 116, "OCaml": 382, @@ -70207,7 +70328,7 @@ "Ox": 1006, "Oxygene": 157, "PAWN": 3263, - "PHP": 20724, + "PHP": 20754, "Pan": 130, "Parrot Assembly": 6, "Parrot Internal Representation": 5, @@ -70273,7 +70394,7 @@ "Visual Basic": 581, "Volt": 388, "XC": 24, - "XML": 7057, + "XML": 8236, "XProc": 22, "XQuery": 801, "XSLT": 44, @@ -70297,10 +70418,11 @@ "Arduino": 1, "AsciiDoc": 3, "AspectJ": 2, - "Assembly": 4, + "Assembly": 1, "AutoHotkey": 1, "Awk": 1, "BlitzBasic": 3, + "BlitzMax": 1, "Bluespec": 2, "Brightscript": 1, "C": 36, @@ -70337,6 +70459,7 @@ "Game Maker Language": 13, "Gnuplot": 6, "Gosu": 4, + "Grace": 2, "Grammatical Framework": 41, "Groovy": 5, "Groovy Server Pages": 4, @@ -70391,6 +70514,7 @@ "NetLogo": 1, "Nginx": 1, "Nimrod": 1, + "Nit": 22, "Nix": 1, "Nu": 2, "OCaml": 2, @@ -70404,7 +70528,7 @@ "Ox": 3, "Oxygene": 1, "PAWN": 1, - "PHP": 9, + "PHP": 10, "Pan": 1, "Parrot Assembly": 1, "Parrot Internal Representation": 1, @@ -70470,7 +70594,7 @@ "Visual Basic": 3, "Volt": 1, "XC": 1, - "XML": 13, + "XML": 14, "XProc": 1, "XQuery": 1, "XSLT": 1, @@ -70483,5 +70607,5 @@ "fish": 3, "wisp": 1 }, - "md5": "6445a23d1a2a3c6a77967a8ea5458359" + "md5": "7c278b259fadd53ef6af28641a206403" } \ No newline at end of file diff --git a/lib/linguist/vendor.yml b/lib/linguist/vendor.yml index 4b67fdda..c497960c 100644 --- a/lib/linguist/vendor.yml +++ b/lib/linguist/vendor.yml @@ -40,6 +40,9 @@ - foundation.min.css - foundation.css +# Normalize.css +- normalize.css + # Vendored dependencies - thirdparty/ - vendors?/ @@ -125,6 +128,9 @@ ## Obj-C ## +# Cocoapods +- ^Pods/ + # Sparkle - (^|/)Sparkle/ diff --git a/lib/linguist/version.rb b/lib/linguist/version.rb index 6704b3fb..89151b75 100644 --- a/lib/linguist/version.rb +++ b/lib/linguist/version.rb @@ -1,3 +1,3 @@ module Linguist - VERSION = "2.12.0" + VERSION = "3.0.3" end diff --git a/samples/Assembly/ASSEMBLE.inc b/samples/Assembly/ASSEMBLE.inc deleted file mode 100644 index c4ffdae3..00000000 --- a/samples/Assembly/ASSEMBLE.inc +++ /dev/null @@ -1,2048 +0,0 @@ - -; flat assembler core -; Copyright (c) 1999-2014, Tomasz Grysztar. -; All rights reserved. - -assembler: - xor eax,eax - mov [stub_size],eax - mov [current_pass],ax - mov [resolver_flags],eax - mov [number_of_sections],eax - mov [actual_fixups_size],eax - assembler_loop: - mov eax,[labels_list] - mov [tagged_blocks],eax - mov eax,[additional_memory] - mov [free_additional_memory],eax - mov eax,[additional_memory_end] - mov [structures_buffer],eax - mov esi,[source_start] - mov edi,[code_start] - xor eax,eax - mov dword [adjustment],eax - mov dword [adjustment+4],eax - mov [addressing_space],eax - mov [error_line],eax - mov [counter],eax - mov [format_flags],eax - mov [number_of_relocations],eax - mov [undefined_data_end],eax - mov [file_extension],eax - mov [next_pass_needed],al - mov [output_format],al - mov [adjustment_sign],al - mov [code_type],16 - call init_addressing_space - pass_loop: - call assemble_line - jnc pass_loop - mov eax,[additional_memory_end] - cmp eax,[structures_buffer] - je pass_done - sub eax,18h - mov eax,[eax+4] - mov [current_line],eax - jmp missing_end_directive - pass_done: - call close_pass - mov eax,[labels_list] - check_symbols: - cmp eax,[memory_end] - jae symbols_checked - test byte [eax+8],8 - jz symbol_defined_ok - mov cx,[current_pass] - cmp cx,[eax+18] - jne symbol_defined_ok - test byte [eax+8],1 - jz symbol_defined_ok - sub cx,[eax+16] - cmp cx,1 - jne symbol_defined_ok - and byte [eax+8],not 1 - or [next_pass_needed],-1 - symbol_defined_ok: - test byte [eax+8],10h - jz use_prediction_ok - mov cx,[current_pass] - and byte [eax+8],not 10h - test byte [eax+8],20h - jnz check_use_prediction - cmp cx,[eax+18] - jne use_prediction_ok - test byte [eax+8],8 - jz use_prediction_ok - jmp use_misprediction - check_use_prediction: - test byte [eax+8],8 - jz use_misprediction - cmp cx,[eax+18] - je use_prediction_ok - use_misprediction: - or [next_pass_needed],-1 - use_prediction_ok: - test byte [eax+8],40h - jz check_next_symbol - and byte [eax+8],not 40h - test byte [eax+8],4 - jnz define_misprediction - mov cx,[current_pass] - test byte [eax+8],80h - jnz check_define_prediction - cmp cx,[eax+16] - jne check_next_symbol - test byte [eax+8],1 - jz check_next_symbol - jmp define_misprediction - check_define_prediction: - test byte [eax+8],1 - jz define_misprediction - cmp cx,[eax+16] - je check_next_symbol - define_misprediction: - or [next_pass_needed],-1 - check_next_symbol: - add eax,LABEL_STRUCTURE_SIZE - jmp check_symbols - symbols_checked: - cmp [next_pass_needed],0 - jne next_pass - mov eax,[error_line] - or eax,eax - jz assemble_ok - mov [current_line],eax - cmp [error],undefined_symbol - jne error_confirmed - mov eax,[error_info] - or eax,eax - jz error_confirmed - test byte [eax+8],1 - jnz next_pass - error_confirmed: - call error_handler - error_handler: - mov eax,[error] - sub eax,error_handler - add [esp],eax - ret - next_pass: - inc [current_pass] - mov ax,[current_pass] - cmp ax,[passes_limit] - je code_cannot_be_generated - jmp assembler_loop - assemble_ok: - ret - -create_addressing_space: - mov ebx,[addressing_space] - test ebx,ebx - jz init_addressing_space - test byte [ebx+0Ah],1 - jnz illegal_instruction - mov eax,edi - sub eax,[ebx+18h] - mov [ebx+1Ch],eax - init_addressing_space: - mov ebx,[tagged_blocks] - mov dword [ebx-4],10h - mov dword [ebx-8],20h - sub ebx,8+20h - cmp ebx,edi - jbe out_of_memory - mov [tagged_blocks],ebx - mov [addressing_space],ebx - xor eax,eax - mov [ebx],edi - mov [ebx+4],eax - mov [ebx+8],eax - mov [ebx+10h],eax - mov [ebx+14h],eax - mov [ebx+18h],edi - mov [ebx+1Ch],eax - ret - -assemble_line: - mov eax,[tagged_blocks] - sub eax,100h - cmp edi,eax - ja out_of_memory - lods byte [esi] - cmp al,1 - je assemble_instruction - jb source_end - cmp al,3 - jb define_label - je define_constant - cmp al,4 - je label_addressing_space - cmp al,0Fh - je new_line - cmp al,13h - je code_type_setting - cmp al,10h - jne illegal_instruction - lods byte [esi] - jmp segment_prefix - code_type_setting: - lods byte [esi] - mov [code_type],al - jmp instruction_assembled - new_line: - lods dword [esi] - mov [current_line],eax - mov [prefixed_instruction],0 - cmp [symbols_file],0 - je continue_line - cmp [next_pass_needed],0 - jne continue_line - mov ebx,[tagged_blocks] - mov dword [ebx-4],1 - mov dword [ebx-8],14h - sub ebx,8+14h - cmp ebx,edi - jbe out_of_memory - mov [tagged_blocks],ebx - mov [ebx],eax - mov [ebx+4],edi - mov eax,[addressing_space] - mov [ebx+8],eax - mov al,[code_type] - mov [ebx+10h],al - continue_line: - cmp byte [esi],0Fh - je line_assembled - jmp assemble_line - define_label: - lods dword [esi] - cmp eax,0Fh - jb invalid_use_of_symbol - je reserved_word_used_as_symbol - mov ebx,eax - lods byte [esi] - mov [label_size],al - call make_label - jmp continue_line - make_label: - mov eax,edi - xor edx,edx - xor cl,cl - mov ebp,[addressing_space] - sub eax,[ds:ebp] - sbb edx,[ds:ebp+4] - sbb cl,[ds:ebp+8] - jp label_value_ok - call recoverable_overflow - label_value_ok: - mov [address_sign],cl - test byte [ds:ebp+0Ah],1 - jnz make_virtual_label - or byte [ebx+9],1 - xchg eax,[ebx] - xchg edx,[ebx+4] - mov ch,[ebx+9] - shr ch,1 - and ch,1 - neg ch - sub eax,[ebx] - sbb edx,[ebx+4] - sbb ch,cl - mov dword [adjustment],eax - mov dword [adjustment+4],edx - mov [adjustment_sign],ch - or al,ch - or eax,edx - setnz ah - jmp finish_label - make_virtual_label: - and byte [ebx+9],not 1 - cmp eax,[ebx] - mov [ebx],eax - setne ah - cmp edx,[ebx+4] - mov [ebx+4],edx - setne al - or ah,al - finish_label: - mov ebp,[addressing_space] - mov ch,[ds:ebp+9] - mov cl,[label_size] - mov edx,[ds:ebp+14h] - mov ebp,[ds:ebp+10h] - finish_label_symbol: - mov al,[address_sign] - xor al,[ebx+9] - and al,10b - or ah,al - xor [ebx+9],al - cmp cl,[ebx+10] - mov [ebx+10],cl - setne al - or ah,al - cmp ch,[ebx+11] - mov [ebx+11],ch - setne al - or ah,al - cmp ebp,[ebx+12] - mov [ebx+12],ebp - setne al - or ah,al - or ch,ch - jz label_symbol_ok - cmp edx,[ebx+20] - mov [ebx+20],edx - setne al - or ah,al - label_symbol_ok: - mov cx,[current_pass] - xchg [ebx+16],cx - mov edx,[current_line] - mov [ebx+28],edx - and byte [ebx+8],not 2 - test byte [ebx+8],1 - jz new_label - cmp cx,[ebx+16] - je symbol_already_defined - btr dword [ebx+8],10 - jc requalified_label - inc cx - sub cx,[ebx+16] - setnz al - or ah,al - jz label_made - test byte [ebx+8],8 - jz label_made - mov cx,[current_pass] - cmp cx,[ebx+18] - jne label_made - requalified_label: - or [next_pass_needed],-1 - label_made: - ret - new_label: - or byte [ebx+8],1 - ret - define_constant: - lods dword [esi] - inc esi - cmp eax,0Fh - jb invalid_use_of_symbol - je reserved_word_used_as_symbol - mov edx,[eax+8] - push edx - cmp [current_pass],0 - je get_constant_value - test dl,4 - jnz get_constant_value - mov cx,[current_pass] - cmp cx,[eax+16] - je get_constant_value - or dl,4 - mov [eax+8],dl - get_constant_value: - push eax - mov al,byte [esi-1] - push eax - or [size_override],-1 - call get_value - pop ebx - mov ch,bl - pop ebx - pop ecx - test cl,4 - jnz constant_referencing_mode_ok - and byte [ebx+8],not 4 - constant_referencing_mode_ok: - xor cl,cl - mov ch,[value_type] - cmp ch,3 - je invalid_use_of_symbol - make_constant: - and byte [ebx+9],not 1 - cmp eax,[ebx] - mov [ebx],eax - setne ah - cmp edx,[ebx+4] - mov [ebx+4],edx - setne al - or ah,al - mov al,[value_sign] - xor al,[ebx+9] - and al,10b - or ah,al - xor [ebx+9],al - cmp cl,[ebx+10] - mov [ebx+10],cl - setne al - or ah,al - cmp ch,[ebx+11] - mov [ebx+11],ch - setne al - or ah,al - xor edx,edx - cmp edx,[ebx+12] - mov [ebx+12],edx - setne al - or ah,al - or ch,ch - jz constant_symbol_ok - mov edx,[symbol_identifier] - cmp edx,[ebx+20] - mov [ebx+20],edx - setne al - or ah,al - constant_symbol_ok: - mov cx,[current_pass] - xchg [ebx+16],cx - mov edx,[current_line] - mov [ebx+28],edx - test byte [ebx+8],1 - jz new_constant - cmp cx,[ebx+16] - jne redeclare_constant - test byte [ebx+8],2 - jz symbol_already_defined - or byte [ebx+8],4 - and byte [ebx+9],not 4 - jmp instruction_assembled - redeclare_constant: - btr dword [ebx+8],10 - jc requalified_constant - inc cx - sub cx,[ebx+16] - setnz al - or ah,al - jz instruction_assembled - test byte [ebx+8],4 - jnz instruction_assembled - test byte [ebx+8],8 - jz instruction_assembled - mov cx,[current_pass] - cmp cx,[ebx+18] - jne instruction_assembled - requalified_constant: - or [next_pass_needed],-1 - jmp instruction_assembled - new_constant: - or byte [ebx+8],1+2 - jmp instruction_assembled - label_addressing_space: - lods dword [esi] - cmp eax,0Fh - jb invalid_use_of_symbol - je reserved_word_used_as_symbol - mov cx,[current_pass] - test byte [eax+8],1 - jz make_addressing_space_label - cmp cx,[eax+16] - je symbol_already_defined - test byte [eax+9],4 - jnz make_addressing_space_label - or [next_pass_needed],-1 - make_addressing_space_label: - mov dx,[eax+8] - and dx,not (2 or 100h) - or dx,1 or 4 or 400h - mov [eax+8],dx - mov [eax+16],cx - mov edx,[current_line] - mov [eax+28],edx - mov ebx,[addressing_space] - mov [eax],ebx - or byte [ebx+0Ah],2 - jmp continue_line - assemble_instruction: -; mov [operand_size],0 -; mov [size_override],0 -; mov [operand_prefix],0 -; mov [opcode_prefix],0 - and dword [operand_size],0 -; mov [rex_prefix],0 -; mov [vex_required],0 -; mov [vex_register],0 -; mov [immediate_size],0 - and dword [rex_prefix],0 - call instruction_handler - instruction_handler: - movzx ebx,word [esi] - mov al,[esi+2] - add esi,3 - add [esp],ebx - ret - instruction_assembled: - mov al,[esi] - cmp al,0Fh - je line_assembled - or al,al - jnz extra_characters_on_line - line_assembled: - clc - ret - source_end: - dec esi - stc - ret - -org_directive: - lods byte [esi] - cmp al,'(' - jne invalid_argument - cmp byte [esi],'.' - je invalid_value - call get_qword_value - mov cl,[value_type] - test cl,1 - jnz invalid_use_of_symbol - push eax - mov ebx,[addressing_space] - mov eax,edi - sub eax,[ebx+18h] - mov [ebx+1Ch],eax - test byte [ebx+0Ah],1 - jnz in_virtual - call init_addressing_space - jmp org_space_ok - in_virtual: - call close_virtual_addressing_space - call init_addressing_space - or byte [ebx+0Ah],1 - org_space_ok: - pop eax - mov [ebx+9],cl - mov cl,[value_sign] - sub [ebx],eax - sbb [ebx+4],edx - sbb byte [ebx+8],cl - jp org_value_ok - call recoverable_overflow - org_value_ok: - mov edx,[symbol_identifier] - mov [ebx+14h],edx - cmp [output_format],1 - ja instruction_assembled - cmp edi,[code_start] - jne instruction_assembled - cmp eax,100h - jne instruction_assembled - bts [format_flags],0 - jmp instruction_assembled -label_directive: - lods byte [esi] - cmp al,2 - jne invalid_argument - lods dword [esi] - cmp eax,0Fh - jb invalid_use_of_symbol - je reserved_word_used_as_symbol - inc esi - mov ebx,eax - mov [label_size],0 - lods byte [esi] - cmp al,':' - je get_label_size - dec esi - cmp al,11h - jne label_size_ok - get_label_size: - lods word [esi] - cmp al,11h - jne invalid_argument - mov [label_size],ah - label_size_ok: - cmp byte [esi],80h - je get_free_label_value - call make_label - jmp instruction_assembled - get_free_label_value: - inc esi - lods byte [esi] - cmp al,'(' - jne invalid_argument - push ebx ecx - or byte [ebx+8],4 - cmp byte [esi],'.' - je invalid_value - call get_address_value - or bh,bh - setnz ch - xchg ch,cl - mov bp,cx - shl ebp,16 - xchg bl,bh - mov bp,bx - pop ecx ebx - and byte [ebx+8],not 4 - mov ch,[value_type] - test ch,1 - jnz invalid_use_of_symbol - make_free_label: - and byte [ebx+9],not 1 - cmp eax,[ebx] - mov [ebx],eax - setne ah - cmp edx,[ebx+4] - mov [ebx+4],edx - setne al - or ah,al - mov edx,[address_symbol] - mov cl,[label_size] - call finish_label_symbol - jmp instruction_assembled -load_directive: - lods byte [esi] - cmp al,2 - jne invalid_argument - lods dword [esi] - cmp eax,0Fh - jb invalid_use_of_symbol - je reserved_word_used_as_symbol - inc esi - push eax - mov al,1 - cmp byte [esi],11h - jne load_size_ok - lods byte [esi] - lods byte [esi] - load_size_ok: - cmp al,8 - ja invalid_value - mov [operand_size],al - and dword [value],0 - and dword [value+4],0 - lods byte [esi] - cmp al,82h - jne invalid_argument - call get_data_point - jc value_loaded - push esi edi - mov esi,ebx - mov edi,value - rep movs byte [edi],[esi] - pop edi esi - value_loaded: - mov [value_sign],0 - mov eax,dword [value] - mov edx,dword [value+4] - pop ebx - xor cx,cx - jmp make_constant - get_data_point: - mov ebx,[addressing_space] - mov ecx,edi - sub ecx,[ebx+18h] - mov [ebx+1Ch],ecx - lods byte [esi] - cmp al,'(' - jne invalid_argument - cmp byte [esi],11h - jne get_data_address - cmp word [esi+1+4],'):' - jne get_data_address - inc esi - lods dword [esi] - add esi,2 - cmp byte [esi],'(' - jne invalid_argument - inc esi - cmp eax,0Fh - jbe reserved_word_used_as_symbol - mov edx,undefined_symbol - test byte [eax+8],1 - jz addressing_space_unavailable - mov edx,symbol_out_of_scope - mov cx,[eax+16] - cmp cx,[current_pass] - jne addressing_space_unavailable - test byte [eax+9],4 - jz invalid_use_of_symbol - mov ebx,eax - mov ax,[current_pass] - mov [ebx+18],ax - or byte [ebx+8],8 - cmp [symbols_file],0 - je get_addressing_space - cmp [next_pass_needed],0 - jne get_addressing_space - call store_label_reference - get_addressing_space: - mov ebx,[ebx] - get_data_address: - push ebx - cmp byte [esi],'.' - je invalid_value - or [size_override],-1 - call get_address_value - pop ebp - call calculate_relative_offset - cmp [next_pass_needed],0 - jne data_address_type_ok - cmp [value_type],0 - jne invalid_use_of_symbol - data_address_type_ok: - mov ebx,edi - xor ecx,ecx - add ebx,eax - adc edx,ecx - mov eax,ebx - sub eax,[ds:ebp+18h] - sbb edx,ecx - jnz bad_data_address - mov cl,[operand_size] - add eax,ecx - cmp eax,[ds:ebp+1Ch] - ja bad_data_address - clc - ret - addressing_space_unavailable: - cmp [error_line],0 - jne get_data_address - push [current_line] - pop [error_line] - mov [error],edx - mov [error_info],eax - jmp get_data_address - bad_data_address: - call recoverable_overflow - stc - ret -store_directive: - cmp byte [esi],11h - je sized_store - lods byte [esi] - cmp al,'(' - jne invalid_argument - call get_byte_value - xor edx,edx - movzx eax,al - mov [operand_size],1 - jmp store_value_ok - sized_store: - or [size_override],-1 - call get_value - store_value_ok: - cmp [value_type],0 - jne invalid_use_of_symbol - mov dword [value],eax - mov dword [value+4],edx - lods byte [esi] - cmp al,80h - jne invalid_argument - call get_data_point - jc instruction_assembled - push esi edi - mov esi,value - mov edi,ebx - rep movs byte [edi],[esi] - mov eax,edi - pop edi esi - cmp ebx,[undefined_data_end] - jae instruction_assembled - cmp eax,[undefined_data_start] - jbe instruction_assembled - mov [undefined_data_start],eax - jmp instruction_assembled - -display_directive: - lods byte [esi] - cmp al,'(' - jne invalid_argument - cmp byte [esi],0 - jne display_byte - inc esi - lods dword [esi] - mov ecx,eax - push edi - mov edi,[tagged_blocks] - sub edi,8 - sub edi,eax - cmp edi,[esp] - jbe out_of_memory - mov [tagged_blocks],edi - rep movs byte [edi],[esi] - stos dword [edi] - xor eax,eax - stos dword [edi] - pop edi - inc esi - jmp display_next - display_byte: - call get_byte_value - push edi - mov edi,[tagged_blocks] - sub edi,8+1 - mov [tagged_blocks],edi - stos byte [edi] - mov eax,1 - stos dword [edi] - dec eax - stos dword [edi] - pop edi - display_next: - cmp edi,[tagged_blocks] - ja out_of_memory - lods byte [esi] - cmp al,',' - je display_directive - dec esi - jmp instruction_assembled -show_display_buffer: - mov eax,[tagged_blocks] - or eax,eax - jz display_done - mov esi,[labels_list] - cmp esi,eax - je display_done - display_messages: - sub esi,8 - mov eax,[esi+4] - mov ecx,[esi] - sub esi,ecx - test eax,eax - jnz skip_block - push esi - call display_block - pop esi - skip_block: - cmp esi,[tagged_blocks] - jne display_messages - display_done: - ret - -times_directive: - lods byte [esi] - cmp al,'(' - jne invalid_argument - cmp byte [esi],'.' - je invalid_value - call get_count_value - cmp eax,0 - je zero_times - cmp byte [esi],':' - jne times_argument_ok - inc esi - times_argument_ok: - push [counter] - push [counter_limit] - mov [counter_limit],eax - mov [counter],1 - times_loop: - mov eax,esp - sub eax,100h - jc stack_overflow - cmp eax,[stack_limit] - jb stack_overflow - push esi - or [prefixed_instruction],-1 - call continue_line - mov eax,[counter_limit] - cmp [counter],eax - je times_done - inc [counter] - pop esi - jmp times_loop - times_done: - pop eax - pop [counter_limit] - pop [counter] - jmp instruction_assembled - zero_times: - call skip_symbol - jnc zero_times - jmp instruction_assembled - -virtual_directive: - lods byte [esi] - cmp al,80h - jne virtual_at_current - lods byte [esi] - cmp al,'(' - jne invalid_argument - cmp byte [esi],'.' - je invalid_value - call get_address_value - mov ebp,[address_symbol] - or bh,bh - setnz ch - jmp set_virtual - virtual_at_current: - dec esi - mov ebp,[addressing_space] - mov al,[ds:ebp+9] - mov [value_type],al - mov eax,edi - xor edx,edx - xor cl,cl - sub eax,[ds:ebp] - sbb edx,[ds:ebp+4] - sbb cl,[ds:ebp+8] - mov [address_sign],cl - mov bx,[ds:ebp+10h] - mov cx,[ds:ebp+10h+2] - xchg bh,bl - xchg ch,cl - mov ebp,[ds:ebp+14h] - set_virtual: - xchg bl,bh - xchg cl,ch - shl ecx,16 - mov cx,bx - push ecx eax - call allocate_structure_data - mov word [ebx],virtual_directive-instruction_handler - mov ecx,[addressing_space] - mov [ebx+12],ecx - mov [ebx+8],edi - mov ecx,[current_line] - mov [ebx+4],ecx - mov ebx,[addressing_space] - mov eax,edi - sub eax,[ebx+18h] - mov [ebx+1Ch],eax - call init_addressing_space - or byte [ebx+0Ah],1 - pop eax - mov cl,[address_sign] - not eax - not edx - not cl - add eax,1 - adc edx,0 - adc cl,0 - add eax,edi - adc edx,0 - adc cl,0 - mov [ebx],eax - mov [ebx+4],edx - mov [ebx+8],cl - pop dword [ebx+10h] - mov [ebx+14h],ebp - mov al,[value_type] - test al,1 - jnz invalid_use_of_symbol - mov [ebx+9],al - jmp instruction_assembled - allocate_structure_data: - mov ebx,[structures_buffer] - sub ebx,18h - cmp ebx,[free_additional_memory] - jb out_of_memory - mov [structures_buffer],ebx - ret - find_structure_data: - mov ebx,[structures_buffer] - scan_structures: - cmp ebx,[additional_memory_end] - je no_such_structure - cmp ax,[ebx] - je structure_data_found - add ebx,18h - jmp scan_structures - structure_data_found: - ret - no_such_structure: - stc - ret - end_virtual: - call find_structure_data - jc unexpected_instruction - push ebx - call close_virtual_addressing_space - pop ebx - mov eax,[ebx+12] - mov [addressing_space],eax - mov edi,[ebx+8] - remove_structure_data: - push esi edi - mov ecx,ebx - sub ecx,[structures_buffer] - shr ecx,2 - lea esi,[ebx-4] - lea edi,[esi+18h] - std - rep movs dword [edi],[esi] - cld - add [structures_buffer],18h - pop edi esi - ret - close_virtual_addressing_space: - mov ebx,[addressing_space] - mov eax,edi - sub eax,[ebx+18h] - mov [ebx+1Ch],eax - test byte [ebx+0Ah],2 - jz addressing_space_closed - push esi edi ecx edx - mov ecx,eax - mov eax,[tagged_blocks] - mov dword [eax-4],11h - mov dword [eax-8],ecx - sub eax,8 - sub eax,ecx - mov [tagged_blocks],eax - lea edi,[eax+ecx-1] - xchg eax,[ebx+18h] - lea esi,[eax+ecx-1] - mov eax,edi - sub eax,esi - std - shr ecx,1 - jnc virtual_byte_ok - movs byte [edi],[esi] - virtual_byte_ok: - dec esi - dec edi - shr ecx,1 - jnc virtual_word_ok - movs word [edi],[esi] - virtual_word_ok: - sub esi,2 - sub edi,2 - rep movs dword [edi],[esi] - cld - xor edx,edx - add [ebx],eax - adc dword [ebx+4],edx - adc byte [ebx+8],dl - pop edx ecx edi esi - addressing_space_closed: - ret -repeat_directive: - cmp [prefixed_instruction],0 - jne unexpected_instruction - lods byte [esi] - cmp al,'(' - jne invalid_argument - cmp byte [esi],'.' - je invalid_value - call get_count_value - cmp eax,0 - je zero_repeat - call allocate_structure_data - mov word [ebx],repeat_directive-instruction_handler - xchg eax,[counter_limit] - mov [ebx+10h],eax - mov eax,1 - xchg eax,[counter] - mov [ebx+14h],eax - mov [ebx+8],esi - mov eax,[current_line] - mov [ebx+4],eax - jmp instruction_assembled - end_repeat: - cmp [prefixed_instruction],0 - jne unexpected_instruction - call find_structure_data - jc unexpected_instruction - mov eax,[counter_limit] - inc [counter] - cmp [counter],eax - jbe continue_repeating - stop_repeat: - mov eax,[ebx+10h] - mov [counter_limit],eax - mov eax,[ebx+14h] - mov [counter],eax - call remove_structure_data - jmp instruction_assembled - continue_repeating: - mov esi,[ebx+8] - jmp instruction_assembled - zero_repeat: - mov al,[esi] - or al,al - jz missing_end_directive - cmp al,0Fh - jne extra_characters_on_line - call find_end_repeat - jmp instruction_assembled - find_end_repeat: - call find_structure_end - cmp ax,repeat_directive-instruction_handler - jne unexpected_instruction - ret -while_directive: - cmp [prefixed_instruction],0 - jne unexpected_instruction - call allocate_structure_data - mov word [ebx],while_directive-instruction_handler - mov eax,1 - xchg eax,[counter] - mov [ebx+10h],eax - mov [ebx+8],esi - mov eax,[current_line] - mov [ebx+4],eax - do_while: - push ebx - call calculate_logical_expression - or al,al - jnz while_true - mov al,[esi] - or al,al - jz missing_end_directive - cmp al,0Fh - jne extra_characters_on_line - stop_while: - call find_end_while - pop ebx - mov eax,[ebx+10h] - mov [counter],eax - call remove_structure_data - jmp instruction_assembled - while_true: - pop ebx - jmp instruction_assembled - end_while: - cmp [prefixed_instruction],0 - jne unexpected_instruction - call find_structure_data - jc unexpected_instruction - mov eax,[ebx+4] - mov [current_line],eax - inc [counter] - jz too_many_repeats - mov esi,[ebx+8] - jmp do_while - find_end_while: - call find_structure_end - cmp ax,while_directive-instruction_handler - jne unexpected_instruction - ret -if_directive: - cmp [prefixed_instruction],0 - jne unexpected_instruction - call calculate_logical_expression - mov dl,al - mov al,[esi] - or al,al - jz missing_end_directive - cmp al,0Fh - jne extra_characters_on_line - or dl,dl - jnz if_true - call find_else - jc instruction_assembled - mov al,[esi] - cmp al,1 - jne else_true - cmp word [esi+1],if_directive-instruction_handler - jne else_true - add esi,4 - jmp if_directive - if_true: - xor al,al - make_if_structure: - call allocate_structure_data - mov word [ebx],if_directive-instruction_handler - mov byte [ebx+2],al - mov eax,[current_line] - mov [ebx+4],eax - jmp instruction_assembled - else_true: - or al,al - jz missing_end_directive - cmp al,0Fh - jne extra_characters_on_line - or al,-1 - jmp make_if_structure - else_directive: - cmp [prefixed_instruction],0 - jne unexpected_instruction - mov ax,if_directive-instruction_handler - call find_structure_data - jc unexpected_instruction - cmp byte [ebx+2],0 - jne unexpected_instruction - found_else: - mov al,[esi] - cmp al,1 - jne skip_else - cmp word [esi+1],if_directive-instruction_handler - jne skip_else - add esi,4 - call find_else - jnc found_else - call remove_structure_data - jmp instruction_assembled - skip_else: - or al,al - jz missing_end_directive - cmp al,0Fh - jne extra_characters_on_line - call find_end_if - call remove_structure_data - jmp instruction_assembled - end_if: - cmp [prefixed_instruction],0 - jne unexpected_instruction - call find_structure_data - jc unexpected_instruction - call remove_structure_data - jmp instruction_assembled - find_else: - call find_structure_end - cmp ax,else_directive-instruction_handler - je else_found - cmp ax,if_directive-instruction_handler - jne unexpected_instruction - stc - ret - else_found: - clc - ret - find_end_if: - call find_structure_end - cmp ax,if_directive-instruction_handler - jne unexpected_instruction - ret - find_structure_end: - push [error_line] - mov eax,[current_line] - mov [error_line],eax - find_end_directive: - call skip_symbol - jnc find_end_directive - lods byte [esi] - cmp al,0Fh - jne no_end_directive - lods dword [esi] - mov [current_line],eax - skip_labels: - cmp byte [esi],2 - jne labels_ok - add esi,6 - jmp skip_labels - labels_ok: - cmp byte [esi],1 - jne find_end_directive - mov ax,[esi+1] - cmp ax,prefix_instruction-instruction_handler - je find_end_directive - add esi,4 - cmp ax,repeat_directive-instruction_handler - je skip_repeat - cmp ax,while_directive-instruction_handler - je skip_while - cmp ax,if_directive-instruction_handler - je skip_if - cmp ax,else_directive-instruction_handler - je structure_end - cmp ax,end_directive-instruction_handler - jne find_end_directive - cmp byte [esi],1 - jne find_end_directive - mov ax,[esi+1] - add esi,4 - cmp ax,repeat_directive-instruction_handler - je structure_end - cmp ax,while_directive-instruction_handler - je structure_end - cmp ax,if_directive-instruction_handler - jne find_end_directive - structure_end: - pop [error_line] - ret - no_end_directive: - mov eax,[error_line] - mov [current_line],eax - jmp missing_end_directive - skip_repeat: - call find_end_repeat - jmp find_end_directive - skip_while: - call find_end_while - jmp find_end_directive - skip_if: - call skip_if_block - jmp find_end_directive - skip_if_block: - call find_else - jc if_block_skipped - cmp byte [esi],1 - jne skip_after_else - cmp word [esi+1],if_directive-instruction_handler - jne skip_after_else - add esi,4 - jmp skip_if_block - skip_after_else: - call find_end_if - if_block_skipped: - ret -end_directive: - lods byte [esi] - cmp al,1 - jne invalid_argument - lods word [esi] - inc esi - cmp ax,virtual_directive-instruction_handler - je end_virtual - cmp ax,repeat_directive-instruction_handler - je end_repeat - cmp ax,while_directive-instruction_handler - je end_while - cmp ax,if_directive-instruction_handler - je end_if - cmp ax,data_directive-instruction_handler - je end_data - jmp invalid_argument -break_directive: - mov ebx,[structures_buffer] - mov al,[esi] - or al,al - jz find_breakable_structure - cmp al,0Fh - jne extra_characters_on_line - find_breakable_structure: - cmp ebx,[additional_memory_end] - je unexpected_instruction - mov ax,[ebx] - cmp ax,repeat_directive-instruction_handler - je break_repeat - cmp ax,while_directive-instruction_handler - je break_while - cmp ax,if_directive-instruction_handler - je break_if - add ebx,18h - jmp find_breakable_structure - break_if: - push [current_line] - mov eax,[ebx+4] - mov [current_line],eax - call remove_structure_data - call skip_if_block - pop [current_line] - mov ebx,[structures_buffer] - jmp find_breakable_structure - break_repeat: - push ebx - call find_end_repeat - pop ebx - jmp stop_repeat - break_while: - push ebx - jmp stop_while - -data_bytes: - call define_data - lods byte [esi] - cmp al,'(' - je get_byte - cmp al,'?' - jne invalid_argument - mov eax,edi - mov byte [edi],0 - inc edi - jmp undefined_data - get_byte: - cmp byte [esi],0 - je get_string - call get_byte_value - stos byte [edi] - ret - get_string: - inc esi - lods dword [esi] - mov ecx,eax - lea eax,[edi+ecx] - cmp eax,[tagged_blocks] - ja out_of_memory - rep movs byte [edi],[esi] - inc esi - ret - undefined_data: - mov ebp,[addressing_space] - test byte [ds:ebp+0Ah],1 - jz mark_undefined_data - ret - mark_undefined_data: - cmp eax,[undefined_data_end] - je undefined_data_ok - mov [undefined_data_start],eax - undefined_data_ok: - mov [undefined_data_end],edi - ret - define_data: - cmp edi,[tagged_blocks] - jae out_of_memory - cmp byte [esi],'(' - jne simple_data_value - mov ebx,esi - inc esi - call skip_expression - xchg esi,ebx - cmp byte [ebx],81h - jne simple_data_value - inc esi - call get_count_value - inc esi - or eax,eax - jz duplicate_zero_times - cmp byte [esi],'{' - jne duplicate_single_data_value - inc esi - duplicate_data: - push eax esi - duplicated_values: - cmp edi,[tagged_blocks] - jae out_of_memory - call near dword [esp+8] - lods byte [esi] - cmp al,',' - je duplicated_values - cmp al,'}' - jne invalid_argument - pop ebx eax - dec eax - jz data_defined - mov esi,ebx - jmp duplicate_data - duplicate_single_data_value: - cmp edi,[tagged_blocks] - jae out_of_memory - push eax esi - call near dword [esp+8] - pop ebx eax - dec eax - jz data_defined - mov esi,ebx - jmp duplicate_single_data_value - duplicate_zero_times: - cmp byte [esi],'{' - jne skip_single_data_value - inc esi - skip_data_value: - call skip_symbol - jc invalid_argument - cmp byte [esi],'}' - jne skip_data_value - inc esi - jmp data_defined - skip_single_data_value: - call skip_symbol - jmp data_defined - simple_data_value: - cmp edi,[tagged_blocks] - jae out_of_memory - call near dword [esp] - data_defined: - lods byte [esi] - cmp al,',' - je define_data - dec esi - add esp,4 - jmp instruction_assembled -data_unicode: - or [base_code],-1 - jmp define_words -data_words: - mov [base_code],0 - define_words: - call define_data - lods byte [esi] - cmp al,'(' - je get_word - cmp al,'?' - jne invalid_argument - mov eax,edi - and word [edi],0 - scas word [edi] - jmp undefined_data - ret - get_word: - cmp [base_code],0 - je word_data_value - cmp byte [esi],0 - je word_string - word_data_value: - call get_word_value - call mark_relocation - stos word [edi] - ret - word_string: - inc esi - lods dword [esi] - mov ecx,eax - jecxz word_string_ok - lea eax,[edi+ecx*2] - cmp eax,[tagged_blocks] - ja out_of_memory - xor ah,ah - copy_word_string: - lods byte [esi] - stos word [edi] - loop copy_word_string - word_string_ok: - inc esi - ret -data_dwords: - call define_data - lods byte [esi] - cmp al,'(' - je get_dword - cmp al,'?' - jne invalid_argument - mov eax,edi - and dword [edi],0 - scas dword [edi] - jmp undefined_data - get_dword: - push esi - call get_dword_value - pop ebx - cmp byte [esi],':' - je complex_dword - call mark_relocation - stos dword [edi] - ret - complex_dword: - mov esi,ebx - cmp byte [esi],'.' - je invalid_value - call get_word_value - push eax - inc esi - lods byte [esi] - cmp al,'(' - jne invalid_operand - mov al,[value_type] - push eax - cmp byte [esi],'.' - je invalid_value - call get_word_value - call mark_relocation - stos word [edi] - pop eax - mov [value_type],al - pop eax - call mark_relocation - stos word [edi] - ret -data_pwords: - call define_data - lods byte [esi] - cmp al,'(' - je get_pword - cmp al,'?' - jne invalid_argument - mov eax,edi - and dword [edi],0 - scas dword [edi] - and word [edi],0 - scas word [edi] - jmp undefined_data - get_pword: - push esi - call get_pword_value - pop ebx - cmp byte [esi],':' - je complex_pword - call mark_relocation - stos dword [edi] - mov ax,dx - stos word [edi] - ret - complex_pword: - mov esi,ebx - cmp byte [esi],'.' - je invalid_value - call get_word_value - push eax - inc esi - lods byte [esi] - cmp al,'(' - jne invalid_operand - mov al,[value_type] - push eax - cmp byte [esi],'.' - je invalid_value - call get_dword_value - call mark_relocation - stos dword [edi] - pop eax - mov [value_type],al - pop eax - call mark_relocation - stos word [edi] - ret -data_qwords: - call define_data - lods byte [esi] - cmp al,'(' - je get_qword - cmp al,'?' - jne invalid_argument - mov eax,edi - and dword [edi],0 - scas dword [edi] - and dword [edi],0 - scas dword [edi] - jmp undefined_data - get_qword: - call get_qword_value - call mark_relocation - stos dword [edi] - mov eax,edx - stos dword [edi] - ret -data_twords: - call define_data - lods byte [esi] - cmp al,'(' - je get_tword - cmp al,'?' - jne invalid_argument - mov eax,edi - and dword [edi],0 - scas dword [edi] - and dword [edi],0 - scas dword [edi] - and word [edi],0 - scas word [edi] - jmp undefined_data - get_tword: - cmp byte [esi],'.' - jne complex_tword - inc esi - cmp word [esi+8],8000h - je fp_zero_tword - mov eax,[esi] - stos dword [edi] - mov eax,[esi+4] - stos dword [edi] - mov ax,[esi+8] - add ax,3FFFh - jo value_out_of_range - cmp ax,7FFFh - jge value_out_of_range - cmp ax,0 - jg tword_exp_ok - mov cx,ax - neg cx - inc cx - cmp cx,64 - jae value_out_of_range - cmp cx,32 - ja large_shift - mov eax,[esi] - mov edx,[esi+4] - mov ebx,edx - shr edx,cl - shrd eax,ebx,cl - jmp tword_mantissa_shift_done - large_shift: - sub cx,32 - xor edx,edx - mov eax,[esi+4] - shr eax,cl - tword_mantissa_shift_done: - jnc store_shifted_mantissa - add eax,1 - adc edx,0 - store_shifted_mantissa: - mov [edi-8],eax - mov [edi-4],edx - xor ax,ax - test edx,1 shl 31 - jz tword_exp_ok - inc ax - tword_exp_ok: - mov bl,[esi+11] - shl bx,15 - or ax,bx - stos word [edi] - add esi,13 - ret - fp_zero_tword: - xor eax,eax - stos dword [edi] - stos dword [edi] - mov al,[esi+11] - shl ax,15 - stos word [edi] - add esi,13 - ret - complex_tword: - call get_word_value - push eax - cmp byte [esi],':' - jne invalid_operand - inc esi - lods byte [esi] - cmp al,'(' - jne invalid_operand - mov al,[value_type] - push eax - cmp byte [esi],'.' - je invalid_value - call get_qword_value - call mark_relocation - stos dword [edi] - mov eax,edx - stos dword [edi] - pop eax - mov [value_type],al - pop eax - call mark_relocation - stos word [edi] - ret -data_file: - lods word [esi] - cmp ax,'(' - jne invalid_argument - add esi,4 - call open_binary_file - mov eax,[esi-4] - lea esi,[esi+eax+1] - mov al,2 - xor edx,edx - call lseek - push eax - xor edx,edx - cmp byte [esi],':' - jne position_ok - inc esi - cmp byte [esi],'(' - jne invalid_argument - inc esi - cmp byte [esi],'.' - je invalid_value - push ebx - call get_count_value - pop ebx - mov edx,eax - sub [esp],edx - jc value_out_of_range - position_ok: - cmp byte [esi],',' - jne size_ok - inc esi - cmp byte [esi],'(' - jne invalid_argument - inc esi - cmp byte [esi],'.' - je invalid_value - push ebx edx - call get_count_value - pop edx ebx - cmp eax,[esp] - ja value_out_of_range - mov [esp],eax - size_ok: - xor al,al - call lseek - pop ecx - mov edx,edi - add edi,ecx - jc out_of_memory - cmp edi,[tagged_blocks] - ja out_of_memory - call read - jc error_reading_file - call close - lods byte [esi] - cmp al,',' - je data_file - dec esi - jmp instruction_assembled - open_binary_file: - push esi - push edi - mov eax,[current_line] - find_current_source_path: - mov esi,[eax] - test byte [eax+7],80h - jz get_current_path - mov eax,[eax+8] - jmp find_current_source_path - get_current_path: - lodsb - stosb - or al,al - jnz get_current_path - cut_current_path: - cmp edi,[esp] - je current_path_ok - cmp byte [edi-1],'\' - je current_path_ok - cmp byte [edi-1],'/' - je current_path_ok - dec edi - jmp cut_current_path - current_path_ok: - mov esi,[esp+4] - call expand_path - pop edx - mov esi,edx - call open - jnc file_opened - mov edx,[include_paths] - search_in_include_paths: - push edx esi - mov edi,esi - mov esi,[esp+4] - call get_include_directory - mov [esp+4],esi - mov esi,[esp+8] - call expand_path - pop edx - mov esi,edx - call open - pop edx - jnc file_opened - cmp byte [edx],0 - jne search_in_include_paths - mov edi,esi - mov esi,[esp] - push edi - call expand_path - pop edx - mov esi,edx - call open - jc file_not_found - file_opened: - mov edi,esi - pop esi - ret -reserve_bytes: - lods byte [esi] - cmp al,'(' - jne invalid_argument - cmp byte [esi],'.' - je invalid_value - call get_count_value - mov ecx,eax - mov edx,ecx - add edx,edi - jc out_of_memory - cmp edx,[tagged_blocks] - ja out_of_memory - push edi - cmp [next_pass_needed],0 - je zero_bytes - add edi,ecx - jmp reserved_data - zero_bytes: - xor eax,eax - shr ecx,1 - jnc bytes_stosb_ok - stos byte [edi] - bytes_stosb_ok: - shr ecx,1 - jnc bytes_stosw_ok - stos word [edi] - bytes_stosw_ok: - rep stos dword [edi] - reserved_data: - pop eax - call undefined_data - jmp instruction_assembled -reserve_words: - lods byte [esi] - cmp al,'(' - jne invalid_argument - cmp byte [esi],'.' - je invalid_value - call get_count_value - mov ecx,eax - mov edx,ecx - shl edx,1 - jc out_of_memory - add edx,edi - jc out_of_memory - cmp edx,[tagged_blocks] - ja out_of_memory - push edi - cmp [next_pass_needed],0 - je zero_words - lea edi,[edi+ecx*2] - jmp reserved_data - zero_words: - xor eax,eax - shr ecx,1 - jnc words_stosw_ok - stos word [edi] - words_stosw_ok: - rep stos dword [edi] - jmp reserved_data -reserve_dwords: - lods byte [esi] - cmp al,'(' - jne invalid_argument - cmp byte [esi],'.' - je invalid_value - call get_count_value - mov ecx,eax - mov edx,ecx - shl edx,1 - jc out_of_memory - shl edx,1 - jc out_of_memory - add edx,edi - jc out_of_memory - cmp edx,[tagged_blocks] - ja out_of_memory - push edi - cmp [next_pass_needed],0 - je zero_dwords - lea edi,[edi+ecx*4] - jmp reserved_data - zero_dwords: - xor eax,eax - rep stos dword [edi] - jmp reserved_data -reserve_pwords: - lods byte [esi] - cmp al,'(' - jne invalid_argument - cmp byte [esi],'.' - je invalid_value - call get_count_value - mov ecx,eax - shl ecx,1 - jc out_of_memory - add ecx,eax - mov edx,ecx - shl edx,1 - jc out_of_memory - add edx,edi - jc out_of_memory - cmp edx,[tagged_blocks] - ja out_of_memory - push edi - cmp [next_pass_needed],0 - je zero_words - lea edi,[edi+ecx*2] - jmp reserved_data -reserve_qwords: - lods byte [esi] - cmp al,'(' - jne invalid_argument - cmp byte [esi],'.' - je invalid_value - call get_count_value - mov ecx,eax - shl ecx,1 - jc out_of_memory - mov edx,ecx - shl edx,1 - jc out_of_memory - shl edx,1 - jc out_of_memory - add edx,edi - jc out_of_memory - cmp edx,[tagged_blocks] - ja out_of_memory - push edi - cmp [next_pass_needed],0 - je zero_dwords - lea edi,[edi+ecx*4] - jmp reserved_data -reserve_twords: - lods byte [esi] - cmp al,'(' - jne invalid_argument - cmp byte [esi],'.' - je invalid_value - call get_count_value - mov ecx,eax - shl ecx,2 - jc out_of_memory - add ecx,eax - mov edx,ecx - shl edx,1 - jc out_of_memory - add edx,edi - jc out_of_memory - cmp edx,[tagged_blocks] - ja out_of_memory - push edi - cmp [next_pass_needed],0 - je zero_words - lea edi,[edi+ecx*2] - jmp reserved_data -align_directive: - lods byte [esi] - cmp al,'(' - jne invalid_argument - cmp byte [esi],'.' - je invalid_value - call get_count_value - mov edx,eax - dec edx - test eax,edx - jnz invalid_align_value - or eax,eax - jz invalid_align_value - cmp eax,1 - je instruction_assembled - mov ecx,edi - mov ebp,[addressing_space] - sub ecx,[ds:ebp] - cmp dword [ds:ebp+10h],0 - jne section_not_aligned_enough - cmp byte [ds:ebp+9],0 - je make_alignment - cmp [output_format],3 - je pe_alignment - mov ebx,[ds:ebp+14h] - cmp byte [ebx],0 - jne section_not_aligned_enough - cmp eax,[ebx+10h] - jbe make_alignment - jmp section_not_aligned_enough - pe_alignment: - cmp eax,1000h - ja section_not_aligned_enough - make_alignment: - dec eax - and ecx,eax - jz instruction_assembled - neg ecx - add ecx,eax - inc ecx - mov edx,ecx - add edx,edi - jc out_of_memory - cmp edx,[tagged_blocks] - ja out_of_memory - push edi - cmp [next_pass_needed],0 - je nops - add edi,ecx - jmp reserved_data - invalid_align_value: - cmp [error_line],0 - jne instruction_assembled - mov eax,[current_line] - mov [error_line],eax - mov [error],invalid_value - jmp instruction_assembled - nops: - mov eax,90909090h - shr ecx,1 - jnc nops_stosb_ok - stos byte [edi] - nops_stosb_ok: - shr ecx,1 - jnc nops_stosw_ok - stos word [edi] - nops_stosw_ok: - rep stos dword [edi] - jmp reserved_data -err_directive: - mov al,[esi] - cmp al,0Fh - je invoked_error - or al,al - jz invoked_error - jmp extra_characters_on_line -assert_directive: - call calculate_logical_expression - or al,al - jnz instruction_assembled - cmp [error_line],0 - jne instruction_assembled - mov eax,[current_line] - mov [error_line],eax - mov [error],assertion_failed - jmp instruction_assembled diff --git a/samples/Assembly/SYSTEM.inc b/samples/Assembly/SYSTEM.inc deleted file mode 100644 index 77a61d29..00000000 --- a/samples/Assembly/SYSTEM.inc +++ /dev/null @@ -1,503 +0,0 @@ - -; flat assembler interface for Win32 -; Copyright (c) 1999-2014, Tomasz Grysztar. -; All rights reserved. - -CREATE_NEW = 1 -CREATE_ALWAYS = 2 -OPEN_EXISTING = 3 -OPEN_ALWAYS = 4 -TRUNCATE_EXISTING = 5 - -FILE_SHARE_READ = 1 -FILE_SHARE_WRITE = 2 -FILE_SHARE_DELETE = 4 - -GENERIC_READ = 80000000h -GENERIC_WRITE = 40000000h - -STD_INPUT_HANDLE = 0FFFFFFF6h -STD_OUTPUT_HANDLE = 0FFFFFFF5h -STD_ERROR_HANDLE = 0FFFFFFF4h - -MEM_COMMIT = 1000h -MEM_RESERVE = 2000h -MEM_DECOMMIT = 4000h -MEM_RELEASE = 8000h -MEM_FREE = 10000h -MEM_PRIVATE = 20000h -MEM_MAPPED = 40000h -MEM_RESET = 80000h -MEM_TOP_DOWN = 100000h - -PAGE_NOACCESS = 1 -PAGE_READONLY = 2 -PAGE_READWRITE = 4 -PAGE_WRITECOPY = 8 -PAGE_EXECUTE = 10h -PAGE_EXECUTE_READ = 20h -PAGE_EXECUTE_READWRITE = 40h -PAGE_EXECUTE_WRITECOPY = 80h -PAGE_GUARD = 100h -PAGE_NOCACHE = 200h - -init_memory: - xor eax,eax - mov [memory_start],eax - mov eax,esp - and eax,not 0FFFh - add eax,1000h-10000h - mov [stack_limit],eax - mov eax,[memory_setting] - shl eax,10 - jnz allocate_memory - push buffer - call [GlobalMemoryStatus] - mov eax,dword [buffer+20] - mov edx,dword [buffer+12] - cmp eax,0 - jl large_memory - cmp edx,0 - jl large_memory - shr eax,2 - add eax,edx - jmp allocate_memory - large_memory: - mov eax,80000000h - allocate_memory: - mov edx,eax - shr edx,2 - mov ecx,eax - sub ecx,edx - mov [memory_end],ecx - mov [additional_memory_end],edx - push PAGE_READWRITE - push MEM_COMMIT - push eax - push 0 - call [VirtualAlloc] - or eax,eax - jz not_enough_memory - mov [memory_start],eax - add eax,[memory_end] - mov [memory_end],eax - mov [additional_memory],eax - add [additional_memory_end],eax - ret - not_enough_memory: - mov eax,[additional_memory_end] - shl eax,1 - cmp eax,4000h - jb out_of_memory - jmp allocate_memory - -exit_program: - movzx eax,al - push eax - mov eax,[memory_start] - test eax,eax - jz do_exit - push MEM_RELEASE - push 0 - push eax - call [VirtualFree] - do_exit: - call [ExitProcess] - -get_environment_variable: - mov ecx,[memory_end] - sub ecx,edi - cmp ecx,4000h - jbe buffer_for_variable_ok - mov ecx,4000h - buffer_for_variable_ok: - push ecx - push edi - push esi - call [GetEnvironmentVariable] - add edi,eax - cmp edi,[memory_end] - jae out_of_memory - ret - -open: - push 0 - push 0 - push OPEN_EXISTING - push 0 - push FILE_SHARE_READ - push GENERIC_READ - push edx - call [CreateFile] - cmp eax,-1 - je file_error - mov ebx,eax - clc - ret - file_error: - stc - ret -create: - push 0 - push 0 - push CREATE_ALWAYS - push 0 - push FILE_SHARE_READ - push GENERIC_WRITE - push edx - call [CreateFile] - cmp eax,-1 - je file_error - mov ebx,eax - clc - ret -write: - push 0 - push bytes_count - push ecx - push edx - push ebx - call [WriteFile] - or eax,eax - jz file_error - clc - ret -read: - mov ebp,ecx - push 0 - push bytes_count - push ecx - push edx - push ebx - call [ReadFile] - or eax,eax - jz file_error - cmp ebp,[bytes_count] - jne file_error - clc - ret -close: - push ebx - call [CloseHandle] - ret -lseek: - movzx eax,al - push eax - push 0 - push edx - push ebx - call [SetFilePointer] - ret - -display_string: - push [con_handle] - call [GetStdHandle] - mov ebp,eax - mov edi,esi - or ecx,-1 - xor al,al - repne scasb - neg ecx - sub ecx,2 - push 0 - push bytes_count - push ecx - push esi - push ebp - call [WriteFile] - ret -display_character: - push ebx - mov [character],dl - push [con_handle] - call [GetStdHandle] - mov ebx,eax - push 0 - push bytes_count - push 1 - push character - push ebx - call [WriteFile] - pop ebx - ret -display_number: - push ebx - mov ecx,1000000000 - xor edx,edx - xor bl,bl - display_loop: - div ecx - push edx - cmp ecx,1 - je display_digit - or bl,bl - jnz display_digit - or al,al - jz digit_ok - not bl - display_digit: - mov dl,al - add dl,30h - push ecx - call display_character - pop ecx - digit_ok: - mov eax,ecx - xor edx,edx - mov ecx,10 - div ecx - mov ecx,eax - pop eax - or ecx,ecx - jnz display_loop - pop ebx - ret - -display_user_messages: - mov [displayed_count],0 - call show_display_buffer - cmp [displayed_count],1 - jb line_break_ok - je make_line_break - mov ax,word [last_displayed] - cmp ax,0A0Dh - je line_break_ok - cmp ax,0D0Ah - je line_break_ok - make_line_break: - mov word [buffer],0A0Dh - push [con_handle] - call [GetStdHandle] - push 0 - push bytes_count - push 2 - push buffer - push eax - call [WriteFile] - line_break_ok: - ret -display_block: - add [displayed_count],ecx - cmp ecx,1 - ja take_last_two_characters - jb block_displayed - mov al,[last_displayed+1] - mov ah,[esi] - mov word [last_displayed],ax - jmp block_ok - take_last_two_characters: - mov ax,[esi+ecx-2] - mov word [last_displayed],ax - block_ok: - push ecx - push [con_handle] - call [GetStdHandle] - pop ecx - push 0 - push bytes_count - push ecx - push esi - push eax - call [WriteFile] - block_displayed: - ret - -fatal_error: - mov [con_handle],STD_ERROR_HANDLE - mov esi,error_prefix - call display_string - pop esi - call display_string - mov esi,error_suffix - call display_string - mov al,0FFh - jmp exit_program -assembler_error: - mov [con_handle],STD_ERROR_HANDLE - call display_user_messages - push dword 0 - mov ebx,[current_line] - get_error_lines: - mov eax,[ebx] - cmp byte [eax],0 - je get_next_error_line - push ebx - test byte [ebx+7],80h - jz display_error_line - mov edx,ebx - find_definition_origin: - mov edx,[edx+12] - test byte [edx+7],80h - jnz find_definition_origin - push edx - get_next_error_line: - mov ebx,[ebx+8] - jmp get_error_lines - display_error_line: - mov esi,[ebx] - call display_string - mov esi,line_number_start - call display_string - mov eax,[ebx+4] - and eax,7FFFFFFFh - call display_number - mov dl,']' - call display_character - pop esi - cmp ebx,esi - je line_number_ok - mov dl,20h - call display_character - push esi - mov esi,[esi] - movzx ecx,byte [esi] - inc esi - call display_block - mov esi,line_number_start - call display_string - pop esi - mov eax,[esi+4] - and eax,7FFFFFFFh - call display_number - mov dl,']' - call display_character - line_number_ok: - mov esi,line_data_start - call display_string - mov esi,ebx - mov edx,[esi] - call open - mov al,2 - xor edx,edx - call lseek - mov edx,[esi+8] - sub eax,edx - jz line_data_displayed - push eax - xor al,al - call lseek - mov ecx,[esp] - mov edx,[additional_memory] - lea eax,[edx+ecx] - cmp eax,[additional_memory_end] - ja out_of_memory - call read - call close - pop ecx - mov esi,[additional_memory] - get_line_data: - mov al,[esi] - cmp al,0Ah - je display_line_data - cmp al,0Dh - je display_line_data - cmp al,1Ah - je display_line_data - or al,al - jz display_line_data - inc esi - loop get_line_data - display_line_data: - mov ecx,esi - mov esi,[additional_memory] - sub ecx,esi - call display_block - line_data_displayed: - mov esi,cr_lf - call display_string - pop ebx - or ebx,ebx - jnz display_error_line - mov esi,error_prefix - call display_string - pop esi - call display_string - mov esi,error_suffix - call display_string - mov al,2 - jmp exit_program - -make_timestamp: - push buffer - call [GetSystemTime] - movzx ecx,word [buffer] - mov eax,ecx - sub eax,1970 - mov ebx,365 - mul ebx - mov ebp,eax - mov eax,ecx - sub eax,1969 - shr eax,2 - add ebp,eax - mov eax,ecx - sub eax,1901 - mov ebx,100 - div ebx - sub ebp,eax - mov eax,ecx - xor edx,edx - sub eax,1601 - mov ebx,400 - div ebx - add ebp,eax - movzx ecx,word [buffer+2] - mov eax,ecx - dec eax - mov ebx,30 - mul ebx - add ebp,eax - cmp ecx,8 - jbe months_correction - mov eax,ecx - sub eax,7 - shr eax,1 - add ebp,eax - mov ecx,8 - months_correction: - mov eax,ecx - shr eax,1 - add ebp,eax - cmp ecx,2 - jbe day_correction_ok - sub ebp,2 - movzx ecx,word [buffer] - test ecx,11b - jnz day_correction_ok - xor edx,edx - mov eax,ecx - mov ebx,100 - div ebx - or edx,edx - jnz day_correction - mov eax,ecx - mov ebx,400 - div ebx - or edx,edx - jnz day_correction_ok - day_correction: - inc ebp - day_correction_ok: - movzx eax,word [buffer+6] - dec eax - add eax,ebp - mov ebx,24 - mul ebx - movzx ecx,word [buffer+8] - add eax,ecx - mov ebx,60 - mul ebx - movzx ecx,word [buffer+10] - add eax,ecx - mov ebx,60 - mul ebx - movzx ecx,word [buffer+12] - add eax,ecx - adc edx,0 - ret - -error_prefix db 'error: ',0 -error_suffix db '.' -cr_lf db 0Dh,0Ah,0 -line_number_start db ' [',0 -line_data_start db ':',0Dh,0Ah,0 diff --git a/samples/Assembly/X86_64.inc b/samples/Assembly/X86_64.inc deleted file mode 100644 index 28413065..00000000 --- a/samples/Assembly/X86_64.inc +++ /dev/null @@ -1,7060 +0,0 @@ - -; flat assembler core -; Copyright (c) 1999-2014, Tomasz Grysztar. -; All rights reserved. - -simple_instruction_except64: - cmp [code_type],64 - je illegal_instruction -simple_instruction: - stos byte [edi] - jmp instruction_assembled -simple_instruction_only64: - cmp [code_type],64 - jne illegal_instruction - jmp simple_instruction -simple_instruction_16bit_except64: - cmp [code_type],64 - je illegal_instruction -simple_instruction_16bit: - cmp [code_type],16 - jne size_prefix - stos byte [edi] - jmp instruction_assembled - size_prefix: - mov ah,al - mov al,66h - stos word [edi] - jmp instruction_assembled -simple_instruction_32bit_except64: - cmp [code_type],64 - je illegal_instruction -simple_instruction_32bit: - cmp [code_type],16 - je size_prefix - stos byte [edi] - jmp instruction_assembled -iret_instruction: - cmp [code_type],64 - jne simple_instruction -simple_instruction_64bit: - cmp [code_type],64 - jne illegal_instruction - mov ah,al - mov al,48h - stos word [edi] - jmp instruction_assembled -simple_extended_instruction_64bit: - cmp [code_type],64 - jne illegal_instruction - mov byte [edi],48h - inc edi -simple_extended_instruction: - mov ah,al - mov al,0Fh - stos word [edi] - jmp instruction_assembled -prefix_instruction: - stos byte [edi] - or [prefixed_instruction],-1 - jmp continue_line -segment_prefix: - mov ah,al - shr ah,4 - cmp ah,6 - jne illegal_instruction - and al,1111b - mov [segment_register],al - call store_segment_prefix - or [prefixed_instruction],-1 - jmp continue_line -int_instruction: - lods byte [esi] - call get_size_operator - cmp ah,1 - ja invalid_operand_size - cmp al,'(' - jne invalid_operand - call get_byte_value - test eax,eax - jns int_imm_ok - call recoverable_overflow - int_imm_ok: - mov ah,al - mov al,0CDh - stos word [edi] - jmp instruction_assembled -aa_instruction: - cmp [code_type],64 - je illegal_instruction - push eax - mov bl,10 - cmp byte [esi],'(' - jne aa_store - inc esi - xor al,al - xchg al,[operand_size] - cmp al,1 - ja invalid_operand_size - call get_byte_value - mov bl,al - aa_store: - cmp [operand_size],0 - jne invalid_operand - pop eax - mov ah,bl - stos word [edi] - jmp instruction_assembled - -basic_instruction: - mov [base_code],al - lods byte [esi] - call get_size_operator - cmp al,10h - je basic_reg - cmp al,'[' - jne invalid_operand - basic_mem: - call get_address - push edx ebx ecx - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,'(' - je basic_mem_imm - cmp al,10h - jne invalid_operand - basic_mem_reg: - lods byte [esi] - call convert_register - mov [postbyte_register],al - pop ecx ebx edx - mov al,ah - cmp al,1 - je instruction_ready - call operand_autodetect - inc [base_code] - instruction_ready: - call store_instruction - jmp instruction_assembled - basic_mem_imm: - mov al,[operand_size] - cmp al,1 - jb basic_mem_imm_nosize - je basic_mem_imm_8bit - cmp al,2 - je basic_mem_imm_16bit - cmp al,4 - je basic_mem_imm_32bit - cmp al,8 - jne invalid_operand_size - basic_mem_imm_64bit: - cmp [size_declared],0 - jne long_immediate_not_encodable - call operand_64bit - call get_simm32 - cmp [value_type],4 - jae long_immediate_not_encodable - jmp basic_mem_imm_32bit_ok - basic_mem_imm_nosize: - call recoverable_unknown_size - basic_mem_imm_8bit: - call get_byte_value - mov byte [value],al - mov al,[base_code] - shr al,3 - mov [postbyte_register],al - pop ecx ebx edx - mov [base_code],80h - call store_instruction_with_imm8 - jmp instruction_assembled - basic_mem_imm_16bit: - call operand_16bit - call get_word_value - mov word [value],ax - mov al,[base_code] - shr al,3 - mov [postbyte_register],al - pop ecx ebx edx - cmp [value_type],0 - jne basic_mem_imm_16bit_store - cmp [size_declared],0 - jne basic_mem_imm_16bit_store - cmp word [value],80h - jb basic_mem_simm_8bit - cmp word [value],-80h - jae basic_mem_simm_8bit - basic_mem_imm_16bit_store: - mov [base_code],81h - call store_instruction_with_imm16 - jmp instruction_assembled - basic_mem_simm_8bit: - mov [base_code],83h - call store_instruction_with_imm8 - jmp instruction_assembled - basic_mem_imm_32bit: - call operand_32bit - call get_dword_value - basic_mem_imm_32bit_ok: - mov dword [value],eax - mov al,[base_code] - shr al,3 - mov [postbyte_register],al - pop ecx ebx edx - cmp [value_type],0 - jne basic_mem_imm_32bit_store - cmp [size_declared],0 - jne basic_mem_imm_32bit_store - cmp dword [value],80h - jb basic_mem_simm_8bit - cmp dword [value],-80h - jae basic_mem_simm_8bit - basic_mem_imm_32bit_store: - mov [base_code],81h - call store_instruction_with_imm32 - jmp instruction_assembled - get_simm32: - call get_qword_value - mov ecx,edx - cdq - cmp ecx,edx - jne value_out_of_range - cmp [value_type],4 - jne get_simm32_ok - mov [value_type],2 - get_simm32_ok: - ret - basic_reg: - lods byte [esi] - call convert_register - mov [postbyte_register],al - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - je basic_reg_reg - cmp al,'(' - je basic_reg_imm - cmp al,'[' - jne invalid_operand - basic_reg_mem: - call get_address - mov al,[operand_size] - cmp al,1 - je basic_reg_mem_8bit - call operand_autodetect - add [base_code],3 - jmp instruction_ready - basic_reg_mem_8bit: - add [base_code],2 - jmp instruction_ready - basic_reg_reg: - lods byte [esi] - call convert_register - mov bl,[postbyte_register] - mov [postbyte_register],al - mov al,ah - cmp al,1 - je nomem_instruction_ready - call operand_autodetect - inc [base_code] - nomem_instruction_ready: - call store_nomem_instruction - jmp instruction_assembled - basic_reg_imm: - mov al,[operand_size] - cmp al,1 - je basic_reg_imm_8bit - cmp al,2 - je basic_reg_imm_16bit - cmp al,4 - je basic_reg_imm_32bit - cmp al,8 - jne invalid_operand_size - basic_reg_imm_64bit: - cmp [size_declared],0 - jne long_immediate_not_encodable - call operand_64bit - call get_simm32 - cmp [value_type],4 - jae long_immediate_not_encodable - jmp basic_reg_imm_32bit_ok - basic_reg_imm_8bit: - call get_byte_value - mov dl,al - mov bl,[base_code] - shr bl,3 - xchg bl,[postbyte_register] - or bl,bl - jz basic_al_imm - mov [base_code],80h - call store_nomem_instruction - mov al,dl - stos byte [edi] - jmp instruction_assembled - basic_al_imm: - mov al,[base_code] - add al,4 - stos byte [edi] - mov al,dl - stos byte [edi] - jmp instruction_assembled - basic_reg_imm_16bit: - call operand_16bit - call get_word_value - mov dx,ax - mov bl,[base_code] - shr bl,3 - xchg bl,[postbyte_register] - cmp [value_type],0 - jne basic_reg_imm_16bit_store - cmp [size_declared],0 - jne basic_reg_imm_16bit_store - cmp dx,80h - jb basic_reg_simm_8bit - cmp dx,-80h - jae basic_reg_simm_8bit - basic_reg_imm_16bit_store: - or bl,bl - jz basic_ax_imm - mov [base_code],81h - call store_nomem_instruction - basic_store_imm_16bit: - mov ax,dx - call mark_relocation - stos word [edi] - jmp instruction_assembled - basic_reg_simm_8bit: - mov [base_code],83h - call store_nomem_instruction - mov al,dl - stos byte [edi] - jmp instruction_assembled - basic_ax_imm: - add [base_code],5 - call store_instruction_code - jmp basic_store_imm_16bit - basic_reg_imm_32bit: - call operand_32bit - call get_dword_value - basic_reg_imm_32bit_ok: - mov edx,eax - mov bl,[base_code] - shr bl,3 - xchg bl,[postbyte_register] - cmp [value_type],0 - jne basic_reg_imm_32bit_store - cmp [size_declared],0 - jne basic_reg_imm_32bit_store - cmp edx,80h - jb basic_reg_simm_8bit - cmp edx,-80h - jae basic_reg_simm_8bit - basic_reg_imm_32bit_store: - or bl,bl - jz basic_eax_imm - mov [base_code],81h - call store_nomem_instruction - basic_store_imm_32bit: - mov eax,edx - call mark_relocation - stos dword [edi] - jmp instruction_assembled - basic_eax_imm: - add [base_code],5 - call store_instruction_code - jmp basic_store_imm_32bit - recoverable_unknown_size: - cmp [error_line],0 - jne ignore_unknown_size - push [current_line] - pop [error_line] - mov [error],operand_size_not_specified - ignore_unknown_size: - ret -single_operand_instruction: - mov [base_code],0F6h - mov [postbyte_register],al - lods byte [esi] - call get_size_operator - cmp al,10h - je single_reg - cmp al,'[' - jne invalid_operand - single_mem: - call get_address - mov al,[operand_size] - cmp al,1 - je single_mem_8bit - jb single_mem_nosize - call operand_autodetect - inc [base_code] - jmp instruction_ready - single_mem_nosize: - call recoverable_unknown_size - single_mem_8bit: - jmp instruction_ready - single_reg: - lods byte [esi] - call convert_register - mov bl,al - mov al,ah - cmp al,1 - je single_reg_8bit - call operand_autodetect - inc [base_code] - single_reg_8bit: - jmp nomem_instruction_ready -mov_instruction: - mov [base_code],88h - lods byte [esi] - call get_size_operator - cmp al,10h - je mov_reg - cmp al,'[' - jne invalid_operand - mov_mem: - call get_address - push edx ebx ecx - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,'(' - je mov_mem_imm - cmp al,10h - jne invalid_operand - mov_mem_reg: - lods byte [esi] - cmp al,60h - jb mov_mem_general_reg - cmp al,70h - jb mov_mem_sreg - mov_mem_general_reg: - call convert_register - mov [postbyte_register],al - pop ecx ebx edx - cmp ah,1 - je mov_mem_reg_8bit - mov al,ah - call operand_autodetect - mov al,[postbyte_register] - or al,bl - or al,bh - jz mov_mem_ax - inc [base_code] - jmp instruction_ready - mov_mem_reg_8bit: - or al,bl - or al,bh - jnz instruction_ready - mov_mem_al: - test ch,22h - jnz mov_mem_address16_al - test ch,44h - jnz mov_mem_address32_al - test ch,88h - jnz mov_mem_address64_al - or ch,ch - jnz invalid_address_size - cmp [code_type],64 - je mov_mem_address64_al - cmp [code_type],32 - je mov_mem_address32_al - cmp edx,10000h - jb mov_mem_address16_al - mov_mem_address32_al: - call store_segment_prefix_if_necessary - call address_32bit_prefix - mov [base_code],0A2h - store_mov_address32: - call store_instruction_code - call store_address_32bit_value - jmp instruction_assembled - mov_mem_address16_al: - call store_segment_prefix_if_necessary - call address_16bit_prefix - mov [base_code],0A2h - store_mov_address16: - cmp [code_type],64 - je invalid_address - call store_instruction_code - mov eax,edx - stos word [edi] - cmp edx,10000h - jge value_out_of_range - jmp instruction_assembled - mov_mem_address64_al: - call store_segment_prefix_if_necessary - mov [base_code],0A2h - store_mov_address64: - call store_instruction_code - call store_address_64bit_value - jmp instruction_assembled - mov_mem_ax: - test ch,22h - jnz mov_mem_address16_ax - test ch,44h - jnz mov_mem_address32_ax - test ch,88h - jnz mov_mem_address64_ax - or ch,ch - jnz invalid_address_size - cmp [code_type],64 - je mov_mem_address64_ax - cmp [code_type],32 - je mov_mem_address32_ax - cmp edx,10000h - jb mov_mem_address16_ax - mov_mem_address32_ax: - call store_segment_prefix_if_necessary - call address_32bit_prefix - mov [base_code],0A3h - jmp store_mov_address32 - mov_mem_address16_ax: - call store_segment_prefix_if_necessary - call address_16bit_prefix - mov [base_code],0A3h - jmp store_mov_address16 - mov_mem_address64_ax: - call store_segment_prefix_if_necessary - mov [base_code],0A3h - jmp store_mov_address64 - mov_mem_sreg: - sub al,61h - mov [postbyte_register],al - pop ecx ebx edx - mov ah,[operand_size] - or ah,ah - jz mov_mem_sreg_store - cmp ah,2 - jne invalid_operand_size - mov_mem_sreg_store: - mov [base_code],8Ch - jmp instruction_ready - mov_mem_imm: - mov al,[operand_size] - cmp al,1 - jb mov_mem_imm_nosize - je mov_mem_imm_8bit - cmp al,2 - je mov_mem_imm_16bit - cmp al,4 - je mov_mem_imm_32bit - cmp al,8 - jne invalid_operand_size - mov_mem_imm_64bit: - cmp [size_declared],0 - jne long_immediate_not_encodable - call operand_64bit - call get_simm32 - cmp [value_type],4 - jae long_immediate_not_encodable - jmp mov_mem_imm_32bit_store - mov_mem_imm_8bit: - call get_byte_value - mov byte [value],al - mov [postbyte_register],0 - mov [base_code],0C6h - pop ecx ebx edx - call store_instruction_with_imm8 - jmp instruction_assembled - mov_mem_imm_16bit: - call operand_16bit - call get_word_value - mov word [value],ax - mov [postbyte_register],0 - mov [base_code],0C7h - pop ecx ebx edx - call store_instruction_with_imm16 - jmp instruction_assembled - mov_mem_imm_nosize: - call recoverable_unknown_size - mov_mem_imm_32bit: - call operand_32bit - call get_dword_value - mov_mem_imm_32bit_store: - mov dword [value],eax - mov [postbyte_register],0 - mov [base_code],0C7h - pop ecx ebx edx - call store_instruction_with_imm32 - jmp instruction_assembled - mov_reg: - lods byte [esi] - mov ah,al - sub ah,10h - and ah,al - test ah,0F0h - jnz mov_sreg - call convert_register - mov [postbyte_register],al - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,'[' - je mov_reg_mem - cmp al,'(' - je mov_reg_imm - cmp al,10h - jne invalid_operand - mov_reg_reg: - lods byte [esi] - mov ah,al - sub ah,10h - and ah,al - test ah,0F0h - jnz mov_reg_sreg - call convert_register - mov bl,[postbyte_register] - mov [postbyte_register],al - mov al,ah - cmp al,1 - je mov_reg_reg_8bit - call operand_autodetect - inc [base_code] - mov_reg_reg_8bit: - jmp nomem_instruction_ready - mov_reg_sreg: - mov bl,[postbyte_register] - mov ah,al - and al,1111b - mov [postbyte_register],al - shr ah,4 - cmp ah,5 - je mov_reg_creg - cmp ah,7 - je mov_reg_dreg - ja mov_reg_treg - dec [postbyte_register] - cmp [operand_size],8 - je mov_reg_sreg64 - cmp [operand_size],4 - je mov_reg_sreg32 - cmp [operand_size],2 - jne invalid_operand_size - call operand_16bit - jmp mov_reg_sreg_store - mov_reg_sreg64: - call operand_64bit - jmp mov_reg_sreg_store - mov_reg_sreg32: - call operand_32bit - mov_reg_sreg_store: - mov [base_code],8Ch - jmp nomem_instruction_ready - mov_reg_treg: - cmp ah,9 - jne invalid_operand - mov [extended_code],24h - jmp mov_reg_xrx - mov_reg_dreg: - mov [extended_code],21h - jmp mov_reg_xrx - mov_reg_creg: - mov [extended_code],20h - mov_reg_xrx: - mov [base_code],0Fh - cmp [code_type],64 - je mov_reg_xrx_64bit - cmp [operand_size],4 - jne invalid_operand_size - cmp [postbyte_register],8 - jne mov_reg_xrx_store - cmp [extended_code],20h - jne mov_reg_xrx_store - mov al,0F0h - stos byte [edi] - mov [postbyte_register],0 - mov_reg_xrx_store: - jmp nomem_instruction_ready - mov_reg_xrx_64bit: - cmp [operand_size],8 - jne invalid_operand_size - jmp nomem_instruction_ready - mov_reg_mem: - call get_address - mov al,[operand_size] - cmp al,1 - je mov_reg_mem_8bit - call operand_autodetect - mov al,[postbyte_register] - or al,bl - or al,bh - jz mov_ax_mem - add [base_code],3 - jmp instruction_ready - mov_reg_mem_8bit: - mov al,[postbyte_register] - or al,bl - or al,bh - jz mov_al_mem - add [base_code],2 - jmp instruction_ready - mov_al_mem: - test ch,22h - jnz mov_al_mem_address16 - test ch,44h - jnz mov_al_mem_address32 - test ch,88h - jnz mov_al_mem_address64 - or ch,ch - jnz invalid_address_size - cmp [code_type],64 - je mov_al_mem_address64 - cmp [code_type],32 - je mov_al_mem_address32 - cmp edx,10000h - jb mov_al_mem_address16 - mov_al_mem_address32: - call store_segment_prefix_if_necessary - call address_32bit_prefix - mov [base_code],0A0h - jmp store_mov_address32 - mov_al_mem_address16: - call store_segment_prefix_if_necessary - call address_16bit_prefix - mov [base_code],0A0h - jmp store_mov_address16 - mov_al_mem_address64: - call store_segment_prefix_if_necessary - mov [base_code],0A0h - jmp store_mov_address64 - mov_ax_mem: - test ch,22h - jnz mov_ax_mem_address16 - test ch,44h - jnz mov_ax_mem_address32 - test ch,88h - jnz mov_ax_mem_address64 - or ch,ch - jnz invalid_address_size - cmp [code_type],64 - je mov_ax_mem_address64 - cmp [code_type],32 - je mov_ax_mem_address32 - cmp edx,10000h - jb mov_ax_mem_address16 - mov_ax_mem_address32: - call store_segment_prefix_if_necessary - call address_32bit_prefix - mov [base_code],0A1h - jmp store_mov_address32 - mov_ax_mem_address16: - call store_segment_prefix_if_necessary - call address_16bit_prefix - mov [base_code],0A1h - jmp store_mov_address16 - mov_ax_mem_address64: - call store_segment_prefix_if_necessary - mov [base_code],0A1h - jmp store_mov_address64 - mov_reg_imm: - mov al,[operand_size] - cmp al,1 - je mov_reg_imm_8bit - cmp al,2 - je mov_reg_imm_16bit - cmp al,4 - je mov_reg_imm_32bit - cmp al,8 - jne invalid_operand_size - mov_reg_imm_64bit: - call operand_64bit - call get_qword_value - mov ecx,edx - cmp [size_declared],0 - jne mov_reg_imm_64bit_store - cmp [value_type],4 - jae mov_reg_imm_64bit_store - cdq - cmp ecx,edx - je mov_reg_64bit_imm_32bit - mov_reg_imm_64bit_store: - push eax ecx - mov al,0B8h - call store_mov_reg_imm_code - pop edx eax - call mark_relocation - stos dword [edi] - mov eax,edx - stos dword [edi] - jmp instruction_assembled - mov_reg_imm_8bit: - call get_byte_value - mov dl,al - mov al,0B0h - call store_mov_reg_imm_code - mov al,dl - stos byte [edi] - jmp instruction_assembled - mov_reg_imm_16bit: - call get_word_value - mov dx,ax - call operand_16bit - mov al,0B8h - call store_mov_reg_imm_code - mov ax,dx - call mark_relocation - stos word [edi] - jmp instruction_assembled - mov_reg_imm_32bit: - call operand_32bit - call get_dword_value - mov edx,eax - mov al,0B8h - call store_mov_reg_imm_code - mov_store_imm_32bit: - mov eax,edx - call mark_relocation - stos dword [edi] - jmp instruction_assembled - store_mov_reg_imm_code: - mov ah,[postbyte_register] - test ah,1000b - jz mov_reg_imm_prefix_ok - or [rex_prefix],41h - mov_reg_imm_prefix_ok: - and ah,111b - add al,ah - mov [base_code],al - call store_instruction_code - ret - mov_reg_64bit_imm_32bit: - mov edx,eax - mov bl,[postbyte_register] - mov [postbyte_register],0 - mov [base_code],0C7h - call store_nomem_instruction - jmp mov_store_imm_32bit - mov_sreg: - mov ah,al - and al,1111b - mov [postbyte_register],al - shr ah,4 - cmp ah,5 - je mov_creg - cmp ah,7 - je mov_dreg - ja mov_treg - cmp al,2 - je illegal_instruction - dec [postbyte_register] - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,'[' - je mov_sreg_mem - cmp al,10h - jne invalid_operand - mov_sreg_reg: - lods byte [esi] - call convert_register - or ah,ah - jz mov_sreg_reg_size_ok - cmp ah,2 - jne invalid_operand_size - mov bl,al - mov_sreg_reg_size_ok: - mov [base_code],8Eh - jmp nomem_instruction_ready - mov_sreg_mem: - call get_address - mov al,[operand_size] - or al,al - jz mov_sreg_mem_size_ok - cmp al,2 - jne invalid_operand_size - mov_sreg_mem_size_ok: - mov [base_code],8Eh - jmp instruction_ready - mov_treg: - cmp ah,9 - jne invalid_operand - mov [extended_code],26h - jmp mov_xrx - mov_dreg: - mov [extended_code],23h - jmp mov_xrx - mov_creg: - mov [extended_code],22h - mov_xrx: - mov [base_code],0Fh - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - mov bl,al - cmp [code_type],64 - je mov_xrx_64bit - cmp ah,4 - jne invalid_operand_size - cmp [postbyte_register],8 - jne mov_xrx_store - cmp [extended_code],22h - jne mov_xrx_store - mov al,0F0h - stos byte [edi] - mov [postbyte_register],0 - mov_xrx_store: - jmp nomem_instruction_ready - mov_xrx_64bit: - cmp ah,8 - je mov_xrx_store - jmp invalid_operand_size -test_instruction: - mov [base_code],84h - lods byte [esi] - call get_size_operator - cmp al,10h - je test_reg - cmp al,'[' - jne invalid_operand - test_mem: - call get_address - push edx ebx ecx - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,'(' - je test_mem_imm - cmp al,10h - jne invalid_operand - test_mem_reg: - lods byte [esi] - call convert_register - mov [postbyte_register],al - pop ecx ebx edx - mov al,ah - cmp al,1 - je test_mem_reg_8bit - call operand_autodetect - inc [base_code] - test_mem_reg_8bit: - jmp instruction_ready - test_mem_imm: - mov al,[operand_size] - cmp al,1 - jb test_mem_imm_nosize - je test_mem_imm_8bit - cmp al,2 - je test_mem_imm_16bit - cmp al,4 - je test_mem_imm_32bit - cmp al,8 - jne invalid_operand_size - test_mem_imm_64bit: - cmp [size_declared],0 - jne long_immediate_not_encodable - call operand_64bit - call get_simm32 - cmp [value_type],4 - jae long_immediate_not_encodable - jmp test_mem_imm_32bit_store - test_mem_imm_8bit: - call get_byte_value - mov byte [value],al - mov [postbyte_register],0 - mov [base_code],0F6h - pop ecx ebx edx - call store_instruction_with_imm8 - jmp instruction_assembled - test_mem_imm_16bit: - call operand_16bit - call get_word_value - mov word [value],ax - mov [postbyte_register],0 - mov [base_code],0F7h - pop ecx ebx edx - call store_instruction_with_imm16 - jmp instruction_assembled - test_mem_imm_nosize: - call recoverable_unknown_size - test_mem_imm_32bit: - call operand_32bit - call get_dword_value - test_mem_imm_32bit_store: - mov dword [value],eax - mov [postbyte_register],0 - mov [base_code],0F7h - pop ecx ebx edx - call store_instruction_with_imm32 - jmp instruction_assembled - test_reg: - lods byte [esi] - call convert_register - mov [postbyte_register],al - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,'[' - je test_reg_mem - cmp al,'(' - je test_reg_imm - cmp al,10h - jne invalid_operand - test_reg_reg: - lods byte [esi] - call convert_register - mov bl,[postbyte_register] - mov [postbyte_register],al - mov al,ah - cmp al,1 - je test_reg_reg_8bit - call operand_autodetect - inc [base_code] - test_reg_reg_8bit: - jmp nomem_instruction_ready - test_reg_imm: - mov al,[operand_size] - cmp al,1 - je test_reg_imm_8bit - cmp al,2 - je test_reg_imm_16bit - cmp al,4 - je test_reg_imm_32bit - cmp al,8 - jne invalid_operand_size - test_reg_imm_64bit: - cmp [size_declared],0 - jne long_immediate_not_encodable - call operand_64bit - call get_simm32 - cmp [value_type],4 - jae long_immediate_not_encodable - jmp test_reg_imm_32bit_store - test_reg_imm_8bit: - call get_byte_value - mov dl,al - mov bl,[postbyte_register] - mov [postbyte_register],0 - mov [base_code],0F6h - or bl,bl - jz test_al_imm - call store_nomem_instruction - mov al,dl - stos byte [edi] - jmp instruction_assembled - test_al_imm: - mov [base_code],0A8h - call store_instruction_code - mov al,dl - stos byte [edi] - jmp instruction_assembled - test_reg_imm_16bit: - call operand_16bit - call get_word_value - mov dx,ax - mov bl,[postbyte_register] - mov [postbyte_register],0 - mov [base_code],0F7h - or bl,bl - jz test_ax_imm - call store_nomem_instruction - mov ax,dx - call mark_relocation - stos word [edi] - jmp instruction_assembled - test_ax_imm: - mov [base_code],0A9h - call store_instruction_code - mov ax,dx - stos word [edi] - jmp instruction_assembled - test_reg_imm_32bit: - call operand_32bit - call get_dword_value - test_reg_imm_32bit_store: - mov edx,eax - mov bl,[postbyte_register] - mov [postbyte_register],0 - mov [base_code],0F7h - or bl,bl - jz test_eax_imm - call store_nomem_instruction - mov eax,edx - call mark_relocation - stos dword [edi] - jmp instruction_assembled - test_eax_imm: - mov [base_code],0A9h - call store_instruction_code - mov eax,edx - stos dword [edi] - jmp instruction_assembled - test_reg_mem: - call get_address - mov al,[operand_size] - cmp al,1 - je test_reg_mem_8bit - call operand_autodetect - inc [base_code] - test_reg_mem_8bit: - jmp instruction_ready -xchg_instruction: - mov [base_code],86h - lods byte [esi] - call get_size_operator - cmp al,10h - je xchg_reg - cmp al,'[' - jne invalid_operand - xchg_mem: - call get_address - push edx ebx ecx - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - je test_mem_reg - jmp invalid_operand - xchg_reg: - lods byte [esi] - call convert_register - mov [postbyte_register],al - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,'[' - je test_reg_mem - cmp al,10h - jne invalid_operand - xchg_reg_reg: - lods byte [esi] - call convert_register - mov bl,al - mov al,ah - cmp al,1 - je xchg_reg_reg_8bit - call operand_autodetect - cmp [postbyte_register],0 - je xchg_ax_reg - or bl,bl - jnz xchg_reg_reg_store - mov bl,[postbyte_register] - xchg_ax_reg: - cmp [code_type],64 - jne xchg_ax_reg_ok - cmp ah,4 - jne xchg_ax_reg_ok - or bl,bl - jz xchg_reg_reg_store - xchg_ax_reg_ok: - test bl,1000b - jz xchg_ax_reg_store - or [rex_prefix],41h - and bl,111b - xchg_ax_reg_store: - add bl,90h - mov [base_code],bl - call store_instruction_code - jmp instruction_assembled - xchg_reg_reg_store: - inc [base_code] - xchg_reg_reg_8bit: - jmp nomem_instruction_ready -push_instruction: - mov [push_size],al - push_next: - lods byte [esi] - call get_size_operator - cmp al,10h - je push_reg - cmp al,'(' - je push_imm - cmp al,'[' - jne invalid_operand - push_mem: - call get_address - mov al,[operand_size] - mov ah,[push_size] - cmp al,2 - je push_mem_16bit - cmp al,4 - je push_mem_32bit - cmp al,8 - je push_mem_64bit - or al,al - jnz invalid_operand_size - cmp ah,2 - je push_mem_16bit - cmp ah,4 - je push_mem_32bit - cmp ah,8 - je push_mem_64bit - call recoverable_unknown_size - jmp push_mem_store - push_mem_16bit: - test ah,not 2 - jnz invalid_operand_size - call operand_16bit - jmp push_mem_store - push_mem_32bit: - test ah,not 4 - jnz invalid_operand_size - cmp [code_type],64 - je illegal_instruction - call operand_32bit - jmp push_mem_store - push_mem_64bit: - test ah,not 8 - jnz invalid_operand_size - cmp [code_type],64 - jne illegal_instruction - push_mem_store: - mov [base_code],0FFh - mov [postbyte_register],110b - call store_instruction - jmp push_done - push_reg: - lods byte [esi] - mov ah,al - sub ah,10h - and ah,al - test ah,0F0h - jnz push_sreg - call convert_register - test al,1000b - jz push_reg_ok - or [rex_prefix],41h - and al,111b - push_reg_ok: - add al,50h - mov [base_code],al - mov al,ah - mov ah,[push_size] - cmp al,2 - je push_reg_16bit - cmp al,4 - je push_reg_32bit - cmp al,8 - jne invalid_operand_size - push_reg_64bit: - test ah,not 8 - jnz invalid_operand_size - cmp [code_type],64 - jne illegal_instruction - jmp push_reg_store - push_reg_32bit: - test ah,not 4 - jnz invalid_operand_size - cmp [code_type],64 - je illegal_instruction - call operand_32bit - jmp push_reg_store - push_reg_16bit: - test ah,not 2 - jnz invalid_operand_size - call operand_16bit - push_reg_store: - call store_instruction_code - jmp push_done - push_sreg: - mov bl,al - mov dl,[operand_size] - mov dh,[push_size] - cmp dl,2 - je push_sreg16 - cmp dl,4 - je push_sreg32 - cmp dl,8 - je push_sreg64 - or dl,dl - jnz invalid_operand_size - cmp dh,2 - je push_sreg16 - cmp dh,4 - je push_sreg32 - cmp dh,8 - je push_sreg64 - jmp push_sreg_store - push_sreg16: - test dh,not 2 - jnz invalid_operand_size - call operand_16bit - jmp push_sreg_store - push_sreg32: - test dh,not 4 - jnz invalid_operand_size - cmp [code_type],64 - je illegal_instruction - call operand_32bit - jmp push_sreg_store - push_sreg64: - test dh,not 8 - jnz invalid_operand_size - cmp [code_type],64 - jne illegal_instruction - push_sreg_store: - mov al,bl - cmp al,70h - jae invalid_operand - sub al,61h - jc invalid_operand - cmp al,4 - jae push_sreg_386 - shl al,3 - add al,6 - mov [base_code],al - cmp [code_type],64 - je illegal_instruction - jmp push_reg_store - push_sreg_386: - sub al,4 - shl al,3 - add al,0A0h - mov [extended_code],al - mov [base_code],0Fh - jmp push_reg_store - push_imm: - mov al,[operand_size] - mov ah,[push_size] - or al,al - je push_imm_size_ok - or ah,ah - je push_imm_size_ok - cmp al,ah - jne invalid_operand_size - push_imm_size_ok: - cmp al,2 - je push_imm_16bit - cmp al,4 - je push_imm_32bit - cmp al,8 - je push_imm_64bit - cmp ah,2 - je push_imm_optimized_16bit - cmp ah,4 - je push_imm_optimized_32bit - cmp ah,8 - je push_imm_optimized_64bit - or al,al - jnz invalid_operand_size - cmp [code_type],16 - je push_imm_optimized_16bit - cmp [code_type],32 - je push_imm_optimized_32bit - push_imm_optimized_64bit: - cmp [code_type],64 - jne illegal_instruction - call get_simm32 - mov edx,eax - cmp [value_type],0 - jne push_imm_32bit_store - cmp eax,-80h - jl push_imm_32bit_store - cmp eax,80h - jge push_imm_32bit_store - jmp push_imm_8bit - push_imm_optimized_32bit: - cmp [code_type],64 - je illegal_instruction - call get_dword_value - mov edx,eax - call operand_32bit - cmp [value_type],0 - jne push_imm_32bit_store - cmp eax,-80h - jl push_imm_32bit_store - cmp eax,80h - jge push_imm_32bit_store - jmp push_imm_8bit - push_imm_optimized_16bit: - call get_word_value - mov dx,ax - call operand_16bit - cmp [value_type],0 - jne push_imm_16bit_store - cmp ax,-80h - jl push_imm_16bit_store - cmp ax,80h - jge push_imm_16bit_store - push_imm_8bit: - mov ah,al - mov [base_code],6Ah - call store_instruction_code - mov al,ah - stos byte [edi] - jmp push_done - push_imm_16bit: - call get_word_value - mov dx,ax - call operand_16bit - push_imm_16bit_store: - mov [base_code],68h - call store_instruction_code - mov ax,dx - call mark_relocation - stos word [edi] - jmp push_done - push_imm_64bit: - cmp [code_type],64 - jne illegal_instruction - call get_simm32 - mov edx,eax - jmp push_imm_32bit_store - push_imm_32bit: - cmp [code_type],64 - je illegal_instruction - call get_dword_value - mov edx,eax - call operand_32bit - push_imm_32bit_store: - mov [base_code],68h - call store_instruction_code - mov eax,edx - call mark_relocation - stos dword [edi] - push_done: - lods byte [esi] - dec esi - cmp al,0Fh - je instruction_assembled - or al,al - jz instruction_assembled - mov [operand_size],0 - mov [size_override],0 - mov [operand_prefix],0 - mov [rex_prefix],0 - jmp push_next -pop_instruction: - mov [push_size],al - pop_next: - lods byte [esi] - call get_size_operator - cmp al,10h - je pop_reg - cmp al,'[' - jne invalid_operand - pop_mem: - call get_address - mov al,[operand_size] - mov ah,[push_size] - cmp al,2 - je pop_mem_16bit - cmp al,4 - je pop_mem_32bit - cmp al,8 - je pop_mem_64bit - or al,al - jnz invalid_operand_size - cmp ah,2 - je pop_mem_16bit - cmp ah,4 - je pop_mem_32bit - cmp ah,8 - je pop_mem_64bit - call recoverable_unknown_size - jmp pop_mem_store - pop_mem_16bit: - test ah,not 2 - jnz invalid_operand_size - call operand_16bit - jmp pop_mem_store - pop_mem_32bit: - test ah,not 4 - jnz invalid_operand_size - cmp [code_type],64 - je illegal_instruction - call operand_32bit - jmp pop_mem_store - pop_mem_64bit: - test ah,not 8 - jnz invalid_operand_size - cmp [code_type],64 - jne illegal_instruction - pop_mem_store: - mov [base_code],08Fh - mov [postbyte_register],0 - call store_instruction - jmp pop_done - pop_reg: - lods byte [esi] - mov ah,al - sub ah,10h - and ah,al - test ah,0F0h - jnz pop_sreg - call convert_register - test al,1000b - jz pop_reg_ok - or [rex_prefix],41h - and al,111b - pop_reg_ok: - add al,58h - mov [base_code],al - mov al,ah - mov ah,[push_size] - cmp al,2 - je pop_reg_16bit - cmp al,4 - je pop_reg_32bit - cmp al,8 - je pop_reg_64bit - jmp invalid_operand_size - pop_reg_64bit: - test ah,not 8 - jnz invalid_operand_size - cmp [code_type],64 - jne illegal_instruction - jmp pop_reg_store - pop_reg_32bit: - test ah,not 4 - jnz invalid_operand_size - cmp [code_type],64 - je illegal_instruction - call operand_32bit - jmp pop_reg_store - pop_reg_16bit: - test ah,not 2 - jnz invalid_operand_size - call operand_16bit - pop_reg_store: - call store_instruction_code - pop_done: - lods byte [esi] - dec esi - cmp al,0Fh - je instruction_assembled - or al,al - jz instruction_assembled - mov [operand_size],0 - mov [size_override],0 - mov [operand_prefix],0 - mov [rex_prefix],0 - jmp pop_next - pop_sreg: - mov dl,[operand_size] - mov dh,[push_size] - cmp al,62h - je pop_cs - mov bl,al - cmp dl,2 - je pop_sreg16 - cmp dl,4 - je pop_sreg32 - cmp dl,8 - je pop_sreg64 - or dl,dl - jnz invalid_operand_size - cmp dh,2 - je pop_sreg16 - cmp dh,4 - je pop_sreg32 - cmp dh,8 - je pop_sreg64 - jmp pop_sreg_store - pop_sreg16: - test dh,not 2 - jnz invalid_operand_size - call operand_16bit - jmp pop_sreg_store - pop_sreg32: - test dh,not 4 - jnz invalid_operand_size - cmp [code_type],64 - je illegal_instruction - call operand_32bit - jmp pop_sreg_store - pop_sreg64: - test dh,not 8 - jnz invalid_operand_size - cmp [code_type],64 - jne illegal_instruction - pop_sreg_store: - mov al,bl - cmp al,70h - jae invalid_operand - sub al,61h - jc invalid_operand - cmp al,4 - jae pop_sreg_386 - shl al,3 - add al,7 - mov [base_code],al - cmp [code_type],64 - je illegal_instruction - jmp pop_reg_store - pop_cs: - cmp [code_type],16 - jne illegal_instruction - cmp dl,2 - je pop_cs_store - or dl,dl - jnz invalid_operand_size - cmp dh,2 - je pop_cs_store - or dh,dh - jnz illegal_instruction - pop_cs_store: - test dh,not 2 - jnz invalid_operand_size - mov al,0Fh - stos byte [edi] - jmp pop_done - pop_sreg_386: - sub al,4 - shl al,3 - add al,0A1h - mov [extended_code],al - mov [base_code],0Fh - jmp pop_reg_store -inc_instruction: - mov [base_code],al - lods byte [esi] - call get_size_operator - cmp al,10h - je inc_reg - cmp al,'[' - je inc_mem - jne invalid_operand - inc_mem: - call get_address - mov al,[operand_size] - cmp al,1 - je inc_mem_8bit - jb inc_mem_nosize - call operand_autodetect - mov al,0FFh - xchg al,[base_code] - mov [postbyte_register],al - jmp instruction_ready - inc_mem_nosize: - call recoverable_unknown_size - inc_mem_8bit: - mov al,0FEh - xchg al,[base_code] - mov [postbyte_register],al - jmp instruction_ready - inc_reg: - lods byte [esi] - call convert_register - mov bl,al - mov al,0FEh - xchg al,[base_code] - mov [postbyte_register],al - mov al,ah - cmp al,1 - je inc_reg_8bit - call operand_autodetect - cmp [code_type],64 - je inc_reg_long_form - mov al,[postbyte_register] - shl al,3 - add al,bl - add al,40h - mov [base_code],al - call store_instruction_code - jmp instruction_assembled - inc_reg_long_form: - inc [base_code] - inc_reg_8bit: - jmp nomem_instruction_ready -set_instruction: - mov [base_code],0Fh - mov [extended_code],al - lods byte [esi] - call get_size_operator - cmp al,10h - je set_reg - cmp al,'[' - jne invalid_operand - set_mem: - call get_address - cmp [operand_size],1 - ja invalid_operand_size - mov [postbyte_register],0 - jmp instruction_ready - set_reg: - lods byte [esi] - call convert_register - cmp ah,1 - jne invalid_operand_size - mov bl,al - mov [postbyte_register],0 - jmp nomem_instruction_ready -arpl_instruction: - cmp [code_type],64 - je illegal_instruction - mov [base_code],63h - lods byte [esi] - call get_size_operator - cmp al,10h - je arpl_reg - cmp al,'[' - jne invalid_operand - call get_address - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - mov [postbyte_register],al - cmp ah,2 - jne invalid_operand_size - jmp instruction_ready - arpl_reg: - lods byte [esi] - call convert_register - cmp ah,2 - jne invalid_operand_size - mov bl,al - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - mov [postbyte_register],al - jmp nomem_instruction_ready -bound_instruction: - cmp [code_type],64 - je illegal_instruction - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - mov [postbyte_register],al - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,'[' - jne invalid_operand - call get_address - mov al,[operand_size] - cmp al,2 - je bound_store - cmp al,4 - jne invalid_operand_size - bound_store: - call operand_autodetect - mov [base_code],62h - jmp instruction_ready -enter_instruction: - lods byte [esi] - call get_size_operator - cmp ah,2 - je enter_imm16_size_ok - or ah,ah - jnz invalid_operand_size - enter_imm16_size_ok: - cmp al,'(' - jne invalid_operand - call get_word_value - cmp [next_pass_needed],0 - jne enter_imm16_ok - cmp [value_type],0 - jne invalid_use_of_symbol - test eax,eax - js value_out_of_range - enter_imm16_ok: - push eax - mov [operand_size],0 - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp ah,1 - je enter_imm8_size_ok - or ah,ah - jnz invalid_operand_size - enter_imm8_size_ok: - cmp al,'(' - jne invalid_operand - call get_byte_value - cmp [next_pass_needed],0 - jne enter_imm8_ok - test eax,eax - js value_out_of_range - enter_imm8_ok: - mov dl,al - pop ebx - mov al,0C8h - stos byte [edi] - mov ax,bx - stos word [edi] - mov al,dl - stos byte [edi] - jmp instruction_assembled -ret_instruction_only64: - cmp [code_type],64 - jne illegal_instruction - jmp ret_instruction -ret_instruction_32bit_except64: - cmp [code_type],64 - je illegal_instruction -ret_instruction_32bit: - call operand_32bit - jmp ret_instruction -ret_instruction_16bit: - call operand_16bit - jmp ret_instruction -retf_instruction: - cmp [code_type],64 - jne ret_instruction -ret_instruction_64bit: - call operand_64bit -ret_instruction: - mov [base_code],al - lods byte [esi] - dec esi - or al,al - jz simple_ret - cmp al,0Fh - je simple_ret - lods byte [esi] - call get_size_operator - or ah,ah - jz ret_imm - cmp ah,2 - je ret_imm - jmp invalid_operand_size - ret_imm: - cmp al,'(' - jne invalid_operand - call get_word_value - cmp [next_pass_needed],0 - jne ret_imm_ok - cmp [value_type],0 - jne invalid_use_of_symbol - test eax,eax - js value_out_of_range - ret_imm_ok: - cmp [size_declared],0 - jne ret_imm_store - or ax,ax - jz simple_ret - ret_imm_store: - mov dx,ax - call store_instruction_code - mov ax,dx - stos word [edi] - jmp instruction_assembled - simple_ret: - inc [base_code] - call store_instruction_code - jmp instruction_assembled -lea_instruction: - mov [base_code],8Dh - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - mov [postbyte_register],al - lods byte [esi] - cmp al,',' - jne invalid_operand - xor al,al - xchg al,[operand_size] - push eax - lods byte [esi] - call get_size_operator - cmp al,'[' - jne invalid_operand - mov [size_override],-1 - call get_address - pop eax - mov [operand_size],al - call operand_autodetect - jmp instruction_ready -ls_instruction: - or al,al - jz les_instruction - cmp al,3 - jz lds_instruction - add al,0B0h - mov [extended_code],al - mov [base_code],0Fh - jmp ls_code_ok - les_instruction: - mov [base_code],0C4h - jmp ls_short_code - lds_instruction: - mov [base_code],0C5h - ls_short_code: - cmp [code_type],64 - je illegal_instruction - ls_code_ok: - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - mov [postbyte_register],al - lods byte [esi] - cmp al,',' - jne invalid_operand - add [operand_size],2 - lods byte [esi] - call get_size_operator - cmp al,'[' - jne invalid_operand - call get_address - mov al,[operand_size] - cmp al,4 - je ls_16bit - cmp al,6 - je ls_32bit - cmp al,10 - je ls_64bit - jmp invalid_operand_size - ls_16bit: - call operand_16bit - jmp instruction_ready - ls_32bit: - call operand_32bit - jmp instruction_ready - ls_64bit: - call operand_64bit - jmp instruction_ready -sh_instruction: - mov [postbyte_register],al - lods byte [esi] - call get_size_operator - cmp al,10h - je sh_reg - cmp al,'[' - jne invalid_operand - sh_mem: - call get_address - push edx ebx ecx - mov al,[operand_size] - push eax - mov [operand_size],0 - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,'(' - je sh_mem_imm - cmp al,10h - jne invalid_operand - sh_mem_reg: - lods byte [esi] - cmp al,11h - jne invalid_operand - pop eax ecx ebx edx - cmp al,1 - je sh_mem_cl_8bit - jb sh_mem_cl_nosize - call operand_autodetect - mov [base_code],0D3h - jmp instruction_ready - sh_mem_cl_nosize: - call recoverable_unknown_size - sh_mem_cl_8bit: - mov [base_code],0D2h - jmp instruction_ready - sh_mem_imm: - mov al,[operand_size] - or al,al - jz sh_mem_imm_size_ok - cmp al,1 - jne invalid_operand_size - sh_mem_imm_size_ok: - call get_byte_value - mov byte [value],al - pop eax ecx ebx edx - cmp al,1 - je sh_mem_imm_8bit - jb sh_mem_imm_nosize - call operand_autodetect - cmp byte [value],1 - je sh_mem_1 - mov [base_code],0C1h - call store_instruction_with_imm8 - jmp instruction_assembled - sh_mem_1: - mov [base_code],0D1h - jmp instruction_ready - sh_mem_imm_nosize: - call recoverable_unknown_size - sh_mem_imm_8bit: - cmp byte [value],1 - je sh_mem_1_8bit - mov [base_code],0C0h - call store_instruction_with_imm8 - jmp instruction_assembled - sh_mem_1_8bit: - mov [base_code],0D0h - jmp instruction_ready - sh_reg: - lods byte [esi] - call convert_register - mov bx,ax - mov [operand_size],0 - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,'(' - je sh_reg_imm - cmp al,10h - jne invalid_operand - sh_reg_reg: - lods byte [esi] - cmp al,11h - jne invalid_operand - mov al,bh - cmp al,1 - je sh_reg_cl_8bit - call operand_autodetect - mov [base_code],0D3h - jmp nomem_instruction_ready - sh_reg_cl_8bit: - mov [base_code],0D2h - jmp nomem_instruction_ready - sh_reg_imm: - mov al,[operand_size] - or al,al - jz sh_reg_imm_size_ok - cmp al,1 - jne invalid_operand_size - sh_reg_imm_size_ok: - push ebx - call get_byte_value - mov dl,al - pop ebx - mov al,bh - cmp al,1 - je sh_reg_imm_8bit - call operand_autodetect - cmp dl,1 - je sh_reg_1 - mov [base_code],0C1h - call store_nomem_instruction - mov al,dl - stos byte [edi] - jmp instruction_assembled - sh_reg_1: - mov [base_code],0D1h - jmp nomem_instruction_ready - sh_reg_imm_8bit: - cmp dl,1 - je sh_reg_1_8bit - mov [base_code],0C0h - call store_nomem_instruction - mov al,dl - stos byte [edi] - jmp instruction_assembled - sh_reg_1_8bit: - mov [base_code],0D0h - jmp nomem_instruction_ready -shd_instruction: - mov [base_code],0Fh - mov [extended_code],al - lods byte [esi] - call get_size_operator - cmp al,10h - je shd_reg - cmp al,'[' - jne invalid_operand - shd_mem: - call get_address - push edx ebx ecx - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - mov [postbyte_register],al - lods byte [esi] - cmp al,',' - jne invalid_operand - mov al,ah - mov [operand_size],0 - push eax - lods byte [esi] - call get_size_operator - cmp al,'(' - je shd_mem_reg_imm - cmp al,10h - jne invalid_operand - lods byte [esi] - cmp al,11h - jne invalid_operand - pop eax ecx ebx edx - call operand_autodetect - inc [extended_code] - jmp instruction_ready - shd_mem_reg_imm: - mov al,[operand_size] - or al,al - jz shd_mem_reg_imm_size_ok - cmp al,1 - jne invalid_operand_size - shd_mem_reg_imm_size_ok: - call get_byte_value - mov byte [value],al - pop eax ecx ebx edx - call operand_autodetect - call store_instruction_with_imm8 - jmp instruction_assembled - shd_reg: - lods byte [esi] - call convert_register - mov [postbyte_register],al - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - mov bl,[postbyte_register] - mov [postbyte_register],al - mov al,ah - push eax ebx - lods byte [esi] - cmp al,',' - jne invalid_operand - mov [operand_size],0 - lods byte [esi] - call get_size_operator - cmp al,'(' - je shd_reg_reg_imm - cmp al,10h - jne invalid_operand - lods byte [esi] - cmp al,11h - jne invalid_operand - pop ebx eax - call operand_autodetect - inc [extended_code] - jmp nomem_instruction_ready - shd_reg_reg_imm: - mov al,[operand_size] - or al,al - jz shd_reg_reg_imm_size_ok - cmp al,1 - jne invalid_operand_size - shd_reg_reg_imm_size_ok: - call get_byte_value - mov dl,al - pop ebx eax - call operand_autodetect - call store_nomem_instruction - mov al,dl - stos byte [edi] - jmp instruction_assembled -movx_instruction: - mov [base_code],0Fh - mov [extended_code],al - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - mov [postbyte_register],al - mov al,ah - push eax - lods byte [esi] - cmp al,',' - jne invalid_operand - mov [operand_size],0 - lods byte [esi] - call get_size_operator - cmp al,10h - je movx_reg - cmp al,'[' - jne invalid_operand - call get_address - pop eax - mov ah,[operand_size] - or ah,ah - jz movx_unknown_size - cmp ah,al - jae invalid_operand_size - cmp ah,1 - je movx_mem_store - cmp ah,2 - jne invalid_operand_size - inc [extended_code] - movx_mem_store: - call operand_autodetect - jmp instruction_ready - movx_unknown_size: - call recoverable_unknown_size - jmp movx_mem_store - movx_reg: - lods byte [esi] - call convert_register - pop ebx - xchg bl,al - cmp ah,al - jae invalid_operand_size - cmp ah,1 - je movx_reg_8bit - cmp ah,2 - je movx_reg_16bit - jmp invalid_operand_size - movx_reg_8bit: - call operand_autodetect - jmp nomem_instruction_ready - movx_reg_16bit: - call operand_autodetect - inc [extended_code] - jmp nomem_instruction_ready -movsxd_instruction: - mov [base_code],al - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - mov [postbyte_register],al - cmp ah,8 - jne invalid_operand_size - lods byte [esi] - cmp al,',' - jne invalid_operand - mov [operand_size],0 - lods byte [esi] - call get_size_operator - cmp al,10h - je movsxd_reg - cmp al,'[' - jne invalid_operand - call get_address - cmp [operand_size],4 - je movsxd_mem_store - cmp [operand_size],0 - jne invalid_operand_size - movsxd_mem_store: - call operand_64bit - jmp instruction_ready - movsxd_reg: - lods byte [esi] - call convert_register - cmp ah,4 - jne invalid_operand_size - mov bl,al - call operand_64bit - jmp nomem_instruction_ready -bt_instruction: - mov [postbyte_register],al - shl al,3 - add al,83h - mov [extended_code],al - mov [base_code],0Fh - lods byte [esi] - call get_size_operator - cmp al,10h - je bt_reg - cmp al,'[' - jne invalid_operand - call get_address - push eax ebx ecx - lods byte [esi] - cmp al,',' - jne invalid_operand - cmp byte [esi],'(' - je bt_mem_imm - cmp byte [esi],11h - jne bt_mem_reg - cmp byte [esi+2],'(' - je bt_mem_imm - bt_mem_reg: - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - mov [postbyte_register],al - pop ecx ebx edx - mov al,ah - call operand_autodetect - jmp instruction_ready - bt_mem_imm: - xor al,al - xchg al,[operand_size] - push eax - lods byte [esi] - call get_size_operator - cmp al,'(' - jne invalid_operand - mov al,[operand_size] - or al,al - jz bt_mem_imm_size_ok - cmp al,1 - jne invalid_operand_size - bt_mem_imm_size_ok: - call get_byte_value - mov byte [value],al - pop eax - or al,al - jz bt_mem_imm_nosize - call operand_autodetect - bt_mem_imm_store: - pop ecx ebx edx - mov [extended_code],0BAh - call store_instruction_with_imm8 - jmp instruction_assembled - bt_mem_imm_nosize: - call recoverable_unknown_size - jmp bt_mem_imm_store - bt_reg: - lods byte [esi] - call convert_register - mov bl,al - lods byte [esi] - cmp al,',' - jne invalid_operand - cmp byte [esi],'(' - je bt_reg_imm - cmp byte [esi],11h - jne bt_reg_reg - cmp byte [esi+2],'(' - je bt_reg_imm - bt_reg_reg: - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - mov [postbyte_register],al - mov al,ah - call operand_autodetect - jmp nomem_instruction_ready - bt_reg_imm: - xor al,al - xchg al,[operand_size] - push eax ebx - lods byte [esi] - call get_size_operator - cmp al,'(' - jne invalid_operand - mov al,[operand_size] - or al,al - jz bt_reg_imm_size_ok - cmp al,1 - jne invalid_operand_size - bt_reg_imm_size_ok: - call get_byte_value - mov byte [value],al - pop ebx eax - call operand_autodetect - bt_reg_imm_store: - mov [extended_code],0BAh - call store_nomem_instruction - mov al,byte [value] - stos byte [edi] - jmp instruction_assembled -bs_instruction: - mov [extended_code],al - mov [base_code],0Fh - call get_reg_mem - jc bs_reg_reg - mov al,[operand_size] - call operand_autodetect - jmp instruction_ready - bs_reg_reg: - mov al,ah - call operand_autodetect - jmp nomem_instruction_ready - get_reg_mem: - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - mov [postbyte_register],al - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - je get_reg_reg - cmp al,'[' - jne invalid_argument - call get_address - clc - ret - get_reg_reg: - lods byte [esi] - call convert_register - mov bl,al - stc - ret - -imul_instruction: - mov [base_code],0F6h - mov [postbyte_register],5 - lods byte [esi] - call get_size_operator - cmp al,10h - je imul_reg - cmp al,'[' - jne invalid_operand - imul_mem: - call get_address - mov al,[operand_size] - cmp al,1 - je imul_mem_8bit - jb imul_mem_nosize - call operand_autodetect - inc [base_code] - jmp instruction_ready - imul_mem_nosize: - call recoverable_unknown_size - imul_mem_8bit: - jmp instruction_ready - imul_reg: - lods byte [esi] - call convert_register - cmp byte [esi],',' - je imul_reg_ - mov bl,al - mov al,ah - cmp al,1 - je imul_reg_8bit - call operand_autodetect - inc [base_code] - imul_reg_8bit: - jmp nomem_instruction_ready - imul_reg_: - mov [postbyte_register],al - inc esi - cmp byte [esi],'(' - je imul_reg_imm - cmp byte [esi],11h - jne imul_reg_noimm - cmp byte [esi+2],'(' - je imul_reg_imm - imul_reg_noimm: - lods byte [esi] - call get_size_operator - cmp al,10h - je imul_reg_reg - cmp al,'[' - jne invalid_operand - imul_reg_mem: - call get_address - push edx ebx ecx - cmp byte [esi],',' - je imul_reg_mem_imm - mov al,[operand_size] - call operand_autodetect - pop ecx ebx edx - mov [base_code],0Fh - mov [extended_code],0AFh - jmp instruction_ready - imul_reg_mem_imm: - inc esi - lods byte [esi] - call get_size_operator - cmp al,'(' - jne invalid_operand - mov al,[operand_size] - cmp al,2 - je imul_reg_mem_imm_16bit - cmp al,4 - je imul_reg_mem_imm_32bit - cmp al,8 - jne invalid_operand_size - imul_reg_mem_imm_64bit: - cmp [size_declared],0 - jne long_immediate_not_encodable - call operand_64bit - call get_simm32 - cmp [value_type],4 - jae long_immediate_not_encodable - jmp imul_reg_mem_imm_32bit_ok - imul_reg_mem_imm_16bit: - call operand_16bit - call get_word_value - mov word [value],ax - cmp [value_type],0 - jne imul_reg_mem_imm_16bit_store - cmp [size_declared],0 - jne imul_reg_mem_imm_16bit_store - cmp ax,-80h - jl imul_reg_mem_imm_16bit_store - cmp ax,80h - jl imul_reg_mem_imm_8bit_store - imul_reg_mem_imm_16bit_store: - pop ecx ebx edx - mov [base_code],69h - call store_instruction_with_imm16 - jmp instruction_assembled - imul_reg_mem_imm_32bit: - call operand_32bit - call get_dword_value - imul_reg_mem_imm_32bit_ok: - mov dword [value],eax - cmp [value_type],0 - jne imul_reg_mem_imm_32bit_store - cmp [size_declared],0 - jne imul_reg_mem_imm_32bit_store - cmp eax,-80h - jl imul_reg_mem_imm_32bit_store - cmp eax,80h - jl imul_reg_mem_imm_8bit_store - imul_reg_mem_imm_32bit_store: - pop ecx ebx edx - mov [base_code],69h - call store_instruction_with_imm32 - jmp instruction_assembled - imul_reg_mem_imm_8bit_store: - pop ecx ebx edx - mov [base_code],6Bh - call store_instruction_with_imm8 - jmp instruction_assembled - imul_reg_imm: - mov bl,[postbyte_register] - dec esi - jmp imul_reg_reg_imm - imul_reg_reg: - lods byte [esi] - call convert_register - mov bl,al - cmp byte [esi],',' - je imul_reg_reg_imm - mov al,ah - call operand_autodetect - mov [base_code],0Fh - mov [extended_code],0AFh - jmp nomem_instruction_ready - imul_reg_reg_imm: - inc esi - lods byte [esi] - call get_size_operator - cmp al,'(' - jne invalid_operand - mov al,[operand_size] - cmp al,2 - je imul_reg_reg_imm_16bit - cmp al,4 - je imul_reg_reg_imm_32bit - cmp al,8 - jne invalid_operand_size - imul_reg_reg_imm_64bit: - cmp [size_declared],0 - jne long_immediate_not_encodable - call operand_64bit - push ebx - call get_simm32 - cmp [value_type],4 - jae long_immediate_not_encodable - jmp imul_reg_reg_imm_32bit_ok - imul_reg_reg_imm_16bit: - call operand_16bit - push ebx - call get_word_value - pop ebx - mov dx,ax - cmp [value_type],0 - jne imul_reg_reg_imm_16bit_store - cmp [size_declared],0 - jne imul_reg_reg_imm_16bit_store - cmp ax,-80h - jl imul_reg_reg_imm_16bit_store - cmp ax,80h - jl imul_reg_reg_imm_8bit_store - imul_reg_reg_imm_16bit_store: - mov [base_code],69h - call store_nomem_instruction - mov ax,dx - call mark_relocation - stos word [edi] - jmp instruction_assembled - imul_reg_reg_imm_32bit: - call operand_32bit - push ebx - call get_dword_value - imul_reg_reg_imm_32bit_ok: - pop ebx - mov edx,eax - cmp [value_type],0 - jne imul_reg_reg_imm_32bit_store - cmp [size_declared],0 - jne imul_reg_reg_imm_32bit_store - cmp eax,-80h - jl imul_reg_reg_imm_32bit_store - cmp eax,80h - jl imul_reg_reg_imm_8bit_store - imul_reg_reg_imm_32bit_store: - mov [base_code],69h - call store_nomem_instruction - mov eax,edx - call mark_relocation - stos dword [edi] - jmp instruction_assembled - imul_reg_reg_imm_8bit_store: - mov [base_code],6Bh - call store_nomem_instruction - mov al,dl - stos byte [edi] - jmp instruction_assembled -in_instruction: - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - or al,al - jnz invalid_operand - lods byte [esi] - cmp al,',' - jne invalid_operand - mov al,ah - push eax - mov [operand_size],0 - lods byte [esi] - call get_size_operator - cmp al,'(' - je in_imm - cmp al,10h - je in_reg - jmp invalid_operand - in_reg: - lods byte [esi] - cmp al,22h - jne invalid_operand - pop eax - cmp al,1 - je in_al_dx - cmp al,2 - je in_ax_dx - cmp al,4 - jne invalid_operand_size - in_ax_dx: - call operand_autodetect - mov [base_code],0EDh - call store_instruction_code - jmp instruction_assembled - in_al_dx: - mov al,0ECh - stos byte [edi] - jmp instruction_assembled - in_imm: - mov al,[operand_size] - or al,al - jz in_imm_size_ok - cmp al,1 - jne invalid_operand_size - in_imm_size_ok: - call get_byte_value - mov dl,al - pop eax - cmp al,1 - je in_al_imm - cmp al,2 - je in_ax_imm - cmp al,4 - jne invalid_operand_size - in_ax_imm: - call operand_autodetect - mov [base_code],0E5h - call store_instruction_code - mov al,dl - stos byte [edi] - jmp instruction_assembled - in_al_imm: - mov al,0E4h - stos byte [edi] - mov al,dl - stos byte [edi] - jmp instruction_assembled -out_instruction: - lods byte [esi] - call get_size_operator - cmp al,'(' - je out_imm - cmp al,10h - jne invalid_operand - lods byte [esi] - cmp al,22h - jne invalid_operand - lods byte [esi] - cmp al,',' - jne invalid_operand - mov [operand_size],0 - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - or al,al - jnz invalid_operand - mov al,ah - cmp al,1 - je out_dx_al - cmp al,2 - je out_dx_ax - cmp al,4 - jne invalid_operand_size - out_dx_ax: - call operand_autodetect - mov [base_code],0EFh - call store_instruction_code - jmp instruction_assembled - out_dx_al: - mov al,0EEh - stos byte [edi] - jmp instruction_assembled - out_imm: - mov al,[operand_size] - or al,al - jz out_imm_size_ok - cmp al,1 - jne invalid_operand_size - out_imm_size_ok: - call get_byte_value - mov dl,al - lods byte [esi] - cmp al,',' - jne invalid_operand - mov [operand_size],0 - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - or al,al - jnz invalid_operand - mov al,ah - cmp al,1 - je out_imm_al - cmp al,2 - je out_imm_ax - cmp al,4 - jne invalid_operand_size - out_imm_ax: - call operand_autodetect - mov [base_code],0E7h - call store_instruction_code - mov al,dl - stos byte [edi] - jmp instruction_assembled - out_imm_al: - mov al,0E6h - stos byte [edi] - mov al,dl - stos byte [edi] - jmp instruction_assembled - -call_instruction: - mov [postbyte_register],10b - mov [base_code],0E8h - mov [extended_code],9Ah - jmp process_jmp -jmp_instruction: - mov [postbyte_register],100b - mov [base_code],0E9h - mov [extended_code],0EAh - process_jmp: - lods byte [esi] - call get_jump_operator - call get_size_operator - cmp al,'(' - je jmp_imm - mov [base_code],0FFh - cmp al,10h - je jmp_reg - cmp al,'[' - jne invalid_operand - jmp_mem: - cmp [jump_type],1 - je illegal_instruction - call get_address - mov edx,eax - mov al,[operand_size] - or al,al - jz jmp_mem_size_not_specified - cmp al,2 - je jmp_mem_16bit - cmp al,4 - je jmp_mem_32bit - cmp al,6 - je jmp_mem_48bit - cmp al,8 - je jmp_mem_64bit - cmp al,10 - je jmp_mem_80bit - jmp invalid_operand_size - jmp_mem_size_not_specified: - cmp [jump_type],3 - je jmp_mem_far - cmp [jump_type],2 - je jmp_mem_near - call recoverable_unknown_size - jmp_mem_near: - cmp [code_type],16 - je jmp_mem_16bit - cmp [code_type],32 - je jmp_mem_near_32bit - jmp_mem_64bit: - cmp [jump_type],3 - je invalid_operand_size - cmp [code_type],64 - jne illegal_instruction - jmp instruction_ready - jmp_mem_far: - cmp [code_type],16 - je jmp_mem_far_32bit - jmp_mem_48bit: - call operand_32bit - jmp_mem_far_store: - cmp [jump_type],2 - je invalid_operand_size - inc [postbyte_register] - jmp instruction_ready - jmp_mem_80bit: - call operand_64bit - jmp jmp_mem_far_store - jmp_mem_far_32bit: - call operand_16bit - jmp jmp_mem_far_store - jmp_mem_32bit: - cmp [jump_type],3 - je jmp_mem_far_32bit - cmp [jump_type],2 - je jmp_mem_near_32bit - cmp [code_type],16 - je jmp_mem_far_32bit - jmp_mem_near_32bit: - cmp [code_type],64 - je illegal_instruction - call operand_32bit - jmp instruction_ready - jmp_mem_16bit: - cmp [jump_type],3 - je invalid_operand_size - call operand_16bit - jmp instruction_ready - jmp_reg: - test [jump_type],1 - jnz invalid_operand - lods byte [esi] - call convert_register - mov bl,al - mov al,ah - cmp al,2 - je jmp_reg_16bit - cmp al,4 - je jmp_reg_32bit - cmp al,8 - jne invalid_operand_size - jmp_reg_64bit: - cmp [code_type],64 - jne illegal_instruction - jmp nomem_instruction_ready - jmp_reg_32bit: - cmp [code_type],64 - je illegal_instruction - call operand_32bit - jmp nomem_instruction_ready - jmp_reg_16bit: - call operand_16bit - jmp nomem_instruction_ready - jmp_imm: - cmp byte [esi],'.' - je invalid_value - mov ebx,esi - dec esi - call skip_symbol - xchg esi,ebx - cmp byte [ebx],':' - je jmp_far - cmp [jump_type],3 - je invalid_operand - jmp_near: - mov al,[operand_size] - cmp al,2 - je jmp_imm_16bit - cmp al,4 - je jmp_imm_32bit - cmp al,8 - je jmp_imm_64bit - or al,al - jnz invalid_operand_size - cmp [code_type],16 - je jmp_imm_16bit - cmp [code_type],64 - je jmp_imm_64bit - jmp_imm_32bit: - cmp [code_type],64 - je invalid_operand_size - call get_address_dword_value - cmp [code_type],16 - jne jmp_imm_32bit_prefix_ok - mov byte [edi],66h - inc edi - jmp_imm_32bit_prefix_ok: - call calculate_jump_offset - cdq - call check_for_short_jump - jc jmp_short - jmp_imm_32bit_store: - mov edx,eax - sub edx,3 - jno jmp_imm_32bit_ok - cmp [code_type],64 - je relative_jump_out_of_range - jmp_imm_32bit_ok: - mov al,[base_code] - stos byte [edi] - mov eax,edx - call mark_relocation - stos dword [edi] - jmp instruction_assembled - jmp_imm_64bit: - cmp [code_type],64 - jne invalid_operand_size - call get_address_qword_value - call calculate_jump_offset - mov ecx,edx - cdq - cmp edx,ecx - jne relative_jump_out_of_range - call check_for_short_jump - jnc jmp_imm_32bit_store - jmp_short: - mov ah,al - mov al,0EBh - stos word [edi] - jmp instruction_assembled - jmp_imm_16bit: - call get_address_word_value - cmp [code_type],16 - je jmp_imm_16bit_prefix_ok - mov byte [edi],66h - inc edi - jmp_imm_16bit_prefix_ok: - call calculate_jump_offset - cwde - cdq - call check_for_short_jump - jc jmp_short - cmp [value_type],0 - jne invalid_use_of_symbol - mov edx,eax - dec edx - mov al,[base_code] - stos byte [edi] - mov eax,edx - stos word [edi] - jmp instruction_assembled - calculate_jump_offset: - add edi,2 - mov ebp,[addressing_space] - call calculate_relative_offset - sub edi,2 - ret - check_for_short_jump: - cmp [jump_type],1 - je forced_short - ja no_short_jump - cmp [base_code],0E8h - je no_short_jump - cmp [value_type],0 - jne no_short_jump - cmp eax,80h - jb short_jump - cmp eax,-80h - jae short_jump - no_short_jump: - clc - ret - forced_short: - cmp [base_code],0E8h - je illegal_instruction - cmp [next_pass_needed],0 - jne jmp_short_value_type_ok - cmp [value_type],0 - jne invalid_use_of_symbol - jmp_short_value_type_ok: - cmp eax,-80h - jae short_jump - cmp eax,80h - jae jump_out_of_range - short_jump: - stc - ret - jump_out_of_range: - cmp [error_line],0 - jne instruction_assembled - mov eax,[current_line] - mov [error_line],eax - mov [error],relative_jump_out_of_range - jmp instruction_assembled - jmp_far: - cmp [jump_type],2 - je invalid_operand - cmp [code_type],64 - je illegal_instruction - mov al,[extended_code] - mov [base_code],al - call get_word_value - push eax - inc esi - lods byte [esi] - cmp al,'(' - jne invalid_operand - mov al,[value_type] - push eax [symbol_identifier] - cmp byte [esi],'.' - je invalid_value - mov al,[operand_size] - cmp al,4 - je jmp_far_16bit - cmp al,6 - je jmp_far_32bit - or al,al - jnz invalid_operand_size - cmp [code_type],16 - jne jmp_far_32bit - jmp_far_16bit: - call get_word_value - mov ebx,eax - call operand_16bit - call store_instruction_code - mov ax,bx - call mark_relocation - stos word [edi] - jmp_far_segment: - pop [symbol_identifier] eax - mov [value_type],al - pop eax - call mark_relocation - stos word [edi] - jmp instruction_assembled - jmp_far_32bit: - call get_dword_value - mov ebx,eax - call operand_32bit - call store_instruction_code - mov eax,ebx - call mark_relocation - stos dword [edi] - jmp jmp_far_segment -conditional_jump: - mov [base_code],al - lods byte [esi] - call get_jump_operator - cmp [jump_type],3 - je invalid_operand - call get_size_operator - cmp al,'(' - jne invalid_operand - cmp byte [esi],'.' - je invalid_value - mov al,[operand_size] - cmp al,2 - je conditional_jump_16bit - cmp al,4 - je conditional_jump_32bit - cmp al,8 - je conditional_jump_64bit - or al,al - jnz invalid_operand_size - cmp [code_type],16 - je conditional_jump_16bit - cmp [code_type],64 - je conditional_jump_64bit - conditional_jump_32bit: - cmp [code_type],64 - je invalid_operand_size - call get_address_dword_value - cmp [code_type],16 - jne conditional_jump_32bit_prefix_ok - mov byte [edi],66h - inc edi - conditional_jump_32bit_prefix_ok: - call calculate_jump_offset - cdq - call check_for_short_jump - jc conditional_jump_short - conditional_jump_32bit_store: - mov edx,eax - sub edx,4 - jno conditional_jump_32bit_range_ok - cmp [code_type],64 - je relative_jump_out_of_range - conditional_jump_32bit_range_ok: - mov ah,[base_code] - add ah,10h - mov al,0Fh - stos word [edi] - mov eax,edx - call mark_relocation - stos dword [edi] - jmp instruction_assembled - conditional_jump_64bit: - cmp [code_type],64 - jne invalid_operand_size - call get_address_qword_value - call calculate_jump_offset - mov ecx,edx - cdq - cmp edx,ecx - jne relative_jump_out_of_range - call check_for_short_jump - jnc conditional_jump_32bit_store - conditional_jump_short: - mov ah,al - mov al,[base_code] - stos word [edi] - jmp instruction_assembled - conditional_jump_16bit: - call get_address_word_value - cmp [code_type],16 - je conditional_jump_16bit_prefix_ok - mov byte [edi],66h - inc edi - conditional_jump_16bit_prefix_ok: - call calculate_jump_offset - cwde - cdq - call check_for_short_jump - jc conditional_jump_short - cmp [value_type],0 - jne invalid_use_of_symbol - mov edx,eax - sub dx,2 - mov ah,[base_code] - add ah,10h - mov al,0Fh - stos word [edi] - mov eax,edx - stos word [edi] - jmp instruction_assembled -loop_instruction_16bit: - cmp [code_type],64 - je illegal_instruction - cmp [code_type],16 - je loop_instruction - mov [operand_prefix],67h - jmp loop_instruction -loop_instruction_32bit: - cmp [code_type],32 - je loop_instruction - mov [operand_prefix],67h - jmp loop_instruction -loop_instruction_64bit: - cmp [code_type],64 - jne illegal_instruction -loop_instruction: - mov [base_code],al - lods byte [esi] - call get_jump_operator - cmp [jump_type],1 - ja invalid_operand - call get_size_operator - cmp al,'(' - jne invalid_operand - cmp byte [esi],'.' - je invalid_value - mov al,[operand_size] - cmp al,2 - je loop_jump_16bit - cmp al,4 - je loop_jump_32bit - cmp al,8 - je loop_jump_64bit - or al,al - jnz invalid_operand_size - cmp [code_type],16 - je loop_jump_16bit - cmp [code_type],64 - je loop_jump_64bit - loop_jump_32bit: - cmp [code_type],64 - je invalid_operand_size - call get_address_dword_value - cmp [code_type],16 - jne loop_jump_32bit_prefix_ok - mov byte [edi],66h - inc edi - loop_jump_32bit_prefix_ok: - call loop_counter_size - call calculate_jump_offset - cdq - make_loop_jump: - call check_for_short_jump - jc conditional_jump_short - scas word [edi] - jmp jump_out_of_range - loop_counter_size: - cmp [operand_prefix],0 - je loop_counter_size_ok - push eax - mov al,[operand_prefix] - stos byte [edi] - pop eax - loop_counter_size_ok: - ret - loop_jump_64bit: - cmp [code_type],64 - jne invalid_operand_size - call get_address_qword_value - call loop_counter_size - call calculate_jump_offset - mov ecx,edx - cdq - cmp edx,ecx - jne relative_jump_out_of_range - jmp make_loop_jump - loop_jump_16bit: - call get_address_word_value - cmp [code_type],16 - je loop_jump_16bit_prefix_ok - mov byte [edi],66h - inc edi - loop_jump_16bit_prefix_ok: - call loop_counter_size - call calculate_jump_offset - cwde - cdq - jmp make_loop_jump - -movs_instruction: - lods byte [esi] - call get_size_operator - cmp al,'[' - jne invalid_operand - call get_address - or eax,eax - jnz invalid_address - or bl,ch - jnz invalid_address - cmp [segment_register],1 - ja invalid_address - push ebx - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,'[' - jne invalid_operand - call get_address - pop edx - or eax,eax - jnz invalid_address - or bl,ch - jnz invalid_address - mov al,dh - mov ah,bh - shr al,4 - shr ah,4 - cmp al,ah - jne address_sizes_do_not_agree - and bh,111b - and dh,111b - cmp bh,6 - jne invalid_address - cmp dh,7 - jne invalid_address - cmp al,2 - je movs_address_16bit - cmp al,4 - je movs_address_32bit - cmp [code_type],64 - jne invalid_address_size - jmp movs_store - movs_address_32bit: - call address_32bit_prefix - jmp movs_store - movs_address_16bit: - cmp [code_type],64 - je invalid_address_size - call address_16bit_prefix - movs_store: - xor ebx,ebx - call store_segment_prefix_if_necessary - mov al,0A4h - movs_check_size: - mov bl,[operand_size] - cmp bl,1 - je simple_instruction - inc al - cmp bl,2 - je simple_instruction_16bit - cmp bl,4 - je simple_instruction_32bit - cmp bl,8 - je simple_instruction_64bit - or bl,bl - jnz invalid_operand_size - call recoverable_unknown_size - jmp simple_instruction -lods_instruction: - lods byte [esi] - call get_size_operator - cmp al,'[' - jne invalid_operand - call get_address - or eax,eax - jnz invalid_address - or bl,ch - jnz invalid_address - cmp bh,26h - je lods_address_16bit - cmp bh,46h - je lods_address_32bit - cmp bh,86h - jne invalid_address - cmp [code_type],64 - jne invalid_address_size - jmp lods_store - lods_address_32bit: - call address_32bit_prefix - jmp lods_store - lods_address_16bit: - cmp [code_type],64 - je invalid_address_size - call address_16bit_prefix - lods_store: - xor ebx,ebx - call store_segment_prefix_if_necessary - mov al,0ACh - jmp movs_check_size -stos_instruction: - mov [base_code],al - lods byte [esi] - call get_size_operator - cmp al,'[' - jne invalid_operand - call get_address - or eax,eax - jnz invalid_address - or bl,ch - jnz invalid_address - cmp bh,27h - je stos_address_16bit - cmp bh,47h - je stos_address_32bit - cmp bh,87h - jne invalid_address - cmp [code_type],64 - jne invalid_address_size - jmp stos_store - stos_address_32bit: - call address_32bit_prefix - jmp stos_store - stos_address_16bit: - cmp [code_type],64 - je invalid_address_size - call address_16bit_prefix - stos_store: - cmp [segment_register],1 - ja invalid_address - mov al,[base_code] - jmp movs_check_size -cmps_instruction: - lods byte [esi] - call get_size_operator - cmp al,'[' - jne invalid_operand - call get_address - or eax,eax - jnz invalid_address - or bl,ch - jnz invalid_address - mov al,[segment_register] - push eax ebx - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,'[' - jne invalid_operand - call get_address - or eax,eax - jnz invalid_address - or bl,ch - jnz invalid_address - pop edx eax - cmp [segment_register],1 - ja invalid_address - mov [segment_register],al - mov al,dh - mov ah,bh - shr al,4 - shr ah,4 - cmp al,ah - jne address_sizes_do_not_agree - and bh,111b - and dh,111b - cmp bh,7 - jne invalid_address - cmp dh,6 - jne invalid_address - cmp al,2 - je cmps_address_16bit - cmp al,4 - je cmps_address_32bit - cmp [code_type],64 - jne invalid_address_size - jmp cmps_store - cmps_address_32bit: - call address_32bit_prefix - jmp cmps_store - cmps_address_16bit: - cmp [code_type],64 - je invalid_address_size - call address_16bit_prefix - cmps_store: - xor ebx,ebx - call store_segment_prefix_if_necessary - mov al,0A6h - jmp movs_check_size -ins_instruction: - lods byte [esi] - call get_size_operator - cmp al,'[' - jne invalid_operand - call get_address - or eax,eax - jnz invalid_address - or bl,ch - jnz invalid_address - cmp bh,27h - je ins_address_16bit - cmp bh,47h - je ins_address_32bit - cmp bh,87h - jne invalid_address - cmp [code_type],64 - jne invalid_address_size - jmp ins_store - ins_address_32bit: - call address_32bit_prefix - jmp ins_store - ins_address_16bit: - cmp [code_type],64 - je invalid_address_size - call address_16bit_prefix - ins_store: - cmp [segment_register],1 - ja invalid_address - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - cmp al,10h - jne invalid_operand - lods byte [esi] - cmp al,22h - jne invalid_operand - mov al,6Ch - ins_check_size: - cmp [operand_size],8 - jne movs_check_size - jmp invalid_operand_size -outs_instruction: - lods byte [esi] - cmp al,10h - jne invalid_operand - lods byte [esi] - cmp al,22h - jne invalid_operand - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,'[' - jne invalid_operand - call get_address - or eax,eax - jnz invalid_address - or bl,ch - jnz invalid_address - cmp bh,26h - je outs_address_16bit - cmp bh,46h - je outs_address_32bit - cmp bh,86h - jne invalid_address - cmp [code_type],64 - jne invalid_address_size - jmp outs_store - outs_address_32bit: - call address_32bit_prefix - jmp outs_store - outs_address_16bit: - cmp [code_type],64 - je invalid_address_size - call address_16bit_prefix - outs_store: - xor ebx,ebx - call store_segment_prefix_if_necessary - mov al,6Eh - jmp ins_check_size -xlat_instruction: - lods byte [esi] - call get_size_operator - cmp al,'[' - jne invalid_operand - call get_address - or eax,eax - jnz invalid_address - or bl,ch - jnz invalid_address - cmp bh,23h - je xlat_address_16bit - cmp bh,43h - je xlat_address_32bit - cmp bh,83h - jne invalid_address - cmp [code_type],64 - jne invalid_address_size - jmp xlat_store - xlat_address_32bit: - call address_32bit_prefix - jmp xlat_store - xlat_address_16bit: - cmp [code_type],64 - je invalid_address_size - call address_16bit_prefix - xlat_store: - call store_segment_prefix_if_necessary - mov al,0D7h - cmp [operand_size],1 - jbe simple_instruction - jmp invalid_operand_size - -pm_word_instruction: - mov ah,al - shr ah,4 - and al,111b - mov [base_code],0Fh - mov [extended_code],ah - mov [postbyte_register],al - lods byte [esi] - call get_size_operator - cmp al,10h - je pm_reg - pm_mem: - cmp al,'[' - jne invalid_operand - call get_address - mov al,[operand_size] - cmp al,2 - je pm_mem_store - or al,al - jnz invalid_operand_size - pm_mem_store: - jmp instruction_ready - pm_reg: - lods byte [esi] - call convert_register - mov bl,al - cmp ah,2 - jne invalid_operand_size - jmp nomem_instruction_ready -pm_store_word_instruction: - mov ah,al - shr ah,4 - and al,111b - mov [base_code],0Fh - mov [extended_code],ah - mov [postbyte_register],al - lods byte [esi] - call get_size_operator - cmp al,10h - jne pm_mem - lods byte [esi] - call convert_register - mov bl,al - mov al,ah - call operand_autodetect - jmp nomem_instruction_ready -lgdt_instruction: - mov [base_code],0Fh - mov [extended_code],1 - mov [postbyte_register],al - lods byte [esi] - call get_size_operator - cmp al,'[' - jne invalid_operand - call get_address - mov al,[operand_size] - cmp al,6 - je lgdt_mem_48bit - cmp al,10 - je lgdt_mem_80bit - or al,al - jnz invalid_operand_size - jmp lgdt_mem_store - lgdt_mem_80bit: - cmp [code_type],64 - jne illegal_instruction - jmp lgdt_mem_store - lgdt_mem_48bit: - cmp [code_type],64 - je illegal_instruction - cmp [postbyte_register],2 - jb lgdt_mem_store - call operand_32bit - lgdt_mem_store: - jmp instruction_ready -lar_instruction: - mov [extended_code],al - mov [base_code],0Fh - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - mov [postbyte_register],al - lods byte [esi] - cmp al,',' - jne invalid_operand - xor al,al - xchg al,[operand_size] - call operand_autodetect - lods byte [esi] - call get_size_operator - cmp al,10h - je lar_reg_reg - cmp al,'[' - jne invalid_operand - call get_address - mov al,[operand_size] - or al,al - jz lar_reg_mem - cmp al,2 - jne invalid_operand_size - lar_reg_mem: - jmp instruction_ready - lar_reg_reg: - lods byte [esi] - call convert_register - cmp ah,2 - jne invalid_operand_size - mov bl,al - jmp nomem_instruction_ready -invlpg_instruction: - mov [base_code],0Fh - mov [extended_code],1 - mov [postbyte_register],7 - lods byte [esi] - call get_size_operator - cmp al,'[' - jne invalid_operand - call get_address - jmp instruction_ready -swapgs_instruction: - cmp [code_type],64 - jne illegal_instruction -rdtscp_instruction: - mov [base_code],0Fh - mov [extended_code],1 - mov [postbyte_register],7 - mov bl,al - jmp nomem_instruction_ready - -basic_486_instruction: - mov [base_code],0Fh - mov [extended_code],al - lods byte [esi] - call get_size_operator - cmp al,10h - je basic_486_reg - cmp al,'[' - jne invalid_operand - call get_address - push edx ebx ecx - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - mov [postbyte_register],al - pop ecx ebx edx - mov al,ah - cmp al,1 - je basic_486_mem_reg_8bit - call operand_autodetect - inc [extended_code] - basic_486_mem_reg_8bit: - jmp instruction_ready - basic_486_reg: - lods byte [esi] - call convert_register - mov [postbyte_register],al - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - mov bl,[postbyte_register] - mov [postbyte_register],al - mov al,ah - cmp al,1 - je basic_486_reg_reg_8bit - call operand_autodetect - inc [extended_code] - basic_486_reg_reg_8bit: - jmp nomem_instruction_ready -bswap_instruction: - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - test al,1000b - jz bswap_reg_code_ok - or [rex_prefix],41h - and al,111b - bswap_reg_code_ok: - add al,0C8h - mov [extended_code],al - mov [base_code],0Fh - cmp ah,8 - je bswap_reg64 - cmp ah,4 - jne invalid_operand_size - call operand_32bit - call store_instruction_code - jmp instruction_assembled - bswap_reg64: - call operand_64bit - call store_instruction_code - jmp instruction_assembled -cmpxchgx_instruction: - mov [base_code],0Fh - mov [extended_code],0C7h - mov [postbyte_register],al - lods byte [esi] - call get_size_operator - cmp al,'[' - jne invalid_operand - call get_address - mov ah,1 - xchg [postbyte_register],ah - mov al,[operand_size] - or al,al - jz cmpxchgx_size_ok - cmp al,ah - jne invalid_operand_size - cmpxchgx_size_ok: - cmp ah,16 - jne cmpxchgx_store - call operand_64bit - cmpxchgx_store: - jmp instruction_ready -nop_instruction: - mov ah,[esi] - cmp ah,10h - je extended_nop - cmp ah,11h - je extended_nop - cmp ah,'[' - je extended_nop - stos byte [edi] - jmp instruction_assembled - extended_nop: - mov [base_code],0Fh - mov [extended_code],1Fh - mov [postbyte_register],0 - lods byte [esi] - call get_size_operator - cmp al,10h - je extended_nop_reg - cmp al,'[' - jne invalid_operand - call get_address - mov al,[operand_size] - or al,al - jz extended_nop_store - call operand_autodetect - extended_nop_store: - jmp instruction_ready - extended_nop_reg: - lods byte [esi] - call convert_register - mov bl,al - mov al,ah - call operand_autodetect - jmp nomem_instruction_ready - -basic_fpu_instruction: - mov [postbyte_register],al - mov [base_code],0D8h - lods byte [esi] - call get_size_operator - cmp al,10h - je basic_fpu_streg - cmp al,'[' - je basic_fpu_mem - dec esi - mov ah,[postbyte_register] - cmp ah,2 - jb invalid_operand - cmp ah,3 - ja invalid_operand - mov bl,1 - jmp nomem_instruction_ready - basic_fpu_mem: - call get_address - mov al,[operand_size] - cmp al,4 - je basic_fpu_mem_32bit - cmp al,8 - je basic_fpu_mem_64bit - or al,al - jnz invalid_operand_size - call recoverable_unknown_size - basic_fpu_mem_32bit: - jmp instruction_ready - basic_fpu_mem_64bit: - mov [base_code],0DCh - jmp instruction_ready - basic_fpu_streg: - lods byte [esi] - call convert_fpu_register - mov bl,al - mov ah,[postbyte_register] - cmp ah,2 - je basic_fpu_single_streg - cmp ah,3 - je basic_fpu_single_streg - or al,al - jz basic_fpu_st0 - test ah,110b - jz basic_fpu_streg_st0 - xor [postbyte_register],1 - basic_fpu_streg_st0: - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_fpu_register - or al,al - jnz invalid_operand - mov [base_code],0DCh - jmp nomem_instruction_ready - basic_fpu_st0: - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_fpu_register - mov bl,al - basic_fpu_single_streg: - mov [base_code],0D8h - jmp nomem_instruction_ready -simple_fpu_instruction: - mov ah,al - or ah,11000000b - mov al,0D9h - stos word [edi] - jmp instruction_assembled -fi_instruction: - mov [postbyte_register],al - lods byte [esi] - call get_size_operator - cmp al,'[' - jne invalid_operand - call get_address - mov al,[operand_size] - cmp al,2 - je fi_mem_16bit - cmp al,4 - je fi_mem_32bit - or al,al - jnz invalid_operand_size - call recoverable_unknown_size - fi_mem_32bit: - mov [base_code],0DAh - jmp instruction_ready - fi_mem_16bit: - mov [base_code],0DEh - jmp instruction_ready -fld_instruction: - mov [postbyte_register],al - lods byte [esi] - call get_size_operator - cmp al,10h - je fld_streg - cmp al,'[' - jne invalid_operand - call get_address - mov al,[operand_size] - cmp al,4 - je fld_mem_32bit - cmp al,8 - je fld_mem_64bit - cmp al,10 - je fld_mem_80bit - or al,al - jnz invalid_operand_size - call recoverable_unknown_size - fld_mem_32bit: - mov [base_code],0D9h - jmp instruction_ready - fld_mem_64bit: - mov [base_code],0DDh - jmp instruction_ready - fld_mem_80bit: - mov al,[postbyte_register] - cmp al,0 - je fld_mem_80bit_store - dec [postbyte_register] - cmp al,3 - je fld_mem_80bit_store - jmp invalid_operand_size - fld_mem_80bit_store: - add [postbyte_register],5 - mov [base_code],0DBh - jmp instruction_ready - fld_streg: - lods byte [esi] - call convert_fpu_register - mov bl,al - cmp [postbyte_register],2 - jae fst_streg - mov [base_code],0D9h - jmp nomem_instruction_ready - fst_streg: - mov [base_code],0DDh - jmp nomem_instruction_ready -fild_instruction: - mov [postbyte_register],al - lods byte [esi] - call get_size_operator - cmp al,'[' - jne invalid_operand - call get_address - mov al,[operand_size] - cmp al,2 - je fild_mem_16bit - cmp al,4 - je fild_mem_32bit - cmp al,8 - je fild_mem_64bit - or al,al - jnz invalid_operand_size - call recoverable_unknown_size - fild_mem_32bit: - mov [base_code],0DBh - jmp instruction_ready - fild_mem_16bit: - mov [base_code],0DFh - jmp instruction_ready - fild_mem_64bit: - mov al,[postbyte_register] - cmp al,1 - je fisttp_64bit_store - jb fild_mem_64bit_store - dec [postbyte_register] - cmp al,3 - je fild_mem_64bit_store - jmp invalid_operand_size - fild_mem_64bit_store: - add [postbyte_register],5 - mov [base_code],0DFh - jmp instruction_ready - fisttp_64bit_store: - mov [base_code],0DDh - jmp instruction_ready -fbld_instruction: - mov [postbyte_register],al - lods byte [esi] - call get_size_operator - cmp al,'[' - jne invalid_operand - call get_address - mov al,[operand_size] - or al,al - jz fbld_mem_80bit - cmp al,10 - je fbld_mem_80bit - jmp invalid_operand_size - fbld_mem_80bit: - mov [base_code],0DFh - jmp instruction_ready -faddp_instruction: - mov [postbyte_register],al - mov [base_code],0DEh - mov edx,esi - lods byte [esi] - call get_size_operator - cmp al,10h - je faddp_streg - mov esi,edx - mov bl,1 - jmp nomem_instruction_ready - faddp_streg: - lods byte [esi] - call convert_fpu_register - mov bl,al - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_fpu_register - or al,al - jnz invalid_operand - jmp nomem_instruction_ready -fcompp_instruction: - mov ax,0D9DEh - stos word [edi] - jmp instruction_assembled -fucompp_instruction: - mov ax,0E9DAh - stos word [edi] - jmp instruction_assembled -fxch_instruction: - mov dx,01D9h - jmp fpu_single_operand -ffreep_instruction: - mov dx,00DFh - jmp fpu_single_operand -ffree_instruction: - mov dl,0DDh - mov dh,al - fpu_single_operand: - mov ebx,esi - lods byte [esi] - call get_size_operator - cmp al,10h - je fpu_streg - or dh,dh - jz invalid_operand - mov esi,ebx - shl dh,3 - or dh,11000001b - mov ax,dx - stos word [edi] - jmp instruction_assembled - fpu_streg: - lods byte [esi] - call convert_fpu_register - shl dh,3 - or dh,al - or dh,11000000b - mov ax,dx - stos word [edi] - jmp instruction_assembled - -fstenv_instruction: - mov byte [edi],9Bh - inc edi -fldenv_instruction: - mov [base_code],0D9h - jmp fpu_mem -fstenv_instruction_16bit: - mov byte [edi],9Bh - inc edi -fldenv_instruction_16bit: - call operand_16bit - jmp fldenv_instruction -fstenv_instruction_32bit: - mov byte [edi],9Bh - inc edi -fldenv_instruction_32bit: - call operand_32bit - jmp fldenv_instruction -fsave_instruction_32bit: - mov byte [edi],9Bh - inc edi -fnsave_instruction_32bit: - call operand_32bit - jmp fnsave_instruction -fsave_instruction_16bit: - mov byte [edi],9Bh - inc edi -fnsave_instruction_16bit: - call operand_16bit - jmp fnsave_instruction -fsave_instruction: - mov byte [edi],9Bh - inc edi -fnsave_instruction: - mov [base_code],0DDh - fpu_mem: - mov [postbyte_register],al - lods byte [esi] - call get_size_operator - cmp al,'[' - jne invalid_operand - call get_address - cmp [operand_size],0 - jne invalid_operand_size - jmp instruction_ready -fstcw_instruction: - mov byte [edi],9Bh - inc edi -fldcw_instruction: - mov [postbyte_register],al - mov [base_code],0D9h - lods byte [esi] - call get_size_operator - cmp al,'[' - jne invalid_operand - call get_address - mov al,[operand_size] - or al,al - jz fldcw_mem_16bit - cmp al,2 - je fldcw_mem_16bit - jmp invalid_operand_size - fldcw_mem_16bit: - jmp instruction_ready -fstsw_instruction: - mov al,9Bh - stos byte [edi] -fnstsw_instruction: - mov [base_code],0DDh - mov [postbyte_register],7 - lods byte [esi] - call get_size_operator - cmp al,10h - je fstsw_reg - cmp al,'[' - jne invalid_operand - call get_address - mov al,[operand_size] - or al,al - jz fstsw_mem_16bit - cmp al,2 - je fstsw_mem_16bit - jmp invalid_operand_size - fstsw_mem_16bit: - jmp instruction_ready - fstsw_reg: - lods byte [esi] - call convert_register - cmp ax,0200h - jne invalid_operand - mov ax,0E0DFh - stos word [edi] - jmp instruction_assembled -finit_instruction: - mov byte [edi],9Bh - inc edi -fninit_instruction: - mov ah,al - mov al,0DBh - stos word [edi] - jmp instruction_assembled -fcmov_instruction: - mov dh,0DAh - jmp fcomi_streg -fcomi_instruction: - mov dh,0DBh - jmp fcomi_streg -fcomip_instruction: - mov dh,0DFh - fcomi_streg: - mov dl,al - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_fpu_register - mov ah,al - cmp byte [esi],',' - je fcomi_st0_streg - add ah,dl - mov al,dh - stos word [edi] - jmp instruction_assembled - fcomi_st0_streg: - or ah,ah - jnz invalid_operand - inc esi - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_fpu_register - mov ah,al - add ah,dl - mov al,dh - stos word [edi] - jmp instruction_assembled - -basic_mmx_instruction: - mov [base_code],0Fh - mov [extended_code],al - mmx_instruction: - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_mmx_register - call make_mmx_prefix - mov [postbyte_register],al - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - je mmx_mmreg_mmreg - cmp al,'[' - jne invalid_operand - mmx_mmreg_mem: - call get_address - jmp instruction_ready - mmx_mmreg_mmreg: - lods byte [esi] - call convert_mmx_register - mov bl,al - jmp nomem_instruction_ready -mmx_bit_shift_instruction: - mov [base_code],0Fh - mov [extended_code],al - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_mmx_register - call make_mmx_prefix - mov [postbyte_register],al - lods byte [esi] - cmp al,',' - jne invalid_operand - mov [operand_size],0 - lods byte [esi] - call get_size_operator - cmp al,10h - je mmx_mmreg_mmreg - cmp al,'(' - je mmx_ps_mmreg_imm8 - cmp al,'[' - je mmx_mmreg_mem - jmp invalid_operand - mmx_ps_mmreg_imm8: - call get_byte_value - mov byte [value],al - test [operand_size],not 1 - jnz invalid_value - mov bl,[extended_code] - mov al,bl - shr bl,4 - and al,1111b - add al,70h - mov [extended_code],al - sub bl,0Ch - shl bl,1 - xchg bl,[postbyte_register] - call store_nomem_instruction - mov al,byte [value] - stos byte [edi] - jmp instruction_assembled -pmovmskb_instruction: - mov [base_code],0Fh - mov [extended_code],al - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - cmp ah,4 - je pmovmskb_reg_size_ok - cmp [code_type],64 - jne invalid_operand_size - cmp ah,8 - jnz invalid_operand_size - pmovmskb_reg_size_ok: - mov [postbyte_register],al - mov [operand_size],0 - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_mmx_register - mov bl,al - call make_mmx_prefix - cmp [extended_code],0C5h - je mmx_nomem_imm8 - jmp nomem_instruction_ready - mmx_imm8: - push ebx ecx edx - xor cl,cl - xchg cl,[operand_size] - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - test ah,not 1 - jnz invalid_operand_size - mov [operand_size],cl - cmp al,'(' - jne invalid_operand - call get_byte_value - mov byte [value],al - pop edx ecx ebx - call store_instruction_with_imm8 - jmp instruction_assembled - mmx_nomem_imm8: - call store_nomem_instruction - call append_imm8 - jmp instruction_assembled - append_imm8: - mov [operand_size],0 - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - test ah,not 1 - jnz invalid_operand_size - cmp al,'(' - jne invalid_operand - call get_byte_value - stosb - ret -pinsrw_instruction: - mov [extended_code],al - mov [base_code],0Fh - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_mmx_register - call make_mmx_prefix - mov [postbyte_register],al - mov [operand_size],0 - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - je pinsrw_mmreg_reg - cmp al,'[' - jne invalid_operand - call get_address - cmp [operand_size],0 - je mmx_imm8 - cmp [operand_size],2 - jne invalid_operand_size - jmp mmx_imm8 - pinsrw_mmreg_reg: - lods byte [esi] - call convert_register - cmp ah,4 - jne invalid_operand_size - mov bl,al - jmp mmx_nomem_imm8 -pshufw_instruction: - mov [mmx_size],8 - mov [opcode_prefix],al - jmp pshuf_instruction -pshufd_instruction: - mov [mmx_size],16 - mov [opcode_prefix],al - pshuf_instruction: - mov [base_code],0Fh - mov [extended_code],70h - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_mmx_register - cmp ah,[mmx_size] - jne invalid_operand_size - mov [postbyte_register],al - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - je pshuf_mmreg_mmreg - cmp al,'[' - jne invalid_operand - call get_address - jmp mmx_imm8 - pshuf_mmreg_mmreg: - lods byte [esi] - call convert_mmx_register - mov bl,al - jmp mmx_nomem_imm8 -movd_instruction: - mov [base_code],0Fh - mov [extended_code],7Eh - lods byte [esi] - call get_size_operator - cmp al,10h - je movd_reg - cmp al,'[' - jne invalid_operand - call get_address - test [operand_size],not 4 - jnz invalid_operand_size - mov [operand_size],0 - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_mmx_register - call make_mmx_prefix - mov [postbyte_register],al - jmp instruction_ready - movd_reg: - lods byte [esi] - cmp al,0B0h - jae movd_mmreg - call convert_register - cmp ah,4 - jne invalid_operand_size - mov [operand_size],0 - mov bl,al - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_mmx_register - mov [postbyte_register],al - call make_mmx_prefix - jmp nomem_instruction_ready - movd_mmreg: - mov [extended_code],6Eh - call convert_mmx_register - call make_mmx_prefix - mov [postbyte_register],al - mov [operand_size],0 - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - je movd_mmreg_reg - cmp al,'[' - jne invalid_operand - call get_address - test [operand_size],not 4 - jnz invalid_operand_size - jmp instruction_ready - movd_mmreg_reg: - lods byte [esi] - call convert_register - cmp ah,4 - jne invalid_operand_size - mov bl,al - jmp nomem_instruction_ready - make_mmx_prefix: - cmp [vex_required],0 - jne mmx_prefix_for_vex - cmp [operand_size],16 - jne no_mmx_prefix - mov [operand_prefix],66h - no_mmx_prefix: - ret - mmx_prefix_for_vex: - cmp [operand_size],16 - jne invalid_operand - mov [opcode_prefix],66h - ret -movq_instruction: - mov [base_code],0Fh - lods byte [esi] - call get_size_operator - cmp al,10h - je movq_reg - cmp al,'[' - jne invalid_operand - call get_address - test [operand_size],not 8 - jnz invalid_operand_size - mov [operand_size],0 - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_mmx_register - mov [postbyte_register],al - cmp ah,16 - je movq_mem_xmmreg - mov [extended_code],7Fh - jmp instruction_ready - movq_mem_xmmreg: - mov [extended_code],0D6h - mov [opcode_prefix],66h - jmp instruction_ready - movq_reg: - lods byte [esi] - cmp al,0B0h - jae movq_mmreg - call convert_register - cmp ah,8 - jne invalid_operand_size - mov bl,al - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - mov [operand_size],0 - lods byte [esi] - call convert_mmx_register - mov [postbyte_register],al - call make_mmx_prefix - mov [extended_code],7Eh - call operand_64bit - jmp nomem_instruction_ready - movq_mmreg: - call convert_mmx_register - mov [postbyte_register],al - mov [extended_code],6Fh - mov [mmx_size],ah - cmp ah,16 - jne movq_mmreg_ - mov [extended_code],7Eh - mov [opcode_prefix],0F3h - movq_mmreg_: - lods byte [esi] - cmp al,',' - jne invalid_operand - mov [operand_size],0 - lods byte [esi] - call get_size_operator - cmp al,10h - je movq_mmreg_reg - call get_address - test [operand_size],not 8 - jnz invalid_operand_size - jmp instruction_ready - movq_mmreg_reg: - lods byte [esi] - cmp al,0B0h - jae movq_mmreg_mmreg - mov [operand_size],0 - call convert_register - cmp ah,8 - jne invalid_operand_size - mov [extended_code],6Eh - mov [opcode_prefix],0 - mov bl,al - cmp [mmx_size],16 - jne movq_mmreg_reg_store - mov [opcode_prefix],66h - movq_mmreg_reg_store: - call operand_64bit - jmp nomem_instruction_ready - movq_mmreg_mmreg: - call convert_mmx_register - cmp ah,[mmx_size] - jne invalid_operand_size - mov bl,al - jmp nomem_instruction_ready -movdq_instruction: - mov [opcode_prefix],al - mov [base_code],0Fh - mov [extended_code],6Fh - lods byte [esi] - call get_size_operator - cmp al,10h - je movdq_mmreg - cmp al,'[' - jne invalid_operand - call get_address - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_xmm_register - mov [postbyte_register],al - mov [extended_code],7Fh - jmp instruction_ready - movdq_mmreg: - lods byte [esi] - call convert_xmm_register - mov [postbyte_register],al - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - je movdq_mmreg_mmreg - cmp al,'[' - jne invalid_operand - call get_address - jmp instruction_ready - movdq_mmreg_mmreg: - lods byte [esi] - call convert_xmm_register - mov bl,al - jmp nomem_instruction_ready -lddqu_instruction: - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_xmm_register - push eax - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,'[' - jne invalid_operand - call get_address - pop eax - mov [postbyte_register],al - mov [opcode_prefix],0F2h - mov [base_code],0Fh - mov [extended_code],0F0h - jmp instruction_ready - -movdq2q_instruction: - mov [opcode_prefix],0F2h - mov [mmx_size],8 - jmp movq2dq_ -movq2dq_instruction: - mov [opcode_prefix],0F3h - mov [mmx_size],16 - movq2dq_: - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_mmx_register - cmp ah,[mmx_size] - jne invalid_operand_size - mov [postbyte_register],al - mov [operand_size],0 - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_mmx_register - xor [mmx_size],8+16 - cmp ah,[mmx_size] - jne invalid_operand_size - mov bl,al - mov [base_code],0Fh - mov [extended_code],0D6h - jmp nomem_instruction_ready - -sse_ps_instruction_imm8: - mov [immediate_size],1 -sse_ps_instruction: - mov [mmx_size],16 - jmp sse_instruction -sse_pd_instruction_imm8: - mov [immediate_size],1 -sse_pd_instruction: - mov [mmx_size],16 - mov [opcode_prefix],66h - jmp sse_instruction -sse_ss_instruction: - mov [mmx_size],4 - mov [opcode_prefix],0F3h - jmp sse_instruction -sse_sd_instruction: - mov [mmx_size],8 - mov [opcode_prefix],0F2h - jmp sse_instruction -cmp_pd_instruction: - mov [opcode_prefix],66h -cmp_ps_instruction: - mov [mmx_size],16 - mov byte [value],al - mov al,0C2h - jmp sse_instruction -cmp_ss_instruction: - mov [mmx_size],4 - mov [opcode_prefix],0F3h - jmp cmp_sx_instruction -cmpsd_instruction: - mov al,0A7h - mov ah,[esi] - or ah,ah - jz simple_instruction_32bit - cmp ah,0Fh - je simple_instruction_32bit - mov al,-1 -cmp_sd_instruction: - mov [mmx_size],8 - mov [opcode_prefix],0F2h - cmp_sx_instruction: - mov byte [value],al - mov al,0C2h - jmp sse_instruction -comiss_instruction: - mov [mmx_size],4 - jmp sse_instruction -comisd_instruction: - mov [mmx_size],8 - mov [opcode_prefix],66h - jmp sse_instruction -cvtdq2pd_instruction: - mov [opcode_prefix],0F3h -cvtps2pd_instruction: - mov [mmx_size],8 - jmp sse_instruction -cvtpd2dq_instruction: - mov [mmx_size],16 - mov [opcode_prefix],0F2h - jmp sse_instruction -movshdup_instruction: - mov [mmx_size],16 - mov [opcode_prefix],0F3h -sse_instruction: - mov [base_code],0Fh - mov [extended_code],al - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - sse_xmmreg: - lods byte [esi] - call convert_xmm_register - sse_reg: - mov [postbyte_register],al - mov [operand_size],0 - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - je sse_xmmreg_xmmreg - sse_reg_mem: - cmp al,'[' - jne invalid_operand - call get_address - cmp [operand_size],0 - je sse_mem_size_ok - mov al,[mmx_size] - cmp [operand_size],al - jne invalid_operand_size - sse_mem_size_ok: - mov al,[extended_code] - mov ah,[supplemental_code] - cmp al,0C2h - je sse_cmp_mem_ok - cmp ax,443Ah - je sse_cmp_mem_ok - cmp [immediate_size],1 - je mmx_imm8 - cmp [immediate_size],-1 - jne sse_ok - call take_additional_xmm0 - mov [immediate_size],0 - sse_ok: - jmp instruction_ready - sse_cmp_mem_ok: - cmp byte [value],-1 - je mmx_imm8 - call store_instruction_with_imm8 - jmp instruction_assembled - sse_xmmreg_xmmreg: - cmp [operand_prefix],66h - jne sse_xmmreg_xmmreg_ok - cmp [extended_code],12h - je invalid_operand - cmp [extended_code],16h - je invalid_operand - sse_xmmreg_xmmreg_ok: - lods byte [esi] - call convert_xmm_register - mov bl,al - mov al,[extended_code] - mov ah,[supplemental_code] - cmp al,0C2h - je sse_cmp_nomem_ok - cmp ax,443Ah - je sse_cmp_nomem_ok - cmp [immediate_size],1 - je mmx_nomem_imm8 - cmp [immediate_size],-1 - jne sse_nomem_ok - call take_additional_xmm0 - mov [immediate_size],0 - sse_nomem_ok: - jmp nomem_instruction_ready - sse_cmp_nomem_ok: - cmp byte [value],-1 - je mmx_nomem_imm8 - call store_nomem_instruction - mov al,byte [value] - stosb - jmp instruction_assembled - take_additional_xmm0: - cmp byte [esi],',' - jne additional_xmm0_ok - inc esi - lods byte [esi] - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_xmm_register - test al,al - jnz invalid_operand - additional_xmm0_ok: - ret - -pslldq_instruction: - mov [postbyte_register],al - mov [opcode_prefix],66h - mov [base_code],0Fh - mov [extended_code],73h - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_xmm_register - mov bl,al - jmp mmx_nomem_imm8 -movpd_instruction: - mov [opcode_prefix],66h -movps_instruction: - mov [base_code],0Fh - mov [extended_code],al - mov [mmx_size],16 - jmp sse_mov_instruction -movss_instruction: - mov [mmx_size],4 - mov [opcode_prefix],0F3h - jmp sse_movs -movsd_instruction: - mov al,0A5h - mov ah,[esi] - or ah,ah - jz simple_instruction_32bit - cmp ah,0Fh - je simple_instruction_32bit - mov [mmx_size],8 - mov [opcode_prefix],0F2h - sse_movs: - mov [base_code],0Fh - mov [extended_code],10h - jmp sse_mov_instruction -sse_mov_instruction: - lods byte [esi] - call get_size_operator - cmp al,10h - je sse_xmmreg - sse_mem: - cmp al,'[' - jne invalid_operand - inc [extended_code] - call get_address - cmp [operand_size],0 - je sse_mem_xmmreg - mov al,[mmx_size] - cmp [operand_size],al - jne invalid_operand_size - mov [operand_size],0 - sse_mem_xmmreg: - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_xmm_register - mov [postbyte_register],al - jmp instruction_ready -movlpd_instruction: - mov [opcode_prefix],66h -movlps_instruction: - mov [base_code],0Fh - mov [extended_code],al - mov [mmx_size],8 - lods byte [esi] - call get_size_operator - cmp al,10h - jne sse_mem - lods byte [esi] - call convert_xmm_register - mov [postbyte_register],al - mov [operand_size],0 - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - jmp sse_reg_mem -movhlps_instruction: - mov [base_code],0Fh - mov [extended_code],al - mov [mmx_size],0 - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_xmm_register - mov [postbyte_register],al - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - je sse_xmmreg_xmmreg_ok - jmp invalid_operand -maskmovq_instruction: - mov cl,8 - jmp maskmov_instruction -maskmovdqu_instruction: - mov cl,16 - mov [opcode_prefix],66h - maskmov_instruction: - mov [base_code],0Fh - mov [extended_code],0F7h - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_mmx_register - cmp ah,cl - jne invalid_operand_size - mov [postbyte_register],al - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_mmx_register - mov bl,al - jmp nomem_instruction_ready -movmskpd_instruction: - mov [opcode_prefix],66h -movmskps_instruction: - mov [base_code],0Fh - mov [extended_code],50h - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - mov [postbyte_register],al - cmp ah,4 - je movmskps_reg_ok - cmp ah,8 - jne invalid_operand_size - cmp [code_type],64 - jne invalid_operand - movmskps_reg_ok: - mov [operand_size],0 - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - je sse_xmmreg_xmmreg_ok - jmp invalid_operand - -cvtpi2pd_instruction: - mov [opcode_prefix],66h -cvtpi2ps_instruction: - mov [base_code],0Fh - mov [extended_code],al - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_xmm_register - mov [postbyte_register],al - mov [operand_size],0 - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - je cvtpi_xmmreg_xmmreg - cmp al,'[' - jne invalid_operand - call get_address - cmp [operand_size],0 - je cvtpi_size_ok - cmp [operand_size],8 - jne invalid_operand_size - cvtpi_size_ok: - jmp instruction_ready - cvtpi_xmmreg_xmmreg: - lods byte [esi] - call convert_mmx_register - cmp ah,8 - jne invalid_operand_size - mov bl,al - jmp nomem_instruction_ready -cvtsi2ss_instruction: - mov [opcode_prefix],0F3h - jmp cvtsi_instruction -cvtsi2sd_instruction: - mov [opcode_prefix],0F2h - cvtsi_instruction: - mov [base_code],0Fh - mov [extended_code],al - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_xmm_register - mov [postbyte_register],al - cvtsi_xmmreg: - mov [operand_size],0 - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - je cvtsi_xmmreg_reg - cmp al,'[' - jne invalid_operand - call get_address - cmp [operand_size],0 - je cvtsi_size_ok - cmp [operand_size],4 - je cvtsi_size_ok - cmp [operand_size],8 - jne invalid_operand_size - call operand_64bit - cvtsi_size_ok: - jmp instruction_ready - cvtsi_xmmreg_reg: - lods byte [esi] - call convert_register - cmp ah,4 - je cvtsi_xmmreg_reg_store - cmp ah,8 - jne invalid_operand_size - call operand_64bit - cvtsi_xmmreg_reg_store: - mov bl,al - jmp nomem_instruction_ready -cvtps2pi_instruction: - mov [mmx_size],8 - jmp cvtpd_instruction -cvtpd2pi_instruction: - mov [opcode_prefix],66h - mov [mmx_size],16 - cvtpd_instruction: - mov [base_code],0Fh - mov [extended_code],al - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_mmx_register - cmp ah,8 - jne invalid_operand_size - mov [operand_size],0 - jmp sse_reg -cvtss2si_instruction: - mov [opcode_prefix],0F3h - mov [mmx_size],4 - jmp cvt2si_instruction -cvtsd2si_instruction: - mov [opcode_prefix],0F2h - mov [mmx_size],8 - cvt2si_instruction: - mov [extended_code],al - mov [base_code],0Fh - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - mov [operand_size],0 - cmp ah,4 - je sse_reg - cmp ah,8 - jne invalid_operand_size - call operand_64bit - jmp sse_reg - -ssse3_instruction: - mov [base_code],0Fh - mov [extended_code],38h - mov [supplemental_code],al - jmp mmx_instruction -palignr_instruction: - mov [base_code],0Fh - mov [extended_code],3Ah - mov [supplemental_code],0Fh - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_mmx_register - call make_mmx_prefix - mov [postbyte_register],al - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - je palignr_mmreg_mmreg - cmp al,'[' - jne invalid_operand - call get_address - jmp mmx_imm8 - palignr_mmreg_mmreg: - lods byte [esi] - call convert_mmx_register - mov bl,al - jmp mmx_nomem_imm8 -amd3dnow_instruction: - mov [base_code],0Fh - mov [extended_code],0Fh - mov byte [value],al - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_mmx_register - cmp ah,8 - jne invalid_operand_size - mov [postbyte_register],al - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - je amd3dnow_mmreg_mmreg - cmp al,'[' - jne invalid_operand - call get_address - call store_instruction_with_imm8 - jmp instruction_assembled - amd3dnow_mmreg_mmreg: - lods byte [esi] - call convert_mmx_register - cmp ah,8 - jne invalid_operand_size - mov bl,al - call store_nomem_instruction - mov al,byte [value] - stos byte [edi] - jmp instruction_assembled - -sse4_instruction_38_xmm0: - mov [immediate_size],-1 -sse4_instruction_38: - mov [mmx_size],16 - mov [opcode_prefix],66h - mov [supplemental_code],al - mov al,38h - jmp sse_instruction -sse4_ss_instruction_3a_imm8: - mov [immediate_size],1 - mov [mmx_size],4 - jmp sse4_instruction_3a_setup -sse4_sd_instruction_3a_imm8: - mov [immediate_size],1 - mov [mmx_size],8 - jmp sse4_instruction_3a_setup -sse4_instruction_3a_imm8: - mov [immediate_size],1 - mov [mmx_size],16 - sse4_instruction_3a_setup: - mov [opcode_prefix],66h - mov [supplemental_code],al - mov al,3Ah - jmp sse_instruction -pclmulqdq_instruction: - mov byte [value],al - mov [mmx_size],16 - mov al,44h - jmp sse4_instruction_3a_setup -extractps_instruction: - mov [opcode_prefix],66h - mov [base_code],0Fh - mov [extended_code],3Ah - mov [supplemental_code],17h - lods byte [esi] - call get_size_operator - cmp al,10h - je extractps_reg - cmp al,'[' - jne invalid_operand - call get_address - cmp [operand_size],4 - je extractps_size_ok - cmp [operand_size],0 - jne invalid_operand_size - extractps_size_ok: - push edx ebx ecx - mov [operand_size],0 - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_xmm_register - mov [postbyte_register],al - pop ecx ebx edx - jmp mmx_imm8 - extractps_reg: - lods byte [esi] - call convert_register - push eax - mov [operand_size],0 - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_xmm_register - mov [postbyte_register],al - pop ebx - mov al,bh - cmp al,4 - je mmx_nomem_imm8 - cmp al,8 - jne invalid_operand_size - call operand_64bit - jmp mmx_nomem_imm8 -insertps_instruction: - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_xmm_register - mov [postbyte_register],al - insertps_xmmreg: - mov [opcode_prefix],66h - mov [base_code],0Fh - mov [extended_code],3Ah - mov [supplemental_code],21h - mov [operand_size],0 - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - je insertps_xmmreg_reg - cmp al,'[' - jne invalid_operand - call get_address - cmp [operand_size],4 - je insertps_size_ok - cmp [operand_size],0 - jne invalid_operand_size - insertps_size_ok: - jmp mmx_imm8 - insertps_xmmreg_reg: - lods byte [esi] - call convert_mmx_register - mov bl,al - jmp mmx_nomem_imm8 -pextrq_instruction: - mov [mmx_size],8 - jmp pextr_instruction -pextrd_instruction: - mov [mmx_size],4 - jmp pextr_instruction -pextrw_instruction: - mov [mmx_size],2 - jmp pextr_instruction -pextrb_instruction: - mov [mmx_size],1 - pextr_instruction: - mov [opcode_prefix],66h - mov [base_code],0Fh - mov [extended_code],3Ah - mov [supplemental_code],al - lods byte [esi] - call get_size_operator - cmp al,10h - je pextr_reg - cmp al,'[' - jne invalid_operand - call get_address - mov al,[mmx_size] - cmp al,[operand_size] - je pextr_size_ok - cmp [operand_size],0 - jne invalid_operand_size - pextr_size_ok: - cmp al,8 - jne pextr_prefix_ok - call operand_64bit - pextr_prefix_ok: - push edx ebx ecx - mov [operand_size],0 - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_xmm_register - mov [postbyte_register],al - pop ecx ebx edx - jmp mmx_imm8 - pextr_reg: - lods byte [esi] - call convert_register - cmp [mmx_size],4 - ja pextrq_reg - cmp ah,4 - je pextr_reg_size_ok - cmp [code_type],64 - jne pextr_invalid_size - cmp ah,8 - je pextr_reg_size_ok - pextr_invalid_size: - jmp invalid_operand_size - pextrq_reg: - cmp ah,8 - jne pextr_invalid_size - call operand_64bit - pextr_reg_size_ok: - mov [operand_size],0 - push eax - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_mmx_register - mov ebx,eax - pop eax - mov [postbyte_register],al - mov al,ah - cmp [mmx_size],2 - jne pextr_reg_store - mov [opcode_prefix],0 - mov [extended_code],0C5h - call make_mmx_prefix - jmp mmx_nomem_imm8 - pextr_reg_store: - cmp bh,16 - jne invalid_operand_size - xchg bl,[postbyte_register] - call operand_autodetect - jmp mmx_nomem_imm8 -pinsrb_instruction: - mov [mmx_size],1 - jmp pinsr_instruction -pinsrd_instruction: - mov [mmx_size],4 - jmp pinsr_instruction -pinsrq_instruction: - mov [mmx_size],8 - call operand_64bit - pinsr_instruction: - mov [opcode_prefix],66h - mov [base_code],0Fh - mov [extended_code],3Ah - mov [supplemental_code],al - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_xmm_register - mov [postbyte_register],al - pinsr_xmmreg: - mov [operand_size],0 - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - je pinsr_xmmreg_reg - cmp al,'[' - jne invalid_operand - call get_address - cmp [operand_size],0 - je mmx_imm8 - mov al,[mmx_size] - cmp al,[operand_size] - je mmx_imm8 - jmp invalid_operand_size - pinsr_xmmreg_reg: - lods byte [esi] - call convert_register - mov bl,al - cmp [mmx_size],8 - je pinsrq_xmmreg_reg - cmp ah,4 - je mmx_nomem_imm8 - jmp invalid_operand_size - pinsrq_xmmreg_reg: - cmp ah,8 - je mmx_nomem_imm8 - jmp invalid_operand_size -pmovsxbw_instruction: - mov [mmx_size],8 - jmp pmovsx_instruction -pmovsxbd_instruction: - mov [mmx_size],4 - jmp pmovsx_instruction -pmovsxbq_instruction: - mov [mmx_size],2 - jmp pmovsx_instruction -pmovsxwd_instruction: - mov [mmx_size],8 - jmp pmovsx_instruction -pmovsxwq_instruction: - mov [mmx_size],4 - jmp pmovsx_instruction -pmovsxdq_instruction: - mov [mmx_size],8 - pmovsx_instruction: - mov [opcode_prefix],66h - mov [base_code],0Fh - mov [extended_code],38h - mov [supplemental_code],al - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_xmm_register - mov [postbyte_register],al - lods byte [esi] - cmp al,',' - jne invalid_operand - mov [operand_size],0 - lods byte [esi] - call get_size_operator - cmp al,10h - je pmovsx_xmmreg_reg - cmp al,'[' - jne invalid_operand - call get_address - cmp [operand_size],0 - je instruction_ready - mov al,[mmx_size] - cmp al,[operand_size] - jne invalid_operand_size - jmp instruction_ready - pmovsx_xmmreg_reg: - lods byte [esi] - call convert_xmm_register - mov bl,al - jmp nomem_instruction_ready - -fxsave_instruction_64bit: - call operand_64bit -fxsave_instruction: - mov [extended_code],0AEh - mov [base_code],0Fh - mov [postbyte_register],al - lods byte [esi] - call get_size_operator - cmp al,'[' - jne invalid_operand - call get_address - mov ah,[operand_size] - or ah,ah - jz fxsave_size_ok - mov al,[postbyte_register] - cmp al,111b - je clflush_size_check - cmp al,10b - jb invalid_operand_size - cmp al,11b - ja invalid_operand_size - cmp ah,4 - jne invalid_operand_size - jmp fxsave_size_ok - clflush_size_check: - cmp ah,1 - jne invalid_operand_size - fxsave_size_ok: - jmp instruction_ready -prefetch_instruction: - mov [extended_code],18h - prefetch_mem_8bit: - mov [base_code],0Fh - mov [postbyte_register],al - lods byte [esi] - call get_size_operator - cmp al,'[' - jne invalid_operand - or ah,ah - jz prefetch_size_ok - cmp ah,1 - jne invalid_operand_size - prefetch_size_ok: - call get_address - jmp instruction_ready -amd_prefetch_instruction: - mov [extended_code],0Dh - jmp prefetch_mem_8bit -fence_instruction: - mov bl,al - mov ax,0AE0Fh - stos word [edi] - mov al,bl - stos byte [edi] - jmp instruction_assembled -pause_instruction: - mov ax,90F3h - stos word [edi] - jmp instruction_assembled -movntq_instruction: - mov [mmx_size],8 - jmp movnt_instruction -movntpd_instruction: - mov [opcode_prefix],66h -movntps_instruction: - mov [mmx_size],16 - movnt_instruction: - mov [extended_code],al - mov [base_code],0Fh - lods byte [esi] - call get_size_operator - cmp al,'[' - jne invalid_operand - call get_address - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_mmx_register - cmp ah,[mmx_size] - jne invalid_operand_size - mov [postbyte_register],al - jmp instruction_ready - -movntsd_instruction: - mov [opcode_prefix],0F2h - mov [mmx_size],8 - jmp movnts_instruction -movntss_instruction: - mov [opcode_prefix],0F3h - mov [mmx_size],4 - movnts_instruction: - mov [extended_code],al - mov [base_code],0Fh - lods byte [esi] - call get_size_operator - cmp al,'[' - jne invalid_operand - call get_address - mov al,[operand_size] - cmp al,[mmx_size] - je movnts_size_ok - test al,al - jnz invalid_operand_size - movnts_size_ok: - lods byte [esi] - cmp al,',' - jne invalid_operand - mov [operand_size],0 - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_xmm_register - mov [postbyte_register],al - jmp instruction_ready - -movnti_instruction: - mov [base_code],0Fh - mov [extended_code],al - lods byte [esi] - call get_size_operator - cmp al,'[' - jne invalid_operand - call get_address - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - cmp ah,4 - je movnti_store - cmp ah,8 - jne invalid_operand_size - call operand_64bit - movnti_store: - mov [postbyte_register],al - jmp instruction_ready -monitor_instruction: - mov [postbyte_register],al - cmp byte [esi],0 - je monitor_instruction_store - cmp byte [esi],0Fh - je monitor_instruction_store - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - cmp ax,0400h - jne invalid_operand - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - cmp ax,0401h - jne invalid_operand - cmp [postbyte_register],0C8h - jne monitor_instruction_store - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - cmp ax,0402h - jne invalid_operand - monitor_instruction_store: - mov ax,010Fh - stos word [edi] - mov al,[postbyte_register] - stos byte [edi] - jmp instruction_assembled -movntdqa_instruction: - mov [opcode_prefix],66h - mov [base_code],0Fh - mov [extended_code],38h - mov [supplemental_code],al - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_xmm_register - mov [postbyte_register],al - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,'[' - jne invalid_operand - call get_address - jmp instruction_ready - -extrq_instruction: - mov [opcode_prefix],66h - mov [base_code],0Fh - mov [extended_code],78h - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_xmm_register - mov [postbyte_register],al - mov [operand_size],0 - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - je extrq_xmmreg_xmmreg - test ah,not 1 - jnz invalid_operand_size - cmp al,'(' - jne invalid_operand - xor bl,bl - xchg bl,[postbyte_register] - call store_nomem_instruction - call get_byte_value - stosb - call append_imm8 - jmp instruction_assembled - extrq_xmmreg_xmmreg: - inc [extended_code] - lods byte [esi] - call convert_xmm_register - mov bl,al - jmp nomem_instruction_ready -insertq_instruction: - mov [opcode_prefix],0F2h - mov [base_code],0Fh - mov [extended_code],78h - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_xmm_register - mov [postbyte_register],al - mov [operand_size],0 - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_xmm_register - mov bl,al - cmp byte [esi],',' - je insertq_with_imm - inc [extended_code] - jmp nomem_instruction_ready - insertq_with_imm: - call store_nomem_instruction - call append_imm8 - call append_imm8 - jmp instruction_assembled - -crc32_instruction: - mov [opcode_prefix],0F2h - mov [base_code],0Fh - mov [extended_code],38h - mov [supplemental_code],0F0h - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - mov [postbyte_register],al - cmp ah,8 - je crc32_reg64 - cmp ah,4 - jne invalid_operand - lods byte [esi] - cmp al,',' - jne invalid_operand - mov [operand_size],0 - lods byte [esi] - call get_size_operator - cmp al,10h - je crc32_reg32_reg - cmp al,'[' - jne invalid_operand - call get_address - mov al,[operand_size] - test al,al - jz crc32_unknown_size - cmp al,1 - je crc32_reg32_mem_store - cmp al,4 - ja invalid_operand_size - inc [supplemental_code] - call operand_autodetect - crc32_reg32_mem_store: - jmp instruction_ready - crc32_unknown_size: - call recoverable_unknown_size - jmp crc32_reg32_mem_store - crc32_reg32_reg: - lods byte [esi] - call convert_register - mov bl,al - mov al,ah - cmp al,1 - je crc32_reg32_reg_store - cmp al,4 - ja invalid_operand_size - inc [supplemental_code] - call operand_autodetect - crc32_reg32_reg_store: - jmp nomem_instruction_ready - crc32_reg64: - lods byte [esi] - cmp al,',' - jne invalid_operand - mov [operand_size],0 - call operand_64bit - lods byte [esi] - call get_size_operator - cmp al,10h - je crc32_reg64_reg - cmp al,'[' - jne invalid_operand - call get_address - mov ah,[operand_size] - mov al,8 - test ah,ah - jz crc32_unknown_size - cmp ah,1 - je crc32_reg32_mem_store - cmp ah,al - jne invalid_operand_size - inc [supplemental_code] - jmp crc32_reg32_mem_store - crc32_reg64_reg: - lods byte [esi] - call convert_register - mov bl,al - mov al,8 - cmp ah,1 - je crc32_reg32_reg_store - cmp ah,al - jne invalid_operand_size - inc [supplemental_code] - jmp crc32_reg32_reg_store -popcnt_instruction: - mov [opcode_prefix],0F3h - jmp bs_instruction -movbe_instruction: - mov [supplemental_code],al - mov [extended_code],38h - mov [base_code],0Fh - lods byte [esi] - call get_size_operator - cmp al,'[' - je movbe_mem - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - mov [postbyte_register],al - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,'[' - jne invalid_argument - call get_address - mov al,[operand_size] - call operand_autodetect - jmp instruction_ready - movbe_mem: - inc [supplemental_code] - call get_address - push edx ebx ecx - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - mov [postbyte_register],al - pop ecx ebx edx - mov al,[operand_size] - call operand_autodetect - jmp instruction_ready -adx_instruction: - mov [base_code],0Fh - mov [extended_code],38h - mov [supplemental_code],0F6h - mov [operand_prefix],al - call get_reg_mem - jc adx_reg_reg - mov al,[operand_size] - cmp al,4 - je instruction_ready - cmp al,8 - jne invalid_operand_size - call operand_64bit - jmp instruction_ready - adx_reg_reg: - cmp ah,4 - je nomem_instruction_ready - cmp ah,8 - jne invalid_operand_size - call operand_64bit - jmp nomem_instruction_ready - -simple_vmx_instruction: - mov ah,al - mov al,0Fh - stos byte [edi] - mov al,1 - stos word [edi] - jmp instruction_assembled -vmclear_instruction: - mov [opcode_prefix],66h - jmp vmx_instruction -vmxon_instruction: - mov [opcode_prefix],0F3h -vmx_instruction: - mov [postbyte_register],al - mov [extended_code],0C7h - lods byte [esi] - call get_size_operator - cmp al,'[' - jne invalid_operand - call get_address - mov al,[operand_size] - or al,al - jz vmx_size_ok - cmp al,8 - jne invalid_operand_size - vmx_size_ok: - mov [base_code],0Fh - jmp instruction_ready -vmread_instruction: - mov [extended_code],78h - lods byte [esi] - call get_size_operator - cmp al,10h - je vmread_nomem - cmp al,'[' - jne invalid_operand - call get_address - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - mov [postbyte_register],al - call vmread_check_size - jmp vmx_size_ok - vmread_nomem: - lods byte [esi] - call convert_register - push eax - call vmread_check_size - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - mov [postbyte_register],al - call vmread_check_size - pop ebx - mov [base_code],0Fh - jmp nomem_instruction_ready - vmread_check_size: - cmp [code_type],64 - je vmread_long - cmp [operand_size],4 - jne invalid_operand_size - ret - vmread_long: - cmp [operand_size],8 - jne invalid_operand_size - ret -vmwrite_instruction: - mov [extended_code],79h - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - mov [postbyte_register],al - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - je vmwrite_nomem - cmp al,'[' - jne invalid_operand - call get_address - call vmread_check_size - jmp vmx_size_ok - vmwrite_nomem: - lods byte [esi] - call convert_register - mov bl,al - mov [base_code],0Fh - jmp nomem_instruction_ready -vmx_inv_instruction: - mov [opcode_prefix],66h - mov [extended_code],38h - mov [supplemental_code],al - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - mov [postbyte_register],al - call vmread_check_size - mov [operand_size],0 - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,'[' - jne invalid_operand - call get_address - mov al,[operand_size] - or al,al - jz vmx_size_ok - cmp al,16 - jne invalid_operand_size - jmp vmx_size_ok -simple_svm_instruction: - push eax - mov [base_code],0Fh - mov [extended_code],1 - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - or al,al - jnz invalid_operand - simple_svm_detect_size: - cmp ah,2 - je simple_svm_16bit - cmp ah,4 - je simple_svm_32bit - cmp [code_type],64 - jne invalid_operand_size - jmp simple_svm_store - simple_svm_16bit: - cmp [code_type],16 - je simple_svm_store - cmp [code_type],64 - je invalid_operand_size - jmp prefixed_svm_store - simple_svm_32bit: - cmp [code_type],32 - je simple_svm_store - prefixed_svm_store: - mov al,67h - stos byte [edi] - simple_svm_store: - call store_instruction_code - pop eax - stos byte [edi] - jmp instruction_assembled -skinit_instruction: - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - cmp ax,0400h - jne invalid_operand - mov al,0DEh - jmp simple_vmx_instruction -invlpga_instruction: - push eax - mov [base_code],0Fh - mov [extended_code],1 - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - or al,al - jnz invalid_operand - mov bl,ah - mov [operand_size],0 - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - cmp ax,0401h - jne invalid_operand - mov ah,bl - jmp simple_svm_detect_size - -rdrand_instruction: - mov [base_code],0Fh - mov [extended_code],0C7h - mov [postbyte_register],al - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - mov bl,al - mov al,ah - call operand_autodetect - jmp nomem_instruction_ready -rdfsbase_instruction: - cmp [code_type],64 - jne illegal_instruction - mov [opcode_prefix],0F3h - mov [base_code],0Fh - mov [extended_code],0AEh - mov [postbyte_register],al - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_register - mov bl,al - mov al,ah - cmp ah,2 - je invalid_operand_size - call operand_autodetect - jmp nomem_instruction_ready - -xabort_instruction: - lods byte [esi] - call get_size_operator - cmp ah,1 - ja invalid_operand_size - cmp al,'(' - jne invalid_operand - call get_byte_value - mov dl,al - mov ax,0F8C6h - stos word [edi] - mov al,dl - stos byte [edi] - jmp instruction_assembled -xbegin_instruction: - lods byte [esi] - cmp al,'(' - jne invalid_operand - mov al,[code_type] - cmp al,64 - je xbegin_64bit - cmp al,32 - je xbegin_32bit - xbegin_16bit: - call get_address_word_value - add edi,4 - mov ebp,[addressing_space] - call calculate_relative_offset - sub edi,4 - shl eax,16 - mov ax,0F8C7h - stos dword [edi] - jmp instruction_assembled - xbegin_32bit: - call get_address_dword_value - jmp xbegin_address_ok - xbegin_64bit: - call get_address_qword_value - xbegin_address_ok: - add edi,5 - mov ebp,[addressing_space] - call calculate_relative_offset - sub edi,5 - mov edx,eax - cwde - cmp eax,edx - jne xbegin_rel32 - mov al,66h - stos byte [edi] - mov eax,edx - shl eax,16 - mov ax,0F8C7h - stos dword [edi] - jmp instruction_assembled - xbegin_rel32: - sub edx,1 - jno xbegin_rel32_ok - cmp [code_type],64 - je relative_jump_out_of_range - xbegin_rel32_ok: - mov ax,0F8C7h - stos word [edi] - mov eax,edx - stos dword [edi] - jmp instruction_assembled - -convert_register: - mov ah,al - shr ah,4 - and al,0Fh - cmp ah,8 - je match_register_size - cmp ah,4 - ja invalid_operand - cmp ah,1 - ja match_register_size - cmp al,4 - jb match_register_size - or ah,ah - jz high_byte_register - or [rex_prefix],40h - match_register_size: - cmp ah,[operand_size] - je register_size_ok - cmp [operand_size],0 - jne operand_sizes_do_not_match - mov [operand_size],ah - register_size_ok: - ret - high_byte_register: - mov ah,1 - or [rex_prefix],80h - jmp match_register_size -convert_fpu_register: - mov ah,al - shr ah,4 - and al,111b - cmp ah,10 - jne invalid_operand - jmp match_register_size -convert_mmx_register: - mov ah,al - shr ah,4 - cmp ah,0Ch - je xmm_register - ja invalid_operand - and al,111b - cmp ah,0Bh - jne invalid_operand - mov ah,8 - cmp [vex_required],0 - jne invalid_operand - jmp match_register_size - xmm_register: - and al,0Fh - mov ah,16 - cmp al,8 - jb match_register_size - cmp [code_type],64 - jne invalid_operand - jmp match_register_size -convert_xmm_register: - mov ah,al - shr ah,4 - cmp ah,0Ch - je xmm_register - jmp invalid_operand -get_size_operator: - xor ah,ah - cmp al,11h - jne no_size_operator - mov [size_declared],1 - lods word [esi] - xchg al,ah - mov [size_override],1 - cmp ah,[operand_size] - je size_operator_ok - cmp [operand_size],0 - jne operand_sizes_do_not_match - mov [operand_size],ah - size_operator_ok: - ret - no_size_operator: - mov [size_declared],0 - cmp al,'[' - jne size_operator_ok - mov [size_override],0 - ret -get_jump_operator: - mov [jump_type],0 - cmp al,12h - jne jump_operator_ok - lods word [esi] - mov [jump_type],al - mov al,ah - jump_operator_ok: - ret -get_address: - mov [segment_register],0 - mov [address_size],0 - mov [free_address_range],0 - mov al,[code_type] - shr al,3 - mov [value_size],al - mov al,[esi] - and al,11110000b - cmp al,60h - jne get_size_prefix - lods byte [esi] - sub al,60h - mov [segment_register],al - mov al,[esi] - and al,11110000b - get_size_prefix: - cmp al,70h - jne address_size_prefix_ok - lods byte [esi] - sub al,70h - cmp al,2 - jb invalid_address_size - cmp al,8 - ja invalid_address_size - mov [address_size],al - mov [value_size],al - address_size_prefix_ok: - call calculate_address - cmp byte [esi-1],']' - jne invalid_address - mov [address_high],edx - mov edx,eax - cmp [code_type],64 - jne address_ok - or bx,bx - jnz address_ok - test ch,0Fh - jnz address_ok - calculate_relative_address: - mov edx,[address_symbol] - mov [symbol_identifier],edx - mov edx,[address_high] - mov ebp,[addressing_space] - call calculate_relative_offset - mov [address_high],edx - cdq - cmp edx,[address_high] - je address_high_ok - call recoverable_overflow - address_high_ok: - mov edx,eax - ror ecx,16 - mov cl,[value_type] - rol ecx,16 - mov bx,0FF00h - address_ok: - ret -operand_16bit: - cmp [code_type],16 - je size_prefix_ok - mov [operand_prefix],66h - ret -operand_32bit: - cmp [code_type],16 - jne size_prefix_ok - mov [operand_prefix],66h - size_prefix_ok: - ret -operand_64bit: - cmp [code_type],64 - jne illegal_instruction - or [rex_prefix],48h - ret -operand_autodetect: - cmp al,2 - je operand_16bit - cmp al,4 - je operand_32bit - cmp al,8 - je operand_64bit - jmp invalid_operand_size -store_segment_prefix_if_necessary: - mov al,[segment_register] - or al,al - jz segment_prefix_ok - cmp al,4 - ja segment_prefix_386 - cmp [code_type],64 - je segment_prefix_ok - cmp al,3 - je ss_prefix - jb segment_prefix_86 - cmp bl,25h - je segment_prefix_86 - cmp bh,25h - je segment_prefix_86 - cmp bh,45h - je segment_prefix_86 - cmp bh,44h - je segment_prefix_86 - ret - ss_prefix: - cmp bl,25h - je segment_prefix_ok - cmp bh,25h - je segment_prefix_ok - cmp bh,45h - je segment_prefix_ok - cmp bh,44h - je segment_prefix_ok - jmp segment_prefix_86 -store_segment_prefix: - mov al,[segment_register] - or al,al - jz segment_prefix_ok - cmp al,5 - jae segment_prefix_386 - segment_prefix_86: - dec al - shl al,3 - add al,26h - stos byte [edi] - jmp segment_prefix_ok - segment_prefix_386: - add al,64h-5 - stos byte [edi] - segment_prefix_ok: - ret -store_instruction_code: - cmp [vex_required],0 - jne store_vex_instruction_code - mov al,[operand_prefix] - or al,al - jz operand_prefix_ok - stos byte [edi] - operand_prefix_ok: - mov al,[opcode_prefix] - or al,al - jz opcode_prefix_ok - stos byte [edi] - opcode_prefix_ok: - mov al,[rex_prefix] - test al,40h - jz rex_prefix_ok - cmp [code_type],64 - jne invalid_operand - test al,0B0h - jnz disallowed_combination_of_registers - stos byte [edi] - rex_prefix_ok: - mov al,[base_code] - stos byte [edi] - cmp al,0Fh - jne instruction_code_ok - store_extended_code: - mov al,[extended_code] - stos byte [edi] - cmp al,38h - je store_supplemental_code - cmp al,3Ah - je store_supplemental_code - instruction_code_ok: - ret - store_supplemental_code: - mov al,[supplemental_code] - stos byte [edi] - ret -store_nomem_instruction: - test [postbyte_register],1000b - jz nomem_reg_code_ok - or [rex_prefix],44h - and [postbyte_register],111b - nomem_reg_code_ok: - test bl,1000b - jz nomem_rm_code_ok - or [rex_prefix],41h - and bl,111b - nomem_rm_code_ok: - call store_instruction_code - mov al,[postbyte_register] - shl al,3 - or al,bl - or al,11000000b - stos byte [edi] - ret -store_instruction: - mov [current_offset],edi - test [postbyte_register],1000b - jz reg_code_ok - or [rex_prefix],44h - and [postbyte_register],111b - reg_code_ok: - cmp [code_type],64 - jne address_value_ok - xor eax,eax - bt edx,31 - sbb eax,[address_high] - jz address_value_ok - cmp [address_high],0 - jne address_value_out_of_range - test ch,44h - jnz address_value_ok - test bx,8080h - jz address_value_ok - address_value_out_of_range: - call recoverable_overflow - address_value_ok: - call store_segment_prefix_if_necessary - test [vex_required],4 - jnz address_vsib - or bx,bx - jz address_immediate - cmp bx,0F800h - je address_rip_based - cmp bx,0F400h - je address_eip_based - cmp bx,0FF00h - je address_relative - mov al,bl - or al,bh - and al,11110000b - cmp al,80h - je postbyte_64bit - cmp al,40h - je postbyte_32bit - cmp al,20h - jne invalid_address - cmp [code_type],64 - je invalid_address_size - call address_16bit_prefix - call store_instruction_code - cmp bl,bh - jbe determine_16bit_address - xchg bl,bh - determine_16bit_address: - cmp bx,2600h - je address_si - cmp bx,2700h - je address_di - cmp bx,2300h - je address_bx - cmp bx,2500h - je address_bp - cmp bx,2625h - je address_bp_si - cmp bx,2725h - je address_bp_di - cmp bx,2723h - je address_bx_di - cmp bx,2623h - jne invalid_address - address_bx_si: - xor al,al - jmp postbyte_16bit - address_bx_di: - mov al,1 - jmp postbyte_16bit - address_bp_si: - mov al,10b - jmp postbyte_16bit - address_bp_di: - mov al,11b - jmp postbyte_16bit - address_si: - mov al,100b - jmp postbyte_16bit - address_di: - mov al,101b - jmp postbyte_16bit - address_bx: - mov al,111b - jmp postbyte_16bit - address_bp: - mov al,110b - postbyte_16bit: - test ch,22h - jnz address_16bit_value - or ch,ch - jnz address_sizes_do_not_agree - cmp edx,10000h - jge value_out_of_range - cmp edx,-8000h - jl value_out_of_range - or dx,dx - jz address - cmp dx,80h - jb address_8bit_value - cmp dx,-80h - jae address_8bit_value - address_16bit_value: - or al,10000000b - mov cl,[postbyte_register] - shl cl,3 - or al,cl - stos byte [edi] - mov eax,edx - stos word [edi] - ret - address_8bit_value: - or al,01000000b - mov cl,[postbyte_register] - shl cl,3 - or al,cl - stos byte [edi] - mov al,dl - stos byte [edi] - cmp dx,80h - jge value_out_of_range - cmp dx,-80h - jl value_out_of_range - ret - address: - cmp al,110b - je address_8bit_value - mov cl,[postbyte_register] - shl cl,3 - or al,cl - stos byte [edi] - ret - address_vsib: - mov al,bl - shr al,4 - cmp al,0Ch - je vector_index_ok - cmp al,0Dh - jne invalid_address - vector_index_ok: - mov al,bh - shr al,4 - cmp al,4 - je postbyte_32bit - cmp [code_type],64 - je address_prefix_ok - test al,al - jnz invalid_address - postbyte_32bit: - call address_32bit_prefix - jmp address_prefix_ok - postbyte_64bit: - cmp [code_type],64 - jne invalid_address_size - address_prefix_ok: - cmp bl,44h - je invalid_address - cmp bl,84h - je invalid_address - test bh,1000b - jz base_code_ok - or [rex_prefix],41h - base_code_ok: - test bl,1000b - jz index_code_ok - or [rex_prefix],42h - index_code_ok: - call store_instruction_code - or cl,cl - jz only_base_register - base_and_index: - mov al,100b - xor ah,ah - cmp cl,1 - je scale_ok - cmp cl,2 - je scale_1 - cmp cl,4 - je scale_2 - or ah,11000000b - jmp scale_ok - scale_2: - or ah,10000000b - jmp scale_ok - scale_1: - or ah,01000000b - scale_ok: - or bh,bh - jz only_index_register - and bl,111b - shl bl,3 - or ah,bl - and bh,111b - or ah,bh - sib_ready: - test ch,44h - jnz sib_address_32bit_value - test ch,88h - jnz sib_address_32bit_value - or ch,ch - jnz address_sizes_do_not_agree - cmp bh,5 - je address_value - or edx,edx - jz sib_address - address_value: - cmp edx,80h - jb sib_address_8bit_value - cmp edx,-80h - jae sib_address_8bit_value - sib_address_32bit_value: - or al,10000000b - mov cl,[postbyte_register] - shl cl,3 - or al,cl - stos word [edi] - jmp store_address_32bit_value - sib_address_8bit_value: - or al,01000000b - mov cl,[postbyte_register] - shl cl,3 - or al,cl - stos word [edi] - mov al,dl - stos byte [edi] - cmp edx,80h - jge value_out_of_range - cmp edx,-80h - jl value_out_of_range - ret - sib_address: - mov cl,[postbyte_register] - shl cl,3 - or al,cl - stos word [edi] - ret - only_index_register: - or ah,101b - and bl,111b - shl bl,3 - or ah,bl - mov cl,[postbyte_register] - shl cl,3 - or al,cl - stos word [edi] - test ch,44h - jnz store_address_32bit_value - test ch,88h - jnz store_address_32bit_value - or ch,ch - jnz invalid_address_size - jmp store_address_32bit_value - zero_index_register: - mov bl,4 - mov cl,1 - jmp base_and_index - only_base_register: - mov al,bh - and al,111b - cmp al,4 - je zero_index_register - test ch,44h - jnz simple_address_32bit_value - test ch,88h - jnz simple_address_32bit_value - or ch,ch - jnz address_sizes_do_not_agree - or edx,edx - jz simple_address - cmp edx,80h - jb simple_address_8bit_value - cmp edx,-80h - jae simple_address_8bit_value - simple_address_32bit_value: - or al,10000000b - mov cl,[postbyte_register] - shl cl,3 - or al,cl - stos byte [edi] - jmp store_address_32bit_value - simple_address_8bit_value: - or al,01000000b - mov cl,[postbyte_register] - shl cl,3 - or al,cl - stos byte [edi] - mov al,dl - stos byte [edi] - cmp edx,80h - jge value_out_of_range - cmp edx,-80h - jl value_out_of_range - ret - simple_address: - cmp al,5 - je simple_address_8bit_value - mov cl,[postbyte_register] - shl cl,3 - or al,cl - stos byte [edi] - ret - address_immediate: - cmp [code_type],64 - je address_immediate_sib - test ch,44h - jnz address_immediate_32bit - test ch,88h - jnz address_immediate_32bit - test ch,22h - jnz address_immediate_16bit - or ch,ch - jnz invalid_address_size - cmp [code_type],16 - je addressing_16bit - address_immediate_32bit: - call address_32bit_prefix - call store_instruction_code - store_immediate_address: - mov al,101b - mov cl,[postbyte_register] - shl cl,3 - or al,cl - stos byte [edi] - store_address_32bit_value: - test ch,0F0h - jz address_32bit_relocation_ok - mov eax,ecx - shr eax,16 - cmp al,4 - jne address_32bit_relocation - mov al,2 - address_32bit_relocation: - xchg [value_type],al - mov ebx,[address_symbol] - xchg ebx,[symbol_identifier] - call mark_relocation - mov [value_type],al - mov [symbol_identifier],ebx - address_32bit_relocation_ok: - mov eax,edx - stos dword [edi] - ret - store_address_64bit_value: - test ch,0F0h - jz address_64bit_relocation_ok - mov eax,ecx - shr eax,16 - xchg [value_type],al - mov ebx,[address_symbol] - xchg ebx,[symbol_identifier] - call mark_relocation - mov [value_type],al - mov [symbol_identifier],ebx - address_64bit_relocation_ok: - mov eax,edx - stos dword [edi] - mov eax,[address_high] - stos dword [edi] - ret - address_immediate_sib: - test ch,44h - jnz address_immediate_sib_32bit - test ch,not 88h - jnz invalid_address_size - address_immediate_sib_store: - call store_instruction_code - mov al,100b - mov ah,100101b - mov cl,[postbyte_register] - shl cl,3 - or al,cl - stos word [edi] - jmp store_address_32bit_value - address_immediate_sib_32bit: - test ecx,0FF0000h - jnz address_immediate_sib_nosignextend - test edx,80000000h - jz address_immediate_sib_store - address_immediate_sib_nosignextend: - call address_32bit_prefix - jmp address_immediate_sib_store - address_eip_based: - mov al,67h - stos byte [edi] - address_rip_based: - cmp [code_type],64 - jne invalid_address - call store_instruction_code - jmp store_immediate_address - address_relative: - call store_instruction_code - movzx eax,[immediate_size] - add eax,edi - sub eax,[current_offset] - add eax,5 - sub edx,eax - jo value_out_of_range - mov al,101b - mov cl,[postbyte_register] - shl cl,3 - or al,cl - stos byte [edi] - shr ecx,16 - xchg [value_type],cl - mov ebx,[address_symbol] - xchg ebx,[symbol_identifier] - mov eax,edx - call mark_relocation - mov [value_type],cl - mov [symbol_identifier],ebx - stos dword [edi] - ret - addressing_16bit: - cmp edx,10000h - jge address_immediate_32bit - cmp edx,-8000h - jl address_immediate_32bit - movzx edx,dx - address_immediate_16bit: - call address_16bit_prefix - call store_instruction_code - mov al,110b - mov cl,[postbyte_register] - shl cl,3 - or al,cl - stos byte [edi] - mov eax,edx - stos word [edi] - cmp edx,10000h - jge value_out_of_range - cmp edx,-8000h - jl value_out_of_range - ret - address_16bit_prefix: - cmp [code_type],16 - je instruction_prefix_ok - mov al,67h - stos byte [edi] - ret - address_32bit_prefix: - cmp [code_type],32 - je instruction_prefix_ok - mov al,67h - stos byte [edi] - instruction_prefix_ok: - ret -store_instruction_with_imm8: - mov [immediate_size],1 - call store_instruction - mov al,byte [value] - stos byte [edi] - ret -store_instruction_with_imm16: - mov [immediate_size],2 - call store_instruction - mov ax,word [value] - call mark_relocation - stos word [edi] - ret -store_instruction_with_imm32: - mov [immediate_size],4 - call store_instruction - mov eax,dword [value] - call mark_relocation - stos dword [edi] - ret diff --git a/samples/BlitzMax/sample.bmx b/samples/BlitzMax/sample.bmx new file mode 100644 index 00000000..e57e5f58 --- /dev/null +++ b/samples/BlitzMax/sample.bmx @@ -0,0 +1,25 @@ +SuperStrict + +Framework Brl.StandardIO + +Type TMyType + Field property:int + + Function A:int(param:int) + 'do nothing + End Function + + Method B:int(param:int) + 'do nothing + End Method +End Type + + +Global my:TMyType = new TMyType +?Win32 + my.A() + my.B() +?Linux + my.B() + my.A() +? \ No newline at end of file diff --git a/samples/Grace/ackerman_function.grace b/samples/Grace/ackerman_function.grace new file mode 100644 index 00000000..a79d3c17 --- /dev/null +++ b/samples/Grace/ackerman_function.grace @@ -0,0 +1,6 @@ +method ack (m : Number, n : Number) -> Number { + print "ack {m} {n}" + if (m < = 0) then {n + 1} + elseif {n <= 0} then {ack((m -1), 1)} + else {ack(m -1, ack(m, n-1))} +} \ No newline at end of file diff --git a/samples/Grace/grace_IDE.grace b/samples/Grace/grace_IDE.grace new file mode 100644 index 00000000..f64d898a --- /dev/null +++ b/samples/Grace/grace_IDE.grace @@ -0,0 +1,554 @@ +import "gtk" as gtk +import "io" as io +import "mgcollections" as collections +import "button_factory" as button_factory +import "dialog_factory" as dialog_factory +import "syntax_highlighter" as highlighter +import "auto_completer" as aComp + +//TODO + +// Autocomplete typing + +// FileChooser +// Themes + +// Details for the Top Level Window +def window = gtk.window(gtk.GTK_WINDOW_TOPLEVEL) +window.title := "Grace" +window.set_default_size(700, 700) +// ------------- + +// Placeholder for the console window that can be popped out +// of the main window +var popped := gtk.window(gtk.GTK_WINDOW_TOPLEVEL) + +// Initialise the Boxes +def mBox = gtk.box(gtk.GTK_ORIENTATION_VERTICAL, 2) +def buttonBox = gtk.box(gtk.GTK_ORIENTATION_HORIZONTAL, 2) +var consoleButtons := gtk.box(gtk.GTK_ORIENTATION_HORIZONTAL, 3) +var consoleBox := gtk.box(gtk.GTK_ORIENTATION_VERTICAL, 2) +var editorBox := gtk.box(gtk.GTK_ORIENTATION_VERTICAL, 2) +var splitPane := gtk.paned(gtk.GTK_ORIENTATION_VERTICAL, 2) +def menuBox = gtk.box(gtk.GTK_ORIENTATION_HORIZONTAL, 4) +// ------------- + +// Initialise the buttons +def runButton = button_factory.make("run") +var clearButton := button_factory.make("clear") +var outButton := button_factory.make("out") +var errorButton := button_factory.make("error") +var popButton := button_factory.make("pop") +def newButton = button_factory.make("new") +def openButton = button_factory.make("open") +def saveButton = button_factory.make("save") +def saveAsButton = button_factory.make("saveAs") +def closeButton = button_factory.make("close") +// ------------- + +// Details for the default text editor and scrolled window +var tEdit := gtk.text_view +tEdit.set_size_request(700, 400) + +var scrolled_main := gtk.scrolled_window +scrolled_main.set_size_request(700, 400) +scrolled_main.add(tEdit) +// ------------- + +// Widget that allows multiple files to be edited (tabs) +var notebook := gtk.notebook +notebook.scrollable := true +// ------------- + +// Maps for holding the text_views and scrolled_windows +var editor_map := collections.map.new +editor_map.put(0, tEdit) +var scrolled_map := collections.map.new +scrolled_map.put(0, scrolled_main) + +// ------------- + +// Class that manages the syntax highlighting (This needs to be passed around otherwise +// the text_tag table gets confused, ie there can only be one) +def lighter = highlighter.Syntax_Highlighter.new(notebook, editor_map) +tEdit.buffer.on "changed" do { + lighter.highlightLine +} + +// Class that manages any auto completion that is required +def completer = aComp.Auto_Completer.new(window, notebook, editor_map) + +// Utility methods +// ------------- + +method deleteCompileFiles(page_num : Number) { + def cur_scrolled = scrolled_map.get(page_num) + var filename := notebook.get_tab_label_text(cur_scrolled) + filename := filename.substringFrom(0)to(filename.size - 7) //Removes .grace extension + + io.system("rm -f files/" ++ filename) + io.system("rm -f files/" ++ filename ++ ".c") + io.system("rm -f files/" ++ filename ++ ".gcn") + io.system("rm -f files/" ++ filename ++ ".gct") +} + +// ------------- + + + +var currentConsole := "output" // Which console is being shown +var out := false + + +var outText := "" +var errorText := "" + + + +// Give actions to the buttons +// ------------- + +runButton.on "clicked" do { + clearConsoles() + + // Get the details for the current page selected + def cur_page_num = notebook.current_page + def cur_page = editor_map.get(cur_page_num) + def cur_scrolled = scrolled_map.get(cur_page_num) + def cur_page_label = notebook.get_tab_label_text(cur_scrolled) + + // Initialise text iterators + def sIter = gtk.text_iter + def eIter = gtk.text_iter + + // Set one at the beggining and one at the end of the text + cur_page.buffer.get_iter_at_offset(sIter, 0) + cur_page.buffer.get_iter_at_offset(eIter, -1) + + // Get the text between the text iterators + def text = cur_page.buffer.get_text(sIter, eIter, true) + + // Save the text to the file (in case the user hasn't already saved it) + def file = io.open("files/" ++ cur_page_label, "w") + file.write(text) + file.close + + // Run the program and pipe the output and errors into files to be read + io.system("../minigrace/minigrace " ++ "files/" ++ cur_page_label ++ " > output.txt 2> error.txt") + def outputFile = io.open("output.txt", "r") + def errorFile = io.open("error.txt", "r") + outText := outputFile.read + errorText := errorFile.read + + io.system("rm -f output.txt error.txt") + + var switched := false + + // Change the console to output if there is output text + if((outText.size > 0) && (currentConsole != "output")) then { + switch_to_output() + switched := true + } + // Change the console to errors if there were errors + if((errorText.size > 0) && (currentConsole != "errors")) then { + switch_to_errors() + switched := true + } + + // Remember to populate the console if it wasn't switched + if(!switched) then { + populateConsoles + } +} + +clearButton.on "clicked" do { + clearConsoles() +} + +outButton.on "clicked" do { + switch_to_output() +} + +errorButton.on "clicked" do { + switch_to_errors() +} + +popButton.on "clicked" do { + if(out) then { + popIn() + } else { + popOut() + } +} + +// Gives a dialog to let the user create a new file to edit +newButton.on "clicked" do { + def new_window_class = dialog_factory.new.new(notebook, editor_map, scrolled_map, lighter) + + def new_window = new_window_class.window() + new_window.show_all +} + +// Gives a dialog that lets the user open a file to edit +openButton.on "clicked" do { + def open_window_class = dialog_factory.open.new(notebook, editor_map, scrolled_map, lighter) + + def open_window = open_window_class.window() + open_window.show_all +} + +// Saves the current file (if the name is Untitled.grace it will ask for a new name) +saveButton.on "clicked" do { + def cur_page_num = notebook.current_page + def cur_page = editor_map.get(cur_page_num) + def cur_scrolled = scrolled_map.get(cur_page_num) + def cur_page_label = notebook.get_tab_label_text(cur_scrolled) + + if(cur_page_label == "Untitled.grace") then { + def saveAs_window_class = dialog_factory.save.new(notebook, editor_map, scrolled_map, true) + + def saveAs_window = saveAs_window_class.window() + saveAs_window.show_all + } else { + // Initialise text iterators + def sIter = gtk.text_iter + def eIter = gtk.text_iter + + // Set one at the beggining and one at the end of the text + cur_page.buffer.get_iter_at_offset(sIter, 0) + cur_page.buffer.get_iter_at_offset(eIter, -1) + + // Get the text between the text iterators + def text = cur_page.buffer.get_text(sIter, eIter, true) + + // Save the file + def file = io.open("files/" ++ cur_page_label, "w") + file.write(text) + file.close + } + +} + +// Gives a dialog that lets the user save the file with a new name +saveAsButton.on "clicked" do { + def saveAs_window_class = dialog_factory.save.new(notebook, editor_map, scrolled_map, false) + + def saveAs_window = saveAs_window_class.window() + saveAs_window.show_all +} + +// This will close a tab on the notebook +// It also "removes" the page from the map, +// by creating a new temporary map and putting all but +// the removed page in. +closeButton.on "clicked" do { + def page_num = notebook.current_page + def num_pages = notebook.n_pages + + if(num_pages > 1) then { + deleteCompileFiles(page_num) + + def e_map = collections.map.new + def s_map = collections.map.new + + // Copy every page up to the current page into the new maps + var x := 0 + while {x < page_num} do { + var eValue := editor_map.get(x) + var sValue := scrolled_map.get(x) + e_map.put(x, eValue) + s_map.put(x, sValue) + + x := x + 1 + } + + // Copy every page after the current page into the new map (shifted one down) + x := page_num + 1 + while {x < num_pages} do { + var eValue := editor_map.get(x) + var sValue := scrolled_map.get(x) + e_map.put((x - 1), eValue) + s_map.put((x - 1), sValue) + + x := x + 1 + } + + editor_map := e_map + scrolled_map := s_map + notebook.remove_page(page_num) + + notebook.show_all + } + +} +// ------------- + + + + + + +// Consoles: +// ------------- + +var outConsole := gtk.text_view +var outScroll := gtk.scrolled_window +var errorConsole := gtk.text_view +var errorScroll := gtk.scrolled_window +var errorTag := errorConsole.buffer.create_tag("fixed", "foreground", "red") + + +// Creates a new output console +method createOut { + outConsole := gtk.text_view + outScroll := gtk.scrolled_window + outScroll.add(outConsole) + if(out) then { + outConsole.set_size_request(400, 400) + outScroll.set_size_request(400, 400) + } else { + outConsole.set_size_request(700, 200) + outScroll.set_size_request(700, 200) + } + outConsole.editable := false + outConsole.buffer.set_text("[Output]:", -1) +} +createOut() + +// Creates a new error console +method createError { + errorConsole := gtk.text_view + errorScroll := gtk.scrolled_window + errorScroll.add(errorConsole) + if(out) then { + errorConsole.set_size_request(400, 400) + errorScroll.set_size_request(400, 400) + } else { + errorConsole.set_size_request(700, 200) + errorScroll.set_size_request(700, 200) + } + errorConsole.editable := false + errorConsole.buffer.set_text("[Errors]:", -1) + errorTag := errorConsole.buffer.create_tag("fixed", "foreground", "red") +} +createError() + +// Switches the console being shown to be output. This requires +// the output console to be remade as it would have been destroyed when +// it was switched previously +method switch_to_output { + if(currentConsole != "output") then { + currentConsole := "output" + consoleBox.remove(errorScroll) // This destroys the errorConsole + + createOut() + + consoleBox.add(outScroll) + + populateConsoles() + if(out) then { + popped.show_all + } else { + window.show_all + } + } +} + +// Switches the console being shown to be errors. This requires +// the error console to be remade as it would have been destroyed when +// it was switched previously +method switch_to_errors { + if(currentConsole != "errors") then { + currentConsole := "errors" + consoleBox.remove(outScroll) // This destroys the outConsole + + createError() + + consoleBox.add(errorScroll) + + populateConsoles() + if(out) then { + popped.show_all + } else { + window.show_all + } + } +} + +// If there is text to be put into the consoles this will add it +method populateConsoles { + if((outText.size > 0) && (currentConsole == "output")) then { + outConsole.buffer.set_text(outText, -1) + } + if((errorText.size > 0) && (currentConsole == "errors")) then { + def sIter = gtk.text_iter + def eIter = gtk.text_iter + + errorConsole.buffer.set_text(errorText, -1) + errorConsole.buffer.get_iter_at_offset(sIter, 0) + errorConsole.buffer.get_iter_at_offset(eIter, -1) + errorConsole.buffer.apply_tag(errorTag, sIter, eIter) + } +} + +method clearConsoles { + if(currentConsole == "output") then { + outConsole.buffer.set_text("[Output]:", -1) + outText := "" + } + if(currentConsole == "errors") then { + errorConsole.buffer.set_text("[Errors]:", -1) + errorText := "" + } +} + + +// Identical as the popIn method, but can be connected to the window's destroy button +def popInBlock = { + consoleBox.reparent(splitPane) + popButton.label := "Pop Out" + + if(currentConsole == "output") then { + outConsole.set_size_request(700, 200) + outScroll.set_size_request(700, 200) + } + if(currentConsole == "errors") then { + errorConsole.set_size_request(700, 200) + errorScroll.set_size_request(700, 200) + } + + def cur_page_num = notebook.current_page + def cur_scrolled = scrolled_map.get(cur_page_num) + def cur_page = editor_map.get(cur_page_num) + + cur_page.set_size_request(700, 400) + cur_scrolled.set_size_request(700, 400) + + out := false + popped.visible := false +} + + +// This pops the console out into a separate window +method popOut { + popped := gtk.window(gtk.GTK_WINDOW_TOPLEVEL) + + consoleBox.reparent(popped) + popButton.label := "Pop In" + + if(currentConsole == "output") then { + outConsole.set_size_request(400, 400) + outScroll.set_size_request(400, 400) + } + if(currentConsole == "errors") then { + errorConsole.set_size_request(400, 400) + errorScroll.set_size_request(400, 400) + } + + def cur_page_num = notebook.current_page + def cur_scrolled = scrolled_map.get(cur_page_num) + def cur_page = editor_map.get(cur_page_num) + + cur_page.set_size_request(700, 580) + cur_scrolled.set_size_request(700, 580) + + out := true + popped.visible := true + popped.connect("destroy", popInBlock) + popped.show_all + +} + +// Puts the console back into the main window +method popIn { + consoleBox.reparent(splitPane) + popButton.label := "Pop Out" + + if(currentConsole == "output") then { + outConsole.set_size_request(700, 200) + outScroll.set_size_request(700, 200) + } + if(currentConsole == "errors") then { + errorConsole.set_size_request(700, 200) + errorScroll.set_size_request(700, 200) + } + + def cur_page_num = notebook.current_page + def cur_scrolled = scrolled_map.get(cur_page_num) + def cur_page = editor_map.get(cur_page_num) + + cur_page.set_size_request(700, 400) + cur_scrolled.set_size_request(700, 400) + + out := false + popped.visible := false +} + +clearConsoles() +// ------------- + + + + + + +// Patch everything together + +var hSeparator1 := gtk.separator(gtk.GTK_ORIENTATION_HORIZONTAL) +var hSeparator2 := gtk.separator(gtk.GTK_ORIENTATION_HORIZONTAL) + +menuBox.add(newButton) +menuBox.add(openButton) +menuBox.add(saveButton) +menuBox.add(saveAsButton) +buttonBox.add(runButton) +buttonBox.add(closeButton) + +consoleButtons.add(outButton) +consoleButtons.add(errorButton) +consoleButtons.add(clearButton) +consoleButtons.add(popButton) + +consoleBox.add(hSeparator1) +consoleBox.add(consoleButtons) +consoleBox.add(outScroll) + +editorBox.add(hSeparator2) +notebook.add(scrolled_main) +notebook.set_tab_label_text(scrolled_main, "Untitled.grace") +editorBox.add(notebook) + +splitPane.add1(editorBox) +splitPane.add2(consoleBox) + +mBox.add(menuBox) +mBox.add(buttonBox) +mBox.add(splitPane) + +window.add(mBox) + +def exit = { + var x := 0 + while {x < notebook.n_pages} do { + deleteCompileFiles(x) + + x := x + 1 + } + + // Delete the compile files of the IDE + io.system("rm -f Grace_IDE.gct Grace_IDE.c Grace_IDE.gcn") + io.system("rm -f scanner.gct scanner.c scanner.gcn") + io.system("rm -f syntax_highlighter.gct syntax_highlighter.c syntax_highlighter.gcn") + io.system("rm -f syntax_colors.gct syntax_colors.c syntax_colors.gcn") + io.system("rm -f button_factory.gct button_factory.c button_factory.gcn") + io.system("rm -f dialog_factory.gct dialog_factory.c dialog_factory.gcn") + io.system("rm -f auto_completer.gct auto_completer.c auto_completer.gcn") + + print "Grace IDE Closed Successfully" + gtk.main_quit +} + +window.connect("destroy", exit) +window.show_all + +gtk.main \ No newline at end of file diff --git a/samples/Nit/calculator.nit b/samples/Nit/calculator.nit new file mode 100644 index 00000000..541f4d28 --- /dev/null +++ b/samples/Nit/calculator.nit @@ -0,0 +1,272 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Copyright 2013 Alexis Laferrière +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import gtk + +class CalculatorContext + var result : nullable Float = null + + var last_op : nullable Char = null + + var current : nullable Float = null + var after_point : nullable Int = null + + fun push_op( op : Char ) + do + apply_last_op_if_any + if op == 'C' then + self.result = 0.0 + last_op = null + else + last_op = op # store for next push_op + end + + # prepare next current + after_point = null + current = null + end + + fun push_digit( digit : Int ) + do + var current = current + if current == null then current = 0.0 + + var after_point = after_point + if after_point == null then + current = current * 10.0 + digit.to_f + else + current = current + digit.to_f * 10.0.pow(after_point.to_f) + self.after_point -= 1 + end + + self.current = current + end + + fun switch_to_decimals + do + if self.current == null then current = 0.0 + if after_point != null then return + + after_point = -1 + end + + fun apply_last_op_if_any + do + var op = last_op + + var result = result + if result == null then result = 0.0 + + var current = current + if current == null then current = 0.0 + + if op == null then + result = current + else if op == '+' then + result = result + current + else if op == '-' then + result = result - current + else if op == '/' then + result = result / current + else if op == '*' then + result = result * current + end + self.result = result + self.current = null + end +end + +class CalculatorGui + super GtkCallable + + var win : GtkWindow + var container : GtkGrid + + var lbl_disp : GtkLabel + var but_eq : GtkButton + var but_dot : GtkButton + + var context = new CalculatorContext + + redef fun signal( sender, user_data ) + do + var after_point = context.after_point + if after_point == null then + after_point = 0 + else + after_point = (after_point.abs) + end + + if user_data isa Char then # is an operation + var c = user_data + if c == '.' then + but_dot.sensitive= false + context.switch_to_decimals + lbl_disp.text = "{context.current.to_i}." + else + but_dot.sensitive= true + context.push_op( c ) + + var s = context.result.to_precision_native(6) + var index : nullable Int = null + for i in s.length.times do + var chiffre = s.chars[i] + if chiffre == '0' and index == null then + index = i + else if chiffre != '0' then + index = null + end + end + if index != null then + s = s.substring(0, index) + if s.chars[s.length-1] == ',' then s = s.substring(0, s.length-1) + end + lbl_disp.text = s + end + else if user_data isa Int then # is a number + var n = user_data + context.push_digit( n ) + lbl_disp.text = context.current.to_precision_native(after_point) + end + end + + init + do + init_gtk + + win = new GtkWindow( 0 ) + + container = new GtkGrid(5,5,true) + win.add( container ) + + lbl_disp = new GtkLabel( "_" ) + container.attach( lbl_disp, 0, 0, 5, 1 ) + + # digits + for n in [0..9] do + var but = new GtkButton.with_label( n.to_s ) + but.request_size( 64, 64 ) + but.signal_connect( "clicked", self, n ) + if n == 0 then + container.attach( but, 0, 4, 1, 1 ) + else container.attach( but, (n-1)%3, 3-(n-1)/3, 1, 1 ) + end + + # operators + var r = 1 + for op in ['+', '-', '*', '/' ] do + var but = new GtkButton.with_label( op.to_s ) + but.request_size( 64, 64 ) + but.signal_connect( "clicked", self, op ) + container.attach( but, 3, r, 1, 1 ) + r+=1 + end + + # = + but_eq = new GtkButton.with_label( "=" ) + but_eq.request_size( 64, 64 ) + but_eq.signal_connect( "clicked", self, '=' ) + container.attach( but_eq, 4, 3, 1, 2 ) + + # . + but_dot = new GtkButton.with_label( "." ) + but_dot.request_size( 64, 64 ) + but_dot.signal_connect( "clicked", self, '.' ) + container.attach( but_dot, 1, 4, 1, 1 ) + + #C + var but_c = new GtkButton.with_label( "C" ) + but_c.request_size( 64, 64 ) + but_c.signal_connect("clicked", self, 'C') + container.attach( but_c, 2, 4, 1, 1 ) + + win.show_all + end +end + +# context tests +var context = new CalculatorContext +context.push_digit( 1 ) +context.push_digit( 2 ) +context.push_op( '+' ) +context.push_digit( 3 ) +context.push_op( '*' ) +context.push_digit( 2 ) +context.push_op( '=' ) +var r = context.result.to_precision( 2 ) +assert r == "30.00" else print r + +context = new CalculatorContext +context.push_digit( 1 ) +context.push_digit( 4 ) +context.switch_to_decimals +context.push_digit( 1 ) +context.push_op( '*' ) +context.push_digit( 3 ) +context.push_op( '=' ) +r = context.result.to_precision( 2 ) +assert r == "42.30" else print r + +context.push_op( '+' ) +context.push_digit( 1 ) +context.push_digit( 1 ) +context.push_op( '=' ) +r = context.result.to_precision( 2 ) +assert r == "53.30" else print r + +context = new CalculatorContext +context.push_digit( 4 ) +context.push_digit( 2 ) +context.switch_to_decimals +context.push_digit( 3 ) +context.push_op( '/' ) +context.push_digit( 3 ) +context.push_op( '=' ) +r = context.result.to_precision( 2 ) +assert r == "14.10" else print r + +#test multiple decimals +context = new CalculatorContext +context.push_digit( 5 ) +context.push_digit( 0 ) +context.switch_to_decimals +context.push_digit( 1 ) +context.push_digit( 2 ) +context.push_digit( 3 ) +context.push_op( '+' ) +context.push_digit( 1 ) +context.push_op( '=' ) +r = context.result.to_precision( 3 ) +assert r == "51.123" else print r + +#test 'C' button +context = new CalculatorContext +context.push_digit( 1 ) +context.push_digit( 0 ) +context.push_op( '+' ) +context.push_digit( 1 ) +context.push_digit( 0 ) +context.push_op( '=' ) +context.push_op( 'C' ) +r = context.result.to_precision( 1 ) +assert r == "0.0" else print r + +# graphical application + +if "NIT_TESTING".environ != "true" then + var app = new CalculatorGui + run_gtk +end diff --git a/samples/Nit/callback_chimpanze.nit b/samples/Nit/callback_chimpanze.nit new file mode 100644 index 00000000..2ca8dc3a --- /dev/null +++ b/samples/Nit/callback_chimpanze.nit @@ -0,0 +1,45 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Copyright 2013 Matthieu Lucas +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This sample has been implemented to show you how simple is it to play +# with native callbacks (C) through an high level with NIT program. + +module callback_chimpanze +import callback_monkey + +class Chimpanze + super MonkeyActionCallable + + fun create + do + var monkey = new Monkey + print "Hum, I'm sleeping ..." + # Invoking method which will take some time to compute, and + # will be back in wokeUp method with information. + # - Callback method defined in MonkeyActionCallable Interface + monkey.wokeUpAction(self, "Hey, I'm awake.") + end + + # Inherit callback method, defined by MonkeyActionCallable interface + # - Back of wokeUpAction method + redef fun wokeUp( sender:Monkey, message:Object ) + do + print message + end +end + +var m = new Chimpanze +m.create diff --git a/samples/Nit/callback_monkey.nit b/samples/Nit/callback_monkey.nit new file mode 100644 index 00000000..6e1ed262 --- /dev/null +++ b/samples/Nit/callback_monkey.nit @@ -0,0 +1,92 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Copyright 2013 Matthieu Lucas +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This sample has been implemented to show you how simple is it to play +# with native callbacks (C) through an high level with NIT program. + +module callback_monkey + +in "C header" `{ + #include + #include + + typedef struct { + int id; + int age; + } CMonkey; + + typedef struct { + MonkeyActionCallable toCall; + Object message; + } MonkeyAction; +`} + +in "C body" `{ + // Method which reproduce a callback answer + // Please note that a function pointer is only used to reproduce the callback + void cbMonkey(CMonkey *mkey, void callbackFunc(CMonkey*, MonkeyAction*), MonkeyAction *data) + { + sleep(2); + callbackFunc( mkey, data ); + } + + // Back of background treatment, will be redirected to callback function + void nit_monkey_callback_func( CMonkey *mkey, MonkeyAction *data ) + { + // To call a your method, the signature must be written like this : + // _... + MonkeyActionCallable_wokeUp( data->toCall, mkey, data->message ); + } +`} + +# Implementable interface to get callback in defined methods +interface MonkeyActionCallable + fun wokeUp( sender:Monkey, message: Object) is abstract +end + +# Defining my object type Monkey, which is, in a low level, a pointer to a C struct (CMonkey) +extern class Monkey `{ CMonkey * `} + + new `{ + CMonkey *monkey = malloc( sizeof(CMonkey) ); + monkey->age = 10; + monkey->id = 1; + return monkey; + `} + + # Object method which will get a callback in wokeUp method, defined in MonkeyActionCallable interface + # Must be defined as Nit/C method because of C call inside + fun wokeUpAction( toCall: MonkeyActionCallable, message: Object ) is extern import MonkeyActionCallable.wokeUp `{ + + // Allocating memory to keep reference of received parameters : + // - Object receiver + // - Message + MonkeyAction *data = malloc( sizeof(MonkeyAction) ); + + // Incrementing reference counter to prevent from releasing + MonkeyActionCallable_incr_ref( toCall ); + Object_incr_ref( message ); + + data->toCall = toCall; + data->message = message; + + // Calling method which reproduce a callback by passing : + // - Receiver + // - Function pointer to object return method + // - Datas + cbMonkey( recv, &nit_monkey_callback_func, data ); + `} +end diff --git a/samples/Nit/circular_list.nit b/samples/Nit/circular_list.nit new file mode 100644 index 00000000..c3ba1edb --- /dev/null +++ b/samples/Nit/circular_list.nit @@ -0,0 +1,167 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Implementation of circular lists +# This example shows the usage of generics and somewhat a specialisation of collections. +module circular_list + +# Sequences of elements implemented with a double-linked circular list +class CircularList[E] + # Like standard Array or LinkedList, CircularList is a Sequence. + super Sequence[E] + + # The first node of the list if any + # The special case of an empty list is handled by a null node + private var node: nullable CLNode[E] = null + + redef fun iterator do return new CircularListIterator[E](self) + + redef fun first do return self.node.item + + redef fun push(e) + do + var new_node = new CLNode[E](e) + var n = self.node + if n == null then + # the first node + self.node = new_node + else + # not the first one, so attach nodes correctly. + var old_last_node = n.prev + new_node.next = n + new_node.prev = old_last_node + old_last_node.next = new_node + n.prev = new_node + end + end + + redef fun pop + do + var n = self.node + assert n != null + var prev = n.prev + if prev == n then + # the only node + self.node = null + return n.item + end + # not the only one do detach nodes correctly. + var prev_prev = prev.prev + n.prev = prev_prev + prev_prev.next = n + return prev.item + end + + redef fun unshift(e) + do + # Circularity has benefits. + push(e) + self.node = self.node.prev + end + + redef fun shift + do + # Circularity has benefits. + self.node = self.node.next + return self.pop + end + + # Move the first at the last position, the second at the first, etc. + fun rotate + do + var n = self.node + if n == null then return + self.node = n.next + end + + # Sort the list using the Josephus algorithm. + fun josephus(step: Int) + do + var res = new CircularList[E] + while not self.is_empty do + # count 'step' + for i in [1..step[ do self.rotate + # kill + var x = self.shift + res.add(x) + end + self.node = res.node + end +end + +# Nodes of a CircularList +private class CLNode[E] + # The current item + var item: E + + # The next item in the circular list. + # Because of circularity, there is always a next; + # so by default let it be self + var next: CLNode[E] = self + + # The previous item in the circular list. + # Coherence between next and previous nodes has to be maintained by the + # circular list. + var prev: CLNode[E] = self +end + +# An iterator of a CircularList. +private class CircularListIterator[E] + super IndexedIterator[E] + + redef var index: Int + + # The current node pointed. + # Is null if the list is empty. + var node: nullable CLNode[E] + + # The list iterated. + var list: CircularList[E] + + redef fun is_ok + do + # Empty lists are not OK. + # Pointing again the first node is not OK. + return self.node != null and (self.index == 0 or self.node != self.list.node) + end + + redef fun next + do + self.node = self.node.next + self.index += 1 + end + + redef fun item do return self.node.item + + init(list: CircularList[E]) + do + self.node = list.node + self.list = list + self.index = 0 + end +end + +var i = new CircularList[Int] +i.add_all([1, 2, 3, 4, 5, 6, 7]) +print i.first +print i.join(":") + +i.push(8) +print i.shift +print i.pop +i.unshift(0) +print i.join(":") + +i.josephus(3) +print i.join(":") diff --git a/samples/Nit/clock.nit b/samples/Nit/clock.nit new file mode 100644 index 00000000..8fdb9abd --- /dev/null +++ b/samples/Nit/clock.nit @@ -0,0 +1,78 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This module provide a simple wall clock. +# It is an example of getters and setters. +# A beefed-up module is available in clock_more +module clock + +# A simple wall clock with 60 minutes and 12 hours. +class Clock + # total number of minutes from 0 to 719 + var total_minutes: Int + # Note: only the read acces is public, the write access is private. + + # number of minutes in the current hour (from 0 to 59) + fun minutes: Int do return self.total_minutes % 60 + + # set the number of minutes in the current hour. + # if m < 0 or m >= 60, the hour will be changed accordinlgy + fun minutes=(m: Int) do self.total_minutes = self.hours * 60 + m + + # number of hours (from 0 to 11) + fun hours: Int do return self.total_minutes / 60 + + # set the number of hours + # the minutes will not be updated + fun hours=(h: Int) do self.total_minutes = h * 60 + minutes + + # the position of the hour arrow in the [0..60[ interval + fun hour_pos: Int do return total_minutes / 12 + + # replace the arrow of hours (from 0 to 59). + # the hours and the minutes will be updated. + fun hour_pos=(h: Int) do self.total_minutes = h * 12 + + redef fun to_s do return "{hours}:{minutes}" + + fun reset(hours, minutes: Int) do self.total_minutes = hours*60 + minutes + + init(hours, minutes: Int) do self.reset(hours, minutes) + + redef fun ==(o) + do + # Note: o is a nullable Object, a type test is required + # Thanks to adaptive typing, there is no downcast + # i.e. the code is safe! + return o isa Clock and self.total_minutes == o.total_minutes + end +end + +var c = new Clock(10,50) +print "It's {c} o'clock." + +c.minutes += 22 +print "Now it's {c} o'clock." + +print "The short arrow in on the {c.hour_pos/5} and the long arrow in on the {c.minutes/5}." + +c.hours -= 2 +print "Now it's {c} o'clock." + +var c2 = new Clock(9, 11) +print "It's {c2} on the second clock." +print "The two clocks are synchronized: {c == c2}." +c2.minutes += 1 +print "It's now {c2} on the second clock." +print "The two clocks are synchronized: {c == c2}." diff --git a/samples/Nit/clock_more.nit b/samples/Nit/clock_more.nit new file mode 100644 index 00000000..d2ef89e2 --- /dev/null +++ b/samples/Nit/clock_more.nit @@ -0,0 +1,60 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This module beef up the clock module by allowing a clock to be comparable. +# It show the usage of class refinement +module clock_more + +import clock + +redef class Clock + # Clock are now comparable + super Comparable + + # Comparaison of a clock make only sense with an other clock + redef type OTHER: Clock + + redef fun <(o) + do + # Note: < is the only abstract method of Comparable. + # All other operators and methods rely on < and ==. + return self.total_minutes < o.total_minutes + end +end + +var c1 = new Clock(8, 12) +var c2 = new Clock(8, 13) +var c3 = new Clock(9, 13) + +print "{c1}<{c2}? {c1{c2}? {c1>c2}" +print "{c1}>={c2}? {c1>=c2}" +print "{c1}<=>{c2}? {c1<=>c2}" +print "{c1},{c2}? max={c1.max(c2)} min={c1.min(c2)}" +print "{c1}.is_between({c2}, {c3})? {c1.is_between(c2, c3)}" +print "{c2}.is_between({c1}, {c3})? {c2.is_between(c1, c3)}" + +print "-" + +c1.minutes += 1 + +print "{c1}<{c2}? {c1{c2}? {c1>c2}" +print "{c1}>={c2}? {c1>=c2}" +print "{c1}<=>{c2}? {c1<=>c2}" +print "{c1},{c2}? max={c1.max(c2)} min={c1.min(c2)}" +print "{c1}.is_between({c2}, {c3})? {c1.is_between(c2, c3)}" +print "{c2}.is_between({c1}, {c3})? {c2.is_between(c1, c3)}" diff --git a/samples/Nit/curl_http.nit b/samples/Nit/curl_http.nit new file mode 100644 index 00000000..079f12c8 --- /dev/null +++ b/samples/Nit/curl_http.nit @@ -0,0 +1,113 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Copyright 2013 Matthieu Lucas +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Sample of the Curl module. +module curl_http + +import curl + +# Small class to represent an Http Fetcher +class MyHttpFetcher + super CurlCallbacks + + var curl: Curl + var our_body: String = "" + + init(curl: Curl) do self.curl = curl + + # Release curl object + fun destroy do self.curl.destroy + + # Header callback + redef fun header_callback(line: String) do + # We keep this callback silent for testing purposes + #if not line.has_prefix("Date:") then print "Header_callback : {line}" + end + + # Body callback + redef fun body_callback(line: String) do self.our_body = "{self.our_body}{line}" + + # Stream callback - Cf : No one is registered + redef fun stream_callback(buffer: String, size: Int, count: Int) do print "Stream_callback : {buffer} - {size} - {count}" +end + + +# Program +if args.length < 2 then + print "Usage: curl_http " +else + var curl = new Curl + var url = args[1] + var request = new CurlHTTPRequest(url, curl) + + # HTTP Get Request + if args[0] == "GET" then + request.verbose = false + var getResponse = request.execute + + if getResponse isa CurlResponseSuccess then + print "Status code : {getResponse.status_code}" + print "Body : {getResponse.body_str}" + else if getResponse isa CurlResponseFailed then + print "Error code : {getResponse.error_code}" + print "Error msg : {getResponse.error_msg}" + end + + # HTTP Post Request + else if args[0] == "POST" then + var myHttpFetcher = new MyHttpFetcher(curl) + request.delegate = myHttpFetcher + + var postDatas = new HeaderMap + postDatas["Bugs Bunny"] = "Daffy Duck" + postDatas["Batman"] = "Robin likes special characters @#ùà!è§'(\"é&://,;<>∞~*" + postDatas["Batman"] = "Yes you can set multiple identical keys, but APACHE will consider only once, the last one" + request.datas = postDatas + request.verbose = false + var postResponse = request.execute + + print "Our body from the callback : {myHttpFetcher.our_body}" + + if postResponse isa CurlResponseSuccess then + print "*** Answer ***" + print "Status code : {postResponse.status_code}" + print "Body should be empty, because we decided to manage callbacks : {postResponse.body_str.length}" + else if postResponse isa CurlResponseFailed then + print "Error code : {postResponse.error_code}" + print "Error msg : {postResponse.error_msg}" + end + + # HTTP Get to file Request + else if args[0] == "GET_FILE" then + var headers = new HeaderMap + headers["Accept"] = "Moo" + request.headers = headers + request.verbose = false + var downloadResponse = request.download_to_file(null) + + if downloadResponse isa CurlFileResponseSuccess then + print "*** Answer ***" + print "Status code : {downloadResponse.status_code}" + print "Size downloaded : {downloadResponse.size_download}" + else if downloadResponse isa CurlResponseFailed then + print "Error code : {downloadResponse.error_code}" + print "Error msg : {downloadResponse.error_msg}" + end + # Program logic + else + print "Usage : Method[POST, GET, GET_FILE]" + end +end diff --git a/samples/Nit/curl_mail.nit b/samples/Nit/curl_mail.nit new file mode 100644 index 00000000..b28f5a4c --- /dev/null +++ b/samples/Nit/curl_mail.nit @@ -0,0 +1,59 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Copyright 2013 Matthieu Lucas +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Mail sender sample using the Curl module +module curl_mail + +import curl + +var curl = new Curl +var mail_request = new CurlMailRequest(curl) + +# Networks +var response = mail_request.set_outgoing_server("smtps://smtp.example.org:465", "user@example.org", "mypassword") +if response isa CurlResponseFailed then + print "Error code : {response.error_code}" + print "Error msg : {response.error_msg}" +end + +# Headers +mail_request.from = "Billy Bob" +mail_request.to = ["user@example.org"] +mail_request.cc = ["bob@example.org"] +mail_request.bcc = null + +var headers_body = new HeaderMap +headers_body["Content-Type:"] = "text/html; charset=\"UTF-8\"" +headers_body["Content-Transfer-Encoding:"] = "quoted-printable" +mail_request.headers_body = headers_body + +# Content +mail_request.body = "

Here you can write HTML stuff.

" +mail_request.subject = "Hello From My Nit Program" + +# Others +mail_request.verbose = false + +# Send mail +response = mail_request.execute +if response isa CurlResponseFailed then + print "Error code : {response.error_code}" + print "Error msg : {response.error_msg}" +else if response isa CurlMailResponseSuccess then + print "Mail Sent" +else + print "Unknown Curl Response type" +end diff --git a/samples/Nit/draw_operation.nit b/samples/Nit/draw_operation.nit new file mode 100644 index 00000000..cada8318 --- /dev/null +++ b/samples/Nit/draw_operation.nit @@ -0,0 +1,243 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Copyright 2012-2013 Alexis Laferrière +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Draws an arithmetic operation to the terminal +module draw_operation + +redef enum Int + fun n_chars: Int `{ + int c; + if ( abs(recv) >= 10 ) + c = 1+(int)log10f( (float)abs(recv) ); + else + c = 1; + if ( recv < 0 ) c ++; + return c; + `} +end + +redef enum Char + fun as_operator(a, b: Int): Int + do + if self == '+' then return a + b + if self == '-' then return a - b + if self == '*' then return a * b + if self == '/' then return a / b + if self == '%' then return a % b + abort + end + + fun override_dispc: Bool + do + return self == '+' or self == '-' or self == '*' or self == '/' or self == '%' + end + + fun lines(s: Int): Array[Line] + do + if self == '+' then + return [new Line(new P(0,s/2),1,0,s), new Line(new P(s/2,1),0,1,s-2)] + else if self == '-' then + return [new Line(new P(0,s/2),1,0,s)] + else if self == '*' then + var lines = new Array[Line] + for y in [1..s-1[ do + lines.add( new Line(new P(1,y), 1,0,s-2) ) + end + return lines + else if self == '/' then + return [new Line(new P(s-1,0), -1,1, s )] + else if self == '%' then + var q4 = s/4 + var lines = [new Line(new P(s-1,0),-1,1,s)] + for l in [0..q4[ do + lines.append([ new Line( new P(0,l), 1,0,q4), new Line( new P(s-1,s-1-l), -1,0,q4) ]) + end + return lines + else if self == '1' then + return [new Line(new P(s/2,0), 0,1,s),new Line(new P(0,s-1),1,0,s), + new Line( new P(s/2,0),-1,1,s/2)] + else if self == '2' then + return [new Line(new P(0,0), 1,0,s),new Line(new P(s-1,0),0,1,s/2), + new Line( new P(0,s-1),1,0,s), new Line( new P(0,s/2), 0,1,s/2), + new Line( new P(0,s/2), 1,0,s)] + else if self == '3' then + return [new Line(new P(0,0), 1,0,s),new Line(new P(s-1,0),0,1,s), + new Line( new P(0,s-1),1,0,s), new Line( new P(0,s/2), 1,0,s)] + else if self == '4' then + return [new Line(new P(s-1,0),0,1,s), new Line( new P(0,0), 0,1,s/2), + new Line( new P(0,s/2), 1,0,s)] + else if self == '5' then + return [new Line(new P(0,0), 1,0,s),new Line(new P(s-1,s/2),0,1,s/2), + new Line( new P(0,s-1),1,0,s), new Line( new P(0,0), 0,1,s/2), + new Line( new P(0,s/2), 1,0,s)] + else if self == '6' then + return [new Line(new P(0,0), 1,0,s),new Line(new P(s-1,s/2),0,1,s/2), + new Line( new P(0,s-1),1,0,s), new Line( new P(0,0), 0,1,s), + new Line( new P(0,s/2), 1,0,s)] + else if self == '7' then + var tl = new P(0,0) + var tr = new P(s-1,0) + return [new Line(tl, 1,0,s), new Line(tr,-1,1,s)] + else if self == '8' then + return [new Line(new P(0,0), 1,0,s),new Line(new P(s-1,0),0,1,s), + new Line( new P(0,s-1),1,0,s), new Line( new P(0,0), 0,1,s), + new Line( new P(0,s/2), 1,0,s)] + else if self == '9' then + return [new Line(new P(0,0), 1,0,s),new Line(new P(s-1,0),0,1,s), + new Line( new P(0,s-1),1,0,s), new Line( new P(0,0), 0,1,s/2), + new Line( new P(0,s/2), 1,0,s)] + else if self == '0' then + return [new Line(new P(0,0), 1,0,s),new Line(new P(s-1,0),0,1,s), + new Line( new P(0,s-1),1,0,s), new Line( new P(0,0), 0,1,s)] + end + return new Array[Line] + end +end + +class P + var x : Int + var y : Int +end + +redef class String + # hack is to support a bug in the evaluation software + fun draw(dispc: Char, size, gap: Int, hack: Bool) + do + var w = size * length +(length-1)*gap + var h = size + var map = new Array[Array[Char]] + for x in [0..w[ do + map[x] = new Array[Char].filled_with( ' ', h ) + end + + var ci = 0 + for c in self.chars do + var local_dispc + if c.override_dispc then + local_dispc = c + else + local_dispc = dispc + end + + var lines = c.lines( size ) + for line in lines do + var x = line.o.x+ci*size + x += ci*gap + var y = line.o.y + for s in [0..line.len[ do + assert map.length > x and map[x].length > y else print "setting {x},{y} as {local_dispc}" + map[x][y] = local_dispc + x += line.step_x + y += line.step_y + end + end + + ci += 1 + end + + if hack then + for c in [0..size[ do + map[c][0] = map[map.length-size+c][0] + map[map.length-size+c][0] = ' ' + end + end + + for y in [0..h[ do + for x in [0..w[ do + printn map[x][y] + end + print "" + end + end +end + +class Line + var o : P + var step_x : Int + var step_y : Int + var len : Int +end + +var a +var b +var op_char +var disp_char +var disp_size +var disp_gap + +if "NIT_TESTING".environ == "true" then + a = 567 + b = 13 + op_char = '*' + disp_char = 'O' + disp_size = 8 + disp_gap = 1 +else + printn "Left operand: " + a = gets.to_i + + printn "Right operand: " + b = gets.to_i + + printn "Operator (+, -, *, /, %): " + op_char = gets.chars[0] + + printn "Char to display: " + disp_char = gets.chars[0] + + printn "Size of text: " + disp_size = gets.to_i + + printn "Space between digits: " + disp_gap = gets.to_i +end + +var result = op_char.as_operator( a, b ) + +var len_a = a.n_chars +var len_b = b.n_chars +var len_res = result.n_chars +var max_len = len_a.max( len_b.max( len_res ) ) + 1 + +# draw first line +var d = max_len - len_a +var line_a = "" +for i in [0..d[ do line_a += " " +line_a += a.to_s +line_a.draw( disp_char, disp_size, disp_gap, false ) + +print "" +# draw second line +d = max_len - len_b-1 +var line_b = op_char.to_s +for i in [0..d[ do line_b += " " +line_b += b.to_s +line_b.draw( disp_char, disp_size, disp_gap, false ) + +# draw ----- +print "" +for i in [0..disp_size*max_len+(max_len-1)*disp_gap] do + printn "_" +end +print "" +print "" + +# draw result +d = max_len - len_res +var line_res = "" +for i in [0..d[ do line_res += " " +line_res += result.to_s +line_res.draw( disp_char, disp_size, disp_gap, false ) diff --git a/samples/Nit/drop_privileges.nit b/samples/Nit/drop_privileges.nit new file mode 100644 index 00000000..932a87be --- /dev/null +++ b/samples/Nit/drop_privileges.nit @@ -0,0 +1,46 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Copyright 2013 Alexis Laferrière +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Example using the privileges module to drop privileges from root +module drop_privileges + +import privileges + +# basic command line options +var opts = new OptionContext +var opt_ug = new OptionUserAndGroup.for_dropping_privileges +opt_ug.mandatory = true +opts.add_option(opt_ug) + +# parse and check command line options +opts.parse(args) +if not opts.errors.is_empty then + print opts.errors + print "Usage: drop_privileges [options]" + opts.usage + exit 1 +end + +# original user +print "before {sys.uid}:{sys.gid}" + +# make the switch +var user_group = opt_ug.value +assert user_group != null +user_group.drop_privileges + +# final user +print "after {sys.uid}:{sys.egid}" diff --git a/samples/Nit/extern_methods.nit b/samples/Nit/extern_methods.nit new file mode 100644 index 00000000..00c6b684 --- /dev/null +++ b/samples/Nit/extern_methods.nit @@ -0,0 +1,69 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Copyright 2012-2013 Alexis Laferrière +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This module illustrates some uses of the FFI, specifically +# how to use extern methods. Which means to implement a Nit method in C. +module extern_methods + +redef enum Int + # Returns self'th fibonnaci number + # implemented here in C for optimization purposes + fun fib : Int import fib `{ + if ( recv < 2 ) + return recv; + else + return Int_fib( recv-1 ) + Int_fib( recv-2 ); + `} + + # System call to sleep for "self" seconds + fun sleep `{ + sleep( recv ); + `} + + # Return atan2l( self, x ) from libmath + fun atan_with( x : Int ) : Float `{ + return atan2( recv, x ); + `} + + # This method callback to Nit methods from C code + # It will use from C code: + # * the local fib method + # * the + operator, a method of Int + # * to_s, a method of all objects + # * String.to_cstring, a method of String to return an equivalent char* + fun foo import fib, +, to_s, String.to_cstring `{ + long recv_fib = Int_fib( recv ); + long recv_plus_fib = Int__plus( recv, recv_fib ); + + String nit_string = Int_to_s( recv_plus_fib ); + char *c_string = String_to_cstring( nit_string ); + + printf( "from C: self + fib(self) = %s\n", c_string ); + `} + + # Equivalent to foo but written in pure Nit + fun bar do print "from Nit: self + fib(self) = {self+self.fib}" +end + +print 12.fib + +print "sleeping 1 second..." +1.sleep + +print 100.atan_with( 200 ) +8.foo +8.bar + diff --git a/samples/Nit/fibonacci.nit b/samples/Nit/fibonacci.nit new file mode 100644 index 00000000..e1a72c9e --- /dev/null +++ b/samples/Nit/fibonacci.nit @@ -0,0 +1,43 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Copyright 2004-2008 Jean Privat +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A simple exemple of refinement where a method is added to the integer class. +module fibonacci + +redef class Int + # Calculate the self-th element of the fibonacci sequence. + fun fibonacci: Int + do + if self < 2 then + return 1 + else + return (self-2).fibonacci + (self-1).fibonacci + end + end +end + +# Print usage and exit. +fun usage +do + print "Usage: fibonnaci " + exit 0 +end + +# Main part +if args.length != 1 then + usage +end +print args.first.to_i.fibonacci diff --git a/samples/Nit/hello_world.nit b/samples/Nit/hello_world.nit new file mode 100644 index 00000000..da6849ae --- /dev/null +++ b/samples/Nit/hello_world.nit @@ -0,0 +1 @@ +print "hello world" diff --git a/samples/Nit/html_page.nit b/samples/Nit/html_page.nit new file mode 100644 index 00000000..cf76665d --- /dev/null +++ b/samples/Nit/html_page.nit @@ -0,0 +1,105 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import html + +class NitHomepage + super HTMLPage + + redef fun head do + add("meta").attr("charset", "utf-8") + add("title").text("Nit") + add("link").attr("rel", "icon").attr("href", "http://nitlanguage.org/favicon.ico").attr("type", "image/x-icon") + add("link").attr("rel", "stylesheet").attr("href", "http://nitlanguage.org/style.css").attr("type", "text/css") + add("link").attr("rel", "stylesheet").attr("href", "http://nitlanguage.org/local.css").attr("type", "text/css") + end + + redef fun body do + open("article").add_class("page") + open("section").add_class("pageheader") + add_html("theNitProgramming Language") + open("header").add_class("header") + open("div").add_class("topsubtitle") + add("p").text("A Fun Language for Serious Programming") + close("div") + close("header") + close("section") + + open("div").attr("id", "pagebody") + open("section").attr("id", "content") + add("h1").text("# What is Nit?") + add("p").text("Nit is an object-oriented programming language. The goal of Nit is to propose a robust statically typed programming language where structure is not a pain.") + add("p").text("So, what does the famous hello world program look like, in Nit?") + add_html("
print 'Hello, World!'
") + + add("h1").text("# Feature Highlights") + add("h2").text("Usability") + add("p").text("Nit's goal is to be usable by real programmers for real projects") + + open("ul") + open("li") + add("a").attr("href", "http://en.wikipedia.org/wiki/KISS_principle").text("KISS principle") + close("li") + add("li").text("Script-like language without verbosity nor cryptic statements") + add("li").text("Painless static types: static typing should help programmers") + add("li").text("Efficient development, efficient execution, efficient evolution.") + close("ul") + + add("h2").text("Robustness") + add("p").text("Nit will help you to write bug-free programs") + + open("ul") + add("li").text("Strong static typing") + add("li").text("No more NullPointerException") + close("ul") + + add("h2").text("Object-Oriented") + add("p").text("Nit's guideline is to follow the most powerful OO principles") + + open("ul") + open("li") + add("a").attr("href", "./everything_is_an_object/").text("Everything is an object") + close("li") + open("li") + add("a").attr("href", "./multiple_inheritance/").text("Multiple inheritance") + close("li") + open("li") + add("a").attr("href", "./refinement/").text("Open classes") + close("li") + open("li") + add("a").attr("href", "./virtual_types/").text("Virtual types") + close("li") + close("ul") + + + add("h1").text("# Getting Started") + add("p").text("Get Nit from its Git repository:") + + add_html("
$ git clone http://nitlanguage.org/nit.git
") + add("p").text("Build the compiler (may be long):") + add_html("
$ cd nit\n")
+					add_html("$ make
") + add("p").text("Compile a program:") + add_html("
$ bin/nitc examples/hello_world.nit
") + add("p").text("Execute the program:") + add_html("
$ ./hello_world
") + close("section") + close("div") + close("article") + end +end + +var page = new NitHomepage +page.write_to stdout +page.write_to_file("nit.html") diff --git a/samples/Nit/int_stack.nit b/samples/Nit/int_stack.nit new file mode 100644 index 00000000..1109bbbc --- /dev/null +++ b/samples/Nit/int_stack.nit @@ -0,0 +1,100 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# An example that defines and uses stacks of integers. +# The implementation is done with a simple linked list. +# It features: free constructors, nullable types and some adaptive typing. +module int_stack + +# A stack of integer implemented by a simple linked list. +# Note that this is only a toy class since a real linked list will gain to use +# generics and extends interfaces, like Collection, from the standard library. +class IntStack + # The head node of the list. + # Null means that the stack is empty. + private var head: nullable ISNode = null + + # Add a new integer in the stack. + fun push(val: Int) + do + self.head = new ISNode(val, self.head) + end + + # Remove and return the last pushed integer. + # Return null if the stack is empty. + fun pop: nullable Int + do + var head = self.head + if head == null then return null + # Note: the followings are statically safe because of the + # previous 'if'. + var val = head.val + self.head = head.next + return val + end + + # Return the sum of all integers of the stack. + # Return 0 if the stack is empty. + fun sumall: Int + do + var sum = 0 + var cur = self.head + while cur != null do + # Note: the followings are statically safe because of + # the condition of the 'while'. + sum += cur.val + cur = cur.next + end + return sum + end + + # Note: Because all attributes have a default value, a free constructor + # "init()" is implicitly defined. +end + +# A node of a IntStack +private class ISNode + # The integer value stored in the node. + var val: Int + + # The next node, if any. + var next: nullable ISNode + + # Note: A free constructor "init(val: Int, next: nullable ISNode)" is + # implicitly defined. +end + +var l = new IntStack +l.push(1) +l.push(2) +l.push(3) + +print l.sumall + +# Note: the 'for' control structure cannot be used on IntStack in its current state. +# It requires a more advanced topic. +# However, why not using the 'loop' control structure? +loop + var i = l.pop + if i == null then break + # The following is statically safe because of the previous 'if'. + print i * 10 +end + +# Note: 'or else' is used to give an alternative of a null expression. +l.push(5) +print l.pop or else 0 # l.pop gives 5, so print 5 +print l.pop or else 0 # l.pop gives null, so print the alternative: 0 + + diff --git a/samples/Nit/opengles2_hello_triangle.nit b/samples/Nit/opengles2_hello_triangle.nit new file mode 100644 index 00000000..2b39b1ba --- /dev/null +++ b/samples/Nit/opengles2_hello_triangle.nit @@ -0,0 +1,193 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Copyright 2014 Alexis Laferrière +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Basic example of OpenGL ES 2.0 usage from the book OpenGL ES 2.0 Programming Guide. +# +# Code reference: +# https://code.google.com/p/opengles-book-samples/source/browse/trunk/LinuxX11/Chapter_2/Hello_Triangle/Hello_Triangle.c +module opengles2_hello_triangle + +import glesv2 +import egl +import mnit_linux # for sdl +import x11 + +if "NIT_TESTING".environ == "true" then exit(0) + +var window_width = 800 +var window_height = 600 + +# +## SDL +# +var sdl_display = new SDLDisplay(window_width, window_height) +var sdl_wm_info = new SDLSystemWindowManagerInfo +var x11_window_handle = sdl_wm_info.x11_window_handle + +# +## X11 +# +var x_display = x_open_default_display +assert x_display != 0 else print "x11 fail" + +# +## EGL +# +var egl_display = new EGLDisplay(x_display) +assert egl_display.is_valid else print "EGL display is not valid" +egl_display.initialize + +print "EGL version: {egl_display.version}" +print "EGL vendor: {egl_display.vendor}" +print "EGL extensions: {egl_display.extensions.join(", ")}" +print "EGL client APIs: {egl_display.client_apis.join(", ")}" + +assert egl_display.is_valid else print egl_display.error + +var config_chooser = new EGLConfigChooser +#config_chooser.surface_type_egl +config_chooser.blue_size = 8 +config_chooser.green_size = 8 +config_chooser.red_size = 8 +#config_chooser.alpha_size = 8 +#config_chooser.depth_size = 8 +#config_chooser.stencil_size = 8 +#config_chooser.sample_buffers = 1 +config_chooser.close + +var configs = config_chooser.choose(egl_display) +assert configs != null else print "choosing config failed: {egl_display.error}" +assert not configs.is_empty else print "no EGL config" + +print "{configs.length} EGL configs available" +for config in configs do + var attribs = config.attribs(egl_display) + print "* caveats: {attribs.caveat}" + print " conformant to: {attribs.conformant}" + print " size of RGBA: {attribs.red_size} {attribs.green_size} {attribs.blue_size} {attribs.alpha_size}" + print " buffer, depth, stencil: {attribs.buffer_size} {attribs.depth_size} {attribs.stencil_size}" +end + +var config = configs.first + +var format = config.attribs(egl_display).native_visual_id + +# TODO android part +# Opengles1Display_midway_init(recv, format); + +var surface = egl_display.create_window_surface(config, x11_window_handle, [0]) +assert surface.is_ok else print egl_display.error + +var context = egl_display.create_context(config) +assert context.is_ok else print egl_display.error + +var make_current_res = egl_display.make_current(surface, surface, context) +assert make_current_res + +var width = surface.attribs(egl_display).width +var height = surface.attribs(egl_display).height +print "Width: {width}" +print "Height: {height}" + +assert egl_bind_opengl_es_api else print "eglBingAPI failed: {egl_display.error}" + +# +## GLESv2 +# + +print "Can compile shaders? {gl_shader_compiler}" +assert_no_gl_error + +assert gl_shader_compiler else print "Cannot compile shaders" + +# gl program +print gl_error.to_s +var program = new GLProgram +if not program.is_ok then + print "Program is not ok: {gl_error.to_s}\nLog:" + print program.info_log + abort +end +assert_no_gl_error + +# vertex shader +var vertex_shader = new GLVertexShader +assert vertex_shader.is_ok else print "Vertex shader is not ok: {gl_error}" +vertex_shader.source = """ +attribute vec4 vPosition; +void main() +{ + gl_Position = vPosition; +} """ +vertex_shader.compile +assert vertex_shader.is_compiled else print "Vertex shader compilation failed with: {vertex_shader.info_log} {program.info_log}" +assert_no_gl_error + +# fragment shader +var fragment_shader = new GLFragmentShader +assert fragment_shader.is_ok else print "Fragment shader is not ok: {gl_error}" +fragment_shader.source = """ +precision mediump float; +void main() +{ + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); +} +""" +fragment_shader.compile +assert fragment_shader.is_compiled else print "Fragment shader compilation failed with: {fragment_shader.info_log}" +assert_no_gl_error + +program.attach_shader vertex_shader +program.attach_shader fragment_shader +program.bind_attrib_location(0, "vPosition") +program.link +assert program.is_linked else print "Linking failed: {program.info_log}" +assert_no_gl_error + +# draw! +var vertices = [0.0, 0.5, 0.0, -0.5, -0.5, 0.0, 0.5, -0.5, 0.0] +var vertex_array = new VertexArray(0, 3, vertices) +vertex_array.attrib_pointer +gl_clear_color(0.5, 0.0, 0.5, 1.0) +for i in [0..10000[ do + printn "." + assert_no_gl_error + gl_viewport(0, 0, width, height) + gl_clear_color_buffer + program.use + vertex_array.enable + vertex_array.draw_arrays_triangles + egl_display.swap_buffers(surface) +end + +# delete +program.delete +vertex_shader.delete +fragment_shader.delete + +# +## EGL +# +# close +egl_display.make_current(new EGLSurface.none, new EGLSurface.none, new EGLContext.none) +egl_display.destroy_context(context) +egl_display.destroy_surface(surface) + +# +## SDL +# +# close +sdl_display.destroy diff --git a/samples/Nit/print_arguments.nit b/samples/Nit/print_arguments.nit new file mode 100644 index 00000000..3bdddc62 --- /dev/null +++ b/samples/Nit/print_arguments.nit @@ -0,0 +1,22 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Copyright 2004-2008 Jean Privat +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# How to print arguments of the command line. +module print_arguments + +for a in args do + print a +end diff --git a/samples/Nit/procedural_array.nit b/samples/Nit/procedural_array.nit new file mode 100644 index 00000000..838bda02 --- /dev/null +++ b/samples/Nit/procedural_array.nit @@ -0,0 +1,48 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Copyright 2004-2008 Jean Privat +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A procedural program (without explicit class definition). +# This program manipulates arrays of integers. +module procedural_array + +# The sum of the elements of `a'. +# Uses a 'for' control structure. +fun array_sum(a: Array[Int]): Int +do + var sum = 0 + for i in a do + sum = sum + i + end + return sum +end + +# The sum of the elements of `a' (alternative version). +# Uses a 'while' control structure. +fun array_sum_alt(a: Array[Int]): Int +do + var sum = 0 + var i = 0 + while i < a.length do + sum = sum + a[i] + i = i + 1 + end + return sum +end + +# The main part of the program. +var a = [10, 5, 8, 9] +print(array_sum(a)) +print(array_sum_alt(a)) diff --git a/samples/Nit/socket_client.nit b/samples/Nit/socket_client.nit new file mode 100644 index 00000000..0ba19132 --- /dev/null +++ b/samples/Nit/socket_client.nit @@ -0,0 +1,38 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Copyright 2013 Matthieu Lucas +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Client sample using the Socket module which connect to the server sample. +module socket_client + +import socket + +if args.length < 2 then + print "Usage : socket_client " + return +end + +var s = new Socket.client(args[0], args[1].to_i) +print "[HOST ADDRESS] : {s.address}" +print "[HOST] : {s.host}" +print "[PORT] : {s.port}" +print "Connecting ... {s.connected}" +if s.connected then + print "Writing ... Hello server !" + s.write("Hello server !") + print "[Response from server] : {s.read(100)}" + print "Closing ..." + s.close +end diff --git a/samples/Nit/socket_server.nit b/samples/Nit/socket_server.nit new file mode 100644 index 00000000..aa77a759 --- /dev/null +++ b/samples/Nit/socket_server.nit @@ -0,0 +1,52 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Copyright 2013 Matthieu Lucas +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Server sample using the Socket module which allow client to connect +module socket_server + +import socket + +if args.is_empty then + print "Usage : socket_server " + return +end + +var socket = new Socket.server(args[0].to_i, 1) +print "[PORT] : {socket.port.to_s}" + +var clients = new Array[Socket] +var max = socket +loop + var fs = new SocketObserver(true, true, true) + fs.readset.set(socket) + + for c in clients do fs.readset.set(c) + + if fs.select(max, 4, 0) == 0 then + print "Error occured in select {sys.errno.strerror}" + break + end + + if fs.readset.is_set(socket) then + var ns = socket.accept + print "Accepting {ns.address} ... " + print "[Message from {ns.address}] : {ns.read(100)}" + ns.write("Goodbye client.") + print "Closing {ns.address} ..." + ns.close + end +end + diff --git a/samples/Nit/tmpl_composer.nit b/samples/Nit/tmpl_composer.nit new file mode 100644 index 00000000..6160b1a8 --- /dev/null +++ b/samples/Nit/tmpl_composer.nit @@ -0,0 +1,94 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import template + +### Here, definition of the specific templates + +# The root template for composers +class TmplComposers + super Template + + # Short list of composers + var composers = new Array[TmplComposer] + + # Detailled list of composers + var composer_details = new Array[TmplComposerDetail] + + # Add a composer in both lists + fun add_composer(firstname, lastname: String, birth, death: Int) + do + composers.add(new TmplComposer(lastname)) + composer_details.add(new TmplComposerDetail(firstname, lastname, birth, death)) + end + + redef fun rendering do + add """ +COMPOSERS +========= +""" + add_all composers + add """ + +DETAILS +======= +""" + add_all composer_details + end +end + +# A composer in the short list of composers +class TmplComposer + super Template + + # Short name + var name: String + + init(name: String) do self.name = name + + redef fun rendering do add "- {name}\n" +end + +# A composer in the detailled list of composers +class TmplComposerDetail + super Template + + var firstname: String + var lastname: String + var birth: Int + var death: Int + + init(firstname, lastname: String, birth, death: Int) do + self.firstname = firstname + self.lastname = lastname + self.birth = birth + self.death = death + end + + redef fun rendering do add """ + +COMPOSER: {{{firstname}}} {{{lastname}}} +BIRTH...: {{{birth}}} +DEATH...: {{{death}}} +""" + +end + +### Here a simple usage of the templates + +var f = new TmplComposers +f.add_composer("Johann Sebastian", "Bach", 1685, 1750) +f.add_composer("George Frideric", "Handel", 1685, 1759) +f.add_composer("Wolfgang Amadeus", "Mozart", 1756, 1791) +f.write_to(stdout) diff --git a/samples/Nit/websocket_server.nit b/samples/Nit/websocket_server.nit new file mode 100644 index 00000000..38029c37 --- /dev/null +++ b/samples/Nit/websocket_server.nit @@ -0,0 +1,46 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Copyright 2014 Lucas Bajolet +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Sample module for a minimal chat server using Websockets on port 8088 +module websocket_server + +import websocket + +var sock = new WebSocket(8088, 1) + +var msg: String + +if sock.listener.eof then + print sys.errno.strerror +end + +sock.accept + +while not sock.listener.eof do + if not sock.connected then sock.accept + if sys.stdin.poll_in then + msg = gets + printn "Received message : {msg}" + if msg == "exit" then sock.close + if msg == "disconnect" then sock.disconnect_client + sock.write(msg) + end + if sock.can_read(10) then + msg = sock.read_line + if msg != "" then print msg + end +end + diff --git a/samples/PHP/filenames/.php b/samples/PHP/filenames/.php new file mode 100755 index 00000000..be170195 --- /dev/null +++ b/samples/PHP/filenames/.php @@ -0,0 +1,34 @@ +#!/usr/bin/env php + diff --git a/samples/XML/filenames/.cproject b/samples/XML/filenames/.cproject new file mode 100755 index 00000000..5fbff7b7 --- /dev/null +++ b/samples/XML/filenames/.cproject @@ -0,0 +1,542 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/test_blob.rb b/test/test_blob.rb index eb65d1d8..fc9e13c5 100644 --- a/test/test_blob.rb +++ b/test/test_blob.rb @@ -140,6 +140,13 @@ class TestBlob < Test::Unit::TestCase assert !blob("Perl/script.pl").binary? end + def test_all_binary + Samples.each do |sample| + blob = blob(sample[:path]) + assert ! (blob.likely_binary? || blob.binary?), "#{sample[:path]} is a binary file" + end + end + def test_text assert blob("Text/README").text? assert blob("Text/dump.sql").text? @@ -277,7 +284,7 @@ class TestBlob < Test::Unit::TestCase # 'thirdparty' directory assert blob("thirdparty/lib/main.c").vendored? - + # 'extern(al)' directory assert blob("extern/util/__init__.py").vendored? assert blob("external/jquery.min.js").vendored? @@ -386,6 +393,12 @@ class TestBlob < Test::Unit::TestCase # NuGet Packages assert blob("packages/Modernizr.2.0.6/Content/Scripts/modernizr-2.0.6-development-only.js").vendored? + # Normalize + assert blob("some/asset/path/normalize.css").vendored? + + # Cocoapods + assert blob('Pods/blah').vendored? + # Html5shiv assert blob("Scripts/html5shiv.js").vendored? assert blob("Scripts/html5shiv.min.js").vendored? diff --git a/test/test_heuristics.rb b/test/test_heuristics.rb index d629c302..9bb18416 100644 --- a/test/test_heuristics.rb +++ b/test/test_heuristics.rb @@ -1,6 +1,7 @@ require 'linguist/heuristics' require 'linguist/language' require 'linguist/samples' +require 'linguist/file_blob' require 'test/unit' @@ -44,7 +45,8 @@ class TestHeuristcs < Test::Unit::TestCase end def test_detect_still_works_if_nothing_matches - match = Language.detect("Hello.m", fixture("Objective-C/hello.m")) + blob = Linguist::FileBlob.new(File.join(samples_path, "Objective-C/hello.m")) + match = Language.detect(blob) assert_equal Language["Objective-C"], match end diff --git a/test/test_language.rb b/test/test_language.rb index 10c5f9a2..fa92f38c 100644 --- a/test/test_language.rb +++ b/test/test_language.rb @@ -249,8 +249,7 @@ class TestLanguage < Test::Unit::TestCase assert_equal Language['Nginx'], Language.find_by_filename('nginx.conf').first assert_equal ['C', 'C++', 'Objective-C'], Language.find_by_filename('foo.h').map(&:name).sort assert_equal [], Language.find_by_filename('rb') - assert_equal [], Language.find_by_filename('.rb') - assert_equal [], Language.find_by_filename('.nkt') + assert_equal [], Language.find_by_filename('.null') assert_equal [Language['Shell']], Language.find_by_filename('.bashrc') assert_equal [Language['Shell']], Language.find_by_filename('bash_profile') assert_equal [Language['Shell']], Language.find_by_filename('.zshrc') diff --git a/test/test_repository.rb b/test/test_repository.rb index 832489d3..f4c5ad70 100644 --- a/test/test_repository.rb +++ b/test/test_repository.rb @@ -3,22 +3,24 @@ require 'linguist/repository' require 'test/unit' class TestRepository < Test::Unit::TestCase - include Linguist - - def repo(base_path) - Repository.from_directory(base_path) + def rugged_repository + @rugged ||= Rugged::Repository.new(File.expand_path("../../.git", __FILE__)) end - def linguist_repo - repo(File.expand_path("../..", __FILE__)) + def master_oid + 'd40b4a33deba710e2f494db357c654fbe5d4b419' + end + + def linguist_repo(oid = master_oid) + Linguist::Repository.new(rugged_repository, oid) end def test_linguist_language - # assert_equal Language['Ruby'], linguist_repo.language + assert_equal 'Ruby', linguist_repo.language end def test_linguist_languages - # assert linguist_repo.languages[Language['Ruby']] > 10_000 + assert linguist_repo.languages['Ruby'] > 10_000 end def test_linguist_size @@ -31,7 +33,18 @@ class TestRepository < Test::Unit::TestCase assert linguist_repo.breakdown_by_file["Ruby"].include?("lib/linguist/language.rb") end - def test_binary_override - assert_equal repo(File.expand_path("../../samples/Nimrod", __FILE__)).language, Language["Nimrod"] + def test_incremental_stats + old_commit = '3d7364877d6794f6cc2a86b493e893968a597332' + old_repo = linguist_repo(old_commit) + + assert old_repo.languages['Ruby'] > 10_000 + assert old_repo.size > 30_000 + + new_repo = Linguist::Repository.incremental(rugged_repository, master_oid, old_commit, old_repo.cache) + + assert new_repo.languages['Ruby'] > old_repo.languages['Ruby'] + assert new_repo.size > old_repo.size + + assert_equal linguist_repo.cache, new_repo.cache end end