text
stringlengths
1
1.05M
; A302707: Number of factors of Chebyshev polynomial S(2*n+1, x) (A049310) over the integers. Factorization is into the minimal integer polynomials C (A187360). ; Submitted by Jamie Morken(s1) ; 1,2,4,3,4,6,4,4,7,6,4,8,4,6,10,5,4,10,4,8,10,6,4,10,7,6,10,8,4,14,4,6,10,6,10,13,4,6,10,10,4,14,4,8,16,6,4,12,7,10,10,8,4,14,10,10,10,6,4,18,4,6,16,7,10,14,4,8,10,14,4,16,4,6,16,8,10,14,4,12,13,6,4,18,10,6,10,10,4,22,10,8,10,6,10,14,4,10,16,13 mul $0,4 add $0,3 seq $0,5 ; d(n) (also called tau(n) or sigma_0(n)), the number of divisors of n. sub $0,2
db "PUNCHING@" ; species name db "To increase the" next "strength of all" next "its punch moves," page "it spins its arms" next "just before making" next "contact.@"
#include "AminoAcidUtil.h" #include "crux_version.h" #include "mass.h" #include "model/Peptide.h" #include "model/objects.h" #include "parameter.h" #include "Params.h" #include "StringUtils.h" #include <algorithm> using namespace std; #include "app/CometApplication.h" /** * \file Params.cpp * * This module handles user-level parameters in Crux. Required * arguments are given on the command line; optional parameters can be * specified either on the command line or in a parameter file. * Textual descriptions of each parameter are stored in the source * code, and these are used to automatically generate usage * statements, comments in output parameter files, and HTML * documentation. * * Following are the steps required to add a new argument or parameter * to an existing command: * * - In Params.cpp, inside the constructor Params::Params(), add a * call to Init{Bool,Int,String,Double,Arg}Param. This will specify * things like the parameter name, type, default value, what * commands it works with, and whether it is visible to the end * user. * * - If your parameter is optional, then in Params::Categorize(), add * an "items.insert()" with the name of your new parameter. This * controls what category the parameter gets printed in when the * HTML documentation is created. Note that if the parameter * doesn't get added to a category in Params::Categorize(), it just * appears under a generic category called "<command name> options" * * - In the .cpp file that contains the main() for the command that * uses this parameter, find a call to either getArgs() (if your new * parameter is required) or getOptions() (if it is optional), and * add the name of your new parameter to the list of options there. * - In the same file, add a call to * Params::Get{Bool,Int,String,Double}() to retrieve the value * associated with the parameter. In general, these methods can be * used anywhere in the source code in order to retrieve parameters. * However, it's good form, when feasible, to access parameters in * the main() and then to pass them as arguments, rather than * accessing them as globals within subroutines. * * - If you need to edit the textual description of the command * itself, search in the same file for a call to getDescription(). * Portions of that description enclosed in "[[nohtml: XXX ]]" will * be used for the usage statement, and portions in "[[html: XXX ]]" * will be in the HTML docs. * */ static Params paramContainer_; Params::Params() : finalized_(false) { /* generate_peptide arguments */ InitArgParam("protein fasta file", "The name of the file in FASTA format from which to retrieve proteins."); InitArgParam("index name", "The desired name of the binary index."); InitArgParam("ms2 file", "The name of one or more files from which to parse the fragmentation " "spectra, in any of the file formats supported by ProteoWizard."); /* psm-convert arguments */ InitArgParam("input PSM file", "The name of a PSM file in tab-delimited text, SQT, pepXML or mzIdentML format"); InitArgParam("output format", "The desired format of the output file. Legal values are tsv, html, sqt, pin, " "pepxml, mzidentml."); /* get-ms2-spectrum */ InitArgParam("scan number", "Scan number identifying the spectrum."); InitArgParam("output file", "File where spectrum will be written."); /* predict-peptide-ions */ InitArgParam("peptide sequence", "The peptide sequence."); InitArgParam("charge state", "The charge state of the peptide."); /* hardklor arguments */ InitArgParam("spectra", "The name of a file from which to parse high-resolution spectra. The file " "may be in MS1 (.ms1), binary MS1 (.bms1), compressed MS1 (.cms1), or mzXML " "(.mzXML) format."); /*Percolator arguments*/ InitArgParam("peptide-spectrum matches", "One or more collections of target and decoy peptide-spectrum matches (PSMs). Input may " "be in one of four formats: PIN, SQT, pepXML, or [[html:<a href=\"../file-formats/txt-format.html\">]]" "Crux tab-delimited text[[html:</a>]]. " "Note that if the input is provided as SQT, pepXML, or Crux " "tab-delimited text, then a PIN file will be generated in the output directory " "prior to execution. " "Crux determines the format of the input file by examining its " "filename extension." "[[html:<br>For PIN files, target and decoy PSMs are assumed to appear in the " "same file. For other file types, decoy PSMs can be provided to Percolator in two " "ways: either as a separate file or embedded within the same file as the target " "PSMs. Percolator will first search for target PSMs in a separate file. The " "decoy file name is constructed from the target name by replacing \"target\" with " "\"decoy\". For example, if search.target.txt is provided as input, then " "Percolator will search for a corresponding file named search.decoy.txt. If no " "decoy file is found, then Percolator will assume that the given input file " "contains a mix of target and decoy PSMs. Within this file, decoys are identified " "using a prefix (specified via --decoy-prefix) on the protein name.]]"); /*make-pin arguments*/ InitIntParam("max-charge-feature", 0, 0, BILLION, "Specifies the maximum charge state feature. When set to zero, use the " "maximum observed charge state.", "Available for make-pin and percolator.", true); InitArgParam("psm results", "A collection of target and decoy peptide-spectrum matches (PSMs). Input may be in " "one of four formats: SQT, PepXML (obtained from SEQUEST), [[html:<a href=\"" "../file-formats/txt-format.html\">]]Crux tab-delimited text[[html:</a>]], or list of files (when " "list-of-files=T)." "[[html:<br>Decoy PSMs can be provided to make-pin in two ways: either as a separate " "file or embedded within the same file as the target PSMs. make-pin will first search " "for the target PSMs in a separate file. The decoy file name is constructed from the " "target name by replacing \"target\" with \"decoy\". For example, if search.target.txt " "is provided as input, then make-pin will search for a corresponding file named " "search.decoy.txt. If no decoy file is found, then make-pin will assume that the " "given input file contains a mix of target and decoy PSMs. Within this file, decoys " "are identified using a prefix (specified via --decoy-prefix) on the protein name.]]"); InitStringParam("decoy input", "", "make-pin can convert any file format in sqt, tab-delimited and pep.xml file " "to pin file ", "Argument, not option for make-pin", false); InitStringParam("output-file", "", "Path where pin file will be written instead of make-pin.pin.", "It is optional for make-pin", true); InitBoolParam("filestem-prefixes", false, "Prefix PSM IDs with filestems instead of target or decoy and file index.", "Available for make-pin", false); InitBoolParam("mod-symbols", false, "Print modification symbols instead of masses in peptide sequences.", "Available for make-pin", false); // q-ranker/barista arguments InitArgParam("fragmentation spectra", "The fragmentation spectra must be provided in [[html:<a href=\"../file-formats/ms2-format.html\">]]" "MS2[[html:</a>]], mzXML, or MGF format."); // pipeline arguments InitArgParam("mass spectra", "The name of the file(s) from which to parse the fragmentation spectra, in any of the " "[[html:<a href=\"http://proteowizard.sourceforge.net/tools.shtml\">]]file formats " "supported by ProteoWizard[[html:</a>]]. Alteratively, with Tide-search, these files " "may be binary spectrum files produced by a previous run of [[html:<code>]]crux " "tide-search[[html:</code>]] using the [[html:<code>]]store-spectra[[html:</code>]] " "parameter."); InitArgParam("peptide source", "Either the name of a file in fasta format from which to retrieve proteins and " "peptides or an index created by a previous run of [[html:<code>]]crux tide-index" "[[html:</code>]] (for Tide searching)."); /* *** Initialize Options (command line and param file) *** */ /* options for all executables */ InitIntParam("verbosity", 30, 0, 100, "Specify the verbosity of the current processes. Each level prints the following " "messages, including all those at lower verbosity levels: 0-fatal errors, 10-non-" "fatal errors, 20-warnings, 30-information on the progress of execution, 40-more " "progress information, 50-debug info, 60-detailed debug info.", "Available for all crux programs.", true); InitStringParam("parameter-file", "", "A file containing parameters. [[html: See the " "<a href=\"../file-formats/parameter-file.html\">parameter documentation</a> page for details.]]", "Available for all crux programs. Any options specified on the " "command line will override values in the parameter file.", true); InitBoolParam("overwrite", false, "Replace existing files if true or fail when trying to overwrite a file if false.", "Available for all crux programs. Applies to parameter file " "as well as index, search, and analysis output files.", true); /* generate_peptide parameters */ InitIntParam("min-length", 6, 1, MAX_PEPTIDE_LENGTH, "The minimum length of peptides to consider.", "Used from the command line or parameter file by " "crux-generate-peptides, and crux tide-index.", true); InitIntParam("max-length", 50, 1, MAX_PEPTIDE_LENGTH, "The maximum length of peptides to consider.", "Available from command line or parameter file for " "crux-generate-peptides, crux tide-index. ", true); InitDoubleParam("min-mass", 200, 0, BILLION, "The minimum mass (in Da) of peptides to consider.", "Available from command line or parameter file for " "crux-generate-peptides and crux tide-index. ", true); InitDoubleParam("max-mass", 7200, 1, BILLION, "The maximum mass (in Da) of peptides to consider.", "Available from command line or parameter file for " "crux-generate-peptides and crux tide-index. ", true); InitIntParam("min-peaks", 20, 0, BILLION, "The minimum number of peaks a spectrum must have for it to be searched.", "Available for tide-search.", true); InitStringParam("enzyme", "trypsin", "no-enzyme|trypsin|trypsin/p|chymotrypsin|" "elastase|clostripain|cyanogen-bromide|iodosobenzoate|proline-endopeptidase|" "staph-protease|asp-n|lys-c|lys-n|arg-c|glu-c|pepsin-a|" "elastase-trypsin-chymotrypsin|custom-enzyme", "Specify the enzyme used to digest the proteins in silico. Available enzymes " "(with the corresponding digestion rules indicated in parentheses) include " "no-enzyme ([X]|[X]), trypsin ([RK]|{P}), trypsin/p ([RK]|[]), chymotrypsin " "([FWYL]|{P}), elastase ([ALIV]|{P}), clostripain ([R]|[]), cyanogen-bromide " "([M]|[]), iodosobenzoate ([W]|[]), proline-endopeptidase ([P]|[]), staph-protease " "([E]|[]), asp-n ([]|[D]), lys-c ([K]|{P}), lys-n ([]|[K]), arg-c ([R]|{P}), " "glu-c ([DE]|{P}), pepsin-a ([FL]|{P}), elastase-trypsin-chymotrypsin " "([ALIVKRWFY]|{P}). Specifying --enzyme no-enzyme yields a non-enzymatic digest. " "[[html:<strong>]]Warning:[[html:</strong>]] the resulting index may be quite large.", "Available for crux-generate-peptides and crux tide-index.", true); InitStringParam("custom-enzyme", "", "Specify rules for in silico digestion of protein sequences. Overrides the enzyme " "option. Two lists of residues are given enclosed in square brackets or curly " "braces and separated by a |. The first list contains residues required/prohibited " "before the cleavage site and the second list is residues after the cleavage site. " "If the residues are required for digestion, they are in square brackets, '[' and " "']'. If the residues prevent digestion, then they are enclosed in curly braces, " "'{' and '}'. Use X to indicate all residues. For example, trypsin cuts after R or " "K but not before P which is represented as [RK]|{P}. AspN cuts after any residue " "but only before D which is represented as [X]|[D]. " "To prevent the sequences from being digested at all, use {X}|{X}.", "", true); InitDoubleParam("deisotope", 0, 0, 1000, "Perform a simple deisotoping operation across each MS2 spectrum. For each peak in an MS2 spectrum, consider lower m/z peaks. " "If the current peak occurs where an expected peak would lie for any charge state " "less than the charge state of the precursor, within mass tolerance, and if the " "current peak is of lower abundance, then the peak is removed. The value of this " "parameter is the mass tolerance, in units of parts-per-million. If set to 0, no " "deisotoping is performed.", "Available for tide-search.", true); InitStringParam("digestion", "full-digest", "full-digest|partial-digest|non-specific-digest", "Specify whether every peptide in the database must have two enzymatic termini " "(full-digest) or if peptides with only one enzymatic terminus are also included " "(partial-digest).", "Available for crux-generate-peptides and crux tide-index.", true); InitIntParam("missed-cleavages", 0, 0, 500, "Maximum number of missed cleavages per peptide to allow in enzymatic digestion.", "Available from command line or parameter file for crux-generate-peptides. " "When used with enzyme=<trypsin|elastase|chymotrypsin> " "includes peptides containing one or more potential cleavage sites.", true); InitDoubleParam("precursor-window", 50.0, 0, BILLION, "Tolerance used for matching peptides to spectra. Peptides must be within +/- " "'precursor-window' of the spectrum value. The precursor window units depend upon " "precursor-window-type.", "Available for tide-search and crux-generate-peptides.", true); InitStringParam("precursor-window-type", "ppm", "mass|mz|ppm", "Specify the units for the window that is used to select peptides around the precursor " "mass location (mass, mz, ppm). The magnitude of the window is defined by the precursor-" "window option, and candidate peptides must fall within this window. For the mass window-" "type, the spectrum precursor m+h value is converted to mass, and the window is defined " "as that mass +/- precursor-window. If the m+h value is not available, then the mass is " "calculated from the precursor m/z and provided charge. The peptide mass is computed as " "the sum of the average amino acid masses plus 18 Da for the terminal OH group. The mz " "window-type calculates the window as spectrum precursor m/z +/- precursor-window and " "then converts the resulting m/z range to the peptide mass range using the precursor " "charge. For the parts-per-million (ppm) window-type, the spectrum mass is calculated as " "in the mass type. The lower bound of the mass window is then defined as the spectrum " "mass / (1.0 + (precursor-window / 1000000)) and the upper bound is defined as spectrum " "mass / (1.0 - (precursor-window / 1000000)).", "Available for search-for-xlinks and tide-search.", true); InitStringParam("auto-precursor-window", "false", "false|warn|fail", "Automatically estimate optimal value for the precursor-window parameter " "from the spectra themselves. false=no estimation, warn=try to estimate " "but use the default value in case of failure, fail=try to estimate and " "quit in case of failure.", "Available for tide-search.", true); InitStringParam("spectrum-parser", "pwiz", "pwiz|mstoolkit", "Specify the parser to use for reading in MS/MS spectra.[[html: The default, " "ProteoWizard parser can read the MS/MS file formats listed <a href=\"" "http://proteowizard.sourceforge.net/formats.shtml\">here</a>. The alternative is " "<a href=\"../mstoolkit.html\">MSToolkit parser</a>. " "If the ProteoWizard parser fails to read your files properly, you may want to try the " "MSToolkit parser instead.]]", "Available for search-for-xlinks.", true); InitBoolParam("use-z-line", true, "Specify whether, when parsing an MS2 spectrum file, Crux obtains the " "precursor mass information from the \"S\" line or the \"Z\" line. ", "Available when spectrum-parser = pwiz.", true); InitStringParam("keep-terminal-aminos", "NC", "N|C|NC|none", "When creating decoy peptides using decoy-format=shuffle or decoy-format=" "peptide-reverse, this option specifies whether the N-terminal and " "C-terminal amino acids are kept in place or allowed to be shuffled or " "reversed. For a target peptide \"EAMPK\" with decoy-format=peptide-reverse, setting " "keep-terminal-aminos to \"NC\" will yield \"EPMAK\"; setting it to \"C\" will yield " "\"PMAEK\"; setting it to \"N\" will yield \"EKPMA\"; and setting it to \"none\" will " "yield \"KPMAE\".", "Available for tide-index.", true); InitBoolParam("peptide-list", false, "Create in the output directory a text file listing of all the peptides in the " "database, along with their neutral masses, one per line. If decoys are generated, " "then a second file will be created containing the decoy peptides. Decoys that also " "appear in the target database are marked with an asterisk in a third column.", "Available for tide-index.", true); InitIntParam("modsoutputter-threshold", 1000, 0, BILLION, "Maximum number of temporary files that would be opened by ModsOutputter " "before switching to ModsOutputterAlt.", "Available for tide-index.", false); // print-processed-spectra option InitStringParam("stop-after", "xcorr", "remove-precursor|square-root|" "remove-grass|ten-bin|xcorr", "Stop after the specified pre-processing step.", "Available for print-processed-spectra.", true); InitStringParam("output-units", "bin", "mz|bin", "Specify the output units for processed spectra.", "Available for print-processed-spectra", true); /* more generate_peptide parameters */ InitBoolParam("sqt-output", false, "Outputs an SQT results file to the output directory. Note that if sqt-output is " "enabled, then compute-sp is automatically enabled and cannot be overridden.", "Available for tide-search.", true); InitBoolParam("mzid-output", false, "Output an mzIdentML results file to the output directory.", "Available for tide-search, percolator.", true); InitBoolParam("pin-output", false, "Output a Percolator input (PIN) file to the output directory.", "Available for tide-search.", true); InitBoolParam("pout-output", false, "Output a Percolator [[html:<a href=\"" "https://github.com/percolator/percolator/blob/master/src/xml/percolator_out.xsd\">]]" "pout.xml[[html:</a>]] format results file to the output directory.", "Available for percolator.", true); InitBoolParam("pepxml-output", false, "Output a pepXML results file to the output directory.", "Available for tide-search, q-ranker, barista, percolator.", true); InitBoolParam("txt-output", true, "Output a tab-delimited results file to the output directory.", "Available for tide-search, percolator, q-ranker, barista.", true); InitStringParam("prelim-score-type", "sp", "sp|xcorr", "Initial scoring (sp, xcorr).", "The score applied to all possible psms for a given spectrum. Typically " "used to filter out the most plausible for further scoring.", false); InitStringParam("score-type", "xcorr", "xcorr|sp|xcorr-pvalue|sp-pvalue", "The primary scoring method to use (xcorr, sp, xcorr-pvalue, sp-pvalue).", "Primary scoring is typically done on a subset (see max-rank-preliminary) of all " "possible psms for each spectrum. Default is the SEQUEST-style xcorr. " "Crux also offers a p-value calculation for each psm based on xcorr " "or sp (xcorr-pvalue, sp-pvalue).", false); InitBoolParam("compute-sp", false, "Compute the preliminary score Sp for all candidate peptides. Report this score in the " "output, along with the corresponding rank, the number of matched ions and the total " "number of ions. This option is recommended if results are to be analyzed by Percolator " "or Barista. If sqt-output is enabled, then compute-sp is automatically enabled and " "cannot be overridden. Note that the Sp computation requires re-processing each " "observed spectrum, so turning on this switch involves significant computational overhead.", "Available for tide-search.", true); InitBoolParam("compute-p-values", false, "Estimate the parameters of the score distribution for each spectrum by fitting to a " "Weibull distribution, and compute a p-value for each xlink product. This option is " "only available when use-old-xlink=F.", "Currently only implemented for XCORR.", true); InitStringParam("scan-number", "", "A single scan number or a range of numbers to be searched. Range should be " "specified as 'first-last' which will include scans 'first' and 'last'.", "The search range x-y is inclusive of x and y.", true); /* N.B. Use NaN to indicate that no user preference was specified. * In this case, the default value depends on the mass type. * S.M. Also prevent a width of 0. */ InitDoubleParam("mz-bin-width", 0.02, 1e-4, BILLION, "Before calculation of the XCorr score, the m/z axes of the observed and theoretical " "spectra are discretized. This parameter specifies the size of each bin. The exact " "formula for computing the discretized m/z value is floor((x/mz-bin-width) + 1.0 - mz-bin-offset), where x is the observed m/z " "value. For low resolution ion trap ms/ms data 1.0005079 and for high resolution ms/ms " "0.02 is recommended.", "Available for tide-search and xlink-assign-ions.", true); InitDoubleParam("mz-bin-offset", 0.40, 0.0, 1.0, "In the discretization of the m/z axes of the observed and theoretical spectra, this " "parameter specifies the location of the left edge of the first bin, relative to " "mass = 0 (i.e., mz-bin-offset = 0.xx means the left edge of the first bin will be " "located at +0.xx Da).", "Available for tide-search.", true); InitStringParam("auto-mz-bin-width", "false", "false|warn|fail", "Automatically estimate optimal value for the mz-bin-width parameter " "from the spectra themselves. false=no estimation, warn=try to estimate " "but use the default value in case of failure, fail=try to estimate and " "quit in case of failure.", "Available for tide-search.", true); InitBoolParam("auto-modifications", false, "Automatically infer modifications from the spectra themselves.", "Available for tide-index.", true); InitStringParam("auto-modifications-spectra", "", "Specify the spectra file to be used for modification inference when the " "auto-modifications option is enabled. Multiple files may be separated by commas.", "Available for tide-index.", true); InitBoolParam("use-flanking-peaks", false, "Include flanking peaks around singly charged b and y theoretical ions. Each flanking " "peak occurs in the adjacent m/z bin and has half the intensity of the primary peak.", "Available for the tide-search and search-for-xlinks commands.", true); InitDoubleParam("spectrum-min-mz", 0.0, 0, BILLION, "The lowest spectrum m/z to search in the ms2 file.", "Available for tide-search.", true); InitDoubleParam("spectrum-max-mz", BILLION, 1, BILLION, "The highest spectrum m/z to search in the ms2 file.", "Available for tide-search.", true); InitStringParam("spectrum-charge", "all", "1|2|3|all", "The spectrum charges to search. With 'all' every spectrum will be searched and " "spectra with multiple charge states will be searched once at each charge state. " "With 1, 2, or 3 only spectra with that charge state will be searched.", "Used by tide-search.", true); InitStringParam("fileroot", "", "The fileroot string will be added as a prefix to all output file names.", "Available for all commands that produce an output directory.", true); InitStringParam("output-dir", "crux-output", "The name of the directory where output files will be created.", "Available for most commands.", true); InitStringParam("temp-dir", "", "The name of the directory where temporary files will be created. If this " "parameter is blank, then the system temporary directory will be used", "Available for tide-index.", true); // coder options regarding decoys InitIntParam("num-decoy-files", 1, 0, 10, "Replaces number-decoy-set. Determined by decoy-location" " and num-decoys-per-target", "", false); InitIntParam("num-decoys-per-target", 1, 1, BILLION, "The number of decoys to generate per target. When set to a value n, then " "with concat=F tide-search will output one target and n decoys. The " "resulting files can be used to run the \"average target-decoy " "competition\" method in assign-confidence. This parameter only applies " "when decoy-format is shuffle.", "Available for tide-index.", true); InitBoolParam("decoy-p-values", false, "Store all decoy p-values in a file", "", false); InitIntParam("top-match", 5, 1, BILLION, "Specify the number of matches to report for each spectrum.", "Available for tide-search and crux percolator", true); InitIntParam("top-match-in", 0, 0, BILLION, "Specify the maximum rank to allow when parsing results files. Matches with " "ranks higher than this value will be ignored (a value of zero allows matches with any rank).", "", true); InitStringParam("seed", "1", "When given a unsigned integer value seeds the random number generator with that value. " "When given the string \"time\" seeds the random number generator with the system time.", "Available for all Crux commands.", true); InitStringParam("fragment-mass", "mono", "average|mono", "Specify which isotopes to use in calculating fragment ion mass.", "Used by crux-predict-peptide-ions.", true); InitStringParam("isotopic-mass", "mono", "average|mono", "Specify the type of isotopic masses to use when calculating the peptide mass.", "Used from command line or parameter file by crux-generate-peptides.", true); InitStringParam("mod", "NO MODS", "Consider modifications on any amino acid in aa list with at most max-per-peptide in one " "peptide. The parameter takes the form " "[[html:&lt;mass change&gt;:&lt;aa list&gt;:&lt;max per peptide&gt;:&lt;prevents cleavage&gt;:" "&lt;prevents cross-link&gt;]]" "[[nohtml:<mass change>:<aa list>:<max per peptide>:<prevents cleavage>:<prevents cross-link>]]" ". This parameter may be included with different values multiple times so long as " "the total number of mod, cmod, and nmod parameters does not exceed 11. The \"prevents " "cleavage\" and \"prevents cross-link\" arguments are optional T/F arguments for describing whether the " "modification prevents enzymatic cleavage of cross-linking, respectively. This option is " "only available when use-old-xlink=F. " "Note that this parameter only takes effect when specified in the " "parameter file.", "Available for search-for-xlinks.", true); InitStringParam("cmod", "NO MODS", "Specify a variable modification to apply to C-terminus of peptides. " "[[html:&lt;mass change&gt;:&lt;max distance from protein c-term (-1 for no max)&gt;]]. " "Note that this parameter only takes effect when specified in the " "parameter file.", "Available for search-for-xlinks.", true); InitStringParam("nmod", "NO MODS", "Specify a variable modification to apply to N-terminus of peptides. " "[[html:&lt;mass change&gt;:&lt;max distance from protein c-term (-1 for no max)&gt;]]. " "Note that this parameter only takes effect when specified in the " "parameter file.", "Available for search-for-xlinks.", true); InitIntParam("min-mods", 0, 0, MAX_PEPTIDE_LENGTH, "The minimum number of modifications that can be applied to a single " "peptide.", "Available for tide-index.", true); InitIntParam("max-mods", MAX_PEPTIDE_LENGTH, 0, MAX_PEPTIDE_LENGTH, "The maximum number of modifications that can be applied to a single " "peptide.", "Available for tide-index.", true); InitIntParam("max-aas-modified", MAX_PEPTIDE_LENGTH, 0, MAX_PEPTIDE_LENGTH, "The maximum number of modified amino acids that can appear in one " "peptide. Each aa can be modified multiple times.", "", true); InitStringParam("mod-mass-format", "mod-only", "mod-only|total|separate", "Specify how sequence modifications are reported in various output files. Each " "modification is reported as a number enclosed in square braces following the " "modified residue; however, the number may correspond to one of three different " "masses: (1) 'mod-only' reports the value of the mass shift induced by the " "modification; (2) 'total' reports the mass of the residue with the modification " "(residue mass plus modification mass); (3) 'separate' is the same as 'mod-only', " "but multiple modifications to a single amino acid are reported as a " "comma-separated list of values. For example, suppose amino acid D has an " "unmodified mass of 115 as well as two moifications of masses +14 and +2. In this " "case, the amino acid would be reported as D[16] with 'mod-only', D[131] with 'total', " "and D[14,2] with 'separate'.", "Available for generate-peptides.", true); InitIntParam("mod-precision", 2, 0, 20,//arbitrary "Set the precision for modifications as written to .txt files.", "Also changes mods written to parameter file. By default, this " "value is set equal to the maximum modification precision in the " "specification of modifications. Available for " "tide-index, tide-search, search-for-xlinks and generate-peptides.", true); InitBoolParam("use-a-ions", false, "Consider a-ions in the search? Note that an a-ion is equivalent to a " "neutral loss of CO from the b-ion. " "Peak height is 10 (in arbitrary units).", "Available for search-for-xlinks and xlink-score-spectrum.", true); InitBoolParam("use-b-ions", true, "Consider b-ions in the search? Peak height is 50 (in arbitrary units).", "Available for search-for-xlinks and xlink-score-spectrum.", true); InitBoolParam("use-c-ions", false, "Consider c-ions in the search? Peak height is 50 (in arbitrary units).", "Available for search-for-xlinks and xlink-score-spectrum.", true); InitBoolParam("use-x-ions", false, "Consider x-ions in the search? Peak height is 10 (in arbitrary units).", "Available for search-for-xlinks and xlink-score-spectrum.", true); InitBoolParam("use-y-ions", true, "Consider y-ions in the search? Peak height is 50 (in arbitrary units).", "Available for search-for-xlinks and xlink-score-spectrum.", true); InitBoolParam("use-z-ions", false, "Consider z-ions in the search? Peak height is 50 (in arbitrary units).", "Available for search-for-xlinks and xlink-score-spectrum.", true); InitIntParam("precision", 8, 1, 100, //max is arbitrary "Set the precision for scores written to sqt and text files.", "Available for all commands.", true); InitIntParam("mass-precision", 4, 1, 100, // max is arbitrary "Set the precision for masses and m/z written to sqt and text files.", "Available for all commands.", true); InitIntParam("print-search-progress", 1000, 0, BILLION, "Show search progress by printing every n spectra searched. Set to 0 to show no " "search progress.", "Available for tide-search", true); // Sp scoring params InitDoubleParam("max-mz", 4000, 0, BILLION, "Used in scoring sp.", "Hide from users", false); InitDoubleParam("fraction-top-scores-to-fit", 0.55, 0, 1, "The fraction of psms per spectrum to use for estimating the " "score distribution for calculating p-values. " "Not compatible with 'number-top-scores-to-fig'.", "For developers/research only.", false); /* analyze-matches options */ InitStringParam("algorithm", "percolator", "percolator|curve-fit|none", "The analysis algorithm to use (percolator, curve-fit, none).", "Available only for crux-analyze-matches. Using 'percolator' will " "assign a q-value to the top-ranking psm for each spectrum based on " "the decoy searches. Using 'curve-fit' will assign a q-value to same " "using the p-values calculated with score-type=<xcorr-pvalue|" "sq-pvalue>. Incorrect combinations of score-type and algorithm cause" " undefined behavior. Using 'none' will turn the binary .csm files " "into text.", false); // **** percolator options. **** InitStringParam("search-input", "auto", "auto|separate|concatenated", "Specify the type of target-decoy search. Using 'auto', percolator attempts " "to detect the search type automatically. Using 'separate' specifies two searches: " "one against target and one against decoy protein db. Using 'concatenated' " "specifies a single search on concatenated target-decoy protein db.", "Available for percolator", true); InitStringParam("percolator-seed", "1", "When given a unsigned integer value seeds the random number generator with that value. " "When given the string \"time\" seeds the random number generator with the system time.", "Available for all percolator", true); InitBoolParam("feature-file-out", false, "Output the computed features in [[html:<a href=\"../file-formats/features.html\">]]" "tab-delimited Percolator input (.pin) format[[html:</a>]]. The features will be " "normalized, using either unit norm or standard deviation normalization (depending " "upon the value of the unit-norm option).", "Available for percolator and q-ranker.", true); InitBoolParam("decoy-xml-output", false, "Include decoys (PSMs, peptides, and/or proteins) in the XML output.", "Available for crux percolator", true); InitStringParam("decoy-prefix", "decoy_", "Specifies the prefix of the protein names that indicate a decoy.", "Available for percolator", true); InitBoolParam("output-weights", false, "Output final weights to a file named \"percolator.weights.txt\".", "Available for crux percolator", true); InitStringParam("init-weights", "", "Read initial weights from the given file (one per line).", "Available for crux percolator", true); InitIntParam("subset-max-train", 0, "Only train Percolator on a subset of PSMs, and use the resulting score " "vector to evaluate the other PSMs. Recommended when analyzing huge numbers " "(>1 million) of PSMs. When set to 0, all PSMs are used for training as " "normal.", "Available for crux percolator", true); InitDoubleParam("c-pos", 0.00, "Penalty for mistakes made on positive examples. If this value is set to 0, " "then it is set via cross validation over the values {0.1, 1, 10}, selecting the " "value that yields the largest number of PSMs identified at the q-value threshold " "set via the --test-fdr parameter.", "Available for crux percolator", true); InitDoubleParam("c-neg", 0.0, 0.0, 0.90, "Penalty for mistake made on negative examples. If not specified, then " "this value is set by cross validation over {0.1, 1, 10}.", "Available for crux percolator", true); InitDoubleParam("train-fdr", 0.01, 0, BILLION, "False discovery rate threshold to define positive examples in training.", "Available for crux percolator", true); InitDoubleParam("test-fdr", 0.01, 0.0, 1.0, "False discovery rate threshold used in selecting hyperparameters during internal " "cross-validation and for reporting the final results.", "Available for crux percolator.", true); InitDoubleParam("fido-fast-gridsearch", 0.0, 0.0, 1.0, "Apply the specified threshold to PSM, peptide and protein probabilities to " "obtain a faster estimate of the alpha, beta and gamma parameters.", "Available for crux percolator.", true); InitBoolParam("fido-no-split-large-components", false, "Do not approximate the posterior distribution by allowing large graph " "components to be split into subgraphs. The splitting is done by " "duplicating peptides with low probabilities. Splitting continues " "until the number of possible configurations of each subgraph is " "below 2^18", "Available for crux percolator", true); InitDoubleParam("fido-protein-truncation-threshold", 0.01, 0.0, 1.0, "To speed up inference, proteins for which none of the associated " "peptides has a probability exceeding the specified threshold will " "be assigned probability = 0.", "Available for crux percolator", true); InitBoolParam("tdc", true, "Use target-decoy competition to assign q-values and PEPs. When set to F, " "the mix-max method, which estimates the proportion pi0 of incorrect target " "PSMs, is used instead.", "Available for crux percolator", true); InitIntParam("maxiter", 10, 0, 100000000, "Maximum number of iterations for training.", "Available for crux percolator", true); InitBoolParam("quick-validation", false, "Quicker execution by reduced internal cross-validation.", "Available for crux percolator", true); InitStringParam("default-direction", "", "In its initial round of training, Percolator uses one feature to induce a ranking " "of PSMs. By default, Percolator will select the feature that produces the largest " "set of target PSMs at a specified FDR threshold (cf. --train-fdr). This option " "allows the user to specify which feature is used for the initial ranking, using the " "name as a string[[html: from <a href=\"../file-formats/features.html\">this table</a>]]. The name " "can be preceded by a hyphen (e.g. \"-XCorr\") to indicate that a lower value is " "better.", "Available for crux percolator", true); InitBoolParam("unitnorm", false, "Use unit normalization (i.e., linearly rescale each PSM's feature vector to have a " "Euclidean length of 1), instead of standard deviation normalization.", "Available for crux percolator.", true); InitBoolParam("test-each-iteration", false, "Measure performance on test set each iteration.", "Available for crux percolator.", true); InitStringParam("picked-protein", "", "Use the picked protein-level FDR to infer protein probabilities, provide the " "fasta file as the argument to this flag.", "Available for crux percolator", true); InitStringParam("protein-enzyme", "trypsin", "no_enzyme|elastase|pepsin|proteinasek|" "thermolysin|trypsinp|chymotrypsin|lys-n|lys-c|arg-c|asp-n|glu-c|trypsin", "Type of enzyme", "Available for crux percolator", true); InitBoolParam("protein-report-fragments", false, "By default, if the peptides associated with protein A are a proper subset " "of the peptides associated with protein B, then protein A is eliminated and " "all the peptides are considered as evidence for protein B. Note that this " "filtering is done based on the complete set of peptides in the database, not " "based on the identified peptides in the search results. Alternatively, if this " "option is set and if all of the identified peptides associated with protein B " "are also associated with protein A, then Percolator will report a comma-" "separated list of protein IDs, where the full-length protein B is first in the " "list and the fragment protein A is listed second. Not available for Fido.", "Available for crux percolator", true); InitBoolParam("protein-report-duplicates", false, "If multiple database proteins contain exactly the same set of peptides, then " "Percolator will randomly discard all but one of the proteins. If this option " "is set, then the IDs of these duplicated proteins will be reported as a comma-" "separated list. Not available for Fido.", "Available for crux percolator", true); InitBoolParam("protein", false, "Use the Fido algorithm to infer protein probabilities. Must be true to use any of the Fido options.", "Available for crux percolator", true); InitDoubleParam("fido-alpha", 0.0, 0.0, 1.0, "Specify the probability with which a present protein emits an associated peptide. " "Set by grid search (see --fido-gridsearch-depth parameter) if not specified.", "Available for crux percolator if --protein T is set.", true); InitDoubleParam("fido-beta", 0.0, 0.0, 10.0, "Specify the probability of the creation of a peptide from noise. Set by grid " "search (see --fido-gridsearch-depth parameter) if not specified.", "Available for crux percolator if --protein T is set.", true); InitDoubleParam("fido-gamma", 0.0, 0.0, 10.0, "Specify the prior probability that a protein is present in the sample. Set by grid " "search (see --fido-gridsearch-depth parameter) if not specified.", "Available for crux percolator if --protein T is set.", true); InitBoolParam("fido-empirical-protein-q", false, "Estimate empirical p-values and q-values for proteins using target-decoy analysis.", "Available for crux percolator if --protein T is set.", true); InitIntParam("fido-gridsearch-depth", 0, 0, 2, "Set depth of the grid search for alpha, beta and gamma estimation.[[html: The values " "considered, for each possible value of the --fido-gridsearch-depth parameter, are as follows:<ul>" "<li>0: alpha = {0.01, 0.04, 0.09, 0.16, 0.25, 0.36, 0.5}; beta = {0.0, 0.01, 0.15, " "0.025, 0.035, 0.05, 0.1}; gamma = {0.1, 0.25, 0.5, 0.75}.</li><li>1: alpha = {0.01, " "0.04, 0.09, 0.16, 0.25, 0.36}; beta = {0.0, 0.01, 0.15, 0.025, 0.035, 0.05}; gamma = " "{0.1, 0.25, 0.5}.</li><li>2: alpha = {0.01, 0.04, 0.16, 0.25, 0.36}; beta = {0.0, " "0.01, 0.15, 0.030, 0.05}; gamma = {0.1, 0.5}.</li><li>3: alpha = {0.01, 0.04, 0.16, " "0.25, 0.36}; beta = {0.0, 0.01, 0.15, 0.030, 0.05}; gamma = {0.5}.</li></ul>]]", "Available for crux percolator if --protein T is set.", true); InitDoubleParam("fido-gridsearch-mse-threshold", 0.05, 0, 1, "Q-value threshold that will be used in the computation of the MSE and ROC AUC " "score in the grid search.", "Available for crux percolator if --protein T is set.", true); InitBoolParam("override", false, "By default, Percolator will examine the learned weights for each feature, and if " "the weight appears to be problematic, then percolator will discard the learned " "weights and instead employ a previously trained, static score vector. This switch " "allows this error checking to be overriden.", "Available for crux percolator.", true); InitBoolParam("klammer", false, "Use retention time features calculated as in \"Improving tandem mass spectrum " "identification using peptide retention time prediction across diverse chromatography " "conditions\" by Klammer AA, Yi X, MacCoss MJ and Noble WS. ([[html:<em>]]Analytical " "Chemistry[[html:</em>]]. 2007 Aug 15;79(16):6111-8.).", "Available for crux percolator", true); InitBoolParam("only-psms", false, "Do not remove redundant peptides; keep all PSMs and exclude peptide level probability.", "Available for crux percolator", true); InitBoolParam("train-best-positive", false, "Enforce that, for each spectrum, at most one PSM is included in the " "positive set during each training iteration. Note that if the user only " "provides one PSM per spectrum, then this option will have no effect.", "Available for crux percolator", true); InitDoubleParam("spectral-counting-fdr", 0, 0, 1, "Report the number of unique PSMs and total (including shared peptides) " "PSMs as two extra columns in the protein tab-delimited output.", "Available for crux percolator", true); // **** Tide arguments **** InitArgParam("spectrum records file", "A spectrum records file generated by a previous run of crux tide-search " "using the store-spectra parameter."); InitArgParam("tide spectra file", "The name of one or more files from which to parse the fragmentation spectra, in any " "of the file formats supported by ProteoWizard. Alternatively, the argument " "may be one or more binary spectrum files produced by a previous run of crux " "tide-search using the store-spectra parameter."); InitArgParam("tide database", "Either a FASTA file or a directory containing a database index created by a previous " "run of crux tide-index."); // **** Tide options **** InitStringParam("decoy-format", "shuffle", "none|shuffle|peptide-reverse|protein-reverse", "Include a decoy version of every peptide by shuffling or reversing the " "target sequence or protein. In shuffle or peptide-reverse mode, each peptide is " "either reversed or shuffled, leaving the N-terminal and C-terminal amino acids in " "place. Note that peptides appear multiple times in the target database are only " "shuffled once. In peptide-reverse mode, palindromic peptides are shuffled. Also, if a " "shuffled peptide produces an overlap with the target or decoy database, then the " "peptide is re-shuffled up to 5 times. Note that, despite this repeated shuffling, " "homopolymers will appear in both the target and decoy database. The protein-reverse " "mode reverses the entire protein sequence, irrespective of the composite peptides.", "Available for tide-index", true); InitStringParam("mods-spec", "C+57.02146", "[[nohtml:Expression for static and variable mass modifications to include. " "Specify a comma-separated list of modification sequences of the form: " "C+57.02146,2M+15.9949,1STY+79.966331,...]][[html:The general form of a modification " "specification has three components, as exemplified by <span style=\"color: red;\">1" "</span><span style=\"color: green;\">STY</span>+<span style=\"color: blue\">79.966331" "</span>.<br>The three components are: [<span style=\"color: red;\">max_per_peptide" "</span>]<span style=\"color: green;\">residues</span>[+/-]<span style-\"color: blue;\">" "mass_change</span><br>In the example, <span style=\"color: red;\">max_per_peptide" "</span> is <span style=\"color: red;\">1</span>, <span style=\"color: green;\">" "residues</span> are <span style=\"color: green;\">STY</span>, and " "<span style=\"color: blue;\">mass_change</span> is <span style=\"color: blue;\">" "+79.966331</span>. To specify a static modification, the number preceding the amino " "acid must be omitted; i.e., <span style=\"color: green;\">C</span>+<span " "style=\"color: blue;\">57.02146</span> specifies a static modification of 57.02146 " "Da to cysteine. Note that Tide allows at most one modification per amino " "acid. Also, the default modification (C+57.02146) will be added to " "every mods-spec string unless an explicit C+0 is included. " "Also note that search-for-xlinks allows two optional Boolean parameters " "with each modification, indicating whether the modification will (1) prevent " "enzymatic cleavage at its site, and (2) prevent cross-linking. " "These are specified like \"K+156.0786:T:T\". " "By default, both of these Booleans are set to false.]]", "Available for tide-index and search-for-xlinks.", true); InitStringParam("nterm-peptide-mods-spec", "", "[[nohtml:Specifies N-terminal static and variable mass modifications on peptides. " "Specify a comma-separated list of N-terminal modification sequences of the form: " "1E-18.0106,C-17.0265]][[html:Specify peptide n-terminal modifications. Like " "--mods-spec, this specification has three components, but with a slightly different " "syntax. The <span style=\"color: red;\">max_per_peptide</span> can be either \"1\", " "in which case it defines a variable terminal modification, or missing, in which case " "the modification is static. The <span style=\"color: green;\">residues</span> field " "indicates which amino acids are subject to the modification, with the residue <span " "style=\"color: green;\">X</span> corresponding to any amino acid. Finally, <span " "style=\"color: blue;\">added_mass</span> is defined as before.]]", "Available for tide-index", true); InitStringParam("cterm-peptide-mods-spec", "", "[[nohtml:Specifies C-terminal static and variable mass modifications on peptides. " "Specify a comma-separated list of C-terminal modification sequences of the form: " "X+21.9819]][[html:Specify peptide c-terminal modifications. See " "nterm-peptide-mods-spec for syntax.]]", "Available for tide-index", true); InitStringParam("cterm-protein-mods-spec", "", "Specifies C-terminal static and variable mass modifications on proteins. " "Specify a comma-separated list of C-terminal protein modification sequences of the form: " ",...", "Available for tide-index", false); InitStringParam("nterm-protein-mods-spec", "", "Specifies N-terminal static and variable mass modifications on proteins. " "Specify a comma-separated list of N-terminal protein modification sequences of the form: " ",...", "Available for tide-index", false); InitStringParam("store-spectra", "", "Specify the name of the file where the binarized fragmentation spectra " "will be stored. Subsequent runs of crux tide-search will execute more quickly if " "provided with the spectra in binary format. The filename is specified relative to " "the current working directory, not the Crux output directory (as specified by " "--output-dir). This option is not valid if multiple input spectrum files are given.", "Available for tide-search", true); InitBoolParam("exact-p-value", false, "Enable the calculation of exact p-values for the XCorr score[[html: as described in " "<a href=\"http://www.ncbi.nlm.nih.gov/pubmed/24895379\">this article</a>]]. Calculation " "of p-values increases the running time but increases the number of identifications at a " "fixed confidence threshold. The p-values will be reported in a new column with header " "\"exact p-value\", and the \"xcorr score\" column will be replaced with a \"refactored " "xcorr\" column. Note that, currently, p-values can only be computed when the " "mz-bin-width parameter is set to its default value. Variable and static mods are allowed " "on non-terminal residues in conjunction with p-value computation, but currently only " "static mods are allowed on the N-terminus, and no mods on the C-terminus.", "Available for tide-search", true); InitStringParam("store-index", "", "When providing a FASTA file as the index, the generated binary index will be stored at " "the given path. This option has no effect if a binary index is provided as the index.", "Available for tide-search", true); InitBoolParam("concat", false, "When set to T, target and decoy search results are reported in a single file, and only " "the top-scoring N matches (as specified via --top-match) are reported for each spectrum, " "irrespective of whether the matches involve target or decoy peptides." "Note that when used with search-for-xlinks, this parameter only has an " "effect if use-old-xlink=F.", "Available for tide-search and search-for-xlinks", true); InitBoolParam("file-column", true, "Include the file column in tab-delimited output.", "Available for tide-search", true); // Same as remove_precursor_peak and remove_precursor tolerance in Comet InitBoolParam("remove-precursor-peak", false, "If true, all peaks around the precursor m/z will be removed, within a range " "specified by the --remove-precursor-tolerance option.", "Available for tide-search.", true); InitDoubleParam("remove-precursor-tolerance", 1.5, 0, BILLION, "This parameter specifies the tolerance (in Th) around each precursor m/z that is " "removed when the --remove-precursor-peak option is invoked.", "Available for print-processed spectra and tide-search.", true); InitBoolParam("clip-nterm-methionine", false, "When set to T, for each protein that begins with methionine, tide-index will " "put two copies of the leading peptide into the index, with and without the N-terminal " "methionine.", "Available for tide-index.", true); InitBoolParam("allow-dups", false, "Prevent duplicate peptides between the target and decoy databases. When set to \"F\", " "the program keeps all target and previously generated decoy peptides in memory. A shuffled " "decoy will be re-shuffled multiple times to avoid duplication. If a non-duplicated peptide " "cannot be generated, the decoy is skipped entirely. When set to \"T\", every decoy is added to " "the database without checking for duplication. This option reduces the memory requirements " "significantly.", "Available for tide-index.", true); InitBoolParam("use-neutral-loss-peaks", true, "Controls whether neutral loss ions are considered in the search. " "Two types of neutral losses are included and are applied only to " "singly charged b- and y-ions: loss of ammonia (NH3, 17.0086343 Da) " "and H2O (18.0091422). Each neutral loss peak has intensity 1/5 of " "the primary peak.", "Available for tide-search.", true); InitIntParam("max-precursor-charge", 5, 1, BILLION, "The maximum charge state of a spectra to consider in search.", "Available for tide-search.", true); InitBoolParam("peptide-centric-search", false, "Carries out a peptide-centric search. For each peptide the top-scoring spectra " "are reported, in contrast to the standard spectrum-centric search where the top-" "scoring peptides are reported. Note that in this case the \"xcorr rank\" column " "will contain the rank of the given spectrum with respect to the given candidate " "peptide, rather than vice versa (which is the default).", "Available for tide-search.", true); InitIntParam("elution-window-size", 0, 0, 10, "Size of the elution window used in smoothing score in DIA mode. " "Used only with peptide-centric-search if greater than 0. A score of a psms " "centred in the window is substituted by the geometric mean of the scores " "in the window. If windows size is even, then it is increased by 1.", "Available for tide-search.", false); InitBoolParam("skip-decoys", true, "Skips decoys when reading a Tide index.", "Available for read-tide-index", false); InitBoolParam("skip-preprocessing", false, "Skip preprocessing steps on spectra. Default = F.", "Available for tide-search", true); InitStringParam("score-function", "xcorr","xcorr|residue-evidence|both", "Function used for scoring PSMs. 'xcorr' is the original scoring function used by SEQUEST; " "'residue-evidence' is designed to score high-resolution MS2 spectra; and 'both' calculates " "both scores. The latter requires that exact-p-value=T.", "Available for tide-search.", true); InitDoubleParam("fragment-tolerance", .02, 0, 2, "Mass tolerance (in Da) for scoring pairs of peaks when creating the residue evidence matrix. " "This parameter only makes sense when score-function is 'residue-evidence' or 'both'.", "Available for tide-search.", true); InitIntParam("evidence-granularity", 25, 1, 100, "When exact-pvalue=T, this parameter controls the granularity of the entries in the dynamic " "programming matrix. Smaller values make the program run faster but give less exact p-values; " "larger values make the program run more slowly but give more exact p-values.", "Available for tide-search",true); InitStringParam("isotope-error", "", "List of positive, non-zero integers.", "Isotope errors to include. " "Specify a comma-separated list of isotope errors of the form: " "1,2,3,..." "Available for tide-search", true); InitIntParam("num-threads", 0, 0, 64, "0=poll CPU to set num threads; else specify num threads directly.", "Available for tide-search tab-delimited files only.", true); /* * Comet parameters */ InitArgParam("input spectra", "The name of the file from which to parse the spectra. Valid formats include mzXML, " "mzML, mz5, raw, ms2, and cms2. Files in mzML or mzXML may be compressed with gzip. " "RAW files can be parsed only under windows and if the appropriate libraries were " "included at compile time."); /* Comet - Database */ InitArgParam("database_name", "A full or relative path to the sequence database, " "in FASTA format, to search. Example databases include " "RefSeq or UniProt. The database can contain amino acid " "sequences or nucleic acid sequences. If sequences are " "amino acid sequences, set the parameter \"nucleotide_reading_frame = 0\". " "If the sequences are nucleic acid sequences, you must instruct Comet to " "translate these to amino acid sequences. Do this by setting " "nucleotide_reading_frame\" to a value between 1 and 9."); InitIntParam("decoy_search", 0, 0, 2, "0=no, 1=concatenated search, 2=separate search.", "Available for comet.", true); /* Comet - CPU threads */ InitIntParam("num_threads", 0, -64, 64, "0=poll CPU to set num threads; else specify num threads directly.", "Available for comet.", true); /* Comet - Masses */ InitDoubleParam("peptide_mass_tolerance", 3.0, 0, BILLION, "Controls the mass tolerance value. The mass tolerance " "is set at +/- the specified number i.e. an entered value " "of \"1.0\" applies a -1.0 to +1.0 tolerance. " "The units of the mass tolerance is controlled by the parameter " "\"peptide_mass_units\". ", "Available for comet.", true); InitIntParam("peptide_mass_units", 0, 0, 2, "0=amu, 1=mmu, 2=ppm.", "Available for comet.", true); InitStringParam("auto_peptide_mass_tolerance", "false", "false|warn|fail", "Automatically estimate optimal value for the peptide_mass_tolerancel parameter " "from the spectra themselves. false=no estimation, warn=try to estimate " "but use the default value in case of failure, fail=try to estimate and " "quit in case of failure.", "Available for comet.", true); InitIntParam("mass_type_parent", 1, 0, 1, "0=average masses, 1=monoisotopic masses.", "Available for comet.", true); InitIntParam("mass_type_fragment", 1, 0, 1, "0=average masses, 1=monoisotopic masses.", "Available for comet.", true); InitIntParam("precursor_tolerance_type", 0, 0, 1, "0=singly charged peptide mass, 1=precursor m/z.", "Available for comet.", true); InitIntParam("isotope_error", 0, 0, 2, "0=off, 1=on -1/0/1/2/3 (standard C13 error), 2=-8/-4/0/4/8 (for +4/+8 labeling).", "Available for comet.", true); /* Comet - Search enzyme */ InitIntParam("search_enzyme_number", 1, 0, BILLION, "Specify a search enzyme from the end of the parameter file.", "Available for comet.", true); InitIntParam("num_enzyme_termini", 2, 1, 9, "valid values are 1 (semi-digested), 2 (fully digested), 8 N-term, 9 C-term.", "Available for comet.", true); InitIntParam("allowed_missed_cleavage", 2, 0, 5, "Maximum value is 5; for enzyme search.", "Available for comet.", true); /* Comet - Fragment ions */ InitDoubleParam("fragment_bin_tol", 1.000507, 0, BILLION, "Binning to use on fragment ions.", "Available for comet.", true); InitDoubleParam("fragment_bin_offset", 0.40, 0, 1.0, "Offset position to start the binning (0.0 to 1.0).", "Available for comet.", true); InitStringParam("auto_fragment_bin_tol", "false", "false|warn|fail", "Automatically estimate optimal value for the fragment_bin_tol parameter " "from the spectra themselves. false=no estimation, warn=try to estimate " "but use the default value in case of failure, fail=try to estimate and " "quit in case of failure.", "Available for comet.", true); InitBoolParam("auto_modifications", false, "Automatically infer modifications from the spectra themselves.", "Available for comet.", true); InitIntParam("theoretical_fragment_ions", 1, 0, 1, "0=default peak shape, 1=M peak only.", "Available for comet.", true); InitIntParam("use_A_ions", 0, 0, 1, "Controls whether or not A-ions are considered in the search (0 - no, 1 - yes).", "Available for comet.", true); InitIntParam("use_B_ions", 1, 0, 1, "Controls whether or not B-ions are considered in the search (0 - no, 1 - yes).", "Available for comet.", true); InitIntParam("use_C_ions", 0, 0, 1, "Controls whether or not C-ions are considered in the search (0 - no, 1 - yes).", "Available for comet.", true); InitIntParam("use_X_ions", 0, 0, 1, "Controls whether or not X-ions are considered in the search (0 - no, 1 - yes).", "Available for comet.", true); InitIntParam("use_Y_ions", 1, 0, 1, "Controls whether or not Y-ions are considered in the search (0 - no, 1 - yes).", "Available for comet.", true); InitIntParam("use_Z_ions", 0, 0, 1, "Controls whether or not Z-ions are considered in the search (0 - no, 1 - yes).", "Available for comet.", true); InitIntParam("use_NL_ions", 1, 0, 1, "0=no, 1= yes to consider NH3/H2O neutral loss peak.", "Available for comet.", true); /* Comet - Output */ InitIntParam("output_sqtfile", 0, 0, 1, "0=no, 1=yes write sqt file.", "Available for comet.", true); InitIntParam("output_txtfile", 1, 0, 1, "0=no, 1=yes write tab-delimited text file.", "Available for comet.", true); InitIntParam("output_pepxmlfile", 1, 0, 1, "0=no, 1=yes write pep.xml file.", "Available for comet.", true); InitIntParam("output_percolatorfile", 0, 0, 1, "0=no, 1=yes write percolator file.", "Available for comet.", true); InitIntParam("output_outfiles", 0, 0, 1, "0=no, 1=yes write .out files.", "Available for comet.", true); InitIntParam("print_expect_score", 1, 0, 1, "0=no, 1=yes to replace Sp with expect in out & sqt.", "Available for comet.", true); InitIntParam("num_output_lines", 5, 1, BILLION, "num peptide results to show.", "Available for comet.", true); InitIntParam("show_fragment_ions", 0, 0, 1, "0=no, 1=yes for out files only.", "Available for comet.", true); InitIntParam("sample_enzyme_number", 1, 0, 10, "Sample enzyme which is possibly different than the one applied to the search. " "Used to calculate NTT & NMC in pepXML output.", "Available for comet. ", true); /* Comet - mzXML/mzML parameters */ InitStringParam("scan_range", "0 0", "Start and scan scan range to search; 0 as first entry ignores parameter.", "Available for comet.", true); InitStringParam("precursor_charge", "0 0", "Precursor charge range to analyze; does not override " "mzXML charge; 0 as first entry ignores parameter.", "Available for comet.", true); InitIntParam("override_charge", 0, 0, 3, "Specifies the whether to override existing precursor charge state information when present " "in the files with the charge range specified by the \"precursor_charge\" parameter.", "Available for comet.", true); InitIntParam("ms_level", 2, 2, 3, "MS level to analyze, valid are levels 2 or 3.", "Available for comet. ", true); InitStringParam("activation_method", "ALL", "ALL|CID|ECD|ETD|PQD|HCD|IRMPD", "Specifies which scan types are searched.", "Available for comet. ", true); /* Comet - Misc. parameters */ InitStringParam("digest_mass_range", "600.0 5000.0", "MH+ peptide mass range to analyze.", "Available for comet.", true); InitIntParam("num_results", 50, 0, BILLION, "Number of search hits to store internally.", "Available for comet.", true); InitIntParam("skip_researching", 1, 0, 1, "For '.out' file output only, 0=search everything again, 1=don't search if .out exists.", "Available for comet.", true); InitIntParam("max_fragment_charge", 3, 1, 5, "Set maximum fragment charge state to analyze (allowed max 5).", "Available for comet.", true); InitIntParam("max_precursor_charge", 6, 1, 9, "Set maximum precursor charge state to analyze (allowed max 9).", "Available for comet.", true); InitIntParam("nucleotide_reading_frame", 0, 0, 9, "0=proteinDB, 1-6, 7=forward three, 8=reverse three, 9=all six.", "Available for comet.", true); InitIntParam("clip_nterm_methionine", 0, 0, 1, "0=leave sequences as-is; 1=also consider sequence w/o N-term methionine.", "Available for comet.", true); InitIntParam("spectrum_batch_size", 0, 0, BILLION, "Maximum number of spectra to search at a time; 0 to search the entire scan range in one loop.", "Available for comet.", true); InitStringParam("decoy_prefix", "decoy_", "Specifies the prefix of the protein names that indicates a decoy.", "Available for comet.", true); InitStringParam("output_suffix", "", "Specifies the suffix string that is appended to the base output name " "for the pep.xml, pin.xml, txt and sqt output files.", "Available for comet.", true); InitStringParam("mass_offsets", "", "Specifies one or more mass offsets to apply. This value(s) are effectively " "subtracted from each precursor mass such that peptides that are smaller " "than the precursor mass by the offset value can still be matched to the " "respective spectrum.", "Available for comet.", true); /* Comet - Spectral processing */ InitIntParam("minimum_peaks", 10, 1, BILLION, "Minimum number of peaks in spectrum to search.", "Available for comet.", true); InitDoubleParam("minimum_intensity", 0, 0, BILLION, "Minimum intensity value to read in.", "Available for comet. ", true); InitIntParam("remove_precursor_peak", 0, 0, 2, "0=no, 1=yes, 2=all charge reduced precursor peaks (for ETD).", "Available for comet. ", true); InitDoubleParam("remove_precursor_tolerance", 1.5, -BILLION, BILLION, "+- Da tolerance for precursor removal.", "Available for comet. ", true); InitStringParam("clear_mz_range", "0.0 0.0", "For iTRAQ/TMT type data; will clear out all peaks in the specified m/z range.", "Available for comet.", true); /* Comet - Variable modifications */ InitStringParam("variable_mod01", "0.0 null 0 4 -1 0 0", "Up to 9 variable modifications are supported. Each modification " "is specified using seven entries: " "\"[[html:&lt;mass&gt;]][[nohtml:<mass>]] " "[[html:&lt;residues&gt;]][[nohtml:<residues>]] " "[[html:&lt;type&gt;]][[nohtml:<type>]] " "[[html:&lt;max&gt;]][[nohtml:<max>]] " "[[html:&lt;distance&gt;]][[nohtml:<distance>]] " "[[html:&lt;terminus&gt;]][[nohtml:<terminus>]] " "[[html:&lt;force&gt;]][[nohtml:<force>]].\" " "Type is 0 for static mods and non-zero for variable mods. " "Note that that if you set the same type value on multiple " "modification entries, Comet will treat those variable modifications " "as a binary set. This means that all modifiable residues in the " "binary set must be unmodified or modified. Multiple binary sets " "can be specified by setting a different binary modification value. " "Max is an integer specifying the maximum number of modified " "residues possible in a peptide for this modification entry. " "Distance specifies the distance the modification is applied to " "from the respective terminus: -1 = no distance contraint; " "0 = only applies to terminal residue; N = only applies to " "terminal residue through next N residues. " "Terminus specifies which terminus the distance constraint is " "applied to: 0 = protein N-terminus; 1 = protein C-terminus; " "2 = peptide N-terminus; 3 = peptide C-terminus." "Force specifies whether peptides must contain this modification: " "0 = not forced to be present; 1 = modification is required.", "Available for comet.", true); for (int i = 2; i <= 9; i++) { InitStringParam("variable_mod0" + StringUtils::ToString(i), "0.0 null 0 4 -1 0 0", "See syntax for variable_mod01.", "Available for comet.", true); } InitIntParam("max_variable_mods_in_peptide", 5, 0, BILLION, "Specifies the total/maximum number of residues that can be modified in a peptide.", "Available for comet.", true); InitIntParam("require_variable_mod", 0, 0, 1, "Controls whether the analyzed peptides must contain at least one variable modification.", "Available for comet.", true); /* Comet - Static modifications */ InitDoubleParam("add_Cterm_peptide", 0, 0, BILLION, "Specifiy a static modification to the c-terminus of all peptides.", "Available for comet.", true); InitDoubleParam("add_Nterm_peptide", 0, 0, BILLION, "Specify a static modification to the n-terminus of all peptides.", "Available for comet.", true); InitDoubleParam("add_Cterm_protein", 0, 0, BILLION, "Specify a static modification to the c-terminal peptide of each protein.", "Available for comet.", true); InitDoubleParam("add_Nterm_protein", 0, 0, BILLION, "Specify a static modification to the n-terminal peptide of each protein.", "Available for comet.", true); for (char c = 'A'; c <= 'Z'; c++) { InitDoubleParam(CometApplication::staticModParam(c), c != 'C' ? 0 : CYSTEINE_DEFAULT, 0, BILLION, "Specify a static modification to the residue " + string(1, c) + ".", "Available for comet.", true); } // **** q-ranker-barista arguments **** InitArgParam("database", "The program requires the FASTA format protein database files against " "which the search was performed. The protein database input may be a " "concatenated database or separate target and decoy databases; the " "latter is supported with the --separate-searches option, described " "below. In either case, Barista distinguishes between target and decoy " "proteins based on the presence of a decoy prefix on the sequence " "identifiers (see the --decoy-prefix option, below). The database can " "be provided in three different ways: (1) as a a single FASTA file " "with suffix \".fa\", \".fsa\" or \".fasta\", (2) as a text file " "containing a list of FASTA files, one per line, or (3) as a directory " "containing multiple FASTA files (identified via the filename suffixes " "\".fa\", \".fsa\" or \".fasta\")."); InitArgParam("search results", "Search results in the [[html:<a href=\"../file-formats/txt-format.html\">]]tab-delimited text format" "[[html:</a>]] produced by Crux or in [[html:<a href=\"../file-formats/sqt-format.html\">]]SQT format[[html:</a>]]. " "Like the spectra, the search results can be provided " "as a single file, a list of files or a directory of files. Note, however, that the " "input mode for spectra and for search results must be the same; i.e., if you provide " "a list of files for the spectra, then you must also provide a list of files " "containing your search results. When the MS2 files and tab-delimited text files are " "provided via a file listing, it is assumed that the order of the MS2 files matches " "the order of the tab-delimited files. Alternatively, when the MS2 files and " "tab-delimited files are provided via directories, the program will search for pairs of " "files with the same root name but different extensions (\".ms2\" and \".txt\")."); // **** q-ranker options. **** InitBoolParam("skip-cleanup", false, "Analysis begins with a pre-processsing step that creates a " "set of lookup tables which are then used during training. Normally, " "these lookup tables are deleted at the end of the analysis, " "but setting this option to T prevents the deletion of these tables. " "Subsequently, analyses can be repeated more efficiently " "by specifying the --re-run option.", "Available for q-ranker and barista.", true); InitStringParam("re-run", "", "Re-run a previous analysis using a previously computed set of " "lookup tables. For this option to work, the --skip-cleanup option must have " "been set to true when the program was run the first time.", "Available for q-ranker and barista.", true); InitBoolParam("use-spec-features", true, "Use an enriched feature set, including separate features for each ion type.", "Available for q-ranker and barista.", true); InitStringParam("separate-searches", "", "If the target and decoy searches were run separately, rather than " "using a concatenated database, then the program will assume that the " "database search results provided as a required argument are from the " "target database search. This option then allows the user to specify " "the location of the decoy search results. Like the required arguments, " "these search results can be provided as a single file, a list of files " "or a directory. However, the choice (file, list or directory) must be " "consistent for the MS2 files and the target and decoy tab-delimited files. Also, " "if the MS2 and tab-delimited files are provided in directories, then Q-ranker " "will use the MS2 filename (foo.ms2) to identify corresponding target " "and decoy tab-delimited files with names like foo*.target.txt and " "foo*.decoy.txt. This naming convention allows the target and decoy txt " "files to reside in the same directory.", "Available for q-ranker and barista.", true); //**** Barista and QRanker options. ****** InitBoolParam("list-of-files", false, "Specify that the search results are provided as lists of files, rather than as " "individual files.", "Available for barista.", true); InitStringParam("optimization", "protein", "protein|peptide|psm", "Specifies whether to do optimization at the protein, peptide or psm level.", "Available for barista.", true); /* analyze-matches parameter options */ InitArgParam("target input", "One or more files, each containing a collection of peptide-spectrum matches (PSMs) " "in [[html:<a href=\"../file-formats/txt-format.html\">]]tab-delimited text[[html:</a>]], [[html:<a " "href=\"http://tools.proteomecenter.org/wiki/index.php?title=Formats:pepXML\">]]PepXML" "[[html:</a>]], or [[html:<a href=\"http://www.psidev.info/mzidentml\">]]mzIdentML" "[[html:</a>]] format. In tab-delimited text format, only the specified score column " "is required. However if --estimation-method is tdc, then the columns \"scan\" and " "\"charge\" are required, as well as \"protein ID\" if the search was run with " "concat=F. Furthermore, if the --estimation-method is specified to peptide-level " "is set to T, then the column " "\"peptide\" must be included, and if --sidak is set to T, then the \"distinct " "matches/spectrum\" column must be included.[[html:<br>Note that multiple files can " "also be provided either on the command line or using the --list-of-files option.<br>" "Decoys can be provided in two ways: either as a separate file or embedded within the " "same file as the targets. Crux will first search the given file for decoys using a " "prefix (specified via --decoy-prefix) on the protein name. If no decoys are found, " "then Crux will search for decoys in a separate file. The decoy file name is constructed " "from the target file name by replacing \"target\" with \"decoy\". For example, if " "tide-search.target.txt is provided as input, then Crux will search for a corresponding " "file named \"tide-search.decoy.txt.\"<br>Note that if decoys are provided in a separate " "file, then assign-confidence will first carry out a target-decoy competition, " "identifying corresponding pairs of targets and decoys and eliminating the one with " "the worse score. In this case, the column/tag called \"delta_cn\" will be eliminated " "from the output.]]"); InitDoubleParam("pi-zero", 1.0, 0, 1, "The estimated percent of target scores that are drawn from the " "null distribution.", "Used by assign-confidence, percolator and q-ranker", false); InitStringParam("estimation-method", "tdc", "mix-max|tdc|peptide-level", "Specify the method used to estimate q-values. The mix-max procedure or target-decoy " "competition apply to PSMs. The peptide-level option eliminates any PSM for which there " "exists a better scoring PSM involving the same peptide, and then uses decoys to " "assign confidence estimates.", "Used by assign-confidence.", true); InitBoolParam("sidak", false, "Adjust the score using the Sidak adjustment and reports them in a new column in the " "output file. Note that this adjustment only makes sense if the given scores are " "p-values, and that it requires the presence of the \"distinct matches/spectrum\" " "feature for each PSM.", "Used by assign-confidence.", true); InitStringParam("score", "", "Specify the column (for tab-delimited input) or tag (for XML input) " "used as input to the q-value estimation procedure. If this parameter is unspecified, " "then the program searches for \"xcorr score\", \"evalue\" (comet), " "\"exact p-value\" score fields in this order in the input file. ", "Used by assign-confidence.", true); InitBoolParam("combine-charge-states", false, "Specify this parameter to T in order to combine charge states with peptide sequences" "in peptide-centric search. Works only if estimation-method = peptide-level.", "Used by assign-confidence.", true); InitBoolParam("combine-modified-peptides", false, "Specify this parameter to T in order to treat peptides carrying different or " "no modifications as being the same. Works only if estimation = peptide-level.", "Used by assign-confidence.", true); InitStringParam("percolator-intraset-features", "F", "Set a feature for percolator that in later versions is not an option.", "Shouldn't be variable; hide from user.", false); InitBoolParam("use-old-atdc", false, "Use the originally described version of aTDC, rather than the improved one.", "Used by assign-confidence.", false); /* Cascade-Search parameters */ InitDoubleParam("q-value-threshold", 0.01, 0, 1.0, "The q-value threshold used by cascade search. Each spectrum identified in one search " "with q-value less than this threshold will be excluded from all subsequent searches. " "Note that the threshold is not applied to the final database in the cascade.", "Used by cascade-search.", true); InitArgParam("database-series", "A comma-separated list of databases, each generated by tide-index. " "Cascade-search will search the given spectra against these databases in the given order."); /*Subtract-index parameters*/ InitArgParam("tide index 1", "A peptide index produced using tide-index"); InitArgParam("tide index 2", "A second peptide index, to be subtracted from the first index."); InitArgParam("output index", "A new peptide index containing all peptides that occur in the" "first index but not the second."); // InitArgParam("index name", "output tide index"); // **** predict-peptide-ions options. **** InitStringParam("primary-ions", "by", "a|b|y|by|bya", "Predict the specified primary ion series. 'a' indicates a-ions only, 'b' indicates " "b-ions only, 'y' indicates y-ions only, 'by' indicates both b and y, 'bya' " "indicates b, y, and a.", "Only available for crux-predict-peptide-ions. Set automatically to " "'by' for searching.", true); InitBoolParam("precursor-ions", false, "Predict the precursor ions, and all associated ions (neutral losses, multiple " "charge states) consistent with the other specified options.", "Only available for crux-predict-peptide-ions.", true); InitIntParam("isotope", 0, 0, 2, "Predict the given number of isotope peaks (0|1|2).", "Only available for crux-predict-peptide-ion. Automatically set to " "0 for Sp scoring and 1 for xcorr scoring.", true); InitBoolParam("flanking", false, "Predict flanking peaks for b- and y ions.", "Only available for crux-predict-peptide-ion.", true); InitStringParam("max-ion-charge", "peptide", "Predict theoretical ions up to max charge state (1, 2, ... ,6) or up to the charge state " "of the peptide (\"peptide\"). If the max-ion-charge is greater than the " "charge state of the peptide, then the maximum is the peptide charge. ", "Available for predict-peptide-ions and search-for-xlinks. " "Set to 'peptide' for search.", true); InitIntParam("nh3", 0, -100, BILLION, "Include among the predicted peaks b/y ions with up to n losses of nh3. For example, " "for --nh3 2, predict a peak for each b- and y-ion with the loss of one nh3 group and " "predict a second peak for each b- and y-ion with the loss of two nh3 groups. These " "peaks will have 1 and 2, respectively, in the NH3 column of the output.", "Only available for crux-predict-peptide-ions.", true); InitIntParam("h2o", 0, -100, BILLION, "Include in the predicted peaks, b/y ions with the loss of 1 to n water molecules. See " "--nh3 for an example.", "Only available for crux-predict-peptide-ions.", true); // ***** spectral-counts aguments ***** InitArgParam("input PSMs", "A PSM file in either tab delimited text format (as produced by percolator, " "q-ranker, or barista) or pepXML format."); // also uses "protein-database" // ***** spectral-counts options ***** InitStringParam("protein-database", "", "The name of the file in FASTA format.", "Option for spectral-counts", true); InitStringParam("measure", "NSAF", "RAW|NSAF|dNSAF|SIN|EMPAI", "Type of analysis to make on the match results: " "(RAW|NSAF|dNSAF|SIN|EMPAI). With exception of the RAW metric, the database of " "sequences need to be provided using --protein-database.", "Available for spectral-counts. RAW is raw counts, " "NSAF is Normalized Spectral Abundance Factor, " "dNSAF is Distributed Spectral Abundance Factor, " "SIN is Spectral Index Normalized and EMPAI is " "Exponentially Modified Protein Abundance Index", true); InitBoolParam("unique-mapping", false, "Ignore peptides that map to multiple proteins.", "Available for spectral-counts.", true); InitStringParam("quant-level", "protein", "protein|peptide", "Quantification at protein or peptide level.", "Available for spectral-counts and either NSAF and SIN.", true); InitStringParam("parsimony", "none", "none|simple|greedy", "Perform a parsimony analysis on the proteins, and report a " "\"parsimony rank\" column in the output file. This column contains " "integers indicating the protein's rank in a list sorted by spectral " "counts. If the parsimony analysis results in two proteins being merged, " "then their parsimony rank is the same. In such a case, the rank is " "assigned based on the largest spectral count of any protein in the merged " "meta-protein. The \"simple\" parsimony algorithm only merges two proteins " "A and B if the peptides identified in protein A are the same as or a " "subset of the peptides identified in protein B. The \"greedy\" parsimony " "algorithm does additional merging, by identifying the longest protein " "(i.e., the protein with the most peptides) that contains one or more " "shared peptides. The shared peptides are assigned to the identified " "protein and removed from any other proteins that contain them, and the " "process is then repeated. Note that, with this option, some proteins end " "up being assigned no peptides at all; these orphan proteins are not " "reported in the output.", "Available for spectral-counts.", true); InitStringParam("threshold-type", "qvalue", "none|qvalue|custom", "Determines what type of threshold to use when filtering matches. none : read all " "matches, qvalue : use calculated q-value from percolator or q-ranker, custom : use " "--custom-threshold-name and --custom-threshold-min parameters.", "used for crux spectral-counts", true); InitDoubleParam("threshold", 0.01, "Only consider PSMs with a threshold value. By default, q-values " "are thresholded using a specified threshold value. This behavior can be " "changed using the --custom-threshold and --threshold-min " "parameters.", "Available for spectral-counts. All PSMs with higher (or lower) than " "this will be ignored.", true); InitStringParam("custom-threshold-name", "", "Specify which field to apply the threshold to. The direction of the threshold " "(<= or >=) is governed by --custom-threshold-min. By default, the threshold " "applies to the q-value, specified by \"percolator q-value\", \"q-ranker q-value\", " "\"decoy q-value (xcorr)\", or \"barista q-value\".", "Available for spectral-counts.", true); InitBoolParam("custom-threshold-min", true, "When selecting matches with a custom threshold, custom-threshold-min determines " "whether to filter matches with custom-threshold-name values that are greater-than or " "equal (F) or less-than or equal (T) than the threshold.", "Available for spectral-counts.", true); InitStringParam("input-ms2", "", "MS2 file corresponding to the psm file. Required to measure the SIN. Ignored for " "NSAF, dNSAF and EMPAI.", "Available for spectral-counts with measure=SIN.", true); InitBoolParam("mzid-use-pass-threshold", false, "Use mzid's passThreshold attribute to filter matches.", "Used when parsing mzIdentML files.", true); // ***** static mods ***** for (char c = 'A'; c <= 'Z'; c++) { double deltaMass = (c != 'C') ? 0 : CYSTEINE_DEFAULT; bool visible = (c != 'B' && c != 'J' && c != 'O' && c != 'U' && c != 'X' && c != 'Z'); InitDoubleParam(string(1, c), deltaMass, "Change the mass of all amino acids '" + string(1, c) + "' by the " "given amount.", "", visible); } /* psm-convert options */ InitStringParam("input-format", "auto", "auto|tsv|sqt|pepxml|mzidentml", "Legal values are auto, tsv, sqt, pepxml or mzidentml format.", "option, for psm-convert", true); InitBoolParam("distinct-matches", true, "Whether matches/ion are distinct (as opposed to total).", "option, for psm-convert.", true); /* get-ms2-spectrum options */ InitBoolParam("stats", false, "Rather than the spectrum, output summary statistics to standard output. Each statistic " "is placed on a separate line, in the format <name>:<value> (e.g. \"TIC:1000.0\")." "[[html:<br>The following statistics are reported for the entire spectrum:<ul><li>" "Precursor m/z</li><li>Total Ion Current</li><li>Base Peak Intensity</li><li>Number of " "peaks</li><li>Minimum m/z</li><li>Maximum m/z</li></ul>In addition, for each possible " "spectrum charge state, the following statistics are reported:<ul><li>Charge state</li>" "<li>Neutral mass</li><li>Charged mass</li><li>M+H+ mass</li></ul>]]", "Available only for crux-get-ms2-spectrum. Does not affect contents " "of the output file.", true); InitBoolParam("write-weibull-points", false, "write out the weibull training points for the" "spectrum,charge", "Available for crux search-for-xlinks", true); // **** xlink-predict-peptide-ions options **** InitArgParam("peptide A", "The sequence of peptide A."); InitArgParam("peptide B", "The sequence of peptide B."); InitArgParam("pos A", "Position of cross-link on peptide A"); InitArgParam("pos B", "Position of cross-link on peptide B"); InitBoolParam("print-theoretical-spectrum", false, "Print the theoretical spectrum", "Available for xlink-predict-peptide-ions.", true); InitBoolParam("use-old-xlink", true /* Turn to false later */, "Use the old version of xlink-searching algorithm. When false, a new version of the " "code is run. The new version supports variable modifications and can handle more " "complex databases. This new code is still in development and should be considered a " "beta release.", "Available for search-for-xlinks.", true); // **** xlink-score-spectrum options **** InitStringParam("xlink-score-method", "composite", "composite|modification|concatenated", "Score method for xlink {composite, modification, concatenated}.", "Available for xlink-score-spectrum.", true); // **** search-xlink options **** InitStringParam("isotope-windows", "0", "Provides a list of isotopic windows to search. For example, -1,0,1 will search in " "three disjoint windows: (1) precursor_mass - neutron_mass +/- window, (2) precursor_mass " "+/- window, and (3) precursor_mass + neutron_mass +/- window. The window size is defined " "from the precursor-window and precursor-window-type parameters. This option is only " "available when use-old-xlink=F.", "Available for search-for-xlinks", true); InitStringParam("mono-link", "", "Provides a list of amino acids and their mass modifications to consider as candidate for " "mono-/dead- links. Format is the same as mods-spec.", "Available for search-for-xlinks (new code)", true); InitIntParam("xlink-top-n", 250, 0, BILLION, "Specify the number of open-mod peptides to consider in the second pass. " "A value of 0 will search all candiates.", "Available for search-for-xlinks", true); InitBoolParam("xlink-print-db", false, "Prints the generated database of xlink products to the file xlink_peptides.txt in " "the output directory.", "Available for search-for-xlinks.", false); InitBoolParam("require-xlink-candidate", false, "If there is no cross-link candidate found, then don't bother looking for linear, " "self-loop, and dead-link candidates.", "Available for search-for-xlinks.", true); InitBoolParam("xlink-use-ion-cache", false, "Use an ion cache for the xlinkable peptides. " "May not be scalable for large databases.", "Available for search-for-xlinks.", false); InitBoolParam("xlink-include-linears", true, "Include linear peptides in the search.", "Available for search-for-xlinks.", true); InitBoolParam("xlink-include-deadends", true, "Include dead-end peptides in the search.", "Available for search-for-xlinks.", true); InitBoolParam("xlink-include-selfloops", true, "Include self-loop peptides in the search.", "Available for search-for-xlinks.", true); InitBoolParam("xlink-include-intra", true, "Include intra-protein cross-link candiates within the search.", "Available for search-for-xlinks.", true); InitBoolParam("xlink-include-inter", true, "Include inter-protein cross-link candidates within the search.", "Available for search-for-xlinks.", true); InitBoolParam("xlink-include-inter-intra", true, "Include crosslink candidates that are both inter and intra.", "Available for search-for-xlinks.", true); InitStringParam("xlink-prevents-cleavage", "K", "List of amino acids for which the cross-linker can prevent cleavage. This option is " "only available when use-old-xlink=F.", "Available for search-for-xlinks program.", true); InitIntParam("max-xlink-mods", 255 , 0, BILLION, "Specify the maximum number of modifications allowed on a crosslinked peptide. This " "option is only available when use-old-xlink=F.", "Available for crux search-for-xlinks", true); InitDoubleParam("precursor-window-weibull", 20.0, 0, 1e6, "Search decoy peptides within +/- precursor-window-weibull of the precursor mass. " "The resulting scores are used only for fitting the Weibull distribution", "Available for crux search-for-xlinks. ", true); InitStringParam("precursor-window-type-weibull", "mass", "mass|mz|ppm", "Window type to use in conjunction with the precursor-window-weibull parameter.", "Available for crux search-for-xlinks", true); InitIntParam("min-weibull-points", 4000, 1, BILLION, "Keep shuffling and collecting XCorr scores until the minimum number of points for " "weibull fitting (using targets and decoys) is achieved.", "Available for crux search-for-xlinks", true); InitArgParam("link sites", "Specification of the the two sets of amino acids that the cross-linker can " "connect. These are specified as two comma-separated sets of amino acids, " "with the two sets separated by a colon. Cross-links involving the terminus " "of a protein can be specified by using \"nterm\" or \"cterm\". For example, " "\"K,nterm:Q\" means that the cross linker can attach K to Q or the protein " "N-terminus to Q. Note that the vast majority of cross-linkers will " "operate on the following reactive groups: amine (K,nterm), " "carboxyl (D,E,cterm), sulfhydrl (C), acyl (Q) or amine+ (K,S,T,Y,nterm)."); InitArgParam("link mass", "The mass modification of the linker when attached to a peptide."); /* hardklor parameters */ InitStringParam("hardklor-algorithm", "version1", "basic|version1|version2", "Determines which spectral feature detection algorithm to use. Different results are " "possible with each algorithm, and there are pros and cons to each.[[html: There are " "three algorithms to choose from:<ul><li>basic &ndash; Performs unoptimized " "deconvolution and is provided for legacy purposes only.</li><li>version1 &ndash; " "Uses the optimizations developed during the 1.0+ series. It is very accurate, but has " "limited sensitivity, and moderate speed improvements.</li><li>version2 &ndash; Uses " "the optimizations developed for version 2.0+. It is highly sensitive, but less " "accurate for very low abundance features, and performs exceptionally fast.</li></ul>]]", "Available for crux hardklor", true); InitStringParam("averagine-mod", "", "Defines alternative averagine models in the analysis that incorporate additional " "atoms and/or isotopic enrichments. Modifications are represented as text strings. " "Inclusion of additional atoms in the model is done using by entering an atomic " "formula, such as: PO2 or Cl. Inclusion of isotopic enrichment to the model is done by " "specifying the percent enrichment (as a decimal) followed by the atom being enriched " "and an index of the isotope. For example, 0.75H1 specifies 75% enrichment of the first " "heavy isotope of hydrogen. In other words, 75% deuterium enrichment. Two or more " "modifications can be combined into the same model, and separated by spaces: B2 0.5B1", "Available for crux hardklor", true); InitIntParam("boxcar-averaging", 0, 0, BILLION, "Boxcar averaging is a sliding window that averages n adjacent spectra prior to feature " "detection. Averaging generally improves the signal-to-noise ratio of features in the " "spectra, as well as improving the shape of isotopic envelopes. However, averaging will " "also change the observed peak intensities. Averaging with too wide a window will " "increase the occurrence of overlapping features and broaden the chromatographic " "profiles of observed features. The number specified is the total adjacent scans to be " "combined, centered on the scan being analyzed. Therefore, an odd number is recommended " "to center the boxcar window. For example, a value of 3 would produce an average of the " "scan of interest, plus one scan on each side. A value of 0 disables boxcar averaging.", "Available for crux hardklor", true); InitIntParam("boxcar-filter", 0, 0, BILLION, "This parameter is only functional when boxcar-averaging is used. The filter will " "remove any peaks not seen in n scans in the boxcar window. The effect is to reduce " "peak accumulation due to noise and reduce chromatographic broadening of peaks. Caution " "should be used as over-filtering can occur. The suggested number of scans to set for " "filtering should be equal to or less than the boxcar-averaging window size. A value of " "0 disables filtering.", "Available for crux hardklor", true); InitDoubleParam("boxcar-filter-ppm", 10.0, 0.0, BILLION, "This parameter is only functional when boxcar-filter is used. The value specifies the " "mass tolerance in ppm for declaring a peak the same prior to filtering across all " "scans in the boxcar window.", "Available for crux hardklor", true); InitBoolParam("centroided", false, "Indicates whether the data contain profile or centroided peaks.", "Available for crux hardklor", true); InitStringParam("cdm", "Q", "B|F|P|Q|S", "Choose the charge state determination method.[[html: There are five methods to " "choose from:<ul><li>B &ndash; Basic method, assume all charge states are possible." "</li><li>F &ndash; Fast Fourier transform.</li><li>P &ndash; Patterson algorithm.</li>" "<li>Q &ndash; QuickCharge method, uses inverse peak distances.</li><li>S &ndash; " "Senko method, or combined Fast Fourier Transform and Patterson algorithm.</li></ul>]]", "Available for crux hardklor", true); InitIntParam("min-charge", 1, 1, BILLION, "Specifies the minimum charge state to allow when finding spectral features. It is " "best to set this value to the lowest assumed charge state to be present. If set higher " "than actual charge states that are present, those features will not be identified or " "incorrectly assigned a different charge state and mass.", "Available for crux hardklor", true); InitIntParam("max-charge", 5, 1, BILLION, "Specifies the maximum charge state to allow when finding spectral features. It is " "best to set this value to a practical number (i.e. do not set it to 20 when doing a " "tryptic shotgun analysis). If set higher than actual charge states that are present, " "the algorithm will perform significantly slower without any improvement in results.", "Available for crux hardklor", true); InitDoubleParam("corr", 0.85, 0, 1.0, "Sets the correlation threshold (cosine similarity) for accepting each predicted " "feature.", "Available for crux hardklor", true); InitIntParam("depth", 3, 1, BILLION, "Sets the depth of combinatorial analysis. For a given set of peaks in a spectrum, " "search for up to this number of combined peptides that explain the observed peaks. " "The analysis stops before depth is reached if the current number of deconvolved " "features explains the observed peaks with a correlation score above the threshold " "defined with the correlation parameter.", "Available for crux hardklor", true); InitBoolParam("distribution-area", false, "When reporting each feature, report abundance as the sum of all isotope peaks. The " "value reported is the estimate of the correct peak heights based on the averagine " "model scaled to the observed peak heights.", "Available for crux hardklor", true); InitStringParam("hardklor-data-file", "", "Specifies an ASCII text file that defines symbols for the periodic table.", "Available for crux hardklor", true); InitStringParam("instrument", "fticr", "fticr|orbitrap|tof|qit", "Indicates the type of instrument used to collect data. This parameter, combined with " "the resolution parameter, define how spectra will be centroided (if you provide " "profile spectra) and the accuracy when aligning observed peaks to the models.", "Available for crux hardklor", true); InitStringParam("isotope-data-file", "", "Specifies an ASCII text file that can be read to override the natural isotope " "abundances for all elements.", "Available for crux hardklor", true); InitIntParam("max-features", 10, 1, BILLION, "Specifies the maximum number of models to build for a set of peaks being analyzed. " "Regardless of the setting, the number of models will never exceed the number of peaks " "in the current set. However, as many of the low abundance peaks are noise or tail ends " "of distributions, defining models for them is detrimental to the analysis.", "Available for crux hardklor", true); InitIntParam("mzxml-filter", 1, 1, 2, "Filters the spectra prior to analysis for the requested MS/MS level. For example, if " "the data contain MS and MS/MS spectra, setting mzxml-filter = 1 will analyze only the " "MS scan events. Setting mzxml-filter = 2 will analyze only the MS/MS scan events.", "Available for crux hardklor", true); InitDoubleParam("mz-max", 0, 0, 10000, "Constrains the search in each spectrum to signals below this value in Thomsons. " "Setting to 0 disables this feature.", "Available for crux hardklor", true); InitDoubleParam("mz-min", 0, 0, 10000, "Constrains the search in each spectrum to signals above this value in Thomsons. " "Setting to 0 disables this feature.", "Available for crux hardklor", true); InitDoubleParam("mz-window", 4.0, 1.0, 20.0, "Only used when algorithm = version1. Defines the maximum window size in Thomsons to " "analyze when deconvolving peaks in a spectrum into features.", "Available for crux hardklor", true); InitDoubleParam("resolution", 100000, 1, BILLION, "Specifies the resolution of the instrument at 400 m/z for the data being analyzed.", "Available for crux hardklor", true); InitIntParam("scan-range-max", 0, 0, BILLION, "Used to restrict analysis to spectra with scan numbers below this parameter value. " "A value of 0 disables this feature.", "Available for crux hardklor", true); InitIntParam("scan-range-min", 0, 0, BILLION, "Used to restrict analysis to spectra with scan numbers above this parameter value. " "A value of 0 disables this feature.", "Available for crux hardklor", true); InitIntParam("sensitivity", 2, 0, 3, "Set the sensitivity level. There are four levels: 0 (low), 1 (moderate), " "2 (high), and 3 (max). Increasing the sensitivity will increase computation time, " "but will also yield more isotope distributions.", "Available for crux hardklor", true); InitDoubleParam("signal-to-noise", 1.0, 0.0, BILLION, "Filters spectra to remove peaks below this signal-to-noise ratio prior to finding " "features.", "Available for crux hardklor", true); InitIntParam("smooth", 0, 0, 21, "Uses Savitzky-Golay smoothing on profile peak data prior to centroiding the spectra. " "This parameter is recommended for low resolution spectra only. Smoothing data causes " "peak depression and broadening. Only use odd numbers for the degree of smoothing (as " "it defines a window centered on each data point). Higher values will produce smoother " "peaks, but with greater depression and broadening. Setting this parameter to 0 disables " "smoothing.", "Available for crux hardklor", true); InitDoubleParam("sn-window", 250.0, 0.0, BILLION, "Set the signal-to-noise window length (in m/z). Because noise may " "be non-uniform across a spectrum, this value adjusts the segment size " "considered when calculating a signal-over-noise ratio.", "Available for crux hardklor", true); InitBoolParam("static-sn", true, "Applies the lowest noise threshold of any sn_window across the entire mass range for a " "spectrum. Setting this parameter to 0 turns off this feature, and different noise " "thresholds will be used for each local mass window in a spectrum.", "Available for crux hardklor", true); InitBoolParam("hardklor-xml-output", false, "Output XML instead of tab-delimited text.", "Available for crux hardklor", false); /* bullseye parameters */ InitArgParam("MS1 spectra", "The name of a file from which to parse high-resolution spectra of intact peptides. " "The file may be in MS1 (.ms1), binary MS1 (.bms1), compressed MS1 (.cms1), or " "mzXML (.mzXML) format. Bullseye will search for PPIDs in these spectra."); InitArgParam("MS2 spectra", "The name of a file from which to parse peptide fragmentation spectra. The file may " "be in MS2 (.ms2), binary MS2 (.bms2), compressed MS2 (.cms2) or mzXML (.mzXML) format. " "Bullseye will assign high-resolution precursor masses to these spectra."); InitStringParam("hardklor-file", "", "Input hardklor file into bullseye", "Hidden option for crux bullseye.", false); InitDoubleParam("max-persist", 2.0, 0, BILLION, "Ignore PPIDs that persist for longer than this length of time in the MS1 spectra. The " "unit of time is whatever unit is used in your data file (usually minutes). These PPIDs " "are considered contaminants.", "Available for crux bullseye", true); InitBoolParam("exact-match", false, "When true, require an exact match (as defined by --exact-tolerance) between the " "center of the precursor isolation window in the MS2 scan and the base isotopic " "peak of the PPID. If this option is set to false and no exact match is observed, " "then attempt to match using a wider m/z tolerance. This wider tolerance is calculated " "using the PPID's monoisotopic mass and charge (the higher the charge, the smaller " "the window).", "Available for crux bullseye", true); InitIntParam("gap-tolerance", 1, 0, BILLION, "Allowed gap size when checking for PPIDs across consecutive MS1 scans.", "Available for crux bullseye", true); InitDoubleParam("bullseye-min-mass", 600, 0, BILLION, "Only consider PPIDs above this minimum mass in daltons.", "Available for crux bullseye", true); InitDoubleParam("bullseye-max-mass", 8000, 1, BILLION, "Only consider PPIDs below this maximum mass in daltons.", "Available for crux bullseye", true); InitDoubleParam("exact-tolerance", 10.0, 0, BILLION, "Set the tolerance (+/-ppm) for --exact-match.", "Available for crux bullseye", true); InitDoubleParam("persist-tolerance", 10.0, 0, BILLION, "Set the mass tolerance (+/-ppm) for finding PPIDs in consecutive MS1 scans.", "Available for crux bullseye", true); InitIntParam("scan-tolerance", 3, 0, BILLION, "Total number of MS1 scans over which a PPID must be observed to be considered real. " "Gaps in persistence are allowed by setting --gap-tolerance.", "Available for crux bullseye", true); InitDoubleParam("retention-tolerance", 0.5, 0, BILLION, "Set the tolerance (+/-units) around the retention time over which a PPID can be " "matches to the MS2 spectrum. The unit of time is whatever unit is used in your data " "file (usually minutes).", "Available for crux bullseye", true); InitStringParam("spectrum-format", "", "|ms2|bms2|cms2|mgf", "The format to write the output spectra to. If empty, the spectra will be " "output in the same format as the MS2 input.", "Available for crux bullseye", true); /* crux-util parameters */ InitBoolParam("ascending", true, "Sort in ascending (T) or descending (F) order.", "Available for sort-by-column", true); InitArgParam("tsv file", "A tab-delimited file, with column headers in the first row. Use \"-\" to read from " "standard input."); InitStringParam("delimiter", "tab", "Specify the input and output delimiter to use when processing the " "delimited file. The argument can be either a single character or " "the keyword 'tab.'", "Available for the delimited utility programs.", true); InitArgParam("column names", "A comma-delimited list of column names."); InitArgParam("column name", "A column name."); InitArgParam("column value", "A cell value for a column."); InitBoolParam("header", true, "Print the header line of the file, in addition to the columns that match.", "Available for crux extract-columns and extract-rows", true); InitStringParam("column-type", "string", "int|real|string", "Specifies the data type of the column, either an integer (int), a floating point " "number (real), or a string.", "Available for crux extract-rows", true); InitStringParam("comparison", "eq", "eq|gt|gte|lt|lte|neq", "Specify the operator that is used to compare an entry in the specified column to the " "value given on the command line.[[html: Legal values are as follows:<ul><li>eq &ndash; " "The two values are equal</li><li>lt &ndash; The file value is less than the argument " "value</li><li>lte &ndash; The file value is less than or equal to the argument value" "</li><li>gt &ndash; The file value is greater than the argument value</li><li>gte " "&ndash; The file value is greater than or equal to the argument value</li><li>neq " "&ndash; The file value is not equal to the argument value</li></ul>]]", "Available for crux extract-rows", true); // crux pipeline options InitBoolParam("bullseye", false, "Run the Bullseye algorithm on the given MS data, using it to assign high-resolution " "precursor values to the MS/MS data. If a spectrum file ends with .ms2 or .cms2, matching " ".ms1/.cms1 files will be used as the MS1 file. Otherwise, it is assumed that the " "spectrum file contains both MS1 and MS2 scans.", "Available for crux pipeline", true); InitStringParam("search-engine", "tide-search", "comet|tide-search", "Specify which search engine to use.", "Available for crux pipeline", true); InitStringParam("post-processor", "percolator", "percolator|assign-confidence|none", "Specify which post-processor to apply to the search results.", "Available for crux pipeline", true); // create-docs InitArgParam("tool-name", "Specifies the Crux tool to generate documentation for. If the value is " "'list', then a list of available tools will be given. If the value is " "'default-params', then a default parameter file will be given." "If the value is 'param-table' then a table will be printed showing " "which parameters are associated with which commands."); InitStringParam("doc-template", "", "Specifies the main template to be used for generating documentation.", "Available for crux create-docs", false); InitStringParam("doc-input-template", "", "Specifies the template to be used for inputs when generating " "documentation.", "Available for crux create-docs", false); InitStringParam("doc-output-template", "", "Specifies the template to be used for outputs when generating " "documentation.", "Available for crux create-docs", false); InitStringParam("doc-option-category-template", "", "Specifies the template to be used for option categories when generating " "documentation.", "Available for crux create-docs", false); InitStringParam("doc-option-template", "", "Specifies the template to be used for options when generating " "documentation.", "Available for crux create-docs", false); // param-medic InitArgParam("spectrum-file", "File from which to parse fragmentation spectra."); InitBoolParam("pm-ignore-no-charge", true, "When parsing spectra for measurement error estimation, ignore those without charge state information.", "Available for param-medic and tide-search and comet", false); InitDoubleParam("pm-min-precursor-mz", 400, "Minimum precursor m/z value to use in measurement error estimation.", "Available for param-medic and tide-search and comet", true); InitDoubleParam("pm-max-precursor-mz", 1800, "Minimum precursor m/z value to use in measurement error estimation.", "Available for param-medic and tide-search and comet", true); InitDoubleParam("pm-min-frag-mz", 150, "Minimum fragment m/z value to use in measurement error estimation.", "Available for param-medic and tide-search and comet", true); InitDoubleParam("pm-max-frag-mz", 1800, "Maximum fragment m/z value to use in measurement error estimation.", "Available for param-medic and tide-search and comet", true); InitIntParam("pm-min-scan-frag-peaks", 40, "Minimum fragment peaks an MS/MS scan must contain to be used in measurement error estimation.", "Available for param-medic and tide-search and comet", true); InitDoubleParam("pm-max-precursor-delta-ppm", 50, "Maximum ppm distance between precursor m/z values to consider two scans " "potentially generated by the same peptide for measurement error estimation.", "Available for param-medic and tide-search and comet", true); InitStringParam("pm-charges", "0,2,3,4", "Precursor charge states to consider MS/MS spectra from, in measurement error estimation, " "provided as comma-separated values.", "Available for param-medic and tide-search and comet", true); InitIntParam("pm-top-n-frag-peaks", 30, "Number of most-intense fragment peaks to consider for measurement error estimation, per MS/MS spectrum.", "Available for param-medic and tide-search and comet", true); InitIntParam("pm-pair-top-n-frag-peaks", 5, "Number of fragment peaks per spectrum pair to be used in fragment error " "estimation.", "Available for param-medic and tide-search and comet", true); InitIntParam("pm-min-common-frag-peaks", 20, "Number of the most-intense peaks that two spectra must share in order to " "potentially be generated by the same peptide, for measurement error estimation.", "Available for param-medic and tide-search and comet", true); InitIntParam("pm-max-scan-separation", 1000, "Maximum number of scans two spectra can be separated by in order to be " "considered potentially generated by the same peptide, for measurement error estimation.", "Available for param-medic and tide-search and comet", true); InitIntParam("pm-min-peak-pairs", 200, "Minimum number of peak pairs (for precursor or fragment) that must be " "successfully paired in order to attempt to estimate measurement error distribution.", "Available for param-medic and tide-search and comet", true); // localize-modification InitDoubleParam("min-mod-mass", 0, 0, BILLION, "Ignore implied modifications where the absolute value of its mass is " "below this value and only score the unmodified peptide.", "Available for localize-modification", true); InitBoolParam("no-analytics", false, "Don't post data to Google Analytics.", "", false); Categorize(); } Params::~Params() { for (map<string, Param*>::iterator i = params_.begin(); i != params_.end(); i++) { delete i->second; } } void Params::Categorize() { set<string> items; items.clear(); items.insert("bullseye-max-mass"); items.insert("bullseye-min-mass"); items.insert("gap-tolerance"); items.insert("max-persist"); items.insert("persist-tolerance"); items.insert("scan-tolerance"); AddCategory("Identifying PPIDs in MS1 spectra", items); items.clear(); items.insert("exact-match"); items.insert("exact-tolerance"); items.insert("retention-tolerance"); AddCategory("Matching PPIDs to MS2 spectra", items); items.clear(); items.insert("clip-nterm-methionine"); items.insert("isotopic-mass"); items.insert("max-length"); items.insert("max-mass"); items.insert("min-length"); items.insert("min-mass"); AddCategory("Peptide properties", items); items.clear(); items.insert("cmod"); items.insert("cterm-peptide-mods-spec"); items.insert("cterm-protein-mods-spec"); items.insert("max-mods"); items.insert("min-mods"); items.insert("mod"); items.insert("mod-precision"); items.insert("mods-spec"); items.insert("nmod"); items.insert("nterm-peptide-mods-spec"); items.insert("nterm-protein-mods-spec"); for (char c = 'A'; c <= 'Z'; c++) { items.insert(string(1, c)); } items.insert("auto-modifications"); AddCategory("Amino acid modifications", items); items.clear(); items.insert("allow-dups"); items.insert("decoy-format"); items.insert("num-decoys-per-target"); items.insert("keep-terminal-aminos"); items.insert("seed"); AddCategory("Decoy database generation", items); items.clear(); items.insert("custom-enzyme"); items.insert("digestion"); items.insert("enzyme"); items.insert("missed-cleavages"); AddCategory("Enzymatic digestion", items); items.clear(); items.insert("auto-precursor-window"); items.insert("max-precursor-charge"); items.insert("precursor-window"); items.insert("precursor-window-type"); AddCategory("Precursor selection", items); items.clear(); items.insert("auto-mz-bin-width"); items.insert("compute-p-values"); items.insert("compute-sp"); items.insert("deisotope"); items.insert("exact-p-value"); items.insert("fragment-mass"); items.insert("isotope-error"); items.insert("isotope-windows"); items.insert("max-ion-charge"); items.insert("min-peaks"); items.insert("min-weibull-points"); items.insert("mod-mass-format"); items.insert("mz-bin-offset"); items.insert("mz-bin-width"); items.insert("peptide-centric-search"); items.insert("precursor-window-type-weibull"); items.insert("precursor-window-weibull"); items.insert("remove-precursor-peak"); items.insert("remove-precursor-tolerance"); items.insert("scan-number"); items.insert("skip-preprocessing"); items.insert("spectrum-charge"); items.insert("spectrum-max-mz"); items.insert("spectrum-min-mz"); items.insert("use-flanking-peaks"); items.insert("use-neutral-loss-peaks"); items.insert("score-function"); items.insert("fragment-tolerance"); items.insert("evidence-granularity"); AddCategory("Search parameters", items); items.clear(); items.insert("use-a-ions"); items.insert("use-b-ions"); items.insert("use-c-ions"); items.insert("use-x-ions"); items.insert("use-y-ions"); items.insert("use-z-ions"); AddCategory("Fragment ion parameters", items); items.clear(); items.insert("picked-protein"); items.insert("protein-enzyme"); items.insert("protein-report-duplicates"); items.insert("protein-report-fragments"); AddCategory("Protein inference options", items); items.clear(); items.insert("protein"); items.insert("fido-alpha"); items.insert("fido-beta"); items.insert("fido-empirical-protein-q"); items.insert("fido-fast-gridsearch"); items.insert("fido-gamma"); items.insert("fido-gridsearch-depth"); items.insert("fido-gridsearch-mse-threshold"); items.insert("fido-no-split-large-components"); items.insert("fido-protein-truncation-threshold"); AddCategory("Fido options", items); items.clear(); items.insert("max-xlink-mods"); items.insert("mono-link"); items.insert("use-old-xlink"); items.insert("xlink-include-deadends"); items.insert("xlink-include-inter"); items.insert("xlink-include-inter-intra"); items.insert("xlink-include-intra"); items.insert("xlink-include-linears"); items.insert("xlink-include-selfloops"); items.insert("xlink-prevents-cleavage"); AddCategory("Cross-linking parameters", items); items.clear(); items.insert("decoy_search"); AddCategory("Database", items); items.clear(); items.insert("num-threads"); items.insert("num_threads"); AddCategory("CPU threads", items); items.clear(); items.insert("auto_peptide_mass_tolerance"); items.insert("isotope_error"); items.insert("mass_type_fragment"); items.insert("mass_type_parent"); items.insert("peptide_mass_tolerance"); items.insert("peptide_mass_units"); items.insert("precursor_tolerance_type"); AddCategory("Masses", items); items.clear(); items.insert("allowed_missed_cleavage"); items.insert("num_enzyme_termini"); items.insert("search_enzyme_number"); AddCategory("Search enzyme", items); items.clear(); items.insert("auto_fragment_bin_tol"); items.insert("fragment_bin_offset"); items.insert("fragment_bin_tol"); items.insert("theoretical_fragment_ions"); items.insert("use_A_ions"); items.insert("use_B_ions"); items.insert("use_C_ions"); items.insert("use_X_ions"); items.insert("use_Y_ions"); items.insert("use_Z_ions"); items.insert("use_NL_ions"); AddCategory("Fragment ions", items); items.clear(); items.insert("activation_method"); items.insert("ms_level"); items.insert("override_charge"); items.insert("precursor_charge"); items.insert("scan_range"); AddCategory("mzXML/mzML parameters", items); items.clear(); items.insert("clip_nterm_methionine"); items.insert("decoy_prefix"); items.insert("digest_mass_range"); items.insert("mass_offsets"); items.insert("max_fragment_charge"); items.insert("max_precursor_charge"); items.insert("nucleotide_reading_frame"); items.insert("num_results"); items.insert("output_suffix"); items.insert("skip_researching"); items.insert("spectrum_batch_size"); AddCategory("Miscellaneous parameters", items); items.clear(); items.insert("clear_mz_range"); items.insert("minimum_intensity"); items.insert("minimum_peaks"); items.insert("remove_precursor_peak"); items.insert("remove_precursor_tolerance"); AddCategory("Spectral processing", items); items.clear(); for (int i = 1; i <= 9; i++) { items.insert("variable_mod0" + StringUtils::ToString(i)); } items.insert("auto_modifications"); items.insert("max_variable_mods_in_peptide"); items.insert("require_variable_mod"); AddCategory("Variable modifications", items); items.clear(); items.insert("add_Cterm_peptide"); items.insert("add_Nterm_peptide"); items.insert("add_Cterm_protein"); items.insert("add_Nterm_protein"); for (char c = 'A'; c <= 'Z'; c++) { string aaString = string(1, c); string aaName = AminoAcidUtil::GetName(c); aaName = aaName.empty() ? "user_amino_acid" : StringUtils::Replace(aaName, " ", "_"); items.insert("add_" + aaString + "_" + aaName); } AddCategory("Static modifications", items); items.clear(); items.insert("only-psms"); items.insert("tdc"); items.insert("search-input"); AddCategory("General options", items); items.clear(); items.insert("c-neg"); items.insert("c-pos"); items.insert("maxiter"); items.insert("percolator-seed"); items.insert("quick-validation"); items.insert("subset-max-train"); items.insert("test-each-iteration"); items.insert("test-fdr"); items.insert("train-fdr"); AddCategory("SVM training options", items); items.clear(); items.insert("default-direction"); items.insert("init-weights"); items.insert("klammer"); items.insert("output-weights"); items.insert("override"); items.insert("unitnorm"); AddCategory("SVM feature input options", items); items.clear(); items.insert("pm-charges"); items.insert("pm-max-frag-mz"); items.insert("pm-max-precursor-delta-ppm"); items.insert("pm-max-precursor-mz"); items.insert("pm-max-scan-separation"); items.insert("pm-min-common-frag-peaks"); items.insert("pm-min-frag-mz"); items.insert("pm-min-peak-pairs"); items.insert("pm-min-precursor-mz"); items.insert("pm-min-scan-frag-peaks"); items.insert("pm-pair-top-n-frag-peaks"); items.insert("pm-top-n-frag-peaks"); AddCategory("param-medic options", items); items.clear(); items.insert("ascending"); items.insert("column-type"); items.insert("comparison"); items.insert("concat"); items.insert("decoy-prefix"); items.insert("decoy-xml-output"); items.insert("delimiter"); items.insert("feature-file-out"); items.insert("file-column"); items.insert("fileroot"); items.insert("header"); items.insert("list-of-files"); items.insert("mass-precision"); items.insert("mzid-output"); items.insert("num_output_lines"); items.insert("output-dir"); items.insert("output-file"); items.insert("output_outfiles"); items.insert("output_pepxmlfile"); items.insert("output_percolatorfile"); items.insert("output_sqtfile"); items.insert("output_txtfile"); items.insert("overwrite"); items.insert("parameter-file"); items.insert("peptide-list"); items.insert("pepxml-output"); items.insert("pin-output"); items.insert("pout-output"); items.insert("precision"); items.insert("print-search-progress"); items.insert("print_expect_score"); items.insert("sample_enzyme_number"); items.insert("show_fragment_ions"); items.insert("spectrum-format"); items.insert("spectrum-parser"); items.insert("sqt-output"); items.insert("store-index"); items.insert("store-spectra"); items.insert("temp-dir"); items.insert("top-match"); items.insert("txt-output"); items.insert("use-z-line"); items.insert("verbosity"); items.insert("xlink-print-db"); AddCategory("Input and output", items); } bool Params::GetBool(const string& name) { return Require(name)->GetBool(); } int Params::GetInt(const string& name) { return Require(name)->GetInt(); } double Params::GetDouble(const string& name) { return Require(name)->GetDouble(); } string Params::GetString(const string& name) { return Require(name)->GetString(); } bool Params::GetBoolDefault(const string& name) { return Require(name)->GetBoolDefault(); } int Params::GetIntDefault(const string& name) { return Require(name)->GetIntDefault(); } double Params::GetDoubleDefault(const string& name) { return Require(name)->GetDoubleDefault(); } string Params::GetStringDefault(const string& name) { return Require(name)->GetStringDefault(); } const vector<string>& Params::GetStrings(const string& name) { Param* param = Require(name); if (!param->IsArgument()) { throw runtime_error("Parameter '" + name + "' is not an argument"); } return ((ArgParam*)param)->GetStrings(); } string Params::GetUsage(const string& name) { return Require(name)->GetUsage(); } string Params::GetFileNotes(const string& name) { return Require(name)->GetFileNotes(); } bool Params::IsVisible(const string& name) { return Require(name)->IsVisible(); } bool Params::IsArgument(const string& name) { return Require(name)->IsArgument(); } string Params::GetAcceptedValues(const string& name) { return Require(name)->GetAcceptedValues(); } bool Params::IsDefault(const string& name) { return Require(name)->IsDefault(); } bool Params::Exists(const string& name) { return paramContainer_.Get(name) != NULL; } void Params::Set(const string& name, bool value) { paramContainer_.CanModifyCheck(); Param* param = Require(name); param->Set(value); param->ThrowIfInvalid(); } void Params::Set(const string& name, int value) { paramContainer_.CanModifyCheck(); Param* param = Require(name); param->Set(value); param->ThrowIfInvalid(); } void Params::Set(const string& name, double value) { paramContainer_.CanModifyCheck(); Param* param = Require(name); param->Set(value); param->ThrowIfInvalid(); } void Params::Set(const string& name, const char* value) { Set(name, string(value)); } void Params::Set(const string& name, const string& value) { paramContainer_.CanModifyCheck(); Param* param = Require(name); param->Set(value); param->ThrowIfInvalid(); } void Params::AddArgValue(const string& name, const string& value) { paramContainer_.CanModifyCheck(); Param* param = Require(name); if (!param->IsArgument()) { throw runtime_error("Cannot add value to '" + name + "', it is not an argument"); } ((ArgParam*)param)->AddValue(value); } void Params::Finalize() { paramContainer_.FinalizeParams(); } void Params::Write(ostream* out, bool defaults) { if (out == NULL || !out->good()) { throw runtime_error("Bad file stream for writing parameter file"); } *out << "# Crux parameter file (generated by Crux version " << CRUX_VERSION << ")" << endl << "# Full documentation available at http://cruxtoolkit.sourceforge.net/" << endl << "# comet_version 2016.01 rev. 1" << endl << "# Everything following the \'#\' symbol is treated as a comment." << endl << endl; for (vector<const Param*>::const_iterator i = Begin(); i != End(); i++) { string name = (*i)->GetName(); // Print mods and Comet parameters later if (!(*i)->IsVisible() || name == "mod" || name == "cmod" || name == "nmod" || name.find('_') != string::npos) { continue; } *out << (*i)->GetParamFileString(defaults) << endl; } print_mods_parameter_file(out, "mod", get_aa_mod_list); print_mods_parameter_file(out, "nmod", get_n_mod_list); print_mods_parameter_file(out, "cmod", get_c_mod_list); // Print Comet parameters *out << "####################" << endl << "# Comet Parameters #" << endl << "####################" << endl; for (vector<const Param*>::const_iterator i = Begin(); i != End(); i++) { string name = (*i)->GetName(); // Print mods and Comet parameters later if (!(*i)->IsVisible() || name == "mod" || name == "cmod" || name == "nmod" || name.find('_') == string::npos) { continue; } *out << (*i)->GetParamFileString(defaults) << endl; } *out << "#" << endl << "# COMET_ENZYME_INFO _must_ be at the end of this parameters file" << endl << "#" << endl << "[COMET_ENZYME_INFO]" << endl; const vector<string>& cometEnzymes = get_comet_enzyme_info_lines(); if (cometEnzymes.empty() || defaults) { *out << "0. No_enzyme 0 - -" << endl << "1. Trypsin 1 KR P" << endl << "2. Trypsin/P 1 KR -" << endl << "3. Lys_C 1 K P" << endl << "4. Lys_N 0 K -" << endl << "5. Arg_C 1 R P" << endl << "6. Asp_N 0 D -" << endl << "7. CNBr 1 M -" << endl << "8. Glu_C 1 DE P" << endl << "9. PepsinA 1 FL P" << endl << "10. Chymotrypsin 1 FWYL P" << endl; /*TODO: Put these back in after we figure out what to do with enzyme info *out << "11. Elastase 1 ALIV P" << endl << "12. Clostripain 1 R -" << endl << "13. Iodosobenzoate 1 W -" << endl << "14. Proline_Endopeptidase 1 P -" << endl << "15. Staph_Protease 1 E -" << endl << "16. Modified_Chymotrypsin 1 FWYL P" << endl << "17. Elastase_Trypsin_Chymotrypsin 1 ALIVKRWFY P" << endl; */ } else { for (vector<string>::const_iterator i = cometEnzymes.begin(); i != cometEnzymes.end(); i++) { *out << *i << endl; } } } map<string, Param*>::const_iterator Params::BeginAll() { return paramContainer_.params_.begin(); } map<string, Param*>::const_iterator Params::EndAll() { return paramContainer_.params_.end(); } vector<const Param*>::const_iterator Params::Begin() { return paramContainer_.paramsOrdered_.begin(); } vector<const Param*>::const_iterator Params::End() { return paramContainer_.paramsOrdered_.end(); } string Params::ProcessHtmlDocTags(string s, bool html) { // If html is true, instances of [[html:{text}]] become {text} and // instances of [[nohtml:{text}]] are removed. // If html is false, instances of [[nohtml:{text}]] become {text} and // instances of [[html:{text}]] are removed. const string OPEN_TAG = "[["; const string CLOSE_TAG = "]]"; const string HTML_PREFIX = "html:"; const string NO_HTML_PREFIX = "nohtml:"; size_t pos, endPos = 0; while ((pos = s.find(OPEN_TAG, endPos)) != string::npos) { size_t prefixStart = pos + OPEN_TAG.length(); if ((endPos = s.find(CLOSE_TAG, prefixStart)) == string::npos) { return s; } string fullOpen = OPEN_TAG; bool fullRemove; if (s.length() >= prefixStart + HTML_PREFIX.length() && s.compare(prefixStart, HTML_PREFIX.length(), HTML_PREFIX) == 0) { fullOpen += HTML_PREFIX; fullRemove = !html; } else if (s.length() >= prefixStart + NO_HTML_PREFIX.length() && s.compare(prefixStart, NO_HTML_PREFIX.length(), NO_HTML_PREFIX) == 0) { fullOpen += NO_HTML_PREFIX; fullRemove = html; } else { endPos = prefixStart; continue; } if (!fullRemove) { s.erase(pos, fullOpen.length()); endPos -= fullOpen.length(); s.erase(endPos, CLOSE_TAG.length()); } else { s.erase(pos, endPos + CLOSE_TAG.length() - pos); endPos = pos; } } return s; } vector< pair< string, vector<string> > > Params::GroupByCategory(const vector<string>& options) { vector< pair< string, vector<string> > > groups; pair< string, vector<string> > uncategorizedPair = make_pair("", vector<string>(options)); vector<string>& uncategorized = uncategorizedPair.second; // Iterate over all categories for (vector<ParamCategory>::const_iterator i = paramContainer_.categories_.begin(); i != paramContainer_.categories_.end(); i++) { bool any = false; // Iterate over each given option and check if it is in the category for (vector<string>::const_iterator j = options.begin(); j != options.end(); j++) { Param* param = Require(*j); // This option was in the category if (i->Items.find(param) != i->Items.end()) { if (!any) { any = true; groups.push_back(make_pair(i->Name, vector<string>())); } groups.back().second.push_back(*j); vector<string>::iterator iter; while ((iter = find(uncategorized.begin(), uncategorized.end(), *j)) != uncategorized.end()) { uncategorized.erase(iter); } } } } if (!uncategorized.empty()) { groups.insert(groups.begin(), uncategorizedPair); } return groups; } void Params::InitBoolParam( const string& name, bool value, const string& usage, const string& fileNotes, bool visible ) { Add(new BoolParam(name, usage, fileNotes, visible, value)); } void Params::InitIntParam( const string& name, int value, int min, int max, const string& usage, const string& fileNotes, bool visible ) { Add(new IntParam(name, usage, fileNotes, visible, value, min, max)); } void Params::InitIntParam( const string& name, int value, const string& usage, const string& fileNotes, bool visible ) { Add(new IntParam(name, usage, fileNotes, visible, value)); } void Params::InitDoubleParam( const string& name, double value, double min, double max, const string& usage, const string& fileNotes, bool visible ) { Add(new DoubleParam(name, usage, fileNotes, visible, value, min, max)); } void Params::InitDoubleParam( const string& name, double value, const string& usage, const string& fileNotes, bool visible ) { Add(new DoubleParam(name, usage, fileNotes, visible, value)); } void Params::InitStringParam( const string& name, const string& value, const string& validValues, const string& usage, const string& fileNotes, bool visible ) { Add(new StringParam(name, usage, fileNotes, visible, value, StringUtils::Split(validValues, '|'))); } void Params::InitStringParam( const string& name, const string& value, const string& usage, const string& fileNotes, bool visible ) { Add(new StringParam(name, usage, fileNotes, visible, value)); } void Params::InitArgParam( const string& name, const string& usage ) { Add(new ArgParam(name, usage)); } Param* Params::Require(const string& name) { Param* param = paramContainer_.Get(name); if (param == NULL) { throw runtime_error("Parameter '" + name + "' does not exist"); } return param; } Param* Params::Get(const string& name) { map<string, Param*>::iterator i = params_.find(name); return (i == params_.end()) ? NULL : i->second; } void Params::Add(Param* param) { CanModifyCheck(); param->ThrowIfInvalid(); string paramName = param->GetName(); if (!params_.insert(make_pair(paramName, param)).second) { throw runtime_error("Parameter '" + paramName + "' already exists"); } if (!param->IsArgument()) { paramsOrdered_.push_back(param); } } void Params::AddCategory(const string& name, const set<string>& params) { // Validate passed in set for (set<string>::const_iterator i = params.begin(); i != params.end(); i++) { if (Get(*i) == NULL) { throw runtime_error("Parameter '" + *i + "' does not exist"); } } ParamCategory* category = NULL; // Check if this category already exists for (vector<ParamCategory>::iterator i = categories_.begin(); i != categories_.end(); i++) { if (i->Name == name) { category = &*i; break; } } // Create new category if (!category) { categories_.push_back(ParamCategory(name)); category = &(categories_.back()); } // Loop over parameters and add them to the category if they are in the passed in set for (vector<const Param*>::const_iterator i = Begin(); i != End(); i++) { string paramName = (*i)->GetName(); if (params.find(paramName) != params.end()) { // Check if this parameter has already been categorized for (vector<ParamCategory>::const_iterator j = categories_.begin(); j != categories_.end(); j++) { if (j->Items.find(*i) != j->Items.end()) { throw runtime_error("Parameter '" + paramName + "' has already been categorized"); } } // Add parameter to category category->Items.insert(*i); } } } void Params::FinalizeParams() { if (finalized_) { return; } for (char c = 'A'; c <= 'Z'; c++) { string aa = string(1, c); double deltaMass = GetDouble(aa); if (deltaMass != 0) { ModificationDefinition::NewStaticMod(aa, deltaMass, ANY); } } if (GetString("enzyme") == "no-enzyme") { Set("digestion", "non-specific-digest"); Set("missed-cleavages", 500); } string customEnzyme = GetString("custom-enzyme"); if (!customEnzyme.empty()) { parse_custom_enzyme(customEnzyme); Set("enzyme", "custom-enzyme"); } if (GetString("enzyme") == "no-enzyme") { Set("digestion", "non-specific-digest"); } else if (GetString("digestion") == "non-specific-digest") { Set("enzyme", "no-enzyme"); } double new_value = GetDouble("mz-bin-width"); // *************************** #ifdef _MSC_VER // Peculiarities of Windows floating point handling // results in us getting 0.0 here rather than Nan // FIXME: is there a more portable way of checking // that a floating point value has not been set? if (new_value == 0.0) { #else if (std::isnan(new_value)) { #endif // If no width specified, choose based on mass type. if (get_mass_type_parameter("fragment-mass") == MONO) { new_value = BIN_WIDTH_MONO; } else { new_value = BIN_WIDTH_AVERAGE; } Set("mz-bin-width", new_value); } // *************************** finalized_ = true; } void Params::CanModifyCheck() const { if (finalized_) { throw runtime_error("Parameters have been finalized and cannot be modified"); } } // ***** Parameter classes ***** // // // Param (base class) // Param::Param(const string& name, const string& usage, const string& fileNotes, bool visible) : name_(name), usage_(usage), fileNotes_(fileNotes), visible_(visible) {} Param::~Param() {} string Param::GetName() const { return name_; } string Param::GetUsage() const { return usage_; } string Param::GetFileNotes() const { return fileNotes_; } bool Param::IsVisible() const { return visible_; } bool Param::IsArgument() const { return false; } void Param::ThrowIfInvalid() const {} string Param::GetParamFileString(bool defaultValue) const { vector<string> lines = StringUtils::Split(Params::ProcessHtmlDocTags(usage_), '\n'); vector<string> noteLines = StringUtils::Split(Params::ProcessHtmlDocTags(fileNotes_), '\n'); lines.insert(lines.end(), noteLines.begin(), noteLines.end()); stringstream ss; for (vector<string>::const_iterator i = lines.begin(); i != lines.end(); i++) { vector<string> formatted = StringUtils::Split(StringUtils::LineFormat(*i, 78), '\n'); for (vector<string>::const_iterator j = formatted.begin(); j != formatted.end(); j++) { ss << "# " << *j << endl; } } ss << name_ << '=' << (defaultValue ? GetStringDefault() : GetString()) << endl; return ss.str(); } void Param::Set(bool value) { throw runtime_error("Cannot set value of '" + name_ + "' from bool"); } void Param::Set(int value) { throw runtime_error("Cannot set value of '" + name_ + "' from int"); } void Param::Set(double value) { throw runtime_error("Cannot set value of '" + name_ + "' from double"); } void Param::Set(const char* value) { Set(string(value)); } void Param::Set(const string& value) { throw runtime_error("Cannot set value of '" + name_ + "' from string"); } // // BoolParam // BoolParam::BoolParam(const string& name, const string& usage, const string& fileNotes, bool visible, bool value) : Param(name, usage, fileNotes, visible), value_(value), original_(value) {} string BoolParam::GetAcceptedValues() const { return "T|F"; } bool BoolParam::IsDefault() const { return value_ == original_; } bool BoolParam::GetBool() const { return value_; } int BoolParam::GetInt() const { return IntParam::From(value_); } double BoolParam::GetDouble() const { return DoubleParam::From(value_); } string BoolParam::GetString() const { return StringParam::From(value_); } bool BoolParam::GetBoolDefault() const { return original_; } int BoolParam::GetIntDefault() const { return IntParam::From(original_); } double BoolParam::GetDoubleDefault() const { return DoubleParam::From(original_); } string BoolParam::GetStringDefault() const { return StringParam::From(original_); } void BoolParam::Set(bool value) { value_ = value; } void BoolParam::Set(int value) { value_ = From(value); } void BoolParam::Set(double value) { value_ = From(value); } void BoolParam::Set(const string& value) { try { value_ = From(value); } catch (...) { throw runtime_error("Invalid value for '" + name_ + "': " + "'" + value + "' " "(expected boolean)"); } } bool BoolParam::From(int i) { return i != 0; } bool BoolParam::From(double d) { return d != 0; } bool BoolParam::From(string s) { s = StringUtils::ToLower(s); if (s == "t" || s == "true") { return true; } else if (s == "f" || s == "false") { return false; } throw runtime_error("Cannot convert '" + s + "' to boolean"); } // // IntParam // IntParam::IntParam(const string& name, const string& usage, const string& fileNotes, bool visible, int value, int min, int max) : Param(name, usage, fileNotes, visible), value_(value), original_(value), min_(min), max_(max) {} void IntParam::ThrowIfInvalid() const { if (value_ < min_ || value_ > max_) { throw runtime_error("Value of '" + name_ + "' must be between " + StringUtils::ToString(min_) + " and " + StringUtils::ToString(max_)); } } string IntParam::GetAcceptedValues() const { return "<integer>"; } bool IntParam::IsDefault() const { return value_ == original_; } bool IntParam::GetBool() const { return BoolParam::From(value_); } int IntParam::GetInt() const { return value_; } double IntParam::GetDouble() const { return DoubleParam::From(value_); } string IntParam::GetString() const { return StringParam::From(value_); } bool IntParam::GetBoolDefault() const { return BoolParam::From(original_); } int IntParam::GetIntDefault() const { return original_; } double IntParam::GetDoubleDefault() const { return DoubleParam::From(original_); } string IntParam::GetStringDefault() const { return StringParam::From(original_); } void IntParam::Set(bool value) { value_ = From(value); } void IntParam::Set(int value) { value_ = value; } void IntParam::Set(double value) { value_ = From(value); } void IntParam::Set(const string& value) { try { value_ = From(value); } catch (...) { throw runtime_error("Invalid value for '" + name_ + "': " + "'" + value + "' " "(expected int)"); } } int IntParam::From(bool b) { return b ? 1 : 0; } int IntParam::From(double d) { return (int)d; } int IntParam::From(const string& s) { return StringUtils::FromString<int>(s); } // // DoubleParam // DoubleParam::DoubleParam(const string& name, const string& usage, const string& fileNotes, bool visible, double value, double min, double max) : Param(name, usage, fileNotes, visible), value_(value), original_(value), min_(min), max_(max) {} void DoubleParam::ThrowIfInvalid() const { if (value_ < min_ || value_ > max_) { throw runtime_error("Value of '" + name_ + "' must be between " + StringUtils::ToString(min_) + " and " + StringUtils::ToString(max_)); } } string DoubleParam::GetAcceptedValues() const { return "<float>"; } bool DoubleParam::IsDefault() const { return value_ == original_; } bool DoubleParam::GetBool() const { return BoolParam::From(value_); } int DoubleParam::GetInt() const { return IntParam::From(value_); } double DoubleParam::GetDouble() const { return value_; } string DoubleParam::GetString() const { return StringParam::From(value_); } bool DoubleParam::GetBoolDefault() const { return BoolParam::From(original_); } int DoubleParam::GetIntDefault() const { return IntParam::From(original_); } double DoubleParam::GetDoubleDefault() const { return original_; } string DoubleParam::GetStringDefault() const { return StringParam::From(original_); } void DoubleParam::Set(bool value) { value_ = From(value); } void DoubleParam::Set(int value) { value_ = From(value); } void DoubleParam::Set(double value) { value_ = value; } void DoubleParam::Set(const string& value) { try { value_ = From(value); } catch (...) { throw runtime_error("Invalid value for '" + name_ + "': " + "'" + value + "' " "(expected float)"); } } double DoubleParam::From(bool b) { return b ? 1 : 0; } double DoubleParam::From(int i) { return (double)i; } double DoubleParam::From(const string& s) { return StringUtils::FromString<double>(s); } // // StringParam // StringParam::StringParam(const string& name, const string& usage, const string& fileNotes, bool visible, const string& value, const vector<string>& validValues) : Param(name, usage, fileNotes, visible), original_(value), validValues_(validValues) { Set(value); } void StringParam::ThrowIfInvalid() const { if (!validValues_.empty() && find(validValues_.begin(), validValues_.end(), value_) == validValues_.end()) { throw runtime_error("Invalid value for '" + name_ + "'; must be one of <" + StringUtils::Join(validValues_, '|') + ">"); } } string StringParam::GetAcceptedValues() const { return validValues_.empty() ? "<string>" : StringUtils::Join(validValues_, '|'); } bool StringParam::IsDefault() const { return value_ == original_; } bool StringParam::GetBool() const { return BoolParam::From(value_); } int StringParam::GetInt() const { return IntParam::From(value_); } double StringParam::GetDouble() const { return DoubleParam::From(value_); } string StringParam::GetString() const { return value_; } bool StringParam::GetBoolDefault() const { return BoolParam::From(original_); } int StringParam::GetIntDefault() const { return IntParam::From(original_); } double StringParam::GetDoubleDefault() const { return DoubleParam::From(original_); } string StringParam::GetStringDefault() const { return original_; } void StringParam::Set(bool value) { value_ = From(value); } void StringParam::Set(int value) { value_ = From(value); } void StringParam::Set(double value) { value_ = From(value); } void StringParam::Set(const string& value) { value_ = value != "__NULL_STR" ? value : ""; } string StringParam::From(bool b) { return b ? "true" : "false"; } string StringParam::From(int i) { return StringUtils::ToString(i); } string StringParam::From(double d) { return StringUtils::ToString(d); } // // ArgParam // ArgParam::ArgParam(const string& name, const string& usage) : Param(name, usage, "", false), values_(vector<string>()) {} string ArgParam::GetAcceptedValues() const { return "<string>"; } bool ArgParam::IsArgument() const { return true; } bool ArgParam::IsDefault() const { return false; } bool ArgParam::GetBool() const { return BoolParam::From(GetString()); } int ArgParam::GetInt() const { return StringUtils::FromString<int>(GetString()); } double ArgParam::GetDouble() const { return StringUtils::FromString<double>(GetString()); } string ArgParam::GetString() const { if (values_.empty()) { throw runtime_error("No value for argument '" + name_ + "'"); } return values_.front(); } bool ArgParam::GetBoolDefault() const { return false; } int ArgParam::GetIntDefault() const { return 0; } double ArgParam::GetDoubleDefault() const { return 0; } string ArgParam::GetStringDefault() const { return ""; } const vector<string>& ArgParam::GetStrings() const { return values_; } void ArgParam::Set(bool value) { values_ = vector<string>(1, StringParam::From(value)); } void ArgParam::Set(int value) { values_ = vector<string>(1, StringParam::From(value)); } void ArgParam::Set(double value) { values_ = vector<string>(1, StringParam::From(value)); } void ArgParam::Set(const string& value) { values_ = vector<string>(1, value); } void ArgParam::AddValue(const string& value) { values_.push_back(value); } /* * Local Variables: * mode: c * c-basic-offset: 2 * End: */
BattleCommand_Present: ; present ld a, [wLinkMode] cp LINK_COLOSSEUM jr z, .colosseum_skippush push bc push de .colosseum_skippush call BattleCommand_Stab ld a, [wLinkMode] cp LINK_COLOSSEUM jr z, .colosseum_skippop pop de pop bc .colosseum_skippop ld a, [wTypeMatchup] and a jp z, AnimateFailedMove ld a, [wAttackMissed] and a jp nz, AnimateFailedMove push bc call BattleRandom ld b, a ld hl, PresentPower ld c, 0 .next ld a, [hli] cp -1 jr z, .heal_effect cp b jr nc, .got_power inc c inc hl jr .next .got_power ld a, c ld [wPresentPower], a call AnimateCurrentMoveEitherSide ld d, [hl] pop bc ret .heal_effect pop bc ld a, 3 ld [wPresentPower], a call AnimateCurrentMove call BattleCommand_SwitchTurn ld hl, AICheckPlayerMaxHP ldh a, [hBattleTurn] and a jr z, .got_hp_fn_pointer ld hl, AICheckEnemyMaxHP .got_hp_fn_pointer ld a, BANK(AICheckPlayerMaxHP) ; aka BANK(AICheckEnemyMaxHP) rst FarCall jr c, .already_fully_healed ld hl, GetQuarterMaxHP call CallBattleCore call BattleCommand_SwitchTurn ld hl, RestoreHP call CallBattleCore call BattleCommand_SwitchTurn ld hl, RegainedHealthText call StdBattleTextbox call BattleCommand_SwitchTurn call UpdateOpponentInParty jr .do_animation .already_fully_healed call BattleCommand_SwitchTurn call _CheckBattleScene jr nc, .do_animation call AnimateFailedMove ld hl, RefusedGiftText call StdBattleTextbox .do_animation jp EndMoveEffect INCLUDE "data/moves/present_power.asm"
; ---------------------------------------------------------------- ; Z88DK INTERFACE LIBRARY FOR THE BIFROST* ENGINE - RELEASE 1.2/L ; ; See "bifrost_h.h" for further details ; ---------------------------------------------------------------- SECTION code_clib SECTION code_bifrost_h PUBLIC asm_BIFROSTH_drawBackTilesH defc asm_BIFROSTH_drawBackTilesH = 57047 ; c = attrib ; e = col ; d = lin
MODULE generic_console_ioctl PUBLIC generic_console_ioctl SECTION code_clib EXTERN generic_console_cls EXTERN __console_h EXTERN __console_w EXTERN __pc6001_mode EXTERN generic_console_font32 EXTERN generic_console_udg32 INCLUDE "target/pc6001/def/pc6001.def" INCLUDE "ioctl.def" ; a = ioctl ; de = arg generic_console_ioctl: ex de,hl ld c,(hl) ;bc = where we point to inc hl ld b,(hl) cp IOCTL_GENCON_SET_FONT32 jr nz,check_set_udg ld (generic_console_font32),bc success: and a ret check_set_udg: cp IOCTL_GENCON_SET_UDGS jr nz,check_mode ld (generic_console_udg32),bc jr success check_mode: cp IOCTL_GENCON_SET_MODE jr nz,failure ld a,c ; The mode and 31 ld e,32 ;columns ld h,MODE_0 ld l,16 and a jr z,set_mode ld h,MODE_1 ld l,24 cp 1 ;HIRES jr z,set_mode ld e,16 ld h,MODE_2 cp 2 ;Half hires jr nz,failure set_mode: bit 5,c jr z,not_css set 1,h not_css: ld a,e ld (__console_w),a ld a,h ld (__pc6001_mode),a ld a,l ld (__console_h),a call generic_console_cls and a ret failure: scf ret
; A083487: Triangle read by rows: T(r,c) = 2*r*c + l + c (1 <= c <= l). ; Submitted by Christian Krause ; 4,7,12,10,17,24,13,22,31,40,16,27,38,49,60,19,32,45,58,71,84,22,37,52,67,82,97,112,25,42,59,76,93,110,127,144,28,47,66,85,104,123,142,161,180,31,52,73,94,115,136,157,178,199,220,34,57,80,103,126,149,172,195,218,241,264,37,62,87,112,137,162,187,212,237,262,287,312,40,67,94,121,148,175,202,229,256,283,310,337,364,43,72,101,130,159,188,217,246,275 mul $0,2 add $0,1 lpb $0 mov $2,$0 sub $0,2 trn $0,$1 add $1,2 add $2,2 lpe add $1,1 mul $1,$2 mov $0,$1 div $0,2
/*----------------------------------------------------------------------- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you 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. -----------------------------------------------------------------------*/ #include "WellboreGeometry.h" #include <limits> #include <sstream> #include <stdexcept> #include "Wellbore.h" #include "../tools/TimeTools.h" using namespace std; using namespace WITSML2_0_NS; using namespace gsoap_eml2_1; const char* WellboreGeometry::XML_TAG = "WellboreGeometry"; WellboreGeometry::WellboreGeometry(WITSML2_NS::Wellbore* witsmlWellbore, const std::string & guid, const std::string & title, gsoap_eml2_1::witsml20__ChannelStatus channelStatus) { if (witsmlWellbore == nullptr) throw invalid_argument("A wellbore must be associated to a wellbore geometry."); gsoapProxy2_1 = soap_new_witsml20__WellboreGeometry(witsmlWellbore->getGsoapContext()); initMandatoryMetadata(); setMetadata(guid, title, std::string(), -1, std::string(), std::string(), -1, std::string()); static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->GrowingStatus = channelStatus; witsmlWellbore->getRepository()->addDataObject(this); setWellbore(witsmlWellbore); } COMMON_NS::DataObjectReference WellboreGeometry::getWellboreDor() const { return COMMON_NS::DataObjectReference(static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->Wellbore); } void WellboreGeometry::setWellbore(WITSML2_NS::Wellbore* witsmlWellbore) { if (witsmlWellbore == nullptr) { throw invalid_argument("Cannot set a null witsml wellbore to a witsml trajectory"); } static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->Wellbore = witsmlWellbore->newEmlReference(); getRepository()->addRelationship(this, witsmlWellbore); } GETTER_AND_SETTER_DEPTH_MEASURE_OPTIONAL_ATTRIBUTE_IMPL(WellboreGeometry, MdBase, gsoap_eml2_1::eml21__LengthUom, gsoap_eml2_1::soap_new_witsml20__MeasuredDepthCoord) GETTER_AND_SETTER_MEASURE_OPTIONAL_ATTRIBUTE_IMPL(WellboreGeometry, GapAir, gsoap_eml2_1::eml21__LengthUom, gsoap_eml2_1::soap_eml21__LengthUom2s, gsoap_eml2_1::soap_new_eml21__LengthMeasure) GETTER_AND_SETTER_MEASURE_OPTIONAL_ATTRIBUTE_IMPL(WellboreGeometry, DepthWaterMean, gsoap_eml2_1::eml21__LengthUom, gsoap_eml2_1::soap_eml21__LengthUom2s, gsoap_eml2_1::soap_new_eml21__LengthMeasure) //*************************************** //************** SECTION **************** //*************************************** // Mandatory GETTER_AND_SETTER_GENERIC_ATTRIBUTE_IN_VECTOR_IMPL(std::string, WellboreGeometry, WellboreGeometrySection, uid) // Optional bool GETTER_AND_SETTER_GENERIC_OPTIONAL_ATTRIBUTE_IN_VECTOR_IMPL(bool, WellboreGeometry, WellboreGeometrySection, CurveConductor, gsoap_eml2_1::soap_new_bool) // Optional double GETTER_AND_SETTER_GENERIC_OPTIONAL_ATTRIBUTE_IN_VECTOR_IMPL(double, WellboreGeometry, WellboreGeometrySection, FactFric, gsoap_eml2_1::soap_new_double) // Optional string GETTER_AND_SETTER_GENERIC_OPTIONAL_ATTRIBUTE_IN_VECTOR_IMPL(std::string, WellboreGeometry, WellboreGeometrySection, Grade, gsoap_eml2_1::soap_new_std__string) // Optional enum GETTER_AND_SETTER_GENERIC_OPTIONAL_ATTRIBUTE_IN_VECTOR_IMPL(gsoap_eml2_1::witsml20__HoleCasingType, WellboreGeometry, WellboreGeometrySection, TypeHoleCasing, gsoap_eml2_1::soap_new_witsml20__HoleCasingType) // Optional Length Measure GETTER_AND_SETTER_MEASURE_OPTIONAL_ATTRIBUTE_IN_VECTOR_IMPL(WellboreGeometry, WellboreGeometrySection, IdSection, gsoap_eml2_1::eml21__LengthUom, gsoap_eml2_1::soap_new_eml21__LengthMeasure) GETTER_AND_SETTER_MEASURE_OPTIONAL_ATTRIBUTE_IN_VECTOR_IMPL(WellboreGeometry, WellboreGeometrySection, OdSection, gsoap_eml2_1::eml21__LengthUom, gsoap_eml2_1::soap_new_eml21__LengthMeasure) GETTER_AND_SETTER_MEASURE_OPTIONAL_ATTRIBUTE_IN_VECTOR_IMPL(WellboreGeometry, WellboreGeometrySection, DiaDrift, gsoap_eml2_1::eml21__LengthUom, gsoap_eml2_1::soap_new_eml21__LengthMeasure) // Optional Mass per Length Measure GETTER_AND_SETTER_MEASURE_OPTIONAL_ATTRIBUTE_IN_VECTOR_IMPL(WellboreGeometry, WellboreGeometrySection, WtPerLen, gsoap_eml2_1::eml21__MassPerLengthUom, gsoap_eml2_1::soap_new_eml21__MassPerLengthMeasure) void WellboreGeometry::setWellboreGeometrySectionMdInterval(unsigned int index, double top, double base, const std::string & datum, gsoap_eml2_1::eml21__LengthUom uom) { if (index >= static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->WellboreGeometrySection.size()) { throw std::range_error("The index is out of range"); } witsml20__WellboreGeometrySection* section = static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->WellboreGeometrySection[index]; section->SectionMdInterval = soap_new_eml21__MdInterval(gsoapProxy2_1->soap); section->SectionMdInterval->datum = datum; section->SectionMdInterval->MdTop = soap_new_eml21__LengthMeasure(gsoapProxy2_1->soap); section->SectionMdInterval->MdTop->uom = uom; section->SectionMdInterval->MdTop->__item = top; section->SectionMdInterval->MdBase = soap_new_eml21__LengthMeasure(gsoapProxy2_1->soap); section->SectionMdInterval->MdBase->uom = uom; section->SectionMdInterval->MdBase->__item = base; } double WellboreGeometry::getWellboreGeometrySectionMdIntervalTop(unsigned int index) const { if (index >= static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->WellboreGeometrySection.size()) { throw std::range_error("The index is out of range"); } return static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->WellboreGeometrySection[index]->SectionMdInterval->MdTop->__item; } gsoap_eml2_1::eml21__LengthUom WellboreGeometry::getWellboreGeometrySectionMdIntervalTopUom(unsigned int index) const { if (index >= static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->WellboreGeometrySection.size()) { throw std::range_error("The index is out of range"); } return static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->WellboreGeometrySection[index]->SectionMdInterval->MdTop->uom; } double WellboreGeometry::getWellboreGeometrySectionMdIntervalBase(unsigned int index) const { if (index >= static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->WellboreGeometrySection.size()) { throw std::range_error("The index is out of range"); } return static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->WellboreGeometrySection[index]->SectionMdInterval->MdBase->__item; } gsoap_eml2_1::eml21__LengthUom WellboreGeometry::getWellboreGeometrySectionMdIntervalBaseUom(unsigned int index) const { if (index >= static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->WellboreGeometrySection.size()) { throw std::range_error("The index is out of range"); } return static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->WellboreGeometrySection[index]->SectionMdInterval->MdBase->uom; } std::string WellboreGeometry::getWellboreGeometrySectionMdIntervaldatum(unsigned int index) const { if (index >= static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->WellboreGeometrySection.size()) { throw std::range_error("The index is out of range"); } return static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->WellboreGeometrySection[index]->SectionMdInterval->datum; } bool WellboreGeometry::hasWellboreGeometrySectionMdInterval(unsigned int index) const { if (index >= static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->WellboreGeometrySection.size()) { throw std::range_error("The index is out of range"); } return static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->WellboreGeometrySection[index]->SectionMdInterval != nullptr; } void WellboreGeometry::setWellboreGeometrySectionTvdInterval(unsigned int index, double top, double base, const std::string & datum, gsoap_eml2_1::eml21__LengthUom uom) { if (index >= static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->WellboreGeometrySection.size()) { throw std::range_error("The index is out of range"); } witsml20__WellboreGeometrySection* section = static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->WellboreGeometrySection[index]; section->SectionTvdInterval = soap_new_eml21__TvdInterval(gsoapProxy2_1->soap); section->SectionTvdInterval->datum = datum; section->SectionTvdInterval->TvdTop = soap_new_eml21__LengthMeasure(gsoapProxy2_1->soap); section->SectionTvdInterval->TvdTop->uom = uom; section->SectionTvdInterval->TvdTop->__item = top; section->SectionTvdInterval->TvdBase = soap_new_eml21__LengthMeasure(gsoapProxy2_1->soap); section->SectionTvdInterval->TvdBase->uom = uom; section->SectionTvdInterval->TvdBase->__item = base; } double WellboreGeometry::getWellboreGeometrySectionTvdIntervalTop(unsigned int index) const { if (index >= static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->WellboreGeometrySection.size()) { throw std::range_error("The index is out of range"); } return static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->WellboreGeometrySection[index]->SectionTvdInterval->TvdTop->__item; } gsoap_eml2_1::eml21__LengthUom WellboreGeometry::getWellboreGeometrySectionTvdIntervalTopUom(unsigned int index) const { if (index >= static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->WellboreGeometrySection.size()) { throw std::range_error("The index is out of range"); } return static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->WellboreGeometrySection[index]->SectionTvdInterval->TvdTop->uom; } double WellboreGeometry::getWellboreGeometrySectionTvdIntervalBase(unsigned int index) const { if (index >= static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->WellboreGeometrySection.size()) { throw std::range_error("The index is out of range"); } return static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->WellboreGeometrySection[index]->SectionTvdInterval->TvdBase->__item; } gsoap_eml2_1::eml21__LengthUom WellboreGeometry::getWellboreGeometrySectionTvdIntervalBaseUom(unsigned int index) const { if (index >= static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->WellboreGeometrySection.size()) { throw std::range_error("The index is out of range"); } return static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->WellboreGeometrySection[index]->SectionTvdInterval->TvdBase->uom; } std::string WellboreGeometry::getWellboreGeometrySectionTvdIntervaldatum(unsigned int index) const { if (index >= static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->WellboreGeometrySection.size()) { throw std::range_error("The index is out of range"); } return static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->WellboreGeometrySection[index]->SectionTvdInterval->datum; } bool WellboreGeometry::hasWellboreGeometrySectionTvdInterval(unsigned int index) const { if (index >= static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->WellboreGeometrySection.size()) { throw std::range_error("The index is out of range"); } return static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->WellboreGeometrySection[index]->SectionTvdInterval != nullptr; } void WellboreGeometry::pushBackSection(const std::string & uid) { static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->WellboreGeometrySection.push_back(gsoap_eml2_1::soap_new_witsml20__WellboreGeometrySection(gsoapProxy2_1->soap, 1)); unsigned int index = getSectionCount() - 1; if (uid.empty()) { std::ostringstream oss; oss << index; setWellboreGeometrySectionuid(index, oss.str()); } else { setWellboreGeometrySectionuid(index, uid); } } unsigned int WellboreGeometry::getSectionCount() const { const size_t count = static_cast<witsml20__WellboreGeometry*>(gsoapProxy2_1)->WellboreGeometrySection.size(); if (count >= (std::numeric_limits<unsigned int>::max)()) { throw range_error("Too much sections"); } return static_cast<unsigned int>(count); }
;//////////////////////////////////////////////////////////////////////////////; ;/// void drawRect(int x, int y, int width, int height, int color) ///; ;//////////////////////////////////////////////////////////////////////////////; ; Label for procedure. drawRect: ;//////////////////////////////////////////////////////////////////////////////; ;/// Initialization code. ///; ;//////////////////////////////////////////////////////////////////////////////; ; Create stack frame. push bp mov bp,sp ; Define aliases for arguments. %define .arg0 bp+4 %define .arg1 bp+6 %define .arg2 bp+8 %define .arg3 bp+10 %define .arg4 bp+12 ; Define aliases for local variables. %define .x bp-10 %define .y bp-8 %define .width bp-6 %define .height bp-4 %define .color bp-2 ; Allocate space for local variables on the stack. sub sp,10 ; Make local copies of arguments. mov ax,[.arg0] mov [.x],ax mov ax,[.arg1] mov [.y],ax mov ax,[.arg2] mov [.width],ax mov ax,[.arg3] mov [.height],ax mov ax,[.arg4] mov [.color],ax ; Preserve register state. push bx push cx push dx push di push es ;//////////////////////////////////////////////////////////////////////////////; ;/// Procedure code. ///; ;//////////////////////////////////////////////////////////////////////////////; mov ax,[.width] test ax,ax jz .exit mov ax,[.height] test ax,ax jz .exit mov ax,GFXSEG mov es,ax mov ax,[.y] mov dx,320 mul dx add ax,[.x] mov dx,ax mov al,[.color] mov di,dx mov cx,[.width] rep stosb dec di mov cx,[.height] dec cx jz .exit .right: add di,320 mov byte [es:di],al loop .right mov di,dx mov cx,[.height] dec cx jz .exit .left: add di,320 mov byte [es:di],al loop .left mov cx,[.width] rep stosb .exit: ;//////////////////////////////////////////////////////////////////////////////; ;/// Deinitialization code. ///; ;//////////////////////////////////////////////////////////////////////////////; ; Restore register state. pop es pop di pop dx pop cx pop bx ; Free local variable stack space. add sp,10 ; Release stack frame and return. pop bp ret
; A022388: Fibonacci sequence beginning 6, 13. ; 6,13,19,32,51,83,134,217,351,568,919,1487,2406,3893,6299,10192,16491,26683,43174,69857,113031,182888,295919,478807,774726,1253533,2028259,3281792,5310051,8591843,13901894,22493737,36395631,58889368,95284999,154174367,249459366,403633733,653093099,1056726832,1709819931,2766546763,4476366694,7242913457,11719280151,18962193608,30681473759,49643667367,80325141126,129968808493,210293949619,340262758112,550556707731,890819465843,1441376173574,2332195639417,3773571812991,6105767452408,9879339265399,15985106717807,25864445983206,41849552701013,67713998684219,109563551385232,177277550069451,286841101454683,464118651524134,750959752978817,1215078404502951,1966038157481768,3181116561984719,5147154719466487,8328271281451206,13475426000917693,21803697282368899,35279123283286592,57082820565655491,92361943848942083,149444764414597574,241806708263539657,391251472678137231,633058180941676888,1024309653619814119,1657367834561491007,2681677488181305126,4339045322742796133,7020722810924101259,11359768133666897392,18380490944590998651,29740259078257896043,48120750022848894694,77861009101106790737,125981759123955685431,203842768225062476168,329824527349018161599,533667295574080637767,863491822923098799366,1397159118497179437133,2260650941420278236499,3657810059917457673632 add $0,2 mov $3,6 mov $4,7 lpb $0 sub $0,1 mov $1,$2 mov $2,$3 add $3,$4 mov $4,$2 lpe mov $0,$1
/* * This file is part of the CitizenFX project - http://citizen.re/ * * See LICENSE and MENTIONS in the root of the source tree for information * regarding licensing. */ #include "StdInc.h" #include <ComponentLoader.h> #include <Server.h> class ServerMain { public: virtual void Run(fwRefContainer<Component> component) = 0; }; DECLARE_INSTANCE_TYPE(ServerMain); #include <sstream> #include <boost/algorithm/string/replace.hpp> namespace fx { void Server::Start(int argc, char* argv[]) { ComponentLoader* loader = ComponentLoader::GetInstance(); loader->Initialize(); // combine argv to a separate command list std::stringstream args; for (int i = 1; i < argc; i++) { std::string arg = argv[i]; boost::algorithm::replace_all(arg, "\\", "\\\\"); args << "\"" << arg << "\" "; } std::string argStr = args.str(); // get the right component auto compName = "citizen:server:main"; if (argStr.find("\"+exec\" ") == std::string::npos) { compName = "citizen:server:monitor"; } fwRefContainer<ComponentData> serverComponent = loader->LoadComponent(compName); ComponentLoader::GetInstance()->ForAllComponents([&](fwRefContainer<ComponentData> componentData) { for (auto& instance : componentData->GetInstances()) { instance->SetCommandLine(argc, argv); instance->Initialize(); } }); if (!serverComponent.GetRef()) { trace("Could not obtain citizen:server:main component, which is required for the server to start.\n"); return; } // create a component instance fwRefContainer<Component> componentInstance = serverComponent->CreateInstance(argStr); // check if the server initialized properly if (componentInstance.GetRef() == nullptr) { return; } Instance<ServerMain>::Get()->Run(componentInstance); } }
; A114219: Number triangle (k-(k-1)*0^(n-k))*[k<=n]. ; Submitted by Simon Strandgaard ; 1,0,1,0,1,1,0,1,2,1,0,1,2,3,1,0,1,2,3,4,1,0,1,2,3,4,5,1,0,1,2,3,4,5,6,1,0,1,2,3,4,5,6,7,1,0,1,2,3,4,5,6,7,8,1,0,1,2,3,4,5,6,7,8,9,1 mov $2,$0 lpb $2 mov $0,4 sub $1,1 add $2,$1 lpe sub $2,1 add $1,$2 add $2,$0 add $2,16 mul $1,$2 mod $2,$1 mov $0,$2 add $0,1 mod $0,10
TITLE RTM86 - 8086 Runtime Module Dispatcher ;*** ; RTM86 - 8086 Runtime Module Dispatcher ; ; Copyright <C> 1986, Microsoft Corporation ; ;Purpose: ; Contains the runtime module entry point for direct ; execution which outputs the copyright messages. ; It also contains the RTM software interrupt handler ; and the runtime entry dispatch tables. ; ;****************************************************************************** INCLUDE switch.inc INCLUDE rmacros.inc USESEG <CONST> USESEG <_DATA> USESEG <_BSS> USESEG <CDATA> USESEG <_TEXT> USESEG <RT_TEXT> INCLUDE seg.inc INCLUDE idmac.inc INCLUDE intasg.inc INCLUDE intmac.inc INCLUDE files.inc INCLUDE addr.inc INCLUDE stack.inc INCLUDE ulib.inc sBegin _BSS externW b$pULVars ;ptr to shared data items ;defined in User lib. sEnd _BSS sBegin _TEXT externW VecTbl ; Start of dispatch table externW _TEXT_START ; Start of _TEXT entries externW _TEXT_END ; Past end of _TEXT entries sEnd _TEXT assumes CS,RT_TEXT sBegin RT_TEXT ; values saved in code segment: staticW SaveAX,,1 ;saved AX register staticW SaveBX,,1 ;saved BX register staticW SaveSI,,1 ;saved SI register staticW SaveDS,,1 ;saved DS register staticD RTMChainPtr,,1 ; RTM interrupt chain pointer staticB UserTableFlag,,1 ;flag whether or not we're using user-table ;*** ; B$RTMInstall - install the RTM interrupt vector ; ;Purpose: ; To install the RTM interrupt vector by first saving the ; current vector and then setting it to the new value. ;Entry: ; None. ;Exit: ; None. ;Uses: ; None. ;Exceptions: ; None. ;****************************************************************************** cProc B$RTMInstall,<FAR,PUBLIC>,<AX,BX,DX,DS,ES> cBegin PUSH CS ; DS = code segment for SAVINT POP DS ; storage and SETVEC SAVINT RTMChainPtr,(W0__NM*4) ;save the vector SETVEC W0__NM,RTMVector ;set vector to the new value cEnd ;*** ; B$RTMDeinstall - deinstall the RTM vector ; ;Purpose: ; To deinstall the RTM interrupt vector by setting it ; to its previous value. ;Entry: ; None. ;Exit: ; None. ;Uses: ; None. ;Exceptions: ; None. ;****************************************************************************** cProc B$RTMDeinstall,<FAR,PUBLIC>,<AX,DX,DS> cBegin RSTVEC W0__NM,RTMChainPtr ;restore to the old vector cEnd ;*** ; RTMVector - Runtime module interrupt service routine. ; ;Purpose: ; This routine is executed when a compiled (non /O) module ; requests runtime support. The routine address is looked ; up in a table based upon the index postbyte (which may be ; preceded by a flag postbyte indicating special handling). ; If the requested routine is found, the far call to the ; interrupt request is backpatched into a far call to the ; requested routine and reexecuted. If a valid request is ; made that does not have a defined entry, an advanced ; feature error is issued. ; ; Before backpatch: ; <FAR CALL stubroutine> --> <INT + postbyte(s)> --> RTMVector ; ; After backpatch: ; <FAR CALL realroutine> ;Entry: ; [SS:SP] - far pointer to first post byte. ;Exit: ; FAR CALL to the Interrupt is backpatched and execution is restarted ; at the backpatched call. ;Uses: ; None. ;Exceptions: ; B$ERR_AFE. ;**** ; These two code fragments are out here so that the normal case (single ; postbyte) can be a complete fall through for speed. If either of ; the double postbyte cases are encountered, the code will jump out ; here to one of these fragments which will jump back when they are done. Part2: LODSB ; [AL] = second post byte INC AH ; [AX] = index into table (adjusted) JMP SHORT DoIt ; continue DbPub RTMVector cProc RTMVector,<FAR> cBegin <nogen> MOV CS:[SaveAX],AX ;save AX, but not on stack MOV CS:[SaveBX],BX ;...and BX MOV CS:[SaveSI],SI ;...and SI MOV CS:[SaveDS],DS ;...and DS POP SI ;get return offset (third byte in call) POP DS ;get return segment POPF ; enable ints ; Some trickery for handling table indicies: ; The RTM dispatch table is "missing" the entry corresponding to ; 255 because a postbyte of FF is a special flag, and IF NOT EI_QB ; it is also "missing" the entry at 254 (another flag). To allow ; addressing the table as a contiguous block, indicies in part 1 ; of the table (single postbyte entries) are bumped up (as a side ; effect of testing for flag values). This makes the index set ; contiguous but 2 bytes (or 4 IF NOT EI_QB) too high. We adjust ; for this by addressing 2 bytes (or 4) below the table base. MOV BX,_TEXTOFFSET VecTbl - 2 ;base of table minus 2 bytes LODSB ; [AL] = dispatch table index or flag XOR AH,AH ; [AX] = dispatch table index or flag INC AL ; part 2 of table? (2 post bytes) JZ Part2 ; yes, go read second post byte DoIt: ADD AX,AX ; [AX] = word offset+2 into dispatch table ADD BX,AX ; [BX] = CS Pointer into dispatch table MOV AX,SEG _TEXT MOV DS,AX ; [DS:BX] points to table MOV AX,[BX] ; [AX] = target offset POP SI POP DS ; [DS:SI] = return address into USER code SUB SI,5 ; [DS:SI] = call instruction in USER code PUSH DS ; restore return segment PUSH SI ; stack far pointer will execute new far CALL MOV [SI+1],AX ; backpatch OFFSET part of far call ; Determine target segment for backpatch MOV AX,RT_TEXTBASE ; [AX] = target segment CMP BX,_TEXTOFFSET _TEXT_START ; past start of _TEXT entries? JB RTMVEC_20 ; Jump if not CMP BX,_TEXTOFFSET _TEXT_END ; past end of _TEXT entries? JAE RTMVEC_20 ; brif so MOV AX,_TEXTBASE ; _TEXTBASE = target segment RTMVEC_20: MOV [SI+3],AX MOV DS,CS:[SaveDS] ;restore original DS MOV SI,CS:[SaveSI] ;restore original SI MOV BX,CS:[SaveBX] ;restore original BX MOV AX,CS:[SaveAX] ;restore original AX RET ;far return to routine address just pushed cEnd <nogen> labelNP <PUBLIC,B$Undef1> ; This is a list of empty slots in labelNP <PUBLIC,B$Undef2> ; the RTMINT table. Remove them when labelNP <PUBLIC,B$Undef3> ; the slot is re-used to eliminate labelNP <PUBLIC,B$Undef4> ; confusion and extranious labels. externNP B$FrameFC JMP B$FrameFC ; Give "Illegal Function Call" sEnd RT_TEXT END
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* * Main authors: * Guido Tack <tack@gecode.org> * * Copyright: * Guido Tack, 2012 * * Last modified: * $Date: 2013-07-11 12:30:18 +0200 (to, 11 jul 2013) $ by $Author: schulte $ * $Revision: 13840 $ * * This file is part of Gecode, the generic constraint * development environment: * http://www.gecode.org * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ #ifndef __GECODE_SEARCH_META_RBS_HH__ #define __GECODE_SEARCH_META_RBS_HH__ #include <gecode/search.hh> namespace Gecode { namespace Search { namespace Meta { /// Engine for restart-based search class RBS : public Engine { private: /// The actual engine Engine* e; /// The master space to restart from Space* master; /// The cutoff object Cutoff* co; /// The stop control object MetaStop* stop; /// Whether the slave can be shared with the master bool shared; /// Empty no-goods GECODE_SEARCH_EXPORT static NoGoods eng; public: /// Constructor RBS(Space* s, Cutoff* co0, MetaStop* stop0, Engine* e0, const Options& o); /// Return next solution (NULL, if none exists or search has been stopped) virtual Space* next(void); /// Return statistics virtual Search::Statistics statistics(void) const; /// Check whether engine has been stopped virtual bool stopped(void) const; /// Reset engine to restart at space \a s virtual void reset(Space* s); /// Return no-goods virtual NoGoods& nogoods(void); /// Destructor virtual ~RBS(void); }; forceinline RBS::RBS(Space* s, Cutoff* co0, MetaStop* stop0, Engine* e0, const Options& opt) : e(e0), master(s), co(co0), stop(stop0), shared(opt.threads == 1) { stop->limit(Statistics(),(*co)()); } }}} #endif // STATISTICS: search-other
; A028914: Divide A028913 by 2. ; 1,1,2,1,3,2,4,2,4,3,5,1,9,2,10,3,5,7,9,2,10,9,9,2,13,9,8,4,20,4,15,6,15,8,12,6,22,6,15,15,21,5,13,12,23,7,24,11,19,15,24,6,30,6,26,7 mov $5,2 mov $7,$0 lpb $5 sub $5,1 add $0,$5 sub $0,1 mov $2,$0 mov $4,3 lpb $2 mov $6,$4 lpb $6 add $4,1 trn $6,$2 lpe sub $2,1 lpe mov $3,$5 mov $8,$4 lpb $3 mov $1,$8 sub $3,1 lpe lpe lpb $7 sub $1,$8 mov $7,0 lpe sub $1,2 div $1,2 add $1,1
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r8 push %r9 push %rbp push %rcx push %rdi push %rdx push %rsi lea addresses_WT_ht+0x10c57, %r11 nop nop nop dec %r9 mov (%r11), %ebp nop and %r8, %r8 lea addresses_WT_ht+0x412f, %rcx nop nop nop cmp %r8, %r8 mov $0x6162636465666768, %r9 movq %r9, %xmm4 movups %xmm4, (%rcx) nop sub %r9, %r9 lea addresses_WC_ht+0x1d037, %rsi lea addresses_A_ht+0x6fb7, %rdi nop nop nop nop nop add %rdx, %rdx mov $37, %rcx rep movsw nop nop nop and $26296, %r8 lea addresses_normal_ht+0xa537, %rdi nop nop nop nop nop sub $26352, %r8 movb $0x61, (%rdi) nop nop cmp $53822, %r8 lea addresses_normal_ht+0x1c517, %rcx nop nop nop nop inc %r9 movl $0x61626364, (%rcx) nop and $40217, %r9 lea addresses_UC_ht+0x18677, %rsi lea addresses_UC_ht+0x12d19, %rdi clflush (%rsi) nop nop nop nop nop xor %r11, %r11 mov $95, %rcx rep movsl nop nop nop and $62501, %rdx pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %r9 pop %r8 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r14 push %r9 push %rax push %rbx push %rcx push %rdx // Load lea addresses_normal+0xf5d7, %rcx nop nop nop nop add %r9, %r9 mov (%rcx), %rbx nop nop nop cmp %rbx, %rbx // Store lea addresses_D+0x7337, %rbx clflush (%rbx) nop nop nop nop and $51751, %r10 movw $0x5152, (%rbx) nop nop nop cmp %r14, %r14 // Store lea addresses_PSE+0x14937, %rcx nop add $5878, %r9 mov $0x5152535455565758, %r10 movq %r10, %xmm6 movntdq %xmm6, (%rcx) xor $58210, %r14 // Store lea addresses_RW+0x4937, %r9 nop nop sub %rbx, %rbx mov $0x5152535455565758, %rcx movq %rcx, %xmm3 vmovups %ymm3, (%r9) nop nop dec %r10 // Store mov $0x37, %r14 nop nop add $65368, %r9 mov $0x5152535455565758, %rcx movq %rcx, %xmm2 vmovups %ymm2, (%r14) xor $16604, %r10 // Store lea addresses_normal+0xfd37, %rax nop nop nop nop nop cmp $23100, %r9 mov $0x5152535455565758, %rcx movq %rcx, (%rax) sub $2280, %r10 // Store mov $0x32995000000009b7, %r9 nop dec %rdx mov $0x5152535455565758, %rcx movq %rcx, (%r9) nop nop nop nop nop sub $12959, %r9 // Store lea addresses_PSE+0x2837, %r10 clflush (%r10) nop and %r14, %r14 movw $0x5152, (%r10) xor $38827, %rdx // Store lea addresses_A+0x14537, %r10 nop add %r9, %r9 mov $0x5152535455565758, %rbx movq %rbx, (%r10) nop sub $36400, %r10 // Faulty Load lea addresses_normal+0x18d37, %rbx nop nop nop and %r14, %r14 movb (%rbx), %r9b lea oracles, %rbx and $0xff, %r9 shlq $12, %r9 mov (%rbx,%r9,1), %r9 pop %rdx pop %rcx pop %rbx pop %rax pop %r9 pop %r14 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'AVXalign': True, 'size': 16, 'congruent': 0, 'same': False, 'type': 'addresses_normal'}, 'OP': 'LOAD'} {'src': {'NT': False, 'AVXalign': True, 'size': 8, 'congruent': 5, 'same': False, 'type': 'addresses_normal'}, 'OP': 'LOAD'} {'dst': {'NT': True, 'AVXalign': False, 'size': 2, 'congruent': 6, 'same': False, 'type': 'addresses_D'}, 'OP': 'STOR'} {'dst': {'NT': True, 'AVXalign': False, 'size': 16, 'congruent': 6, 'same': False, 'type': 'addresses_PSE'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 9, 'same': False, 'type': 'addresses_RW'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 6, 'same': False, 'type': 'addresses_P'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': True, 'size': 8, 'congruent': 9, 'same': False, 'type': 'addresses_normal'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 4, 'same': False, 'type': 'addresses_NC'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 7, 'same': False, 'type': 'addresses_PSE'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 10, 'same': False, 'type': 'addresses_A'}, 'OP': 'STOR'} [Faulty Load] {'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0, 'same': True, 'type': 'addresses_normal'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 5, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 3, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'STOR'} {'src': {'congruent': 6, 'same': True, 'type': 'addresses_WC_ht'}, 'dst': {'congruent': 7, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM'} {'dst': {'NT': True, 'AVXalign': False, 'size': 1, 'congruent': 11, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 5, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'STOR'} {'src': {'congruent': 5, 'same': False, 'type': 'addresses_UC_ht'}, 'dst': {'congruent': 0, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM'} {'34': 7} 34 34 34 34 34 34 34 */
db 0 ; 390 DEX NO db 44, 58, 44, 61, 58, 44 ; hp atk def spd sat sdf db FIRE, FIRE ; type db 45 ; catch rate db 65 ; base exp db NO_ITEM, NO_ITEM ; items db GENDER_F12_5 ; gender ratio db 100 ; unknown 1 db 20 ; step cycles to hatch db 5 ; unknown 2 INCBIN "gfx/pokemon/sinnoh/chimchar/front.dimensions" db 0, 0, 0, 0 ; padding db GROWTH_MEDIUM_SLOW ; growth rate dn EGG_GROUND, EGG_HUMANSHAPE ; egg groups ; tm/hm learnset tmhm ; end
/* WDL - resample.cpp Copyright (C) 2010 and later Cockos Incorporated This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. You may also distribute this software under the LGPL v2 or later. */ #include "resample.h" #include <math.h> #include "denormal.h" #if !defined(WDL_RESAMPLE_NO_SSE) && !defined(WDL_RESAMPLE_USE_SSE) #if defined(__SSE2__) || _M_IX86_FP >= 2 || (defined(_WIN64) && (_MSC_VER > 1400 || __INTEL_COMPILER > 0)) #define WDL_RESAMPLE_USE_SSE #endif #endif #ifdef WDL_RESAMPLE_USE_SSE #include <emmintrin.h> #endif #ifndef PI #define PI 3.1415926535897932384626433832795 #endif class WDL_Resampler::WDL_Resampler_IIRFilter { public: WDL_Resampler_IIRFilter() { m_fpos=-1; Reset(); } ~WDL_Resampler_IIRFilter() { } void Reset() { memset(m_hist,0,sizeof(m_hist)); } void setParms(double fpos, double Q) { if (fabs(fpos-m_fpos)<0.000001) return; m_fpos=fpos; double pos = fpos * PI; double cpos=cos(pos); double spos=sin(pos); double alpha=spos/(2.0*Q); double sc=1.0/( 1 + alpha); m_b1 = (1-cpos) * sc; m_b2 = m_b0 = m_b1*0.5; m_a1 = -2 * cpos * sc; m_a2 = (1-alpha)*sc; } void Apply(WDL_ResampleSample *in1, WDL_ResampleSample *out1, int ns, int span, int w) { double b0=m_b0,b1=m_b1,b2=m_b2,a1=m_a1,a2=m_a2; double hist[4]; memcpy(hist,&m_hist[w][0], sizeof(hist)); while (ns--) { double in=*in1; in1+=span; double out = (double) ( in*b0 + hist[0]*b1 + hist[1]*b2 - hist[2]*a1 - hist[3]*a2); hist[1]=hist[0]; hist[0]=in; hist[3]=hist[2]; *out1 = hist[2]=denormal_filter_double(out); out1+=span; } memcpy(&m_hist[w][0], hist, sizeof(hist)); } private: double m_fpos; double m_a1,m_a2; double m_b0,m_b1,m_b2; double m_hist[WDL_RESAMPLE_MAX_FILTERS*WDL_RESAMPLE_MAX_NCH][4]; }; template <class T1, class T2> static void inline SincSample(T1 *outptr, const T1 *inptr, double fracpos, int nch, const T2 *filter, int filtsz, int oversize) { fracpos *= oversize; const int ifpos=(int)fracpos; filter += (oversize-ifpos) * filtsz; fracpos -= ifpos; int x; for (x = 0; x < nch; x ++) { double sum=0.0,sum2=0.0; const T2 *fptr2=filter; const T2 *fptr=fptr2 - filtsz; const T1 *iptr=inptr+x; int i=filtsz/2; while (i--) { sum += fptr[0]*iptr[0]; sum2 += fptr2[0]*iptr[0]; sum += fptr[1]*iptr[nch]; sum2 += fptr2[1]*iptr[nch]; iptr+=nch*2; fptr+=2; fptr2+=2; } outptr[x]=sum*fracpos + sum2*(1.0-fracpos); } } template <class T1, class T2> static void inline SincSampleN(T1 *outptr, const T1 *inptr, double fracpos, int nch, const T2 *filter, int filtsz, int oversize) { const int ifpos=(int)(fracpos*oversize+0.5); filter += (oversize-ifpos) * filtsz; int x; for (x = 0; x < nch; x ++) { double sum2=0.0; const T2 *fptr2=filter; const T1 *iptr=inptr+x; int i=filtsz/2; while (i--) { sum2 += fptr2[0]*iptr[0]; sum2 += fptr2[1]*iptr[nch]; iptr+=nch*2; fptr2+=2; } outptr[x]=sum2; } } template <class T1, class T2> static void inline SincSample1(T1 *outptr, const T1 *inptr, double fracpos, const T2 *filter, int filtsz, int oversize) { fracpos *= oversize; const int ifpos=(int)fracpos; fracpos -= ifpos; double sum=0.0,sum2=0.0; const T2 *fptr2=filter + (oversize-ifpos) * filtsz; const T2 *fptr=fptr2 - filtsz; const T1 *iptr=inptr; int i=filtsz/2; while (i--) { sum += fptr[0]*iptr[0]; sum2 += fptr2[0]*iptr[0]; sum += fptr[1]*iptr[1]; sum2 += fptr2[1]*iptr[1]; iptr+=2; fptr+=2; fptr2+=2; } outptr[0]=sum*fracpos+sum2*(1.0-fracpos); } template <class T1, class T2> static void inline SincSample1N(T1 *outptr, const T1 *inptr, double fracpos, const T2 *filter, int filtsz, int oversize) { const int ifpos=(int)(fracpos*oversize+0.5); double sum2=0.0; const T2 *fptr2=filter + (oversize-ifpos) * filtsz; const T1 *iptr=inptr; int i=filtsz/2; while (i--) { sum2 += fptr2[0]*iptr[0]; sum2 += fptr2[1]*iptr[1]; iptr+=2; fptr2+=2; } outptr[0]=sum2; } template <class T1, class T2> static void inline SincSample2(T1 *outptr, const T1 *inptr, double fracpos, const T2 *filter, int filtsz, int oversize) { fracpos *= oversize; const int ifpos=(int)fracpos; fracpos -= ifpos; const T2 *fptr2=filter + (oversize-ifpos) * filtsz; const T2 *fptr=fptr2 - filtsz; double sum=0.0; double sum2=0.0; double sumb=0.0; double sum2b=0.0; const T1 *iptr=inptr; int i=filtsz/2; while (i--) { sum += fptr[0]*iptr[0]; sum2 += fptr[0]*iptr[1]; sumb += fptr2[0]*iptr[0]; sum2b += fptr2[0]*iptr[1]; sum += fptr[1]*iptr[2]; sum2 += fptr[1]*iptr[3]; sumb += fptr2[1]*iptr[2]; sum2b += fptr2[1]*iptr[3]; iptr+=4; fptr+=2; fptr2+=2; } outptr[0]=sum*fracpos + sumb*(1.0-fracpos); outptr[1]=sum2*fracpos + sum2b*(1.0-fracpos); } template <class T1, class T2> static void inline SincSample2N(T1 *outptr, const T1 *inptr, double fracpos, const T2 *filter, int filtsz, int oversize) { const int ifpos=(int)(fracpos*oversize+0.5); const T2 *fptr2=filter + (oversize-ifpos) * filtsz; double sumb=0.0; double sum2b=0.0; const T1 *iptr=inptr; int i=filtsz/2; while (i--) { sumb += fptr2[0]*iptr[0]; sum2b += fptr2[0]*iptr[1]; sumb += fptr2[1]*iptr[2]; sum2b += fptr2[1]*iptr[3]; iptr+=4; fptr2+=2; } outptr[0]=sumb; outptr[1]=sum2b; } #ifdef WDL_RESAMPLE_USE_SSE static void inline SincSample(double *outptr, const double *inptr, double fracpos, int nch, const float *filter, int filtsz, int oversize) { fracpos *= oversize; const int ifpos=(int)fracpos; filter += (oversize-ifpos) * filtsz; fracpos -= ifpos; int x; for (x = 0; x < nch; x ++) { double sum, sum2; const float *fptr2=filter; const float *fptr=fptr2 - filtsz; const double *iptr=inptr+x; int i=filtsz/2; __m128d xmm0 = _mm_setzero_pd(); __m128d xmm1 = _mm_setzero_pd(); __m128d xmm2, xmm3; while (i--) { xmm2 = _mm_set_pd(iptr[nch], iptr[0]); xmm3 = _mm_load_sd((double *)fptr); xmm3 = _mm_cvtps_pd(_mm_castpd_ps(xmm3)); xmm3 = _mm_mul_pd(xmm3, xmm2); xmm0 = _mm_add_pd(xmm0, xmm3); xmm3 = _mm_load_sd((double *)fptr2); xmm3 = _mm_cvtps_pd(_mm_castpd_ps(xmm3)); xmm3 = _mm_mul_pd(xmm3, xmm2); xmm1 = _mm_add_pd(xmm1, xmm3); iptr+=nch*2; fptr+=2; fptr2+=2; } xmm2 = xmm0; xmm0 = _mm_unpackhi_pd(xmm0, xmm2); xmm0 = _mm_add_pd(xmm0, xmm2); _mm_store_sd(&sum, xmm0); xmm3 = xmm1; xmm1 = _mm_unpackhi_pd(xmm1, xmm3); xmm1 = _mm_add_pd(xmm1, xmm3); _mm_store_sd(&sum2, xmm1); outptr[x]=sum*fracpos + sum2*(1.0-fracpos); } } static void inline SincSampleN(double *outptr, const double *inptr, double fracpos, int nch, const float *filter, int filtsz, int oversize) { const int ifpos=(int)(fracpos*oversize+0.5); filter += (oversize-ifpos) * filtsz; int x; for (x = 0; x < nch; x ++) { double sum2; const float *fptr2=filter; const double *iptr=inptr+x; int i=filtsz/2; __m128d xmm0 = _mm_setzero_pd(); __m128d xmm1 = _mm_setzero_pd(); __m128d xmm2, xmm3; while (i >= 2) { xmm2 = _mm_set_pd(iptr[nch], iptr[0]); xmm3 = _mm_load_sd((double *)fptr2); xmm3 = _mm_cvtps_pd(_mm_castpd_ps(xmm3)); xmm3 = _mm_mul_pd(xmm3, xmm2); xmm0 = _mm_add_pd(xmm0, xmm3); xmm2 = _mm_set_pd(iptr[nch*3], iptr[nch*2]); xmm3 = _mm_load_sd((double *)fptr2 + 1); xmm3 = _mm_cvtps_pd(_mm_castpd_ps(xmm3)); xmm3 = _mm_mul_pd(xmm3, xmm2); xmm1 = _mm_add_pd(xmm1, xmm3); iptr+=nch*4; fptr2+=4; i-=2; } if (i) { xmm2 = _mm_set_pd(iptr[nch], iptr[0]); xmm3 = _mm_load_sd((double *)fptr2); xmm3 = _mm_cvtps_pd(_mm_castpd_ps(xmm3)); xmm3 = _mm_mul_pd(xmm3, xmm2); xmm0 = _mm_add_pd(xmm0, xmm3); } xmm1 = _mm_add_pd(xmm1, xmm0); xmm3 = xmm1; xmm1 = _mm_unpackhi_pd(xmm1, xmm3); xmm1 = _mm_add_pd(xmm1, xmm3); _mm_store_sd(&sum2, xmm1); outptr[x]=sum2; } } static void inline SincSample1(double *outptr, const double *inptr, double fracpos, const float *filter, int filtsz, int oversize) { fracpos *= oversize; const int ifpos=(int)fracpos; fracpos -= ifpos; double sum, sum2; const float *fptr2=filter + (oversize-ifpos) * filtsz; const float *fptr=fptr2 - filtsz; const double *iptr=inptr; int i=filtsz/2; __m128d xmm0 = _mm_setzero_pd(); __m128d xmm1 = _mm_setzero_pd(); __m128d xmm2, xmm3; while (i >= 2) { xmm2 = _mm_loadu_pd(iptr); xmm3 = _mm_cvtps_pd(_mm_load_ps(fptr)); xmm3 = _mm_mul_pd(xmm3, xmm2); xmm0 = _mm_add_pd(xmm0, xmm3); xmm3 = _mm_cvtps_pd(_mm_load_ps(fptr2)); xmm3 = _mm_mul_pd(xmm3, xmm2); xmm1 = _mm_add_pd(xmm1, xmm3); xmm2 = _mm_loadu_pd(iptr+2); xmm3 = _mm_load_sd((double *)fptr + 1); xmm3 = _mm_cvtps_pd(_mm_castpd_ps(xmm3)); xmm3 = _mm_mul_pd(xmm3, xmm2); xmm0 = _mm_add_pd(xmm0, xmm3); xmm3 = _mm_load_sd((double *)fptr2 + 1); xmm3 = _mm_cvtps_pd(_mm_castpd_ps(xmm3)); xmm3 = _mm_mul_pd(xmm3, xmm2); xmm1 = _mm_add_pd(xmm1, xmm3); iptr+=4; fptr+=4; fptr2+=4; i-=2; } if (i) { xmm2 = _mm_loadu_pd(iptr); xmm3 = _mm_load_sd((double *)fptr); xmm3 = _mm_cvtps_pd(_mm_castpd_ps(xmm3)); xmm3 = _mm_mul_pd(xmm3, xmm2); xmm0 = _mm_add_pd(xmm0, xmm3); xmm3 = _mm_load_sd((double *)fptr2); xmm3 = _mm_cvtps_pd(_mm_castpd_ps(xmm3)); xmm3 = _mm_mul_pd(xmm3, xmm2); xmm1 = _mm_add_pd(xmm1, xmm3); } xmm2 = xmm0; xmm0 = _mm_unpackhi_pd(xmm0, xmm2); xmm0 = _mm_add_pd(xmm0, xmm2); _mm_store_sd(&sum, xmm0); xmm3 = xmm1; xmm1 = _mm_unpackhi_pd(xmm1, xmm3); xmm1 = _mm_add_pd(xmm1, xmm3); _mm_store_sd(&sum2, xmm1); outptr[0]=sum*fracpos+sum2*(1.0-fracpos); } static void inline SincSample1N(double *outptr, const double *inptr, double fracpos, const float *filter, int filtsz, int oversize) { const int ifpos=(int)(fracpos*oversize+0.5); double sum2; const float *fptr2=filter + (oversize-ifpos) * filtsz; const double *iptr=inptr; int i=filtsz/2; __m128d xmm0 = _mm_setzero_pd(); __m128d xmm1 = _mm_setzero_pd(); __m128d xmm2, xmm3; while (i >= 2) { xmm2 = _mm_loadu_pd(iptr); xmm3 = _mm_cvtps_pd(_mm_load_ps(fptr2)); xmm3 = _mm_mul_pd(xmm3, xmm2); xmm0 = _mm_add_pd(xmm0, xmm3); xmm2 = _mm_loadu_pd(iptr+2); xmm3 = _mm_load_sd((double *)fptr2 + 1); xmm3 = _mm_cvtps_pd(_mm_castpd_ps(xmm3)); xmm3 = _mm_mul_pd(xmm3, xmm2); xmm1 = _mm_add_pd(xmm1, xmm3); iptr+=4; fptr2+=4; i-=2; } if (i) { xmm2 = _mm_loadu_pd(iptr); xmm3 = _mm_load_sd((double *)fptr2); xmm3 = _mm_cvtps_pd(_mm_castpd_ps(xmm3)); xmm3 = _mm_mul_pd(xmm3, xmm2); xmm0 = _mm_add_pd(xmm0, xmm3); } xmm1 = _mm_add_pd(xmm1, xmm0); xmm3 = xmm1; xmm1 = _mm_unpackhi_pd(xmm1, xmm3); xmm1 = _mm_add_pd(xmm1, xmm3); _mm_store_sd(&sum2, xmm1); outptr[0]=sum2; } static void inline SincSample2(double *outptr, const double *inptr, double fracpos, const float *filter, int filtsz, int oversize) { fracpos *= oversize; const int ifpos=(int)fracpos; fracpos -= ifpos; const float *fptr2=filter + (oversize-ifpos) * filtsz; const float *fptr=fptr2 - filtsz; double sum, sum2, sumb, sum2b; const double *iptr=inptr; int i=filtsz/2; __m128d xmm0 = _mm_setzero_pd(); __m128d xmm1 = _mm_setzero_pd(); __m128d xmm2, xmm3; __m128 xmm4; while (i--) { xmm2 = _mm_loadu_pd(iptr); xmm4 = _mm_set1_ps(fptr[0]); xmm3 = _mm_cvtps_pd(xmm4); xmm3 = _mm_mul_pd(xmm3, xmm2); xmm0 = _mm_add_pd(xmm0, xmm3); xmm4 = _mm_set1_ps(fptr2[0]); xmm3 = _mm_cvtps_pd(xmm4); xmm3 = _mm_mul_pd(xmm3, xmm2); xmm1 = _mm_add_pd(xmm1, xmm3); xmm2 = _mm_loadu_pd(iptr+2); xmm4 = _mm_set1_ps(fptr[1]); xmm3 = _mm_cvtps_pd(xmm4); xmm3 = _mm_mul_pd(xmm3, xmm2); xmm0 = _mm_add_pd(xmm0, xmm3); xmm4 = _mm_set1_ps(fptr2[1]); xmm3 = _mm_cvtps_pd(xmm4); xmm3 = _mm_mul_pd(xmm3, xmm2); xmm1 = _mm_add_pd(xmm1, xmm3); iptr+=4; fptr+=2; fptr2+=2; } xmm2 = xmm0; _mm_store_sd(&sum, xmm0); xmm2 = _mm_unpackhi_pd(xmm2, xmm0); _mm_store_sd(&sum2, xmm2); xmm3 = xmm1; _mm_store_sd(&sumb, xmm1); xmm3 = _mm_unpackhi_pd(xmm3, xmm1); _mm_store_sd(&sum2b, xmm3); outptr[0]=sum*fracpos + sumb*(1.0-fracpos); outptr[1]=sum2*fracpos + sum2b*(1.0-fracpos); } static void inline SincSample2N(double *outptr, const double *inptr, double fracpos, const float *filter, int filtsz, int oversize) { const int ifpos=(int)(fracpos*oversize+0.5); const float *fptr2=filter + (oversize-ifpos) * filtsz; double sumb, sum2b; const double *iptr=inptr; int i=filtsz/2; __m128d xmm0 = _mm_setzero_pd(); __m128d xmm1 = _mm_setzero_pd(); __m128d xmm2, xmm3; __m128 xmm4; while (i--) { xmm2 = _mm_loadu_pd(iptr); xmm4 = _mm_set1_ps(fptr2[0]); xmm3 = _mm_cvtps_pd(xmm4); xmm3 = _mm_mul_pd(xmm3, xmm2); xmm0 = _mm_add_pd(xmm0, xmm3); xmm2 = _mm_loadu_pd(iptr+2); xmm4 = _mm_set1_ps(fptr2[1]); xmm3 = _mm_cvtps_pd(xmm4); xmm3 = _mm_mul_pd(xmm3, xmm2); xmm1 = _mm_add_pd(xmm1, xmm3); iptr+=4; fptr2+=2; } xmm1 = _mm_add_pd(xmm1, xmm0); xmm3 = xmm1; _mm_store_sd(&sumb, xmm1); xmm3 = _mm_unpackhi_pd(xmm3, xmm1); _mm_store_sd(&sum2b, xmm3); outptr[0]=sumb; outptr[1]=sum2b; } static void inline SincSample(double *outptr, const double *inptr, double fracpos, int nch, const double *filter, int filtsz, int oversize) { fracpos *= oversize; const int ifpos=(int)fracpos; filter += (oversize-ifpos) * filtsz; fracpos -= ifpos; int x; for (x = 0; x < nch; x ++) { double sum, sum2; const double *fptr2=filter; const double *fptr=fptr2 - filtsz; const double *iptr=inptr+x; int i=filtsz/2; __m128d xmm0 = _mm_setzero_pd(); __m128d xmm1 = _mm_setzero_pd(); __m128d xmm2 = _mm_setzero_pd(); __m128d xmm3 = _mm_setzero_pd(); __m128d xmm4, xmm5; while (i >= 2) { xmm4 = _mm_set_pd(iptr[nch], iptr[0]); xmm5 = _mm_load_pd(fptr); xmm5 = _mm_mul_pd(xmm5, xmm4); xmm0 = _mm_add_pd(xmm0, xmm5); xmm5 = _mm_load_pd(fptr2); xmm5 = _mm_mul_pd(xmm5, xmm4); xmm1 = _mm_add_pd(xmm1, xmm5); xmm4 = _mm_set_pd(iptr[nch*3], iptr[nch*2]); xmm5 = _mm_load_pd(fptr+2); xmm5 = _mm_mul_pd(xmm5, xmm4); xmm2 = _mm_add_pd(xmm2, xmm5); xmm5 = _mm_load_pd(fptr2+2); xmm5 = _mm_mul_pd(xmm5, xmm4); xmm3 = _mm_add_pd(xmm3, xmm5); iptr+=nch*4; fptr+=4; fptr2+=4; i-=2; } if (i) { xmm4 = _mm_set_pd(iptr[nch], iptr[0]); xmm5 = _mm_load_pd(fptr); xmm5 = _mm_mul_pd(xmm5, xmm4); xmm0 = _mm_add_pd(xmm0, xmm5); xmm5 = _mm_load_pd(fptr2); xmm5 = _mm_mul_pd(xmm5, xmm4); xmm1 = _mm_add_pd(xmm1, xmm5); } xmm0 = _mm_add_pd(xmm0, xmm2); xmm1 = _mm_add_pd(xmm1, xmm3); xmm2 = xmm0; xmm0 = _mm_unpackhi_pd(xmm0, xmm2); xmm0 = _mm_add_pd(xmm0, xmm2); _mm_store_sd(&sum, xmm0); xmm3 = xmm1; xmm1 = _mm_unpackhi_pd(xmm1, xmm3); xmm1 = _mm_add_pd(xmm1, xmm3); _mm_store_sd(&sum2, xmm1); outptr[x]=sum*fracpos + sum2*(1.0-fracpos); } } static void inline SincSampleN(double *outptr, const double *inptr, double fracpos, int nch, const double *filter, int filtsz, int oversize) { const int ifpos=(int)(fracpos*oversize+0.5); filter += (oversize-ifpos) * filtsz; int x; for (x = 0; x < nch; x ++) { double sum2; const double *fptr2=filter; const double *iptr=inptr+x; int i=filtsz/2; __m128d xmm0 = _mm_setzero_pd(); __m128d xmm1 = _mm_setzero_pd(); __m128d xmm2, xmm3; while (i >= 2) { xmm2 = _mm_set_pd(iptr[nch], iptr[0]); xmm3 = _mm_load_pd(fptr2); xmm3 = _mm_mul_pd(xmm3, xmm2); xmm0 = _mm_add_pd(xmm0, xmm3); xmm2 = _mm_set_pd(iptr[nch*3], iptr[nch*2]); xmm3 = _mm_load_pd(fptr2+2); xmm3 = _mm_mul_pd(xmm3, xmm2); xmm1 = _mm_add_pd(xmm1, xmm3); iptr+=nch*4; fptr2+=4; i-=2; } if (i) { xmm2 = _mm_set_pd(iptr[nch], iptr[0]); xmm3 = _mm_load_pd(fptr2); xmm3 = _mm_mul_pd(xmm3, xmm2); xmm0 = _mm_add_pd(xmm0, xmm3); } xmm1 = _mm_add_pd(xmm1, xmm0); xmm3 = xmm1; xmm1 = _mm_unpackhi_pd(xmm1, xmm3); xmm1 = _mm_add_pd(xmm1, xmm3); _mm_store_sd(&sum2, xmm1); outptr[x]=sum2; } } static void inline SincSample1(double *outptr, const double *inptr, double fracpos, const double *filter, int filtsz, int oversize) { fracpos *= oversize; const int ifpos=(int)fracpos; fracpos -= ifpos; double sum, sum2; const double *fptr2=filter + (oversize-ifpos) * filtsz; const double *fptr=fptr2 - filtsz; const double *iptr=inptr; int i=filtsz/2; __m128d xmm0 = _mm_setzero_pd(); __m128d xmm1 = _mm_setzero_pd(); __m128d xmm2 = _mm_setzero_pd(); __m128d xmm3 = _mm_setzero_pd(); __m128d xmm4, xmm5; while (i >= 2) { xmm4 = _mm_loadu_pd(iptr); xmm5 = _mm_load_pd(fptr); xmm5 = _mm_mul_pd(xmm5, xmm4); xmm0 = _mm_add_pd(xmm0, xmm5); xmm5 = _mm_load_pd(fptr2); xmm5 = _mm_mul_pd(xmm5, xmm4); xmm1 = _mm_add_pd(xmm1, xmm5); xmm4 = _mm_loadu_pd(iptr+2); xmm5 = _mm_load_pd(fptr+2); xmm5 = _mm_mul_pd(xmm5, xmm4); xmm2 = _mm_add_pd(xmm2, xmm5); xmm5 = _mm_load_pd(fptr2+2); xmm5 = _mm_mul_pd(xmm5, xmm4); xmm3 = _mm_add_pd(xmm3, xmm5); iptr+=4; fptr+=4; fptr2+=4; i-=2; } if (i) { xmm4 = _mm_loadu_pd(iptr); xmm5 = _mm_load_pd(fptr); xmm5 = _mm_mul_pd(xmm5, xmm4); xmm0 = _mm_add_pd(xmm0, xmm5); xmm5 = _mm_load_pd(fptr2); xmm5 = _mm_mul_pd(xmm5, xmm4); xmm1 = _mm_add_pd(xmm1, xmm5); } xmm0 = _mm_add_pd(xmm0, xmm2); xmm1 = _mm_add_pd(xmm1, xmm3); xmm2 = xmm0; xmm0 = _mm_unpackhi_pd(xmm0, xmm2); xmm0 = _mm_add_pd(xmm0, xmm2); _mm_store_sd(&sum, xmm0); xmm3 = xmm1; xmm1 = _mm_unpackhi_pd(xmm1, xmm3); xmm1 = _mm_add_pd(xmm1, xmm3); _mm_store_sd(&sum2, xmm1); outptr[0]=sum*fracpos+sum2*(1.0-fracpos); } static void inline SincSample1N(double *outptr, const double *inptr, double fracpos, const double *filter, int filtsz, int oversize) { const int ifpos=(int)(fracpos*oversize+0.5); double sum2; const double *fptr2=filter + (oversize-ifpos) * filtsz; const double *iptr=inptr; int i=filtsz/2; __m128d xmm0 = _mm_setzero_pd(); __m128d xmm1 = _mm_setzero_pd(); __m128d xmm2; while (i >= 2) { xmm2 = _mm_loadu_pd(iptr); xmm2 = _mm_mul_pd(xmm2, _mm_load_pd(fptr2)); xmm0 = _mm_add_pd(xmm0, xmm2); xmm2 = _mm_loadu_pd(iptr+2); xmm2 = _mm_mul_pd(xmm2, _mm_load_pd(fptr2+2)); xmm1 = _mm_add_pd(xmm1, xmm2); iptr+=4; fptr2+=4; i-=2; } if (i) { xmm2 = _mm_loadu_pd(iptr); xmm2 = _mm_mul_pd(xmm2, _mm_load_pd(fptr2)); xmm0 = _mm_add_pd(xmm0, xmm2); } xmm1 = _mm_add_pd(xmm1, xmm0); xmm2 = xmm1; xmm1 = _mm_unpackhi_pd(xmm1, xmm2); xmm1 = _mm_add_pd(xmm1, xmm2); _mm_store_sd(&sum2, xmm1); outptr[0]=sum2; } static void inline SincSample2(double *outptr, const double *inptr, double fracpos, const double *filter, int filtsz, int oversize) { fracpos *= oversize; const int ifpos=(int)fracpos; fracpos -= ifpos; const double *fptr2=filter + (oversize-ifpos) * filtsz; const double *fptr=fptr2 - filtsz; double sum, sum2, sumb, sum2b; const double *iptr=inptr; int i=filtsz/2; __m128d xmm0 = _mm_setzero_pd(); __m128d xmm1 = _mm_setzero_pd(); __m128d xmm2 = _mm_setzero_pd(); __m128d xmm3 = _mm_setzero_pd(); __m128d xmm4, xmm5, xmm6, xmm7; while (i--) { xmm4 = _mm_load_pd(fptr); xmm5 = _mm_load_pd(fptr2); xmm6 = _mm_loadu_pd(iptr); xmm7 = xmm4; xmm7 = _mm_unpacklo_pd(xmm7, xmm4); xmm7 = _mm_mul_pd(xmm7, xmm6); xmm0 = _mm_add_pd(xmm0, xmm7); xmm7 = xmm5; xmm7 = _mm_unpacklo_pd(xmm7, xmm5); xmm7 = _mm_mul_pd(xmm7, xmm6); xmm1 = _mm_add_pd(xmm1, xmm7); xmm6 = _mm_loadu_pd(iptr+2); xmm4 = _mm_unpackhi_pd(xmm4, xmm4); xmm4 = _mm_mul_pd(xmm4, xmm6); xmm2 = _mm_add_pd(xmm2, xmm4); xmm5 = _mm_unpackhi_pd(xmm5, xmm5); xmm5 = _mm_mul_pd(xmm5, xmm6); xmm3 = _mm_add_pd(xmm3, xmm5); iptr+=4; fptr+=2; fptr2+=2; } xmm0 = _mm_add_pd(xmm0, xmm2); xmm1 = _mm_add_pd(xmm1, xmm3); xmm2 = xmm0; _mm_store_sd(&sum, xmm0); xmm2 = _mm_unpackhi_pd(xmm2, xmm0); _mm_store_sd(&sum2, xmm2); xmm3 = xmm1; _mm_store_sd(&sumb, xmm1); xmm3 = _mm_unpackhi_pd(xmm3, xmm1); _mm_store_sd(&sum2b, xmm3); outptr[0]=sum*fracpos + sumb*(1.0-fracpos); outptr[1]=sum2*fracpos + sum2b*(1.0-fracpos); } static void inline SincSample2N(double *outptr, const double *inptr, double fracpos, const double *filter, int filtsz, int oversize) { const int ifpos=(int)(fracpos*oversize+0.5); const double *fptr2=filter + (oversize-ifpos) * filtsz; double sumb, sum2b; const double *iptr=inptr; int i=filtsz/2; __m128d xmm0 = _mm_setzero_pd(); __m128d xmm1 = _mm_setzero_pd(); __m128d xmm2 = _mm_setzero_pd(); __m128d xmm3 = _mm_setzero_pd(); __m128d xmm4, xmm5, xmm6; while (i >= 2) { xmm4 = _mm_load_pd(fptr2); xmm5 = xmm4; xmm6 = _mm_loadu_pd(iptr); xmm4 = _mm_unpacklo_pd(xmm4, xmm5); xmm6 = _mm_mul_pd(xmm6, xmm4); xmm0 = _mm_add_pd(xmm0, xmm6); xmm6 = _mm_loadu_pd(iptr+2); xmm5 = _mm_unpackhi_pd(xmm5, xmm5); xmm6 = _mm_mul_pd(xmm6, xmm5); xmm1 = _mm_add_pd(xmm1, xmm6); xmm4 = _mm_load_pd(fptr2+2); xmm5 = xmm4; xmm6 = _mm_loadu_pd(iptr+4); xmm4 = _mm_unpacklo_pd(xmm4, xmm5); xmm6 = _mm_mul_pd(xmm6, xmm4); xmm2 = _mm_add_pd(xmm2, xmm6); xmm6 = _mm_loadu_pd(iptr+6); xmm5 = _mm_unpackhi_pd(xmm5, xmm5); xmm6 = _mm_mul_pd(xmm6, xmm5); xmm3 = _mm_add_pd(xmm3, xmm6); iptr+=8; fptr2+=4; i-=2; } if (i) { xmm4 = _mm_load_pd(fptr2); xmm5 = xmm4; xmm6 = _mm_loadu_pd(iptr); xmm4 = _mm_unpacklo_pd(xmm4, xmm5); xmm6 = _mm_mul_pd(xmm6, xmm4); xmm0 = _mm_add_pd(xmm0, xmm6); xmm6 = _mm_loadu_pd(iptr+2); xmm5 = _mm_unpackhi_pd(xmm5, xmm5); xmm6 = _mm_mul_pd(xmm6, xmm5); xmm1 = _mm_add_pd(xmm1, xmm6); } xmm0 = _mm_add_pd(xmm0, xmm2); xmm1 = _mm_add_pd(xmm1, xmm3); xmm1 = _mm_add_pd(xmm1, xmm0); xmm3 = xmm1; _mm_store_sd(&sumb, xmm1); xmm3 = _mm_unpackhi_pd(xmm3, xmm1); _mm_store_sd(&sum2b, xmm3); outptr[0]=sumb; outptr[1]=sum2b; } #endif // WDL_RESAMPLE_USE_SSE WDL_Resampler::WDL_Resampler() { m_filterq=0.707f; m_filterpos=0.693f; // .792 ? m_sincoversize=0; m_lp_oversize=1; m_sincsize=0; m_filtercnt=1; m_interp=true; m_feedmode=false; m_filter_coeffs_size=0; m_sratein=44100.0; m_srateout=44100.0; m_ratio=1.0; m_filter_ratio=-1.0; m_iirfilter=0; Reset(); } WDL_Resampler::~WDL_Resampler() { delete m_iirfilter; } void WDL_Resampler::Reset(double fracpos) { m_last_requested=0; m_filtlatency=0; m_fracpos=fracpos; m_samples_in_rsinbuf=0; if (m_iirfilter) m_iirfilter->Reset(); } void WDL_Resampler::SetMode(bool interp, int filtercnt, bool sinc, int sinc_size, int sinc_interpsize) { m_sincsize = sinc && sinc_size>= 4 ? sinc_size > 8192 ? 8192 : (sinc_size&~1) : 0; m_sincoversize = m_sincsize ? (sinc_interpsize<= 1 ? 1 : sinc_interpsize>=8192 ? 8192 : sinc_interpsize) : 1; m_filtercnt = m_sincsize ? 0 : (filtercnt<=0?0 : filtercnt >= WDL_RESAMPLE_MAX_FILTERS ? WDL_RESAMPLE_MAX_FILTERS : filtercnt); m_interp=interp && !m_sincsize; // char buf[512]; // sprintf(buf,"setting interp=%d, filtercnt=%d, sinc=%d,%d\n",m_interp,m_filtercnt,m_sincsize,m_sincoversize); // OutputDebugString(buf); if (!m_sincsize) { m_filter_coeffs.Resize(0); m_filter_coeffs_size=0; } if (!m_filtercnt) { delete m_iirfilter; m_iirfilter=0; } } void WDL_Resampler::SetRates(double rate_in, double rate_out) { if (rate_in<1.0) rate_in=1.0; if (rate_out<1.0) rate_out=1.0; if (rate_in != m_sratein || rate_out != m_srateout) { m_sratein=rate_in; m_srateout=rate_out; m_ratio=m_sratein / m_srateout; } } const WDL_SincFilterSample *WDL_Resampler::BuildLowPass(double filtpos, bool *isIdeal) // only called in sinc modes { const int wantsize=m_sincsize; int wantinterp=m_sincoversize; int ideal_interp = 0; if (wantinterp) { if (m_ratio < 1.0) { const double drat = m_srateout/m_sratein; const int irat = (int) (drat + 0.5); if (irat > 1 && irat==drat) ideal_interp=irat; } else { const int irat = (int) (m_ratio + 0.5); if (m_ratio == irat) ideal_interp=1; // eg 96k to 48k, only need one table } if (!ideal_interp) { // if whole integer rates, calculate GCD const int in1 = (int)m_sratein, out1 = (int)m_srateout; if (out1 > 0 && in1 > 0 && m_sratein == (double)in1 && m_srateout == (double)out1) { // don't bother finding the GCD if it's lower than is useful int min_cd = out1 / (2*wantinterp); if (min_cd < 1) min_cd = 1; int n1 = out1, n2=in1; while (n2 >= min_cd) { const int tmp = n1; n1 = n2; n2 = tmp % n2; } if (!n2) ideal_interp = out1 / n1; } } if (ideal_interp > 0 && ideal_interp <= wantinterp*2) // use ideal filter for reduced cpu use even if it means more memory { wantinterp = ideal_interp; } } *isIdeal = ideal_interp == wantinterp; if (m_filter_ratio!=filtpos || m_filter_coeffs_size != wantsize || m_lp_oversize != wantinterp) { m_lp_oversize = wantinterp; m_filter_ratio=filtpos; // build lowpass filter const int allocsize = wantsize*(m_lp_oversize+1); const int alignedsize = allocsize + 16/sizeof(WDL_SincFilterSample) - 1; if (m_filter_coeffs.ResizeOK(alignedsize)) { WDL_SincFilterSample *cfout=m_filter_coeffs.GetAligned(16); m_filter_coeffs_size=wantsize; const double dwindowpos = 2.0 * PI/(double)wantsize; const double dsincpos = PI * filtpos; // filtpos is outrate/inrate, i.e. 0.5 is going to half rate const int hwantsize=wantsize/2, hwantinterp=wantinterp/2; double filtpower=0.0; WDL_SincFilterSample *ptrout = cfout; int slice; for (slice=0;slice<=hwantinterp;slice++) { const double frac = slice / (double)wantinterp; const int center_x = slice == 0 ? hwantsize : -1; const int n = ((slice < hwantinterp) | (wantinterp & 1)) ? wantsize : hwantsize; int x; for (x=0;x<n;x++) { if (x==center_x) { // we know this will be 1.0 *ptrout++ = 1.0; } else { const double xfrac = frac + x; const double windowpos = dwindowpos * xfrac; const double sincpos = dsincpos * (xfrac - hwantsize); // blackman-harris * sinc const double val = (0.35875 - 0.48829 * cos(windowpos) + 0.14128 * cos(2*windowpos) - 0.01168 * cos(3*windowpos)) * sin(sincpos) / sincpos; filtpower += slice ? val*2 : val; *ptrout++ = (WDL_SincFilterSample)val; } } } filtpower = wantinterp/(filtpower+1.0); const int n = allocsize/2; int x; for (x = 0; x < n; x ++) { cfout[x] = (WDL_SincFilterSample) (cfout[x]*filtpower); } int y; for (x = n, y = n - 1; y >= 0; ++x, --y) cfout[x] = cfout[y]; } else m_filter_coeffs_size=0; } return m_filter_coeffs_size > 0 ? m_filter_coeffs.GetAligned(16) : NULL; } double WDL_Resampler::GetCurrentLatency() { double v=((double)m_samples_in_rsinbuf-m_filtlatency)/m_sratein; if (v<0.0)v=0.0; return v; } int WDL_Resampler::ResamplePrepare(int out_samples, int nch, WDL_ResampleSample **inbuffer) { if (nch > WDL_RESAMPLE_MAX_NCH || nch < 1) return 0; int fsize=0; if (m_sincsize>1) fsize = m_sincsize; int hfs=fsize/2; if (hfs>1 && m_samples_in_rsinbuf<hfs-1) { m_filtlatency+=hfs-1 - m_samples_in_rsinbuf; m_samples_in_rsinbuf=hfs-1; if (m_samples_in_rsinbuf>0) { WDL_ResampleSample *p = m_rsinbuf.Resize(m_samples_in_rsinbuf*nch,false); memset(p,0,sizeof(WDL_ResampleSample)*m_rsinbuf.GetSize()); } } int sreq = 0; if (!m_feedmode) sreq = (int)(m_ratio * out_samples) + 4 + fsize - m_samples_in_rsinbuf; else sreq = out_samples; if (sreq<0)sreq=0; again: m_rsinbuf.Resize((m_samples_in_rsinbuf+sreq)*nch,false); int sz = m_rsinbuf.GetSize()/(nch?nch:1) - m_samples_in_rsinbuf; if (sz!=sreq) { if (sreq>4 && !sz) { sreq/=2; goto again; // try again with half the size } // todo: notify of error? sreq=sz; } *inbuffer = m_rsinbuf.Get() + m_samples_in_rsinbuf*nch; m_last_requested=sreq; return sreq; } int WDL_Resampler::ResampleOut(WDL_ResampleSample *out, int nsamples_in, int nsamples_out, int nch) { if (nch > WDL_RESAMPLE_MAX_NCH || nch < 1) return 0; #ifdef WDL_DENORMAL_WANTS_SCOPED_FTZ WDL_denormal_ftz_scope ftz_force; #endif if (m_filtercnt>0) { if (m_ratio > 1.0 && nsamples_in > 0) // filter input { if (!m_iirfilter) m_iirfilter = new WDL_Resampler_IIRFilter; int n=m_filtercnt; m_iirfilter->setParms((1.0/m_ratio)*m_filterpos,m_filterq); WDL_ResampleSample *buf=(WDL_ResampleSample *)m_rsinbuf.Get() + m_samples_in_rsinbuf*nch; int a,x; int offs=0; for (x=0; x < nch; x ++) for (a = 0; a < n; a ++) m_iirfilter->Apply(buf+x,buf+x,nsamples_in,nch,offs++); } } // prevent the caller from corrupting the internal state m_samples_in_rsinbuf += nsamples_in < m_last_requested ? nsamples_in : m_last_requested; int rsinbuf_availtemp = m_samples_in_rsinbuf; if (nsamples_in < m_last_requested) // flush out to ensure we can deliver { int fsize=(m_last_requested-nsamples_in)*2 + m_sincsize*2; int alloc_size=(m_samples_in_rsinbuf+fsize)*nch; WDL_ResampleSample *zb=m_rsinbuf.Resize(alloc_size,false); if (m_rsinbuf.GetSize()==alloc_size) { memset(zb+m_samples_in_rsinbuf*nch,0,fsize*nch*sizeof(WDL_ResampleSample)); rsinbuf_availtemp = m_samples_in_rsinbuf+fsize; } } int ret=0; double srcpos=m_fracpos; double drspos = m_ratio; WDL_ResampleSample *localin = m_rsinbuf.Get(); WDL_ResampleSample *outptr=out; int ns=nsamples_out; int outlatadj=0; bool isideal = false; if (m_sincsize) // sinc interpolating { const WDL_SincFilterSample *filter; if (m_ratio > 1.0) filter=BuildLowPass(1.0 / (m_ratio*1.03), &isideal); else filter=BuildLowPass(1.0, &isideal); const int oversize = m_lp_oversize; int filtsz=m_filter_coeffs_size; int filtlen = rsinbuf_availtemp - filtsz; outlatadj=filtsz/2-1; if (WDL_NOT_NORMALLY(!filter)) {} else if (nch == 1) { if (isideal) while (ns--) { int ipos = (int)srcpos; if (ipos >= filtlen-1) break; // quit decoding, not enough input samples SincSample1N(outptr,localin + ipos,srcpos-ipos,filter,filtsz,oversize); outptr ++; srcpos+=drspos; ret++; } else while (ns--) { int ipos = (int)srcpos; if (ipos >= filtlen-1) break; // quit decoding, not enough input samples SincSample1(outptr,localin + ipos,srcpos-ipos,filter,filtsz,oversize); outptr ++; srcpos+=drspos; ret++; } } else if (nch==2) { if (isideal) while (ns--) { int ipos = (int)srcpos; if (ipos >= filtlen-1) break; // quit decoding, not enough input samples SincSample2N(outptr,localin + ipos*2,srcpos-ipos,filter,filtsz,oversize); outptr+=2; srcpos+=drspos; ret++; } else while (ns--) { int ipos = (int)srcpos; if (ipos >= filtlen-1) break; // quit decoding, not enough input samples SincSample2(outptr,localin + ipos*2,srcpos-ipos,filter,filtsz,oversize); outptr+=2; srcpos+=drspos; ret++; } } else { if (isideal) while (ns--) { int ipos = (int)srcpos; if (ipos >= filtlen-1) break; // quit decoding, not enough input samples SincSampleN(outptr,localin + ipos*nch,srcpos-ipos,nch,filter,filtsz,oversize); outptr += nch; srcpos+=drspos; ret++; } else while (ns--) { int ipos = (int)srcpos; if (ipos >= filtlen-1) break; // quit decoding, not enough input samples SincSample(outptr,localin + ipos*nch,srcpos-ipos,nch,filter,filtsz,oversize); outptr += nch; srcpos+=drspos; ret++; } } } else if (!m_interp) // point sampling { if (nch == 1) { while (ns--) { int ipos = (int)srcpos; if (ipos >= rsinbuf_availtemp) break; // quit decoding, not enough input samples *outptr++ = localin[ipos]; srcpos+=drspos; ret++; } } else if (nch == 2) { while (ns--) { int ipos = (int)srcpos; if (ipos >= rsinbuf_availtemp) break; // quit decoding, not enough input samples ipos+=ipos; outptr[0] = localin[ipos]; outptr[1] = localin[ipos+1]; outptr+=2; srcpos+=drspos; ret++; } } else while (ns--) { int ipos = (int)srcpos; if (ipos >= rsinbuf_availtemp) break; // quit decoding, not enough input samples memcpy(outptr,localin + ipos*nch,nch*sizeof(WDL_ResampleSample)); outptr += nch; srcpos+=drspos; ret++; } } else // linear interpolation { if (nch == 1) { while (ns--) { int ipos = (int)srcpos; double fracpos=srcpos-ipos; if (ipos >= rsinbuf_availtemp-1) { break; // quit decoding, not enough input samples } double ifracpos=1.0-fracpos; WDL_ResampleSample *inptr = localin + ipos; *outptr++ = inptr[0]*(ifracpos) + inptr[1]*(fracpos); srcpos+=drspos; ret++; } } else if (nch == 2) { while (ns--) { int ipos = (int)srcpos; double fracpos=srcpos-ipos; if (ipos >= rsinbuf_availtemp-1) { break; // quit decoding, not enough input samples } double ifracpos=1.0-fracpos; WDL_ResampleSample *inptr = localin + ipos*2; outptr[0] = inptr[0]*(ifracpos) + inptr[2]*(fracpos); outptr[1] = inptr[1]*(ifracpos) + inptr[3]*(fracpos); outptr += 2; srcpos+=drspos; ret++; } } else { while (ns--) { int ipos = (int)srcpos; double fracpos=srcpos-ipos; if (ipos >= rsinbuf_availtemp-1) { break; // quit decoding, not enough input samples } double ifracpos=1.0-fracpos; int ch=nch; WDL_ResampleSample *inptr = localin + ipos*nch; while (ch--) { *outptr++ = inptr[0]*(ifracpos) + inptr[nch]*(fracpos); inptr++; } srcpos+=drspos; ret++; } } } if (m_filtercnt>0) { if (m_ratio < 1.0 && ret>0) // filter output { if (!m_iirfilter) m_iirfilter = new WDL_Resampler_IIRFilter; int n=m_filtercnt; m_iirfilter->setParms(m_ratio*m_filterpos,m_filterq); int x,a; int offs=0; for (x=0; x < nch; x ++) for (a = 0; a < n; a ++) m_iirfilter->Apply(out+x,out+x,ret,nch,offs++); } } if (ret>0 && rsinbuf_availtemp>m_samples_in_rsinbuf) // we had to pad!! { // check for the case where rsinbuf_availtemp>m_samples_in_rsinbuf, decrease ret down to actual valid samples double adj=(srcpos-m_samples_in_rsinbuf + outlatadj) / drspos; if (adj>0) { ret -= (int) (adj + 0.5); if (ret<0)ret=0; } } int isrcpos=(int)srcpos; if (isrcpos > m_samples_in_rsinbuf) isrcpos=m_samples_in_rsinbuf; m_fracpos = srcpos - isrcpos; if (m_sincsize && isideal) m_fracpos = floor(m_lp_oversize*m_fracpos + 0.5)/m_lp_oversize; m_samples_in_rsinbuf -= isrcpos; if (m_samples_in_rsinbuf <= 0) m_samples_in_rsinbuf=0; else memmove(localin, localin + isrcpos*nch,m_samples_in_rsinbuf*sizeof(WDL_ResampleSample)*nch); return ret; }
// Copyright 2016 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/android/mojo/chrome_service_registrar_android.h" #include "base/android/context_utils.h" #include "base/android/jni_android.h" #include "content/public/browser/android/service_registry_android.h" #include "content/public/browser/web_contents.h" #include "jni/ChromeServiceRegistrar_jni.h" #include "services/shell/public/cpp/interface_registry.h" // static bool ChromeServiceRegistrarAndroid::Register(JNIEnv* env) { return RegisterNativesImpl(env); } // static void ChromeServiceRegistrarAndroid::RegisterRenderFrameMojoInterfaces( shell::InterfaceRegistry* registry, content::RenderFrameHost* render_frame_host) { content::WebContents* web_contents = content::WebContents::FromRenderFrameHost(render_frame_host); // Happens when, for example, showing the malware interstitial page. if (!web_contents) return; Java_ChromeServiceRegistrar_registerRenderFrameMojoServices( base::android::AttachCurrentThread(), content::ServiceRegistryAndroid::Create(registry, nullptr)->GetObj().obj(), web_contents->GetJavaWebContents().obj()); }
;LOW ORDER HVEC VALUE INX H ORA M ;VALUE = 0? LXI H, ZERCNT JNZ ZCHK1 ;VALUE IS NOT ZERO, PRINT LINE ;VALUE IS ZERO, ALREADY PRINTED? MOV A, M ;GET ZERCNT ORA A JNZ ZCHK0 ;JUMP IF ALREADY PRINTED LINE ;NOT PRINTED YET, SET ZERCNT TO TRUE AND PRINT MSG MVI M, 0FFH PUSH B PUSH D LXI D, PERMSG CALL PRINT POP D POP B ZCHK0: ;INCREMENT LINE ADDRESS LHLD INC DAD D XCHG JMP DISP0 ; ZCHK1: ;LINE IS NOT ZERO, FLAG IT AND CONTINUE MVI M, 0 ;ZERCNT SET FALSE PUSH B ;INDEX TO HVEC SAVED PUSH D ;CURRENT LINE SAVED PUSH D ;ANOTHER COPY CALL CRLF POP D ;LINE ADDRESS TO DE CALL PADDR ;PRINTED POP D ;RECALL LINE ADDRESS LHLD INC ;INCREMENT BETWEEN LINES DAD D XTHL ;LINE ADDRESS STACKED, INDEX TO HVEC IN HL MOV E, M INX H MOV D, M INX H PUSH H ;SAVE UPDATED HVEC ADDRESS CALL STARS ;PRINTS STARS FOR THIS LINE POP B ;RECALL HVEC BASE POP D ;RECALL CURRENT LINE JMP DISP0 DISP1: ;END OF DISPLAY CALL CRLF RET ;RETURN TO DDT STARS: ;PRINT STARS ACROSS LINE BASED ON SCALE VALUE MOV A, E ORA D RZ ;RETURN IF ZERO STARS PUSH D MVI A, ' ' CALL PCHAR POP D STAR0: ;LOOP PRINTING STARS LHLD SCALE ;SCALING FACTOR CALL DIFF ;X = SIZE - SCALE RC PUSH D ;SAVE REMAINING LENGTH MVI A, '*' CALL PCHAR POP D JMP STAR0 ; ; ; DATA AREAS ERMSG: DB CR, LF, 'ERROR - FORM IS X, Y', 0 BOUNDS: DB CR, LF, 'TYPE HISTOGRAM BOUNDS ', 0 LARMSG: DB CR, LF, 'HISTOGRAM, ' DB CR, LF, 'ADDR RELATIVE FREQUENCY, LARGEST VALUE', 0 INIMSG: DB CR, LF, 'INITIAL = ', 0 COLMSG: DB CR, LF, 'COLLECT = ', 0 DISMSG: DB CR, LF, 'DISPLAY = ', 0 PERMSG: DB CR, LF, '....', 0 ZERCNT: DS 1 LB: DS 2 ;LOWER BOUND UB: DS 2 ;UPPER BOUND HVEC: DS HSIZE*2 ;HISTOGRAM VECTOR SCALE: DS 2 ;SCALE FACTOR INC: DS 2 ;INCREMENT BETWEEN LINES NOP ENDMOD EQU ($+100H) AND 0FF00H ;BEGINNING OF NEXT MODULE END HISTO ORG 100H TRUE EQU 0FFFFH FALSE EQU NOT TRUE TEST EQU FALSE ; ; TRACE INSTRUCTIONS IN DDT ; ; COPYRIGHT (C) 1976 ; DIGITAL RESEARCH ; BOX 579, PACIFIC GROVE, CA ; 93950 ; ; ENTRY VECTOR JMP ENDMOD INIE: JMP INITIAL COLE: JMP COLLECT DISE: JMP DISPLAY ; DB 'COPYRIGHT (C) 1976, DIGITAL RESEARCH ' ; DDT BASE EQU 7*8-1 ;ADDRESS OF DDT ENTRY VECTOR CR EQU BDH LF EQU BAH ; PCHAR: ;PRINT CHARACTER FROM REGISTER A LX1 B, 9 JMP GODDT ; PADDR: ;PRINT ADDRESS FROM D, E LXI B, 15 GODDT: LHLD DDTBASE ;GET ENTRY TO DDT FROM RST 7 LOCATION DAD B PCHL ; PRINT: ;PRINT MESSAGE IN, D, E 'TIL FIRST ZERO LDAX D ORA A RZ ;MORE TO PRINT INX D PUSH D CALL PCHAR POP D JMP PRINT ; CRLF: ;PRINT CARRIAGE RETURN, LINE FEED PUSH B PUSH D MVI A, CR CALL PCHAR MVI A, LF CALL PCHAR POP D POP B RET ; INITIAL: ;PRINT ENTRY POINT ADDRESSES LXI D, INIMSG CALL PRINT LXI D, INIE CALL PADDR LXI D, COLMSG CALL PRINT LXI D, COLE CALL PADDR LXI D, DISMSG CALL PRINT LXI D, DISE CALL PADDR ; ;DETERMINE IF THE DISASSEMBLER IS PRESENT LDA DDTBASE+1 ;HIGH ORDER ADDRESS OF DDT TO REG-A CPI ENDMOD SHR B JNZ INIT1 ;DISASSEMBLER HAS BEEN OVERLAYED LXI D, OVERMSG MVI A, 1 ;MARK AS ADDRESSES ONLY JMP INIT2 INIT1: ;MARK AS FULL TRACE XRA A LXI D, UNDMSG ; IHIT2: STA DISFLG ;SET TO 1 IF ADDRESSES ONLY CALL PRINT LXI H, COUNT MVI M, 0 ;ZERO THE INSTRUCTION, COUNT LXI H, ABUFF ;ADDRESS BUFFER SHLD NEXT ;NEXT TO FILL AT BEGINNING OF BUFFER RET ;BACK TO DDT ; COLLECT: ;ENTER WITH INSTRUCTION, ADDRESS IN D, E LXI H, COUNT MOV& A, M ;INSTRUCTION COUNT ORA A JM FULLC ;STOP AT 128 COUNTS INR M ;NOT AT 128 YET FULLC: LHLD NEXT ;NEXT POSITION TO FILL MOV& M, E INR L ;WRAP-AROUND ON PAGE MOV& M, D INR L SHLD NEXT XRA A RET ;RETURN TO DDT WITH ZERO FLAG ; DISPLAY: ;ENTER WITH C=1 IF ONLY ADDRESS TRACE IS REQUESTED LXI H, DISFLG MOV& A, M ORA C ;DISFLG = 1 IF DISASSEMBLER NOT PRESENT MOV& C, A PUSH B LXI D, TRMSG ;TRACE MESSAGE CALL PRINT POP B LXI H, COUNT MOV& B, M ;QUEUE SIZE IN B XRA A ;CLEAR COLUMN COUNT STA COLUMN MOV& A, C ORA A ;ADDRESS MODE? JNZ DISP0 ;SAVE OLD PC FROM DISASSEMBLER LHLD PC SHLD TPC DISP0: LHLD NEXT ; DISP1: ;DISPLAY COLLECTED ADDRESSES OR INSTRUCTIONS MOV& A, B ;QUEUE SIZE ORA A JZ ENDISP DCR B ;COUNT SIZE DOWN PUSH B ;SAVE COUNT AND MODE DCR L ;ADDRESS LAST HIGH ORDER ADDRESS MOV& D, M DCR L ;ADDRESS LAST LOW ORDER ADDRESS MOV& E, M PUSH H ;SAVE NEXT TO GET XCHG ;CHECK MODE OF DISPLAY MOV& A, C ORA A JZ* FDISP ;FULL DISPLAY? ; ;PARTIAL ADDRESS DISPLAY XCHC ;READY FOR ADDRESS PRINTING LXI H, COLUMN MOV& A, M INR M ANI 111B ;COUNTS 0-7 CZ CRLF ;START NEW LINE CALL PADDR MVI A, ' ' CALL PCHAR JMP EDISP ; FDISP: SHLD PC ;READY FOR DECODE MVI A, 2 STA PAGM ;TO DISPLAY ONE LINE CALL DISENT ;DISPLAYED EDISP: POP H ;RECOVER NEXT TO DECODE POP B ;RECOVER COUNT JMP DISP1 ; ENDISP: ;END OF DISPLAY MOV& A, C ORA A RZ* ;RETURN WITHOUT RESTORING PC LHLD TPC SHLD PC ;DISASSEMBLER'S PC RESTORED RET ; ;MESSAGES INIMSG: DB CR, LF, 'INITIAL = ', 0 COLMSG: DB CR, LF, 'COLLECT = ', 0 DISMSG: DB CR, LF, 'DISPLAY = ', 0 OVERMSG: DB CR, LF, 'DISASSEMBLER OVERLAYED, ADDRESSES ONLY ', 0 UNDMSG: DB CR, LF, 'READY FOR SYMBOLIC TRACE ', 0 TRMSG: DB CR, LF, 'TRACEBACK, ', 0 ; ;DATA AREAS COUNT: DB 0 NEXT: DW ABUFF TPC: DS 2 DISFLG: DS 1 ;1 IF ADDRESSES ONLY COLUMN: DS 1 ;COLUMN COUNT IF ADDRESSES ONLY ORG ($ + 100H) AND 0FF00H ABUFF: DS 255 DB B ENDMOD: EQU $ IF TEST DISEM: EQU 0D900H ENDIF IF NOT TEST DISEM: EQU ENDMOD ENDIF ; PC EQU DISEM+0CH PAGM EQU DISEM+10H DISENT EQU DISEM+06H END
.global s_prepare_buffers s_prepare_buffers: push %r15 push %rcx push %rdi push %rsi lea addresses_D_ht+0x2282, %rsi lea addresses_WC_ht+0xae82, %rdi add %r15, %r15 mov $88, %rcx rep movsw nop nop nop add %rdi, %rdi pop %rsi pop %rdi pop %rcx pop %r15 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r13 push %r14 push %r8 push %rax push %rbp // Store lea addresses_WC+0x13282, %rax nop cmp $42378, %r10 movl $0x51525354, (%rax) nop nop sub $35154, %r10 // Store lea addresses_UC+0x96b1, %rbp nop nop sub $13049, %r12 movl $0x51525354, (%rbp) nop nop nop cmp %rbp, %rbp // Store lea addresses_normal+0xdb82, %rax nop inc %rbp movl $0x51525354, (%rax) // Exception!!! nop nop nop mov (0), %r10 and $48270, %r8 // Load lea addresses_A+0x1740a, %r13 clflush (%r13) nop nop nop nop nop cmp %rax, %rax movups (%r13), %xmm5 vpextrq $1, %xmm5, %r14 // Exception!!! nop nop nop nop nop mov (0), %r8 nop nop nop inc %r13 // Faulty Load lea addresses_normal+0x13e82, %rbp nop nop nop xor $13527, %r13 mov (%rbp), %r14 lea oracles, %rax and $0xff, %r14 shlq $12, %r14 mov (%rax,%r14,1), %r14 pop %rbp pop %rax pop %r8 pop %r14 pop %r13 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 10, 'size': 4, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': False, 'NT': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'AVXalign': False, 'congruent': 8, 'size': 4, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_A', 'AVXalign': False, 'congruent': 3, 'size': 16, 'same': False, 'NT': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'AVXalign': True, 'congruent': 0, 'size': 8, 'same': True, 'NT': False}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 11, 'same': False}} {'34': 21829} 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 */
;Take 2 numbers and returns sum ; https://www.spoj.com/problems/TESTINT/ global _start section .data section .bss numb resb 1 sum resb 3 section .text _start: mov edi,0 mov esi,0 getfirstnum: mov eax,3 mov ebx,0 mov ecx,numb mov edx,1 int 80h movzx eax, BYTE[numb] cmp eax, '0' jl getsecondnum cmp eax, '9' jg getsecondnum imul edi,10 add edi, eax sub edi, '0' jmp getfirstnum getsecondnum: mov eax,3 mov ebx,0 mov ecx,numb mov edx,1 int 80h movzx eax, BYTE[numb] cmp eax, '0' jl sumandprint cmp eax, '9' jg sumandprint imul esi,10 add esi, eax sub esi, '0' jmp getsecondnum sumandprint: add esi,edi mov eax,esi xor edx,edx xor ecx,ecx mov ebx,10 loopconvert: xor edx,edx div ebx push edx inc ecx cmp eax,0 jne loopconvert mov ebx,sum mov edx,ecx gettostring: pop eax add eax,'0' mov BYTE [ebx],al inc ebx sub ecx,1 jnz gettostring print: mov eax,4 mov ebx,1 mov ecx,sum int 80h ;exit mov eax,1 ; 'exit' system call mov ebx,0 ; exit with error code 0 int 80h
#include <GL/error.h> #include <ResourceImp.h> #include "materials/TexturedMaterial.h" #include "materials/TexturedLitMaterial.h" #include "Renderer.h" #include "Texture.h" namespace GLRenderer { Texture2DRGBA8::Texture2DRGBA8(Renderer& renderer, GLsizei width, GLsizei height, GLsizei levels, const std::uint32_t* data) : renderer(renderer) { glBindTexture(GL_TEXTURE_2D, tex); glTexStorage2D(GL_TEXTURE_2D, levels, GL_SRGB8_ALPHA8, width, height); for (GLsizei i = 0; i < levels; ++i) { glTexSubImage2D(GL_TEXTURE_2D, i, 0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); data += width * height; width = std::max(width / 2, 1); height = std::max(height / 2, 1); } glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); GL::throw_error(); } ::Material* Texture2DRGBA8::createTexturedMaterial(const math::float4& color) { return renderer.createTexturedMaterial(tex, color); } ::Material* Texture2DRGBA8::createTexturedLitMaterial(const math::float4& color) { return renderer.createTexturedLitMaterial(tex, color); } }
;---------------------------------------------------------------------------- ; Configuration parameters ; NUM_INTERRUPT_STACKS = 4 INTERRUPT_STACK_SIZE = 1000h ;---------------------------------------------------------------------------- ; TASM red tape ; .386 .model flat .code PUBLICDLL SetIRQHandler PUBLICDLL GetIRQHandler SIZE_OF_ENTRY EQU ((OFFSET __entryEnd - OFFSET __entryStart) SHR 4) SIZE_OF_WRAPPER EQU ((OFFSET __wrapperEnd - OFFSET __wrapperStart) SHR 4) ;+--------------------------------------------------------------------------- ; DLL Entry point ; DllMain PROC NEAR pushad mov DataSelector, ds mov TIBSelector, fs mov ebx, 8 mov edi, OFFSET __wrapperStart mov esi, OFFSET __entryStart @@getSetLoop: mov eax, 0204h int 31h mov [edi + SIZE_OF_WRAPPER - 8], edx mov [edi + SIZE_OF_WRAPPER - 4], ecx mov edx, esi mov ecx, cs mov eax, 0205h int 31h add esi, SIZE_OF_ENTRY add edi, SIZE_OF_WRAPPER inc ebx cmp ebx, 78h je @@getSetDone cmp ebx, 16 jne @@getSetLoop mov ebx, 70h jmp @@getSetLoop @@getSetDone: popad mov eax, 1 retn 12 DllMain ENDP ;---------------------------------------------------------------------------- ; The actual interrupt glue code ; EnterInterrupt PROC NEAR xchg ecx, [esp] push eax push edx push gs push fs push es push ds mov ds, DWORD PTR cs:[OFFSET DataSelector] mov fs, TIBSelector mov edx, ss mov eax, esp push ds push ds pop es pop ss mov esp, DWORD PTR [OFFSET IntStackTop] sub DWORD PTR [OFFSET IntStackTop], INTERRUPT_STACK_SIZE push edx push eax call ecx cli lss esp, [esp] add DWORD PTR [OFFSET IntStackTop], INTERRUPT_STACK_SIZE pop ds pop es pop fs pop gs pop edx pop eax pop ecx iretd EnterInterrupt ENDP ;---------------------------------------------------------------------------- ; Standard Interrupt entry points ; __entryStart LABEL NEAR i = 0 REPT 16 IrqEntry CATSTR <Irq>,%i,<Entry> IrqEntry LABEL NEAR call EnterInterrupt jmp DWORD PTR [OFFSET HandlerArray + i * 4] i = i + 1 ENDM __entryEnd LABEL NEAR ;---------------------------------------------------------------------------- ; NEAR callable irq handler entries with IRET stackframe ; __wrapperStart LABEL NEAR i = 0 REPT 16 xchg eax, [esp] push eax push eax pushfd pop eax xchg [esp + 8], eax mov [esp + 4], cs db 0EAh dd ? dd ? i = i + 1 ENDM __wrapperEnd LABEL NEAR ;+---------------------------------------------------------------------------- ; GetIrqHandler ; GetIrqHandler PROC NEAR mov eax, [esp + 4] mov eax, [eax * 4 + OFFSET HandlerArray] retn 4 GetIrqHandler ENDP ;+---------------------------------------------------------------------------- ; SetIrqHandler ; SetIrqHandler PROC NEAR mov edx, [esp + 4] mov eax, [esp + 8] mov [edx * 4 + OFFSET HandlerArray], eax retn 8 SetIrqHandler ENDP .data HandlerArray LABEL DWORD i = 0 REPT 16 dd OFFSET __wrapperStart + i * SIZE_OF_WRAPPER i = i + 1 ENDM IntStackTop dd OFFSET TheTopOfStack .data? DataSelector dd ? TIBSelector dd ? db NUM_INTERRUPT_STACKS * INTERRUPT_STACK_SIZE DUP (?) TheTopOfStack LABEL DWORD END DllMain
; A340301: a(n) = n * floor(log_2(n)). ; 0,2,3,8,10,12,14,24,27,30,33,36,39,42,45,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,124,160,165,170,175,180,185,190,195,200,205,210,215,220,225,230,235,240,245,250,255,260,265,270,275,280,285,290,295,300,305,310,315,384,390,396,402,408,414,420,426,432,438,444,450,456,462,468,474,480,486,492,498,504,510,516,522,528,534,540,546,552,558,564,570,576,582,588,594,600,606,612,618,624,630,636,642,648,654,660,666,672,678,684,690,696,702,708,714,720,726,732,738,744,750,756,762,896,903,910,917,924,931,938,945,952,959,966,973,980,987,994,1001,1008,1015,1022,1029,1036,1043,1050,1057,1064,1071,1078,1085,1092,1099,1106,1113,1120,1127,1134,1141,1148,1155,1162,1169,1176,1183,1190,1197,1204,1211,1218,1225,1232,1239,1246,1253,1260,1267,1274,1281,1288,1295,1302,1309,1316,1323,1330,1337,1344,1351,1358,1365,1372,1379,1386,1393,1400,1407,1414,1421,1428,1435,1442,1449,1456,1463,1470,1477,1484,1491,1498,1505,1512,1519,1526,1533,1540,1547,1554,1561,1568,1575,1582,1589,1596,1603,1610,1617,1624,1631,1638,1645,1652,1659,1666,1673,1680,1687,1694,1701,1708,1715,1722,1729,1736,1743,1750 add $0,1 mov $1,$0 log $0,2 mul $1,$0
; A248474: Numbers congruent to 13 or 17 mod 30. ; 13,17,43,47,73,77,103,107,133,137,163,167,193,197,223,227,253,257,283,287,313,317,343,347,373,377,403,407,433,437,463,467,493,497,523,527,553,557,583,587,613,617,643,647,673,677,703,707,733,737,763,767,793,797,823,827,853,857,883,887,913,917,943,947,973,977,1003,1007,1033,1037,1063,1067,1093,1097,1123,1127,1153,1157,1183,1187,1213,1217,1243,1247,1273,1277,1303,1307,1333,1337,1363,1367,1393,1397,1423,1427,1453,1457,1483,1487,1513,1517,1543,1547,1573,1577,1603,1607,1633,1637,1663,1667,1693,1697,1723,1727,1753,1757,1783,1787,1813,1817,1843,1847,1873,1877,1903,1907,1933,1937,1963,1967,1993,1997,2023,2027,2053,2057,2083,2087,2113,2117,2143,2147,2173,2177,2203,2207,2233,2237,2263,2267,2293,2297,2323,2327,2353,2357,2383,2387,2413,2417,2443,2447,2473,2477,2503,2507,2533,2537,2563,2567,2593,2597,2623,2627,2653,2657,2683,2687,2713,2717,2743,2747,2773,2777,2803,2807,2833,2837,2863,2867,2893,2897,2923,2927,2953,2957,2983,2987,3013,3017,3043,3047,3073,3077,3103,3107,3133,3137,3163,3167,3193,3197,3223,3227,3253,3257,3283,3287,3313,3317,3343,3347,3373,3377,3403,3407,3433,3437,3463,3467,3493,3497,3523,3527,3553,3557,3583,3587,3613,3617,3643,3647,3673,3677,3703,3707,3733,3737 mov $2,$0 div $0,2 mul $0,11 mul $2,2 add $0,$2 mov $1,$0 mul $1,2 add $1,13
.memorymap slotsize $7000 defaultslot 0 slot 0 $200 .endme .rombankmap bankstotal 1 banksize $7000 banks 1 .endro .emptyfill 0 ;;;;;;;;;;; SPC700 CPU registers / IO locations ;;;;;;;;;;;;;;;;;;;; .define TEST $00F0 ; Testing functions .define CONTROL $00F1 ; Timer, I/O and ROM Control .define DSPADDR $00F2 ; DSP Register Index (R/W) .define DSPDATA $00F3 ; DSP Register Data (R/W) .define CPUIO0 $00F4 .define CPUIO1 $00F5 .define CPUIO2 $00F6 .define CPUIO3 $00F7 .define AUXIO4 $00F8 .define AUXIO5 $00F9 .define T0DIV $00FA ; Timer 0 Divider (for 8000Hz clock source) (W) .define T1DIV $00FA ; Timer 0 Divider (for 8000Hz clock source) (W) .define T2DIV $00FA ; Timer 0 Divider (for 64000Hz clock source) (W) .define T0OUT $00FD .define T1OUT $00FE .define T2OUT $00FF ;;;;;;;;;;; DSP registers ;;;;;;;;;;;; ;; voice registers (repeated at $10 interval for 8 voices) .define VOL_L $00 ; \ left and right volume .define VOL_R $01 ; / .define P_L $02 ; \ The total 14 bits of P(H) & P(L) express .define P_H $03 ; / pitch height .define SCRN $04 ; Designates source number from 0-256 .define ADSR1 $05 ; \ Address is designated by D7 = 1 of ADSR(1): .define ADSR2 $06 ; / .define GAIN $07 ; Envelope can be freely designated by the program. .define ENVX $08 ; Present value of evelope which DSP rewrittes at each Ts. .define OUTX $09 ; Value after envelope multiplication & before VOL multiplication (present wave height value) .define CHN0_OFF $00 .define CHN1_OFF $10 .define CHN2_OFF $20 .define CHN3_OFF $30 .define CHN4_OFF $40 .define CHN5_OFF $50 .define CHN6_OFF $60 .define CHN7_OFF $70 ;; Global / common register .define MVOL_L $0c ; Main Volume (L) .define MVOL_R $1c ; Main Volume (R) .define EVOL_L $2c ; Echo Volume (L) .define EVOL_R $3c ; Echo Volume (R) .define KON $4c ; Key On. D0-D7 correspond to Voice0-Voice7 .define KOF $5c ; key Off .define FLG $6c ; Designated on/off of reset, mute, echo and noise clock. .define FLG_RES $80 ; soft reset .define FLG_MUTE $40 ; mute .define FLG_ECHO_DIS $20 ; echo enable .define FLG_NCK $04 ; noise generator clock .define ENDX $7c ; Indicates source end block. .define EFB $0d ; Echo Feed-Back .define PMON $2d ; Pitch modulation of Voice i with OUTX of Voice (i=1) as modulated wave. .define NOV $3d ; Noise on/off. D0-D7 correspond to Voice0-Voice7 .define EOV $4d ; Echo On/Off .define DIR $5d ; Off-set address of source directory .define ESA $6d ; Off-set address of echo region. Echo Start Address .define EDL $7d ; Echo Delay. Only lower 4 bits operative. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; syntax writeDspReg reg data .macro writeDspReg mov DSPADDR, #\1 mov DSPDATA, #\2 .endm ; syntax writeDspReg reg ; (value written taken from register A) .macro writeDspReg_A mov DSPADDR, #\1 mov DSPDATA, A .endm .macro writeDspReg16 mov DSPADDR, #\1 mov DSPDATA, #<\2 mov DSPADDR, #\1+1 mov DSPDATA, #>\2 .endm ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; .bank 0 .section "Code" FORCE entry: jmp !main main: writeDspReg DIR >source_directory writeDspReg MVOL_L 96 writeDspReg MVOL_R 96 writeDspReg EVOL_L 0 writeDspReg EVOL_R 0 writeDspReg FLG FLG_ECHO_DIS ; Init all voices in silence` writeDspReg SCRN+CHN0_OFF 0 writeDspReg VOL_L+CHN0_OFF 0 writeDspReg VOL_R+CHN0_OFF 0 writeDspReg16 ADSR1+CHN0_OFF 0 writeDspReg GAIN+CHN0_OFF 0 writeDspReg SCRN+CHN1_OFF 0 writeDspReg VOL_L+CHN1_OFF 0 writeDspReg VOL_R+CHN1_OFF 0 writeDspReg16 ADSR1+CHN1_OFF 0 writeDspReg GAIN+CHN1_OFF 0 writeDspReg SCRN+CHN2_OFF 0 writeDspReg VOL_L+CHN2_OFF 0 writeDspReg VOL_R+CHN2_OFF 0 writeDspReg16 ADSR1+CHN2_OFF 0 writeDspReg GAIN+CHN2_OFF 0 writeDspReg SCRN+CHN3_OFF 0 writeDspReg VOL_L+CHN3_OFF 0 writeDspReg VOL_R+CHN3_OFF 0 writeDspReg16 ADSR1+CHN3_OFF 0 writeDspReg GAIN+CHN3_OFF 0 writeDspReg SCRN+CHN4_OFF 0 writeDspReg VOL_L+CHN4_OFF 0 writeDspReg VOL_R+CHN4_OFF 0 writeDspReg16 ADSR1+CHN4_OFF 0 writeDspReg GAIN+CHN4_OFF 0 writeDspReg SCRN+CHN5_OFF 0 writeDspReg VOL_L+CHN5_OFF 0 writeDspReg VOL_R+CHN5_OFF 0 writeDspReg16 ADSR1+CHN5_OFF 0 writeDspReg GAIN+CHN5_OFF 0 writeDspReg SCRN+CHN6_OFF 0 writeDspReg VOL_L+CHN6_OFF 0 writeDspReg VOL_R+CHN6_OFF 0 writeDspReg16 ADSR1+CHN6_OFF 0 writeDspReg GAIN+CHN6_OFF 0 writeDspReg SCRN+CHN7_OFF 0 writeDspReg VOL_L+CHN7_OFF 0 writeDspReg VOL_R+CHN7_OFF 0 writeDspReg16 ADSR1+CHN7_OFF 0 writeDspReg GAIN+CHN7_OFF 0 ; Disable echo writeDspReg EOV 0 ; Disable noise writeDspReg NOV 0 ; Dsiable pitch modulation writeDspReg PMON 0 ; Sound 0 (error) writeDspReg SCRN 0 writeDspReg16 P_L $0400 ; original $1000 writeDspReg VOL_L 128 writeDspReg VOL_R 128 writeDspReg16 ADSR1 $0000 writeDspReg GAIN 64 ; Sound 1 (write) writeDspReg SCRN+CHN1_OFF 1 writeDspReg16 P_L+CHN1_OFF $0800 ; original writeDspReg VOL_L+CHN1_OFF 128 writeDspReg VOL_R+CHN1_OFF 128 writeDspReg16 ADSR1+CHN1_OFF $0000 writeDspReg GAIN+CHN1_OFF 64 ; Sound 2 (erase) writeDspReg SCRN+CHN2_OFF 2 writeDspReg16 P_L+CHN2_OFF $0800 ; original writeDspReg VOL_L+CHN2_OFF 128 writeDspReg VOL_R+CHN2_OFF 128 writeDspReg16 ADSR1+CHN2_OFF $0000 writeDspReg GAIN+CHN2_OFF 64 ; Sound 3 (click) writeDspReg SCRN+CHN3_OFF 3 writeDspReg16 P_L+CHN3_OFF $0800 ; original writeDspReg VOL_L+CHN3_OFF 128 writeDspReg VOL_R+CHN3_OFF 128 writeDspReg16 ADSR1+CHN3_OFF $0000 writeDspReg GAIN+CHN3_OFF 64 ; Sound 4 (back) writeDspReg SCRN+CHN4_OFF 4 writeDspReg16 P_L+CHN4_OFF $0800 ; original writeDspReg VOL_L+CHN4_OFF 128 writeDspReg VOL_R+CHN4_OFF 128 writeDspReg16 ADSR1+CHN4_OFF $0000 writeDspReg GAIN+CHN4_OFF 64 ; Sound 5 (back) writeDspReg SCRN+CHN5_OFF 5 writeDspReg16 P_L+CHN5_OFF $0800 ; original writeDspReg VOL_L+CHN5_OFF 128 writeDspReg VOL_R+CHN5_OFF 128 writeDspReg16 ADSR1+CHN5_OFF $0000 writeDspReg GAIN+CHN5_OFF 64 ; Silence unused channels writeDspReg SCRN+CHN6_OFF 0 writeDspReg VOL_L+CHN6_OFF 0 writeDspReg VOL_R+CHN6_OFF 0 writeDspReg16 ADSR1+CHN6_OFF 0 writeDspReg GAIN+CHN6_OFF 0 writeDspReg SCRN+CHN7_OFF 0 writeDspReg VOL_L+CHN7_OFF 0 writeDspReg VOL_R+CHN7_OFF 0 writeDspReg16 ADSR1+CHN7_OFF 0 writeDspReg GAIN+CHN7_OFF 0 @mainloop: mov A, CPUIO0 ; handshake @waitChange: cmp A, CPUIO0 beq @waitChange mov A, CPUIO1 ; command ; acknowledge the command push A mov A, CPUIO0 mov CPUIO0, A pop A ; cmp A, #$10 bra @keyon bra @mainloop ; Take A holding a value from 0 to 7, convert it to a ; bit for KON : In other words, do this: 1<<A @keyon: and A, #$7 mov X, A mov A, #1 @n: dec X bmi @done_shifting asl A bra @n @done_shifting: writeDspReg_A KON bra @mainloop .ends .section "source_directory" align $100 FREE source_directory: .dw errorSample ; Source start address .dw errorSample ; Source loop start address .dw writeSample .dw writeSample .dw eraseSample .dw eraseSample .dw clickSample .dw clickSample .dw backSample .dw backSample .dw solvedSample .dw solvedSample .ends .section "samples" errorSample: .incbin "error.brr" writeSample: .incbin "write.brr" eraseSample: .incbin "erase.brr" clickSample: .incbin "click.brr" backSample: .incbin "back.brr" solvedSample: .incbin "solved.brr" .ends
; ; jccolor.asm - colorspace conversion (SSE2) ; ; Copyright (C) 2009, D. R. Commander. ; ; Based on the x86 SIMD extension for IJG JPEG library ; Copyright (C) 1999-2006, MIYASAKA Masaru. ; For conditions of distribution and use, see copyright notice in jsimdext.inc ; ; This file should be assembled with NASM (Netwide Assembler), ; can *not* be assembled with Microsoft's MASM or any compatible ; assembler (including Borland's Turbo Assembler). ; NASM is available from http://nasm.sourceforge.net/ or ; http://sourceforge.net/project/showfiles.php?group_id=6208 ; ; [TAB8] %include "jsimdext.inc" ; -------------------------------------------------------------------------- %define SCALEBITS 16 F_0_081 equ 5329 ; FIX(0.08131) F_0_114 equ 7471 ; FIX(0.11400) F_0_168 equ 11059 ; FIX(0.16874) F_0_250 equ 16384 ; FIX(0.25000) F_0_299 equ 19595 ; FIX(0.29900) F_0_331 equ 21709 ; FIX(0.33126) F_0_418 equ 27439 ; FIX(0.41869) F_0_587 equ 38470 ; FIX(0.58700) F_0_337 equ (F_0_587 - F_0_250) ; FIX(0.58700) - FIX(0.25000) ; -------------------------------------------------------------------------- SECTION SEG_CONST alignz 16 global EXTN(jconst_rgb_ycc_convert_sse2) PRIVATE EXTN(jconst_rgb_ycc_convert_sse2): PW_F0299_F0337 times 4 dw F_0_299, F_0_337 PW_F0114_F0250 times 4 dw F_0_114, F_0_250 PW_MF016_MF033 times 4 dw -F_0_168,-F_0_331 PW_MF008_MF041 times 4 dw -F_0_081,-F_0_418 PD_ONEHALFM1_CJ times 4 dd (1 << (SCALEBITS-1)) - 1 + (CENTERJSAMPLE << SCALEBITS) PD_ONEHALF times 4 dd (1 << (SCALEBITS-1)) alignz 16 ; -------------------------------------------------------------------------- SECTION SEG_TEXT BITS 32 %include "jccolext-sse2.asm" %undef RGB_RED %undef RGB_GREEN %undef RGB_BLUE %undef RGB_PIXELSIZE %define RGB_RED EXT_RGB_RED %define RGB_GREEN EXT_RGB_GREEN %define RGB_BLUE EXT_RGB_BLUE %define RGB_PIXELSIZE EXT_RGB_PIXELSIZE %define jsimd_rgb_ycc_convert_sse2 jsimd_extrgb_ycc_convert_sse2 %include "jccolext-sse2.asm" %undef RGB_RED %undef RGB_GREEN %undef RGB_BLUE %undef RGB_PIXELSIZE %define RGB_RED EXT_RGBX_RED %define RGB_GREEN EXT_RGBX_GREEN %define RGB_BLUE EXT_RGBX_BLUE %define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE %define jsimd_rgb_ycc_convert_sse2 jsimd_extrgbx_ycc_convert_sse2 %include "jccolext-sse2.asm" %undef RGB_RED %undef RGB_GREEN %undef RGB_BLUE %undef RGB_PIXELSIZE %define RGB_RED EXT_BGR_RED %define RGB_GREEN EXT_BGR_GREEN %define RGB_BLUE EXT_BGR_BLUE %define RGB_PIXELSIZE EXT_BGR_PIXELSIZE %define jsimd_rgb_ycc_convert_sse2 jsimd_extbgr_ycc_convert_sse2 %include "jccolext-sse2.asm" %undef RGB_RED %undef RGB_GREEN %undef RGB_BLUE %undef RGB_PIXELSIZE %define RGB_RED EXT_BGRX_RED %define RGB_GREEN EXT_BGRX_GREEN %define RGB_BLUE EXT_BGRX_BLUE %define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE %define jsimd_rgb_ycc_convert_sse2 jsimd_extbgrx_ycc_convert_sse2 %include "jccolext-sse2.asm" %undef RGB_RED %undef RGB_GREEN %undef RGB_BLUE %undef RGB_PIXELSIZE %define RGB_RED EXT_XBGR_RED %define RGB_GREEN EXT_XBGR_GREEN %define RGB_BLUE EXT_XBGR_BLUE %define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE %define jsimd_rgb_ycc_convert_sse2 jsimd_extxbgr_ycc_convert_sse2 %include "jccolext-sse2.asm" %undef RGB_RED %undef RGB_GREEN %undef RGB_BLUE %undef RGB_PIXELSIZE %define RGB_RED EXT_XRGB_RED %define RGB_GREEN EXT_XRGB_GREEN %define RGB_BLUE EXT_XRGB_BLUE %define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE %define jsimd_rgb_ycc_convert_sse2 jsimd_extxrgb_ycc_convert_sse2 %include "jccolext-sse2.asm"
; A116520: a(0) = 0, a(1) = 1; a(n) = max { 4*a(k) + a(n-k) | 1 <= k <= n/2 }, for n > 1. ; 0,1,5,9,25,29,45,61,125,129,145,161,225,241,305,369,625,629,645,661,725,741,805,869,1125,1141,1205,1269,1525,1589,1845,2101,3125,3129,3145,3161,3225,3241,3305,3369,3625,3641,3705,3769,4025,4089,4345,4601,5625,5641,5705,5769,6025,6089,6345,6601,7625,7689,7945,8201,9225,9481,10505,11529,15625,15629,15645,15661,15725,15741,15805,15869,16125,16141,16205,16269,16525,16589,16845,17101,18125,18141,18205,18269,18525,18589,18845,19101,20125,20189,20445,20701,21725,21981,23005,24029,28125,28141,28205 mov $2,$0 mov $3,$0 lpb $2 mov $0,$3 sub $2,1 sub $0,$2 sub $0,1 seq $0,102376 ; a(n) = 4^A000120(n). add $1,$0 lpe mov $0,$1
// Copyright 2009-2020 Intel Corporation // SPDX-License-Identifier: Apache-2.0 #pragma once #if defined(RKCOMMON_TASKING_TBB) #define __TBB_NO_IMPLICIT_LINKAGE 1 #define __TBBMALLOC_NO_IMPLICIT_LINKAGE 1 #include <tbb/task_group.h> #elif defined(RKCOMMON_TASKING_OMP) #include <thread> #elif defined(RKCOMMON_TASKING_INTERNAL) #include "TaskSys.h" #endif namespace rkcommon { namespace tasking { namespace detail { template <typename TASK_T> struct AsyncTaskImpl { AsyncTaskImpl(TASK_T &&fcn); void wait(); private: #if defined(RKCOMMON_TASKING_TBB) tbb::task_group taskGroup; #elif defined(RKCOMMON_TASKING_OMP) std::thread thread; #elif defined(RKCOMMON_TASKING_INTERNAL) struct LocalTask : public enki::ITaskSet { TASK_T t; LocalTask(TASK_T &&fcn) : t(std::forward<TASK_T>(fcn)) {} void ExecuteRange(enki::TaskSetPartition, uint32_t) override { t(); } }; LocalTask task; #endif }; // Inlined definitions // //////////////////////////////////////////////////// template <typename TASK_T> inline AsyncTaskImpl<TASK_T>::AsyncTaskImpl(TASK_T &&fcn) #if defined(RKCOMMON_TASKING_TBB) { taskGroup.run(std::forward<TASK_T>(fcn)); } #elif defined(RKCOMMON_TASKING_OMP) : thread(std::forward<TASK_T>(fcn)) { } #elif defined(RKCOMMON_TASKING_INTERNAL) : task(std::forward<TASK_T>(fcn)) { detail::scheduleTaskInternal(&task); } #else { fcn(); } #endif template <typename TASK_T> inline void AsyncTaskImpl<TASK_T>::wait() { #if defined(RKCOMMON_TASKING_TBB) taskGroup.wait(); #elif defined(RKCOMMON_TASKING_OMP) if (thread.joinable()) thread.join(); #elif defined(RKCOMMON_TASKING_INTERNAL) detail::waitInternal(&task); #endif } } // namespace detail } // namespace tasking } // namespace rkcommon
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QVBoxLayout> #include <QHBoxLayout> #include <QLabel> #include <QWidget> #include <QDebug> #include <QMessageBox> #include <QList> #include <QFileDialog> #include <QInputDialog> #include "parsetextedit.h" #include "nodeeditor.h" #include "treemanager.h" #include "spglobal.h" #include "element.h" #include "classifycsvfiles.h" #include "verifymessage.h" #include "fileutilities.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), mTreeManager(new TreeManager()), ui(new Ui::MainWindow) { ui->setupUi(this); initMenuBar(); initView(); mResultString = QString(); } MainWindow::~MainWindow() { delete ui; if(mTreeManager != NULL) { delete mTreeManager; mTreeManager = NULL; } } int MainWindow::tryToFindTemplate(QString& leftString) { QString source = mSourceTextEdit->toPlainText(); source = FileUtilities::preProcess(source); QList<Element*> elements; if(mTreeManager->findTemplate(source, elements, leftString)) { // 将elements内容显示在 Element* element = NULL; QString result = QString(); for(int i = 0; i < elements.size(); i++) { element = elements[i]; if(element != NULL) { result += element->getPickWord() + "/" + element->getContent() + "\n"; } } mElementsLabel->setText(result); return RESULT_SUCCEED; } else { return RESULT_FAIL_FIND_TEMPLATE; } } // Private Sections void MainWindow::initView() { QWidget *centralWidget = ui->centralWidget; QVBoxLayout *layout = new QVBoxLayout(centralWidget); QHBoxLayout *sourceLayout = new QHBoxLayout; QLabel *sourceLabel = new QLabel(centralWidget); sourceLabel->setText(tr("Source:")); mSourceTextEdit = new QTextEdit(centralWidget); connect(mSourceTextEdit, SIGNAL(textChanged()), this, SLOT(sourceTextChanged())); sourceLayout->addWidget(sourceLabel); sourceLayout->addWidget(mSourceTextEdit); layout->addLayout(sourceLayout); QHBoxLayout *elementsLayout = new QHBoxLayout; QLabel *elementsLabel = new QLabel(centralWidget); elementsLabel->setText(tr("Parse Result:")); mElementsLabel = new QLabel(centralWidget); mElementsLabel->setWordWrap(true); elementsLayout->addWidget(elementsLabel); elementsLayout->addWidget(mElementsLabel); elementsLayout->addStretch(); layout->addLayout(elementsLayout); QVBoxLayout *parseLayout = new QVBoxLayout; //mResultLayout = new QBoxLayout(QBoxLayout::LeftToRight); //mResultLayout->addStretch(); //mResultLayout->setSizeConstraint(QLayout::SetFixedSize); //parseLayout->addLayout(mResultLayout); mResultLabel = new QLabel(this); mResultLabel->setWordWrap(true); parseLayout->addWidget(mResultLabel); mParseTextEdit = new ParseTextEdit(centralWidget); connect(mParseTextEdit, &ParseTextEdit::flagTriggered, this, &MainWindow::flagTriggered); parseLayout->addWidget(mParseTextEdit); layout->addLayout(parseLayout); mNodeEditor = new NodeEditor(centralWidget); connect(mNodeEditor, &NodeEditor::addNode, this, &MainWindow::addNode); layout->addWidget(mNodeEditor); QHBoxLayout *saveFileLayout = new QHBoxLayout; QPushButton *saveButton = new QPushButton(centralWidget); saveButton->setText(tr("Save")); connect(saveButton, &QPushButton::clicked, this, &MainWindow::saveToFile); saveFileLayout->addWidget(saveButton); layout->addLayout(saveFileLayout); } void MainWindow::initMenuBar() { QAction* pActionA = new QAction(tr("&Classify")); connect(pActionA, &QAction::triggered, this, &MainWindow::classifyAction); QAction* pActionB = new QAction(tr("&Verify")); connect(pActionB, &QAction::triggered, this, &MainWindow::verifyAction); QMenu* fileMenu = menuBar()->addMenu(tr("&File")); fileMenu->addAction(pActionA); fileMenu->addAction(pActionB); } void MainWindow::clearAll(QBoxLayout* layout) { if(layout != NULL) { qDebug() << "layout count: " << layout->count(); for(int i = layout->count() - 1; i >= 0; i--) { layout->removeItem(layout->itemAt(i)); } } } // Private slots void MainWindow::sourceTextChanged() { if(mSourceTextEdit != NULL && mParseTextEdit != NULL) { QString sourceString = mSourceTextEdit->toPlainText(); if(sourceString.startsWith("【") || sourceString.startsWith("[") || sourceString.endsWith("】") || sourceString.endsWith("]")) { QString leftString = QString(); if(tryToFindTemplate(leftString) == RESULT_SUCCEED) { mParseTextEdit->setText(tr("Find a template to match.")); } else { if(leftString.isEmpty()) { mParseTextEdit->setText(FileUtilities::preProcess(sourceString)); mParseTextEdit->init(true); } else { mParseTextEdit->setText(leftString); mParseTextEdit->init(false); } } } else { if(!sourceString.isEmpty()) { QMessageBox::information(this, tr("Information"), tr("The message must start with 【 or [")); } } } } void MainWindow::flagTriggered(int type, const QString& selected) { qDebug() << "Process flag string in MainWindow: " << type <<"/" << selected; switch(type) { case ParseTextEdit::TYPE_HEAD: { QLabel *label = new QLabel(ui->centralWidget); label->setStyleSheet("color:red;"); label->setText(selected); //qDebug() << "result layout count: " << mResultLayout->count(); mResultString += "<font color=\"red\">" + selected + " "; //mResultLayout->insertWidget(mResultLayout->count() - 1, label); mResultLabel->setText(mResultString); if(mTreeManager != NULL) { mTreeManager->flagHead(selected, true); } } break; case ParseTextEdit::TYPE_KEYWORD: { QLabel *label = new QLabel(ui->centralWidget); label->setStyleSheet("color:red;"); label->setText(selected); //qDebug() << "result layout count: " << mResultLayout->count(); mResultString += "<font color=\"red\">" + selected + " "; //mResultLayout->insertWidget(mResultLayout->count() - 1, label); mResultLabel->setText(mResultString); mNodeEditor->setKeyWord(selected); } break; case ParseTextEdit::TYPE_PICKEND: { QLabel *label = new QLabel(ui->centralWidget); label->setStyleSheet("color:red;"); label->setText(selected); //qDebug() << "result layout count: " << mResultLayout->count(); mResultString += "<font color=\"red\">" + selected + " "; //mResultLayout->insertWidget(mResultLayout->count() - 1, label); mResultLabel->setText(mResultString); mNodeEditor->setPickEnd(selected); } break; case ParseTextEdit::TYPE_CONTENT: { QLabel *label = new QLabel(ui->centralWidget); label->setStyleSheet("color:blue;"); label->setText(selected); //qDebug() << "result layout count: " << mResultLayout->count(); mResultString += "<font color=\"blue\">" + selected + " "; //mResultLayout->insertWidget(mResultLayout->count() - 1, label); mResultLabel->setText(mResultString); mNodeEditor->setContent(selected); } break; default: qDebug() << "The type " << type << "can not be matched."; } } void MainWindow::addNode(Node* node) { if(mTreeManager != NULL) { mTreeManager->addNode(node); } } void MainWindow::saveToFile() { int result = mTreeManager->saveTreeToFile(); qDebug() << "The result of saving tree to file is " << result; } void MainWindow::classifyAction() { qDebug() << "Classify action is triggered."; QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), "/Users/willwu/Documents", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); qDebug() << "Process files in " << dir; // 获取提取关键字 bool ok; QString text = QInputDialog::getText(this, tr("QInputDialog::getText()"), tr("Key Word:"), QLineEdit::Normal, QDir::home().dirName(), &ok); if (ok && !text.isEmpty()) { if(ClassifyCsvFiles::process(dir, text)) { qDebug() << "Succeed to process csv files."; } } } void MainWindow::verifyAction() { // mVerifyMessageWidget = new VerifyMessage(ui->centralWidget); //mVerifyMessageWidget->show(); VerifyMessage verifyMessageDialog; verifyMessageDialog.exec(); }
############################################################################### # Copyright 2019 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material ("Material") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # "License"), the following terms apply: # # 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. ############################################################################### .text .p2align 4, 0x90 .globl _cpSub_BNU _cpSub_BNU: push %ebp mov %esp, %ebp push %ebx push %esi push %edi movl (12)(%ebp), %eax movl (16)(%ebp), %ebx movl (8)(%ebp), %edx movl (20)(%ebp), %edi shl $(2), %edi xor %ecx, %ecx pandn %mm0, %mm0 .p2align 4, 0x90 .Lmain_loopgas_1: movd (%ecx,%eax), %mm1 movd (%ebx,%ecx), %mm2 paddq %mm1, %mm0 psubq %mm2, %mm0 movd %mm0, (%edx,%ecx) pshufw $(254), %mm0, %mm0 add $(4), %ecx cmp %edi, %ecx jl .Lmain_loopgas_1 movd %mm0, %eax neg %eax emms pop %edi pop %esi pop %ebx pop %ebp ret
; Basic block with two non-branching instructions terminated by a ; branching instruction with the successors block_1 and block_2. block_0: mov eax, 0 cmp ecx, 42 je block_2 ; Basic block with one non-branching instruction terminated by a ; fallthrough into block_2, as branches may only target the first ; instruction of basic blocks, and the je terminator instruction ; of block_0 targets block_2. block_1: mov eax, 1 ; Basic block with zero non-branching instructions terminated by ; a branching instruction, returning control flow to the caller. block_2: ret
// Copyright 2018, Bosch Software Innovations GmbH. // // 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. #include "rosbag2_node.hpp" #include <algorithm> #include <map> #include <memory> #include <string> #include <vector> #include <unordered_map> #include <utility> #include "rcl/expand_topic_name.h" #include "rosbag2_cpp/typesupport_helpers.hpp" #include "rosbag2_transport/logging.hpp" namespace rosbag2_transport { Rosbag2Node::Rosbag2Node(const std::string & node_name) : rclcpp::Node(node_name) {} std::shared_ptr<GenericPublisher> Rosbag2Node::create_generic_publisher( const std::string & topic, const std::string & type) { auto type_support = rosbag2_cpp::get_typesupport(type, "rosidl_typesupport_cpp"); return std::make_shared<GenericPublisher>(get_node_base_interface().get(), topic, *type_support); } std::shared_ptr<GenericSubscription> Rosbag2Node::create_generic_subscription( const std::string & topic, const std::string & type, std::function<void(std::shared_ptr<rmw_serialized_message_t>)> callback) { auto type_support = rosbag2_cpp::get_typesupport(type, "rosidl_typesupport_cpp"); auto subscription = std::shared_ptr<GenericSubscription>(); try { subscription = std::make_shared<GenericSubscription>( get_node_base_interface().get(), *type_support, topic, callback); get_node_topics_interface()->add_subscription(subscription, nullptr); } catch (const std::runtime_error & ex) { ROSBAG2_TRANSPORT_LOG_ERROR_STREAM( "Error subscribing to topic '" << topic << "'. Error: " << ex.what()); } return subscription; } std::shared_ptr<rcutils_string_map_t> get_initialized_string_map() { rcutils_allocator_t allocator = rcutils_get_default_allocator(); auto substitutions_map = new rcutils_string_map_t; *substitutions_map = rcutils_get_zero_initialized_string_map(); rcutils_ret_t map_init = rcutils_string_map_init(substitutions_map, 0, allocator); if (map_init != RCUTILS_RET_OK) { ROSBAG2_TRANSPORT_LOG_ERROR("Failed to initialize string map within rcutils."); return std::shared_ptr<rcutils_string_map_t>(); } return std::shared_ptr<rcutils_string_map_t>( substitutions_map, [](rcutils_string_map_t * map) { rcl_ret_t cleanup = rcutils_string_map_fini(map); delete map; if (cleanup != RCL_RET_OK) { ROSBAG2_TRANSPORT_LOG_ERROR("Failed to deallocate string map when expanding topic."); } }); } std::string Rosbag2Node::expand_topic_name(const std::string & topic_name) { rcl_allocator_t allocator = rcl_get_default_allocator(); auto substitutions_map = get_initialized_string_map(); if (!substitutions_map) { ROSBAG2_TRANSPORT_LOG_ERROR("Failed to initialize string map within rcutils."); return ""; } rcl_ret_t ret = rcl_get_default_topic_name_substitutions(substitutions_map.get()); if (ret != RCL_RET_OK) { ROSBAG2_TRANSPORT_LOG_ERROR("Failed to initialize map with default values."); return ""; } char * expanded_topic_name = nullptr; ret = rcl_expand_topic_name( topic_name.c_str(), get_name(), get_namespace(), substitutions_map.get(), allocator, &expanded_topic_name); if (ret != RCL_RET_OK) { ROSBAG2_TRANSPORT_LOG_ERROR_STREAM( "Failed to expand topic name " << topic_name << " with error: " << rcutils_get_error_string().str); return ""; } std::string expanded_topic_name_std(expanded_topic_name); allocator.deallocate(expanded_topic_name, allocator.state); return expanded_topic_name_std; } std::unordered_map<std::string, std::string> Rosbag2Node::get_topics_with_types( const std::vector<std::string> & topic_names) { std::vector<std::string> sanitized_topic_names; for (const auto & topic_name : topic_names) { auto sanitized_topic_name = expand_topic_name(topic_name); if (!sanitized_topic_name.empty()) { sanitized_topic_names.push_back(sanitized_topic_name); } } auto topics_and_types = this->get_topic_names_and_types(); std::map<std::string, std::vector<std::string>> filtered_topics_and_types; for (const auto & topic_and_type : topics_and_types) { if ( std::find( sanitized_topic_names.begin(), sanitized_topic_names.end(), topic_and_type.first) != sanitized_topic_names.end()) { filtered_topics_and_types.insert(topic_and_type); } } return filter_topics_with_more_than_one_type(filtered_topics_and_types); } std::unordered_map<std::string, std::string> Rosbag2Node::get_all_topics_with_types() { return filter_topics_with_more_than_one_type(this->get_topic_names_and_types()); } std::unordered_map<std::string, std::string> Rosbag2Node::filter_topics_with_more_than_one_type( std::map<std::string, std::vector<std::string>> topics_and_types) { std::unordered_map<std::string, std::string> filtered_topics_and_types; for (const auto & topic_and_type : topics_and_types) { if (topic_and_type.second.size() > 1) { ROSBAG2_TRANSPORT_LOG_ERROR_STREAM( "Topic '" << topic_and_type.first << "' has several types associated. Only topics with one type are supported"); } else { filtered_topics_and_types.insert({topic_and_type.first, topic_and_type.second[0]}); } } return filtered_topics_and_types; } } // namespace rosbag2_transport
%ifdef CONFIG { "RegData": { "XMM0": ["0x0", "0xFFFFFFFFFFFFFFFF"], "XMM1": ["0x0", "0xFFFFFFFFFFFFFFFF"], "XMM2": ["0x1010101010101010", "0xFFFFFFFFFFFFFFFF"] }, "MemoryRegions": { "0x100000000": "4096" } } %endif mov rdx, 0xe0000000 mov rax, 0xFFFFFFFFFFFFFFFF mov [rdx + 8 * 0], rax mov rax, 0x0 mov [rdx + 8 * 1], rax mov rax, 0x1010101010101010 mov [rdx + 8 * 2], rax mov rax, 0xFFFFFFFFFFFFFFFF mov [rdx + 8 * 3], rax movapd xmm0, [rdx] andnpd xmm0, [rdx + 8 * 2] movapd xmm1, [rdx] movapd xmm2, [rdx + 8 * 2] andnpd xmm1, xmm2 hlt
; A104887: Triangle T(n,k) = (n-k+1)th prime, read by rows. ; 2,3,2,5,3,2,7,5,3,2,11,7,5,3,2,13,11,7,5,3,2,17,13,11,7,5,3,2,19,17,13,11,7,5,3,2,23,19,17,13,11,7,5,3,2,29,23,19,17,13,11,7,5,3,2,31,29,23,19,17,13,11,7,5,3,2,37,31,29,23,19,17,13,11,7,5,3,2,41,37,31,29,23,19,17,13,11,7,5,3,2,43,41,37,31,29,23,19,17,13,11,7,5,3,2,47,43,41,37,31,29,23,19,17,13,11,7,5,3,2,53,47,43,41,37,31,29,23,19,17,13,11,7,5,3,2,59,53,47,43,41,37,31,29,23,19,17,13,11,7,5,3,2,61,59,53,47,43,41,37,31,29,23,19,17,13,11,7,5,3,2,67,61,59,53,47,43,41,37,31,29,23,19,17,13,11,7,5,3,2,71,67,61,59,53,47,43,41,37,31,29,23,19,17,13,11,7,5,3,2,73,71,67,61,59,53,47,43,41,37,31,29,23,19,17,13,11,7,5,3,2,79,73,71,67,61,59,53,47,43,41,37,31,29,23,19,17,13,11,7 cal $0,25676 ; Exponent of 8 (value of i) in n-th number of form 8^i*9^j. cal $0,40 ; The prime numbers. mov $1,$0
HappinessData_OlderHaircutBrother: db $4c, 2, HAPPINESS_OLDERCUT1 ; 30% chance db $80, 3, HAPPINESS_OLDERCUT2 ; 20% chance db $ff, 4, HAPPINESS_OLDERCUT3 ; 50% chance HappinessData_YoungerHaircutBrother: db $9a, 2, HAPPINESS_YOUNGCUT1 ; 60% chance db $4c, 3, HAPPINESS_YOUNGCUT2 ; 10% chance db $ff, 4, HAPPINESS_YOUNGCUT3 ; 30% chance HappinessData_DaisysGrooming: db $ff, 2, HAPPINESS_GROOMING ; 99.6% chance
#define BOOST_FILESYSTEM_NO_DEPRECATED #define BOOST_FILESYSTEM_NO_LIB #include "3rd/Catch/single_include/catch.hpp" //#include <atomic> #include "ara/async_rwqueue.h" #include "ara/async_threadpool.h" #include "ara/event.h" #include "ara/log.h" #include "test_async_helper.h" TEST_CASE("async rwqueue", "[async]") { SECTION("base") { ara::log::init_defaul_log(); auto oldLevel = ara::log::get_logger().set_level(ara::log::warning); ara::defer _auGuard([oldLevel]() { ara::log::get_logger().set_level(oldLevel); }); typedef ara::async_rwqueue<std::string> name_queue; auto p = name_queue::make_rwqueue(10); auto num = std::make_shared<ara::event<int>>(0); ara::async_thread_pool pool("test"); auto & io = pool.io(); pool.init(2).start(); enum { THREAD1_GOT_READ_KEY = 1, THREAD2_GOT_WRITE_KEY_FAIL, THREAD1_RELEASE_READ_KEY, ALL_FINISHED, }; auto errinfo = std::make_shared<async_error>(); io.post([p, num, &io, errinfo]() { LOG_INFO().printfln("T1: begin to read work"); p->apply_read(io, "key1", ara::timer_val::max_time, [num, errinfo](const boost::system::error_code & ec, ara::async_token token) { ara::glog g(ara::log::info); g(ara::log::info).printfln("T1: I got the read key"); num->signal_all(THREAD1_GOT_READ_KEY); if (token == nullptr) errinfo->set_error("Token is null while T1 apply read"); else if (!num->wait(THREAD2_GOT_WRITE_KEY_FAIL)) errinfo->set_error("T1 fail to wait for thread2 got write key fail"); else { g(ara::log::info).printfln("T1: T2 get write key fail, I will release the read key"); token = nullptr; } num->signal_all(THREAD1_RELEASE_READ_KEY); }, "thread 1 apply 1"); }); io.post([p, num, &io, errinfo]() { ara::glog g(ara::log::info); g.printfln("T2: begin to work wait for T1"); REQUIRE(num->wait(THREAD1_GOT_READ_KEY)); g.printfln("T2: T1 got the read key, now to my turn to try get the read key."); p->apply_read(io, "key1", ara::timer_val(1, 0), [num, &io, p, errinfo](const boost::system::error_code & ec, ara::async_token token) { ara::glog g(ara::log::info); g.printfln("T2: I should got the read key."); if (token == nullptr) { errinfo->set_error("T2 should got the read key because T1 just hold read key."); return; } g.printfln("T2: Now I release the read key, which hold by me."); token = nullptr; p->apply_write(io, "key1", ara::timer_val(0, 1), [num, &io, p, errinfo](const boost::system::error_code & ec, ara::async_token token) { ara::glog g(ara::log::info); g.printfln("T2: I got the write key fail, because T1 hold read key"); if (token != nullptr) { errinfo->set_error("T2 should not got the write key because T1 hold read key. But now T2 got it."); } else if (ec != boost::asio::error::timed_out) { errinfo->set_error("T2 should not got the write key and should be timeout. But now T2 is not timeout."); } else { g.printfln("T2: I tell T1 to release the read key"); num->signal_all(THREAD2_GOT_WRITE_KEY_FAIL); num->wait(THREAD1_RELEASE_READ_KEY); g(ara::log::info).printfln("T2: T1 has release read key, I will try to get the write key again"); io.post([p, num, &io, errinfo]() { p->apply_write(io, "key1", ara::timer_val(1, 0), [num, errinfo](const boost::system::error_code & ec, ara::async_token token) { ara::glog g(ara::log::info); if (token == nullptr) { errinfo->set_error( ara::printf<std::string>("T2 should got write key after T1 release read key. But T2 can not got it now: %v", ec.message())); } else { g(ara::log::info).printfln("T2: I got the write key now"); } num->signal_all(ALL_FINISHED); }, "thread 2 apply write key 2"); }); } }, "thread 2 apply read key 1"); }, "thread 2 apply read key 2"); }); num->wait(ALL_FINISHED); pool.stop(); REQUIRE(errinfo->get_error() == ""); } SECTION("base 2") { ara::log::init_defaul_log(); auto oldLevel = ara::log::get_logger().set_level(ara::log::warning); ara::defer _auGuard([oldLevel]() { ara::log::get_logger().set_level(oldLevel); }); typedef ara::async_rwqueue<std::string> name_queue; auto p = name_queue::make_rwqueue(10); auto num = std::make_shared<ara::event<int>>(0); ara::async_thread_pool pool("test"); auto & io = pool.io(); pool.init(3).start(); enum { THREAD3_GOT_WRITE_KEY = 1, THREAD4_GOT_KEY_FAIL, THREAD4_WAIT_FOR_KEY, THREAD5_WAIT_FOR_KEY, ALL_FINISHED_1, ALL_FINISHED_2, }; auto errinfo = std::make_shared<async_error>(); io.post([p, num, &io, &errinfo]() { LOG_INFO().printfln("T3: begin to write work"); p->apply_write(io, "key2", ara::timer_val::max_time, [num, errinfo](const boost::system::error_code & ec, ara::async_token token) { ara::glog g(ara::log::info); g(ara::log::info).printfln("T3: I got the write key"); num->signal_all(THREAD3_GOT_WRITE_KEY); if (token == nullptr) { errinfo->set_error("T3 should got the write key"); } else { num->wait(THREAD5_WAIT_FOR_KEY); g(ara::log::info).printfln("T3: T4/T5 waiting for key, I will release the key"); token = nullptr; } }, "thread 3 apply write"); }); io.post([p, num, &io, errinfo]() { ara::glog g(ara::log::info); g.printfln("T4: begin to work wait for T3"); if (!num->wait(THREAD3_GOT_WRITE_KEY)) { errinfo->set_error("T4 should wait for T3 got write key"); return; } g.printfln("T4: T3 got the write key, now to my turn to try get the write key."); p->apply_write(io, "key2", ara::timer_val(0, 1), [num, &io, p, errinfo](const boost::system::error_code & ec, ara::async_token token) { ara::glog g(ara::log::info); g.printfln("T4: I got the write key fail, because T3 hold it"); if (token != nullptr) { errinfo->set_error("T4 should not got the write key, because T3 hold it, but now T4 got it"); return; } else if (ec != boost::asio::error::timed_out) { errinfo->set_error("T4 should not got the write key and timeout. But now it's not timeout"); return; } p->apply_read(io, "key2", ara::timer_val(10, 0), [num, errinfo](const boost::system::error_code & ec, ara::async_token token) { ara::glog g(ara::log::info); if (token == nullptr) errinfo->set_error(ara::printf<std::string>("T4 should got the read key, because T3 release it, but now T4 can not got it:%v",ec.message())); else g(ara::log::info).printfln("T4: I got the read key now"); num->signal_all(ALL_FINISHED_1); }, "thread 2 apply 2"); g.printfln("T4: I tell T3 I am waiting."); num->signal_all(THREAD4_WAIT_FOR_KEY); }, "thread 4 apply 1"); }); io.post([p, num, &io, errinfo]() { ara::glog g(ara::log::info); g.printfln("T5: begin to work wait for T3"); if (!num->wait(THREAD3_GOT_WRITE_KEY)) { errinfo->set_error("T5 should wait for T3 got write key"); return; } g.printfln("T5: T3 got the write key, now to my turn to try get the read key."); p->apply_read(io, "key2", ara::timer_val(0, 1), [num, &io, p, errinfo](const boost::system::error_code & ec, ara::async_token token) { ara::glog g(ara::log::info); g.printfln("T5: I got the read key fail, because T3 hold it"); if (token != nullptr) { errinfo->set_error("T5 should not got the read key, because T3 hold it, but now T5 got it"); return; } else if (ec != boost::asio::error::timed_out) { errinfo->set_error("T5 should not got the read key and timeout. But now it's not timeout"); return; } p->apply_read(io, "key2", ara::timer_val(10, 0), [num, errinfo](const boost::system::error_code & ec, ara::async_token token) { ara::glog g(ara::log::info); if (token == nullptr) errinfo->set_error(ara::printf<std::string>("T5 should got the read key, because T3 release it, but now T5 can not got it:%v",ec.message())); else g(ara::log::info).printfln("T5: I got the read key now"); num->wait(ALL_FINISHED_1); num->signal_all(ALL_FINISHED_2); }, "thread 2 apply 2"); num->wait(THREAD4_WAIT_FOR_KEY); g.printfln("T5: I tell T3 I am waiting."); num->signal_all(THREAD5_WAIT_FOR_KEY); }, "thread 4 apply 1"); }); num->wait(ALL_FINISHED_2); pool.stop(); REQUIRE(errinfo->get_error() == ""); } }
dnl Intel Pentium 4 mpn_popcount, mpn_hamdist -- population count and dnl hamming distance. dnl Copyright 2000-2002, 2007 Free Software Foundation, Inc. dnl This file is part of the GNU MP Library. dnl dnl The GNU MP Library is free software; you can redistribute it and/or modify dnl it under the terms of either: dnl dnl * the GNU Lesser General Public License as published by the Free dnl Software Foundation; either version 3 of the License, or (at your dnl option) any later version. dnl dnl or dnl dnl * the GNU General Public License as published by the Free Software dnl Foundation; either version 2 of the License, or (at your option) any dnl later version. dnl dnl or both in parallel, as here. dnl dnl The GNU MP Library is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License dnl for more details. dnl dnl You should have received copies of the GNU General Public License and the dnl GNU Lesser General Public License along with the GNU MP Library. If not, dnl see https://www.gnu.org/licenses/. include(`../config.m4') C popcount hamdist C P3 model 9 (Banias) ? ? C P3 model 13 (Dothan) 6 6 C P4 model 0 (Willamette) C P4 model 1 (?) C P4 model 2 (Northwood) 8 9 C P4 model 3 (Prescott) 8 9 C P4 model 4 (Nocona) C unsigned long mpn_popcount (mp_srcptr src, mp_size_t size); C unsigned long mpn_hamdist (mp_srcptr src, mp_srcptr src2, mp_size_t size); C C Loading with unaligned movq's costs an extra 1 c/l and hence is avoided. C Two movd's and a punpckldq seems to be the same speed as an aligned movq, C and using them saves fiddling about with alignment testing on entry. C C For popcount there's 13 mmx instructions in the loop, so perhaps 6.5 c/l C might be possible, but 8 c/l relying on out-of-order execution is already C quite reasonable. ifdef(`OPERATION_popcount',, `ifdef(`OPERATION_hamdist',, `m4_error(`Need OPERATION_popcount or OPERATION_hamdist defined ')')') define(HAM, m4_assert_numargs(1) `ifdef(`OPERATION_hamdist',`$1')') define(POP, m4_assert_numargs(1) `ifdef(`OPERATION_popcount',`$1')') HAM(` defframe(PARAM_SIZE, 12) defframe(PARAM_SRC2, 8) defframe(PARAM_SRC, 4) define(M4_function,mpn_hamdist) ') POP(` defframe(PARAM_SIZE, 8) defframe(PARAM_SRC, 4) define(M4_function,mpn_popcount) ') MULFUNC_PROLOGUE(mpn_popcount mpn_hamdist) ifdef(`PIC',,` dnl non-PIC RODATA ALIGN(8) L(rodata_AAAAAAAAAAAAAAAA): .long 0xAAAAAAAA .long 0xAAAAAAAA L(rodata_3333333333333333): .long 0x33333333 .long 0x33333333 L(rodata_0F0F0F0F0F0F0F0F): .long 0x0F0F0F0F .long 0x0F0F0F0F ') TEXT ALIGN(16) PROLOGUE(M4_function) deflit(`FRAME',0) movl PARAM_SIZE, %ecx movl PARAM_SRC, %eax ifdef(`PIC',` movl $0xAAAAAAAA, %edx movd %edx, %mm7 punpckldq %mm7, %mm7 movl $0x33333333, %edx movd %edx, %mm6 punpckldq %mm6, %mm6 movl $0x0F0F0F0F, %edx movd %edx, %mm5 punpckldq %mm5, %mm5 HAM(` movl PARAM_SRC2, %edx') ',` dnl non-PIC HAM(` movl PARAM_SRC2, %edx') movq L(rodata_AAAAAAAAAAAAAAAA), %mm7 movq L(rodata_3333333333333333), %mm6 movq L(rodata_0F0F0F0F0F0F0F0F), %mm5 ') pxor %mm4, %mm4 C zero pxor %mm0, %mm0 C total subl $1, %ecx ja L(top) L(last): movd (%eax,%ecx,4), %mm1 C src high limb HAM(` movd (%edx,%ecx,4), %mm2 pxor %mm2, %mm1 ') jmp L(loaded) L(top): C eax src C ebx C ecx counter, size-1 to 2 or 1, inclusive C edx [hamdist] src2 C C mm0 total (low dword) C mm1 (scratch) C mm2 (scratch) C mm3 C mm4 0x0000000000000000 C mm5 0x0F0F0F0F0F0F0F0F C mm6 0x3333333333333333 C mm7 0xAAAAAAAAAAAAAAAA movd (%eax), %mm1 movd 4(%eax), %mm2 punpckldq %mm2, %mm1 addl $8, %eax HAM(` movd (%edx), %mm2 movd 4(%edx), %mm3 punpckldq %mm3, %mm2 pxor %mm2, %mm1 addl $8, %edx ') L(loaded): movq %mm7, %mm2 pand %mm1, %mm2 psrlq $1, %mm2 psubd %mm2, %mm1 C bit pairs movq %mm6, %mm2 pand %mm1, %mm2 psrlq $2, %mm1 pand %mm6, %mm1 paddd %mm2, %mm1 C nibbles movq %mm5, %mm2 pand %mm1, %mm2 psrlq $4, %mm1 pand %mm5, %mm1 paddd %mm2, %mm1 C bytes psadbw( %mm4, %mm1) paddd %mm1, %mm0 C to total subl $2, %ecx jg L(top) C ecx is 0 or -1 representing respectively 1 or 0 further limbs jz L(last) movd %mm0, %eax emms ret EPILOGUE()
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r14 push %r8 push %rax push %rcx push %rdi push %rdx push %rsi lea addresses_D_ht+0x1bb4a, %rdx and $9566, %r10 movw $0x6162, (%rdx) and %r8, %r8 lea addresses_UC_ht+0x1b01a, %rsi nop and %rdx, %rdx movw $0x6162, (%rsi) nop nop nop nop nop add %r12, %r12 lea addresses_WT_ht+0x14b4a, %rdx nop nop and %rsi, %rsi and $0xffffffffffffffc0, %rdx vmovntdqa (%rdx), %ymm7 vextracti128 $0, %ymm7, %xmm7 vpextrq $1, %xmm7, %rax nop nop xor %r8, %r8 lea addresses_UC_ht+0x1c44e, %r12 nop nop nop nop xor $64593, %r14 mov (%r12), %si nop nop nop nop nop cmp %r8, %r8 lea addresses_D_ht+0x5f4a, %rsi lea addresses_D_ht+0x15a42, %rdi xor %rax, %rax mov $106, %rcx rep movsb nop nop and $60726, %r12 lea addresses_D_ht+0x197c0, %r14 dec %r10 mov $0x6162636465666768, %rdx movq %rdx, (%r14) nop nop nop cmp $45848, %r10 lea addresses_UC_ht+0x1984a, %rsi lea addresses_D_ht+0x1d8cb, %rdi nop nop nop nop inc %r14 mov $104, %rcx rep movsq nop nop nop nop nop sub $894, %r14 lea addresses_A_ht+0xaaba, %rcx nop nop nop nop add $52989, %r8 movw $0x6162, (%rcx) nop nop nop nop nop add %rax, %rax lea addresses_WC_ht+0x3b4a, %rsi lea addresses_UC_ht+0x762a, %rdi nop nop nop nop inc %r10 mov $30, %rcx rep movsb nop sub $33721, %rax pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r8 pop %r14 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r15 push %rax push %rbp push %rbx push %rcx push %rdi // Store lea addresses_UC+0x250a, %r11 nop nop nop nop nop inc %r15 movw $0x5152, (%r11) nop nop nop xor $53436, %r11 // Store lea addresses_D+0x14b4a, %rbp nop nop nop nop add $28705, %rdi mov $0x5152535455565758, %rbx movq %rbx, %xmm5 movups %xmm5, (%rbp) nop add $26850, %rcx // Store lea addresses_WC+0x8b4a, %r11 nop and $45903, %rax mov $0x5152535455565758, %r15 movq %r15, %xmm3 vmovups %ymm3, (%r11) nop nop nop nop nop lfence // Store lea addresses_A+0x61aa, %rbp nop nop nop xor %rdi, %rdi mov $0x5152535455565758, %rax movq %rax, %xmm3 vmovups %ymm3, (%rbp) nop nop nop cmp %r15, %r15 // Load lea addresses_UC+0x1097, %rax nop nop nop nop cmp $14121, %rbx movups (%rax), %xmm7 vpextrq $1, %xmm7, %r15 nop nop nop nop sub $35064, %rbx // Store lea addresses_UC+0x1e3fa, %rdi nop nop nop nop add $55851, %rcx movb $0x51, (%rdi) nop nop xor $62427, %rcx // Store mov $0x4a, %rcx and %r11, %r11 mov $0x5152535455565758, %rbp movq %rbp, (%rcx) nop nop nop nop nop sub %rcx, %rcx // Store lea addresses_UC+0xb799, %r15 cmp %r11, %r11 mov $0x5152535455565758, %rcx movq %rcx, %xmm0 and $0xffffffffffffffc0, %r15 movntdq %xmm0, (%r15) add %r11, %r11 // Store mov $0xfca, %r15 nop nop inc %rbx movl $0x51525354, (%r15) nop nop add $14555, %rdi // Store lea addresses_RW+0x339a, %rax and %rbx, %rbx movl $0x51525354, (%rax) sub $26002, %r11 // Store lea addresses_WC+0x167aa, %r15 nop nop xor $9922, %rax mov $0x5152535455565758, %rbp movq %rbp, %xmm5 vmovups %ymm5, (%r15) nop nop add %rdi, %rdi // Store lea addresses_WC+0x4ca, %rcx and %rbx, %rbx mov $0x5152535455565758, %rdi movq %rdi, (%rcx) cmp $43212, %rdi // Store lea addresses_D+0x1444a, %r15 nop nop nop nop nop add %r11, %r11 movl $0x51525354, (%r15) nop nop nop add $51817, %rbp // Store lea addresses_WC+0xd4a, %r11 nop nop nop xor %rbx, %rbx mov $0x5152535455565758, %rbp movq %rbp, (%r11) nop inc %rbp // Faulty Load lea addresses_WT+0x17b4a, %rbp clflush (%rbp) nop nop nop nop nop add $40040, %rcx mov (%rbp), %r15 lea oracles, %rax and $0xff, %r15 shlq $12, %r15 mov (%rax,%r15,1), %r15 pop %rdi pop %rcx pop %rbx pop %rbp pop %rax pop %r15 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 6}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 11}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 10}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 4}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 4}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_P', 'NT': False, 'AVXalign': True, 'size': 8, 'congruent': 6}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC', 'NT': True, 'AVXalign': False, 'size': 16, 'congruent': 0}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_P', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 7}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_RW', 'NT': True, 'AVXalign': False, 'size': 4, 'congruent': 3}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 5}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 6}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D', 'NT': True, 'AVXalign': False, 'size': 4, 'congruent': 8}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 9}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_WT', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 10}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 1}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT_ht', 'NT': True, 'AVXalign': False, 'size': 32, 'congruent': 11}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 2}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 9, 'type': 'addresses_D_ht'}, 'dst': {'same': False, 'congruent': 2, 'type': 'addresses_D_ht'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 8, 'type': 'addresses_UC_ht'}, 'dst': {'same': False, 'congruent': 0, 'type': 'addresses_D_ht'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 4}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 11, 'type': 'addresses_WC_ht'}, 'dst': {'same': True, 'congruent': 4, 'type': 'addresses_UC_ht'}} {'39': 21829} 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 */
; A113655: Invert blocks of three in the sequence of natural numbers. ; 3,2,1,6,5,4,9,8,7,12,11,10,15,14,13,18,17,16,21,20,19,24,23,22,27,26,25,30,29,28,33,32,31,36,35,34,39,38,37,42,41,40,45,44,43,48,47,46,51,50,49,54,53,52,57,56,55,60,59,58,63,62,61,66,65,64,69,68,67,72,71,70,75,74,73,78,77,76,81,80,79,84,83,82,87,86,85,90,89,88,93,92,91,96,95,94,99,98,97,102,101,100,105,104,103,108,107,106,111,110,109,114,113,112,117,116,115,120,119,118,123,122,121,126,125,124,129,128,127,132,131,130,135,134,133,138,137,136,141,140,139,144,143,142,147,146,145,150,149,148,153,152,151,156,155,154,159,158,157,162,161,160,165,164,163,168,167,166,171,170,169,174,173,172,177,176,175,180,179,178,183,182,181,186,185,184,189,188,187,192,191,190,195,194,193,198,197,196,201,200,199,204,203,202,207,206,205,210,209,208,213,212,211,216,215,214,219,218,217,222,221,220,225,224,223,228,227,226,231,230,229,234,233,232,237,236,235,240,239,238,243,242,241,246,245,244,249,248,247,252 mov $1,$0 mod $0,3 sub $1,$0 sub $1,$0 add $1,3
.global s_prepare_buffers s_prepare_buffers: push %r13 push %r15 push %r8 push %rax push %rbp push %rcx push %rdi push %rsi lea addresses_WT_ht+0x7edc, %r15 nop nop inc %rax mov $0x6162636465666768, %r8 movq %r8, %xmm6 vmovups %ymm6, (%r15) sub $36265, %r13 lea addresses_UC_ht+0x7d40, %rsi lea addresses_normal_ht+0xa340, %rdi nop nop nop nop nop sub $11675, %r15 mov $62, %rcx rep movsl nop cmp %r8, %r8 lea addresses_A_ht+0xf940, %rax nop nop nop inc %rsi mov $0x6162636465666768, %r8 movq %r8, %xmm3 vmovups %ymm3, (%rax) nop nop nop nop inc %r13 lea addresses_WT_ht+0x2380, %rax clflush (%rax) nop and %r15, %r15 mov (%rax), %edi nop nop dec %r15 lea addresses_WC_ht+0x4d40, %rsi lea addresses_D_ht+0x7df0, %rdi nop xor %rbp, %rbp mov $85, %rcx rep movsq nop nop nop nop nop sub %rsi, %rsi lea addresses_A_ht+0x3440, %rcx and %r15, %r15 movups (%rcx), %xmm2 vpextrq $1, %xmm2, %rax nop nop nop nop nop inc %r13 lea addresses_UC_ht+0x8640, %rdi nop nop nop nop nop xor %r8, %r8 mov (%rdi), %r15 nop nop nop nop nop inc %rax lea addresses_D_ht+0xf140, %rsi lea addresses_UC_ht+0x4db8, %rdi nop nop nop cmp $60175, %rax mov $87, %rcx rep movsb nop and $13276, %rax lea addresses_normal_ht+0xac86, %rsi lea addresses_A_ht+0x18120, %rdi nop nop cmp $61716, %r13 mov $6, %rcx rep movsb nop nop and %rbp, %rbp pop %rsi pop %rdi pop %rcx pop %rbp pop %rax pop %r8 pop %r15 pop %r13 ret .global s_faulty_load s_faulty_load: push %r12 push %r15 push %r9 push %rcx push %rdx // Faulty Load mov $0x5c9f530000000d40, %r9 nop xor $10361, %r15 vmovaps (%r9), %ymm1 vextracti128 $1, %ymm1, %xmm1 vpextrq $0, %xmm1, %rcx lea oracles, %r9 and $0xff, %rcx shlq $12, %rcx mov (%r9,%rcx,1), %rcx pop %rdx pop %rcx pop %r9 pop %r15 pop %r12 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_NC', 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': True, 'size': 32, 'type': 'addresses_NC', 'congruent': 0}} <gen_prepare_buffer> {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_WT_ht', 'congruent': 2}, 'OP': 'STOR'} {'dst': {'same': False, 'congruent': 9, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 11, 'type': 'addresses_UC_ht'}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_A_ht', 'congruent': 10}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_WT_ht', 'congruent': 5}} {'dst': {'same': False, 'congruent': 3, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 10, 'type': 'addresses_WC_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_A_ht', 'congruent': 6}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_UC_ht', 'congruent': 8}} {'dst': {'same': True, 'congruent': 0, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 10, 'type': 'addresses_D_ht'}} {'dst': {'same': False, 'congruent': 4, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'src': {'same': True, 'congruent': 0, 'type': 'addresses_normal_ht'}} {'48': 4925, '4f': 3, '50': 1, '00': 648} 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 00 48 00 48 48 48 48 00 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 00 48 48 48 48 00 48 48 00 48 48 48 48 48 48 48 00 48 00 48 48 48 48 48 48 00 48 48 48 48 00 48 00 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 00 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 00 00 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 00 00 48 00 00 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 00 48 00 48 48 48 48 48 00 48 00 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 4f 00 48 48 48 48 48 00 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 00 48 48 00 00 48 48 48 48 48 00 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 00 00 48 48 48 48 48 48 48 48 48 48 00 00 48 48 48 48 00 48 00 00 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 00 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 00 48 48 48 48 48 48 00 48 48 48 48 00 48 48 00 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 00 48 00 48 48 00 00 00 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 00 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 4f 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 48 48 48 48 48 48 48 48 48 00 48 48 00 00 48 48 48 48 48 48 00 48 48 00 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 00 48 48 */
global _main section .text _main: MOV EAX, 2 MOV EBX, 3 ADD EAX, EBX INC EAX MOV ECX, 6 JMP SHORT
// Copyright 2020 The Tint Authors. // // 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. #include "src/tint/ast/fallthrough_statement.h" #include "src/tint/program_builder.h" TINT_INSTANTIATE_TYPEINFO(tint::ast::FallthroughStatement); namespace tint::ast { FallthroughStatement::FallthroughStatement(ProgramID pid, const Source& src) : Base(pid, src) {} FallthroughStatement::FallthroughStatement(FallthroughStatement&&) = default; FallthroughStatement::~FallthroughStatement() = default; const FallthroughStatement* FallthroughStatement::Clone( CloneContext* ctx) const { // Clone arguments outside of create() call to have deterministic ordering auto src = ctx->Clone(source); return ctx->dst->create<FallthroughStatement>(src); } } // namespace tint::ast
; A173522: Zero together with the partial sums of A105321. ; 0,1,4,8,14,20,26,34,46,56,62,70,82,94,106,122,146,164,170,178,190,202,214,230,254,274,286,302,326,350,374,406,454,488,494,502,514,526,538,554,578,598,610,626,650,674,698,730,778,814,826,842,866,890,914,946,994,1034,1058,1090,1138,1186,1234,1298,1394,1460,1466,1474,1486,1498,1510,1526,1550,1570,1582,1598,1622,1646,1670,1702,1750,1786,1798,1814,1838,1862,1886,1918,1966,2006,2030,2062,2110,2158,2206,2270,2366,2434,2446,2462,2486,2510,2534,2566,2614,2654,2678,2710,2758,2806,2854,2918,3014,3086,3110,3142,3190,3238,3286,3350,3446,3526,3574,3638,3734,3830,3926,4054,4246,4376,4382,4390,4402,4414,4426,4442,4466,4486,4498,4514,4538,4562,4586,4618,4666,4702,4714,4730,4754,4778,4802,4834,4882,4922,4946,4978,5026,5074,5122,5186,5282,5350,5362,5378,5402,5426,5450,5482,5530,5570,5594,5626,5674,5722,5770,5834,5930,6002,6026,6058,6106,6154,6202,6266,6362,6442,6490,6554,6650,6746,6842,6970,7162,7294,7306,7322,7346,7370,7394,7426,7474,7514,7538,7570,7618,7666,7714,7778,7874,7946,7970,8002,8050,8098,8146,8210,8306,8386,8434,8498,8594,8690,8786,8914,9106,9242,9266,9298,9346,9394,9442,9506,9602,9682,9730,9794,9890,9986,10082,10210,10402,10546,10594,10658,10754,10850,10946,11074,11266,11426 mov $2,$0 mov $4,$0 lpb $2 mov $0,$4 sub $2,1 sub $0,$2 lpb $0 sub $0,1 mov $3,$0 cal $3,105321 ; Convolution of binomial(1,n) and Gould's sequence A001316. sub $0,$0 add $3,1 lpe mul $3,2 sub $3,2 div $3,2 add $1,$3 lpe
;Test file for assembly of the ADD instruction ;This is a comment .orig x3000 ADD R0, R1, R2 ADD R1, R2, R3 ADD R2, R3, R4 ADD R3, R4, R5 ADD R4, R5, R6 ADD R5, R6, R7 ADD R6, R7, R0 ADD R7, R0, R1 ADD R0, R0, #15 ADD R1, R1, #-15 ADD R2, R2, #10 ADD R3, R3, #-10 ADD R5, R4, #0 ADD R7, R5, #-1 .END
; A246697: Row sums of the triangular array A246696. ; 1,5,16,34,67,111,178,260,373,505,676,870,1111,1379,1702,2056,2473,2925,3448,4010,4651,5335,6106,6924,7837,8801,9868,10990,12223,13515,14926,16400,18001,19669,21472,23346,25363,27455,29698,32020,34501,37065,39796 mov $12,$0 mov $14,$0 add $14,1 lpb $14,1 clr $0,12 mov $0,$12 sub $14,1 sub $0,$14 mov $9,$0 mov $11,$0 add $11,1 lpb $11,1 mov $0,$9 sub $11,1 sub $0,$11 mov $5,$0 mul $5,2 lpb $0,1 sub $0,1 mod $0,2 sub $5,$0 mul $5,2 lpe mul $5,2 mov $1,$5 div $1,8 mul $1,2 add $1,1 add $10,$1 lpe add $13,$10 lpe mov $1,$13
; void printhex(int stdout_stderr, int number); global printhex section .data hex_table db '0123456789abcdef' section .text printhex: mov rax,1 ; write syscall mov rbx,rsp mov rdx,1 ; write 1 character divide: mov rcx,rsi and rcx,15 ; push mod 16 push rcx shr rsi,4 jnz divide print_stack: pop rcx lea rsi,[rel hex_table] add rsi,rcx syscall cmp rbx,rsp jne print_stack ret
;================================================================================ ;-------------------------------------------------------------------------------- AssignKiki: LDA.b #$00 : STA $7EF3D3 ; defuse bomb LDA.b #$0A : STA $7EF3CC ; assign kiki as follower RTL ;-------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------- ; Name: AllowSQ ; Returns: Accumulator = 0 if S&Q is disallowed, 1 if allowed ;-------------------------------------------------------------------------------- !ITEM_BUSY = "$7F5091" AllowSQ: LDA $7EF3C5 : BEQ .done ; thing we overwrote - check if link is in his bed LDA !ITEM_BUSY : EOR #$01 .done RTL ;-------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------- ;0 = Reset Music ;1 = Don't Reset Music MSMusicReset: LDA $8A : CMP.b #$80 : BNE + LDA $23 + RTL ;-------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------- ;0 = Become (Perma)bunny DecideIfBunny: LDA $7EF357 : BEQ + : RTL : + LDA $7EF3CA : AND.b #$40 PHA : LDA.l InvertedMode : BNE .inverted .normal PLA : EOR #$40 BRA .done .inverted PLA .done RTL ;-------------------------------------------------------------------------------- ;0 = Become (Perma)bunny DecideIfBunnyByScreenIndex: ; If indoors we don't have a screen index. Return non-bunny to make mirror-based ; superbunny work LDA $1B : BEQ + : RTL : + LDA $7EF357 : BEQ + : RTL : + LDA $8A : AND.b #$40 : PHA LDA.l InvertedMode : BNE .inverted .normal PLA : EOR #$40 BRA .done .inverted PLA .done RTL ;-------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------- ;ReadInventoryPond: ; CPX.b #$1B : BNE + : LDA.b #$01 : RTL : + ; LDA $7EF340, X ;RTL ;-------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------- FixBunnyOnExitToLightWorld: LDA.w $02E0 : BEQ + JSL.l DecideIfBunny : BEQ + STZ $5D ; set player mode to Normal STZ $02E0 : STZ $56 ; return player graphics to normal + RTS ;-------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------- ; fix issue where if a player beats aga1 without moon pearl, they don't turn into ; bunny on the pyramid FixAga2Bunny: LDA.l FixFakeWorld : BEQ + ; Only use this fix is fakeworld fix is in use LDA.l InvertedMode : BEQ +++ LDA.b #$00 : STA !DARK_WORLD ; Switch to light world BRA ++ +++ LDA.b #$40 : STA !DARK_WORLD ; Switch to dark world ++ JSL DecideIfBunny : BNE + JSR MakeBunny LDA.b #$04 : STA.w $012C ; play bunny music BRA .done + LDA.b #$09 : STA.w $012C ; what we wrote over .done RTL ;-------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------- MakeBunny: PHX : PHY LDA.b #$17 : STA $5D ; set player mode to permabunny LDA.b #$01 : STA $02E0 : STA $56 ; make player look like bunny JSL LoadGearPalettes_bunny PLY : PLX RTS ;-------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------- ; fix issue where cross world caves (in Entrance randomizer) don't cause ; frog to become smith or vice versa. FixFrogSmith: LDA.l $7EF3CA : BNE .darkWorld LDA.l $7EF3CC : CMP.b #$07 : BNE .done LDA.b #$08 : STA.l $7EF3CC ; make frog into smith in light world BRA .loadgfx .darkWorld LDA.l $7EF3CC : CMP.b #$08 : BNE .done LDA.b #$07 : STA.l $7EF3CC ; make smith into frog in dark world .loadgfx JSL Tagalong_LoadGfx .done RTL ;-------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------- ;Fix for PoD causing accidental Exploration Glitch PodEGFix: LDA Bugfix_PodEG : BNE .done LDA $040C : CMP.b #$0C : BNE .done ;check if we are in PoD STZ $047A ;disarm exploration glitch .done RTL ;-------------------------------------------------------------------------------- ; Fix crystal not spawning when using somaria vs boss TryToSpawnCrystalUntilSuccess: STX $02D8 ; what we overwrote JSL AddAncillaLong : BCC .spawned ; a clear carry flag indicates success .failed RTL .spawned STZ $AE ; the "trying to spawn crystal" flag STZ $AF ; the "trying to spawn pendant" flag RTL ;-------------------------------------------------------------------------------- ; Fix crystal not spawning when using somaria vs boss WallmasterCameraFix: STZ $A7 ; disable vertical camera scrolling for current room REP #$20 STZ $0618 ; something about scrolling, setting these to 0 tricks the game STZ $061A ; into thinking we're at the edge of the room so it doesn't scroll. SEP #$20 JML Sound_SetSfx3PanLong ; what we wrote over, also this will RTL ;-------------------------------------------------------------------------------- ; Fix losing glove colors LoadActualGearPalettesWithGloves: REP #$20 LDA $7EF359 : STA $0C LDA $7EF35B : AND.w #$00FF JSL LoadGearPalettes_variable JSL Palette_ArmorAndGlovesRandSprite_part_two RTL ;-------------------------------------------------------------------------------- ; Fix Bunny Palette Map Bug LoadGearPalette_safe_for_bunny: LDA $10 CMP.w #$030E : BEQ .new ; opening dungeon map CMP.w #$070E : BEQ .new ; opening overworld map .original - lda [$00] sta $7ec300, x sta $7ec500, x inc $00 : inc $00 inx #2 dey bpl - RTL .new - lda [$00] sta $7ec500, x inc $00 : inc $00 inx #2 dey bpl - RTL ;-------------------------------------------------------------------------------- ; Fix pedestal pull overlay PedestalPullOverlayFix: LDA.b #$09 : STA $039F, X ; the thing we wrote over LDA $1B : BNE + LDA $8A : CMP.b #$80 : BNE + LDA $8C : CMP.b #$97 + RTL ;-------------------------------------------------------------------------------- SetOverworldTransitionFlags: LDA #$01 STA $0ABF ; used by witch STA $021B ; used by race game RTL
%assign limit 15 is_prime: db 0, 0, 1 ; 0: not, 1: not, 2: is %assign n 3 %rep limit %assign current 1 %assign i 1 %rep n/2 %assign i i+1 %if n % i = 0 %assign current 0 %exitrep %endif %endrep db current %assign n n+1 %endrep
section ".data" xdef pSnd_GetFrequency_voice1 pSnd_GetFrequency_voice1: move.w frequency_voice1,d0 rts
;/* ; * Microsoft Confidential ; * Copyright (C) Microsoft Corporation 1991 ; * All Rights Reserved. ; */ PAGE ,132 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; FILENAME: CPS Device Driver -- Font Parser ;; MODULE NAME: CPSFONT ;; TYPE: Font Parser Module ;; LINK PROCEDURE: Link CPS+CPSSUB+CPSINT9+...+CPSINIT into .EXE format ;; CPS must be first. CPSINIT must be last. Everything ;; before CPSINIT will be resident. ;; INCLUDE FILES: ;; CPSPEQU.INC ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; INCLUDE CPSPEQU.INC ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; CSEG SEGMENT PUBLIC 'CODE' ;; ASSUME CS:CSEG ;; ASSUME DS:NOTHING ;; ;; PUBLIC FTABLE,FONT_PARSER ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ************************************ ;; ** ** ;; ** Resident Code ** ;; ** ** ;; ************************************ ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; FONT_PARSER data ;; ;; -- Interface table : FTABLE ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FTABLE: FBUFS <0FFFFH,,,> ;; for temporary testing FTB1 FTBLK <,,,,,,,,,,,,> ;; -- at most 12 entries FTB2 FTBLK <,,,,,,,,,,,,> ;; FTB3 FTBLK <,,,,,,,,,,,,> ;; FTB4 FTBLK <,,,,,,,,,,,,> ;; FTB5 FTBLK <,,,,,,,,,,,,> ;; FTB6 FTBLK <,,,,,,,,,,,,> ;; FTB7 FTBLK <,,,,,,,,,,,,> ;; FTB8 FTBLK <,,,,,,,,,,,,> ;; FTB9 FTBLK <,,,,,,,,,,,,> ;; FTBa FTBLK <,,,,,,,,,,,,> ;; FTBb FTBLK <,,,,,,,,,,,,> ;; FTBc FTBLK <,,,,,,,,,,,,> ;; ;; FP_ERROR DW 0000H ;; internal error register ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; the followings are bytes accumulated ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FTAG_LEN EQU 8 ;; FILE TAGE in the font file header FTAG_COUNT DW 0000H ;; ;; FTAG_PATTERN LABEL BYTE ;; DB 0FFH ;; DB 'FONT ' ;; ;; ;; ;; POINTER in the font file header fptr_LOW LABEL WORD ;; fptr_LOL DB 00H ;; NEXT fptr_LOH DB 00H ;; fptr_HIGH LABEL WORD ;; fptr_HIL DB 00H ;; fptr_HIH DB 00H ;; ;; ;; ;; ENTRY_WORD LABEL WORD ;; ENTRY_LOB DB 00H ;; ENTRY COUNT ENTRY_HIB DB 00H ;; NEXT_LOW LABEL WORD ;; NEXT_LOL DB 00H ;; NEXT NEXT_LOH DB 00H ;; NEXT_HIGH LABEL WORD ;; NEXT_HIL DB 00H ;; NEXT_HIH DB 00H ;; TYPE_WORD LABEL WORD ;; TYPE_LOB DB 00H ;; TYPE TYPE_HIB DB 00H ;; TID_CNT DW 00000H ;; TYPEID COUNT(0 to 8) TYPE_ID : DB ' ' ;; TYPEID CPG_WORD LABEL WORD ;; CPG_LOB DB 00H ;; CODE PAGE CPG_HIB DB 00H ;; FONT_LOW LABEL WORD ;; FONT_LOL DB 00H ;; FONT ADDRESS FONT_LOH DB 00H ;; FONT_HIGH LABEL WORD ;; FONT_HIL DB 00H ;; FONT_HIH DB 00H ;; ;; the followings are contained in the font-block in the exact order & length MOD_WORD LABEL WORD ;; MOD_LOB DB 00H ;; MODIFIER MOD_HIB DB 00H ;; FONTS_WORD LABEL WORD ;; FONTS_LOB DB 00H ;; FONTS FONTS_HIB DB 00H ;; FDLEN_WORD LABEL WORD ;; FDLEN_LOB DB 00H ;; FONT DATA LENGTH FDLEN_HIB DB 00H ;; PRE_FONT_ND EQU ($-MOD_WORD) ;; used to update target for font data ;; to follow. -- for NON-DISPLAY DISP_ROWS DB 00H ;; DISPLAY's parameters : DISP_COLS DB 00H ;; BOX SIZE DISP_X DB 00H ;; ASPECT RATIO DISP_Y DB 00H ;; COUNT_WORD LABEL WORD ;; NO. OF DISPLAY CHARACTERS COUNT_LOB DB 00H ;; COUNT_HIB DB 00H ;; PRE_FONT_D EQU ($-MOD_WORD) ;; used to update target for font data ;; to follow. -- for DISPLAY ;; PTR_SEL_WORD LABEL WORD ;; PTR_SELOB DB 00H ;; PTR_SEHIB DB 00H ;; PRE_FONT_P0 EQU ($-PTR_SELOB+PRE_FONT_ND) ;; to update target for font data ;; to follow -- for PRINTER with ;; selection type = 0. ;; PTR_LEN_WORD LABEL WORD ;; PTR_LNLOB DB 00H ;; PTR_LNHIB DB 00H ;; PRE_FONT_P EQU ($-PTR_SELOB+PRE_FONT_ND) ;; to update target for font data ;; to follow -- for PRINTER with ;; selection type <> 0. ;; ;; ;; also update STAGE_CASES and indexing constants ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; the stage the parsing is in : ;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; STAGE_CASES LABEL WORD ;; the stage the parsing is in : ;; ;; *** INDEXED BY STAGE-INDEX ;; DW OFFSET ENTRYLO ;; 0 DW OFFSET ENTRYHI ;; 1 DW OFFSET NEXTLOL ;; 2 DW OFFSET NEXTLOH ;; 3 DW OFFSET NEXTHIL ;; 4 DW OFFSET NEXTHIH ;; 5 DW OFFSET TYPELO ;; 6 DW OFFSET TYPEHI ;; 7 DW OFFSET TYPEIDS ;; 8 DW OFFSET CPGLO ;; 9 DW OFFSET CPGHI ;; A DW OFFSET FONTLOL ;; B DW OFFSET FONTLOH ;; C DW OFFSET FONTHIL ;; D DW OFFSET FONTHIH ;; E DW 00H ;; MATCH case -- end of SEARCH stages DW 00H ;; SCAN case -- before PRE-FOUND stage DW OFFSET MODLO ;; 11 DW OFFSET MODHI ;; 12 DW OFFSET FONTSLO ;; 13 DW OFFSET FONTSHI ;; 14 DW OFFSET FDLENLO ;; 15 DW OFFSET FDLENHI ;; 16 -- lead to FONT case,NON- DISPLAY DW OFFSET DSPROWS ;; 17 -- DISPLAY only DW OFFSET DSPCOLS ;; 18 DW OFFSET DSPX ;; 19 DW OFFSET DSPY ;; 1A DW OFFSET DSPCOUNTLO ;; 1B DW OFFSET DSPCOUNTHI ;; 1C -- lead to FONT case, DISPLAY DW OFFSET PTRSELLO ;; 1D -- PRINTER only DW OFFSET PTRSELHI ;; 1E DW OFFSET PTRLENLO ;; 1F DW OFFSET PTRLENHI ;; 20 -- lead to FONT case, PRINTER DW 00H ;; FOUND case DW 00H ;; GET_FONT case DW 00H ;; PASS special stage DW OFFSET FILETAG ;; 24 DW OFFSET fptrLOL ;; 25 DW OFFSET fptrLOH ;; 26 DW OFFSET fptrHIL ;; 27 DW OFFSET fptrHIH ;; 28 DW 00H ;; FPTR_SKIP_CASE ;; ;; The followings are individual stage STAGE_MAX EQU ($-STAGE_CASES)/2 ;; number of stages ;; ;; STAGE-INDEX ;; ;; **** INDEX TO STAGE_CASES **** ENTRY_LOX EQU 00H ;; ENTRY_HIX EQU 01H ;; NEXT_LOLX EQU 02H ;; NEXT NEXT_LOHX EQU 03H ;; NEXT_HILX EQU 04H ;; NEXT_HIHX EQU 05H ;; TYPE_LOBX EQU 06H ;; TYPE TYPE_HIBX EQU 07H ;; TYPE_IDX EQU 08H ;; TYPEID CPG_LOBX EQU 09H ;; CODE PAGE CPG_HIBX EQU 0AH ;; FONT_LOLX EQU 0BH ;; FONT ADDRESS FONT_LOHX EQU 0CH ;; FONT_HILX EQU 0DH ;; FONT_HIHX EQU 0EH ;; ;; ------------------------------ MATCHX EQU 0FH ;; MATCH is the end of SEARCH's stages SCANX EQU 10H ;; SCANX is before the PRE-FOUND stages ;; ------------------------------ MOD_LOBX EQU 11H ;; MODIFIER MOD_HIBX EQU 12H ;; FONTS_LOBX EQU 13H ;; FONTS FONTS_HIBX EQU 14H ;; FDLEN_LOBX EQU 15H ;; FONT DATA LENGTH FDLEN_HIBX EQU 16H ;; DISP_ROWSX EQU 17H ;; DISPLAY -- CHAR. SIZE DISP_COLSX EQU 18H ;; DISP_XX EQU 19H ;; DISPLAY -- ASPECT RATIO DISP_YX EQU 1AH ;; COUNT_LOBX EQU 1BH ;; DISPLAY -- COUNT COUNT_HIBX EQU 1CH ;; PTRSELLOX EQU 1DH ;; PTRSELHIX EQU 1EH ;; PTRLENLOX EQU 1FH ;; PTRLENHIX EQU 20H ;; ;; ;; ------------------------------ FOUNDX EQU 21H ;; GET_FX is the end of PRE-FOUND stage GET_FX EQU 22H ;; ;; ------------------------------ PASSX EQU 23H ;; see pass_brk table ;; ------------------------------ FTAGX EQU 24H ;; RESTART ==> FILE TAG ;; fptr_LOLX EQU 25H ;; POINTER in font file header fptr_LOHX EQU 26H ;; fptr_HILX EQU 27H ;; fptr_HIHX EQU 28H ;; --------------------------------- ;; fptr_SKIPX EQU 29H ;; ==> ENTRY_LOX ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; PASS -- to skip some bytes ;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; the PASS mechanism is used to skip ;; a number of bytes between two fields ;; The numbers are tabulated in ;; PASS_BRK table in the accumulative ;; sum. The PASS_POSTX(and PASS_POSTXX) ;; are used to tell what is the stage ;; after all the bytes have skipped. ;; PASS_POSTX DW STAGE_MAX ;; the stage after pass-stage ;; FILE_OFFSET EQU 0BH ;; spaces to be skipped in font file : ;; ( after TAG, before POINTER) ;; PASS_CNT DW 0 ;; PASS_BRK LABEL WORD ;; DW FILE_OFFSET ;; skip in the font file header DW FILE_OFFSET+2 ;; pass header-length, needs to reset ;; PASS_CNT for each of the font_header DW FILE_OFFSET+8 ;; pass header-reserved bytes PASS_INDX EQU ($-PASS_BRK)/2 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; the control variables : ;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; STAGE DW STAGE_MAX ;; of the STAGE-INDEX ;; Pre_font_len DW 00000H ;; no. of bytes before the FONT DATA ;; ;; COUNT_LO DW 00000H ;; no. of bytes parsed so far COUNT_hI DW 00000H ;; ;; HIT_LO DW 00000H ;; the next byte that is addressed by : HIT_HI DW 00000H ;; either NEXT or TARGET in FTBLK. ;; HIT_FLAG DW 00000H ;; IF ZERO, the NEXT is approaching HIT_BX DW 00000H ;; where FTB is found for nearest hit ;; NUM_FTB DW 00000H ;; as defined in the FP_BUFFER ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; FONT_PARSER routine ;; ;; -- to be called at every packet received to extract informations ;; from Font File on byte basis. ;; ;; -- Interface though FTABLE ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; FONT_PARSER PROC ;; PUSH DS ;; save all registers Revised PUSH ES ;; PUSH AX ;; PUSH BX ;; PUSH CX ;; PUSH DX ;; PUSH DI ;; PUSH SI ;; ;; BP isn't used, so it isn't saved LEA BX,FTABLE ;; PUSH CS ;; POP ES ;; ES:[BX] LDS SI,FTP.BUFFER_ADDR ;; DS:[SI] MOV CX,FTP.BUFFER_LEN ;; CX = length of packet MOV DX,FTP.NUM_FTBLK ;; DX = number of FTB MOV cs:num_ftb,DX ;; AND DX,DX ;; JNZ VALID_BUFFER ;; MOV cs:fp_error,0020H ;; ERROR 0020H JMP FP_RET ;; VALID_BUFFER : ;; MOV AX,FTP.FLAG ;; AND AX,FLAG_RESTART ;; Jnz has_RESTART ;; JMP NO_RESTART ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; has_restart : ;; PUSH BX ;; reset all the output fields ADD BX,TYPE FBUFS ;; FTP = FONT BLOCK XOR AX,AX ;; ;; MOV cs:ftag_count,AX ;; MOV cs:fptr_low,AX ;; MOV cs:fptr_high,AX ;; MOV cs:pre_font_len,AX ;; MOV cs:count_lo,AX ;; MOV cs:count_hi,AX ;; MOV cs:next_low,AX ;; MOV cs:next_high,AX ;; MOV cs:hit_lo,AX ;; MOV cs:hit_hi,AX ;; MOV cs:hit_flag,AX ;; MOV cs:pass_cnt,AX ;; MOV cs:pass_postx,STAGE_MAX ;; ;; MOV cs:stage,STAGE_MAX ;; ;; RESET_FTB : ;; MOV FTP.FTB_STATUS,FSTAT_SEARCH MOV FTP.FTB_TYPE,AX ;; MOV FTP.FTB_MOD,AX ;; MOV FTP.FTB_FONTS,AX ;; MOV FTP.FTB_ROWS,AL ;; MOV FTP.FTB_COLS,AL ;; MOV FTP.FTB_X,AL ;; MOV FTP.FTB_Y,AL ;; MOV FTP.FTB_COUNT,AX ;; MOV FTP.FTB_DLEFT,AX ;; MOV FTP.FTB_DLEN,AX ;; MOV FTP.FTB_DALO,AX ;; MOV FTP.FTB_DAHI,AX ;; MOV FTP.TARGET_LO,AX ;; MOV FTP.TARGET_HI,AX ;; ;; ADD BX, TYPE FTBLK ;; ;; DEC DX ;; AND DX,DX ;; JNZ RESET_FTB ;; ;; POP BX ;; NO_RESTART : ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; any FTBLKs have their data all ;; returned ? if so set their status ;; from FOUND to COMPLETE PUSH BX ;; ADD BX,TYPE FBUFS ;; FTP = FONT BLOCK ;; MOV DX,cs:num_ftb ;; ;; SET_COMPLETE : ;; MOV AX,FTP.FTB_STATUS ;; CMP AX,FSTAT_FONT ;; JNE SET_NEXT ;; ;; MOV AX,FTP.FTB_DLEFT ;; AND AX,AX ;; JNZ SET_NEXT ;; ;; MOV FTP.FTB_STATUS,FSTAT_COMPLETE ;; SET_NEXT : ;; ;; ADD BX,TYPE FTBLK ;; ;; DEC DX ;; AND DX,DX ;; JNZ SET_COMPLETE ;; ;; POP BX ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ADD BX,TYPE FBUFS ;; FTP = FONT BLOCK ;; PUSH CX ;; STACK 1 = CX ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; DO WHILE CX is not zero : ;; ;; -- on each loop, the CX, COUNTs are updated ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; FTB_LOOP : ;; POP AX ;; STACK -1 SUB AX,CX ;; ADD cs:count_lo,AX ;; JNC NO_CARRY ;; ADD cs:count_hi,1000H ;; NO_CARRY : ;; PUSH CX ;; STACK 1 = CX AND CX,CX ;; JNZ FTB_CONT ;; JMP FTB_LPEND ;; ;; DO CASES : FTB_CONT : ;; ========== ;; MOV AX,cs:stage ;; ;; CMP AX,STAGE_MAX ;; JNE FTB_010 ;; JMP START_CASE ;; ** RESTART ** ;; FTB_010 : ;; CMP AX,MATCHX ;; JAE FTB_020 ;; JMP SEARCH_CASE ;; ** SEARCH ** ;; FTB_020 : ;; CMP AX,MATCHX ;; JNE FTB_030 ;; JMP MATCH_CASE ;; ** MATCH ** ;; FTB_030 : ;; CMP AX,SCANX ;; JNE FTB_040 ;; JMP SCAN_CASE ;; ** SCAN ** ;; FTB_040 : ;; CMP AX,FOUNDX ;; JAE FTB_050 ;; JMP PRE_FOUND_CASE ;; ** PRE-FOUND ** ;; FTB_050 : ;; CMP AX,FOUNDX ;; JNE FTB_060 ;; JMP FOUND_CASE ;; ** FOUND ** ;; FTB_060 : ;; CMP AX,GET_FX ;; JNE FTB_070 ;; JMP GETFONT_CASE ;; ** GET_FONT ** ;; FTB_070 : ;; CMP AX,PASSX ;; JNE FTB_080 ;; JMP PASS ;; ** PASS ** ;; FTB_080 : ;; CMP AX,FPTR_SKIPX ;; JAE FTB_090 ;; JMP SEARCH_CASE ;; ** SEARCH ** ;; FTB_090 : ;; CMP AX,FPTR_SKIPX ;; JNE FTB_FFF ;; JMP FPTR_SKIP_CASE ;; ** SEARCH ** ;; FTB_FFF : ;; MOV FTP.FTB_STATUS,STAT_DEVERR JMP FTB_LPEND ;; ** DEVICE ERROR ** ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; at the entry of each STAGES /CASES ;; ;; -- DS:[SI] (FPKT) points to PACKET, of DOS's buffer ;; -- CX remaining packet length ;; -- ES:[BX] points to the first FTBLK ;; -- COUNT_LO, COUNT_HI, upto but and including the address pointed by FPKT ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;============================================================================ START_CASE : ;; pass the FILE leading bytes ;; MOV cs:ftag_count,0 ;; MOV cs:stage,ftagx ;; JMP FTB_LOOP ;; ;; ;============================================================================= FPTR_SKIP_CASE : ;; skip until the ENTRY pointed by ;; POINTER (in FPTR) is reached. ;; ;; ************** MOV AX,cs:fptr_low ;; * HIT = FPTR * MOV cs:hit_lo,AX ;; ************** MOV DX,cs:fptr_high ;; MOV cs:hit_hi,DX ;; ;; CMP AX,0FFFFH ;; JNE FPTR_SKIP_VALID ;; CMP DX,0FFFFH ;; JNE FPTR_SKIP_VALID ;; ;; MOV FTP.FTB_STATUS,STAT_BADATA ;; returned at the first FTBLK JMP FPTR_SKIP_MORE ;; ;; FPTR_SKIP_VALID : ;; ;; normalised HIT_HI, HIT_LO MOV AX,DX ;; AND AX,00FFFH ;; PUSH CX ;; MOV CX,4 ;; SHL AX,CL ;; POP CX ;; AND DX,0F000H ;; ADD AX,cs:hit_lo ;; JNC NO_CARRY10 ;; ADD DX,01000H ;; NO_CARRY10: ;; MOV cs:hit_lo,AX ;; MOV cs:hit_hi,DX ;; ;; ************************** ;; * compare FPTR and COUNT * ;; ************************** ;; DX:AX = HIT_HI:HIT_LO (normalised) ;; SUB AX,cs:count_lo ;; Jnc more_fptrlo ;; sub dx,01000h ;; jc fptr_bad ;; ;; more_fptrlo : ;; SUB DX,cs:count_hi ;; JC fptr_BAD ;; ;; INC AX ;; COUNT can be at the HIT, then AX=0 JNC NO_CARRY11 ;; INC AX to make AX comparable to CX ADD DX,01000H ;; i.e. AX = offset + 1 ;; NO_CARRY11: ;; CMP AX,CX ;; JA fptr_skip_more ;; AX > CX, whole CX to be skipped ;; PUSH DX ;; normalise dx:ax AND DX,00FFFH ;; PUSH CX ;; MOV CX,4 ;; SHL DX,CL ;; POP CX ;; ADD AX,DX ;; POP DX ;; JNC NO_CARRY13 ;; ADD DX,01000H ;; NO_CARRY13: ;; AND DX,0F000H ;; ;; PUSH AX ;; PUSH DX ;; STACK +1 : normalosed DX:AX SUB AX,CX ;; JNC NO_BORROW11 ;; SUB DX,1000H ;; JC fptr_MORE_CXp ;; dx:ax < cx NO_BORROW11: ;; ;; dx:ax >= cx AND AX,AX ;; JNE fptr_skip_MOREP ;; AND DX,DX ;; JNE fptr_skip_MOREP ;; ;; dx:ax = cx, or ;; offset + 1 = CX ;; ;; ************************************ ;; * POINTER is within the current CX * ;; ************************************ fptr_MORE_CXP : ;; POP DX ;; POP AX ;; STACK -1 ;; fptr_MORE_CX : ;; DX = 0,to have more CX than offset+1 DEC AX ;; = offset : 0 and above SUB CX,AX ;; ADD SI,AX ;; where the first byte is ;; MOV cs:stage,entry_lox ;; ENTRIES in the font file ;; JMP FTB_LOOP ;; ****** RETURN ******* ;; ;; *********************************** ;; * more to skip ==> FPTR_SKIP_CASE * ;; *********************************** fptr_skip_morep: ;; POP DX ;; POP AX ;; STACK -1 ;; fptr_skip_more : ;; ADD SI,CX ;; SUB CX,CX ;; JMP FTB_LOOP ;; ****** RETURN ***** ;; ;; *********************************** ;; * bad POINTER in font file header * ;; *********************************** ;; fptr_bad : ;; MOV cs:fptr_low,0FFFFH ;; MOV cs:fptr_high,0FFFFH ;; ;; MOV FTP.FTB_STATUS,STAT_BADATA ;; returned at the first FTBLK ;; JMP FPTR_SKIP_MORE ;; ;; ;============================================================================= SEARCH_CASE : ;; ;; still looking for header to match ;; the input : codepage and typeid ;; MOV DI,cs:stage ;; ;; ADD DI,DI ;; double to index to WORD-offset ;; JMP CS:STAGE_CASES[DI] ;; call routine to process the stage ;; ;; ;=========================================================================== MATCH_CASE : ;; ;; PUSH BX ;; MOV DX,cs:num_ftb ;; ;; ;; MATCH_LOOP : ;; MOV AX,FTP.FTB_STATUS ;; CMP AX,FSTAT_SEARCH ;; JE MATCH_SEARCH ;; JMP MATCH_NEXT ;; ;; MATCH_SEARCH : ;; MOV AX,FTP.FTB_CP ;; check the FTB with SEARCH status CMP AX,cs:cpg_word ;; JNE MATCH_MORE ;; PUSH DS ;; code page matched PUSH SI ;; PUSH CX ;; ;; PUSH CS ;; POP DS ;; MOV SI,OFFSET TYPE_ID ;; LEA DI,[BX].FTB_TID ;; MOV CX,8 ;; REPE CMPSB ;; ;; POP CX ;; POP SI ;; POP DS ;; ;; JNE MATCH_MORE ;; ;; MATCH !!!!! (type_id matched) MOV FTP.FTB_STATUS,FSTAT_MATCH MOV AX,cs:type_word ;; MOV FTP.FTB_TYPE,AX ;; MOV AX,cs:font_low ;; MOV FTP.TARGET_LO,AX ;; MOV AX,cs:font_high ;; MOV FTP.TARGET_HI,AX ;; ;; JMP MATCH_NEXT ;; ;; MATCH_MORE : ;; if this is the last rounf ? ;; MOV AX,cs:next_low ;; NEXT = FFFF:FFFF means no more CMP AX,-1 ;; header to come. JNE MATCH_NEXT ;; ;; MOV AX,cs:next_high ;; CMP AX,-1 ;; JNE MATCH_NEXT ;; ;; MOV FTP.FTB_STATUS,STAT_NOFIND ;; ERROR : no match ;; MATCH_NEXT : ;; ADD BX,FTP.FTB_LENGTH ;; DEC DX ;; AND DX,DX ;; JZ MATCH_ALL ;; JMP MATCH_LOOP ;; ;; MATCH_ALL : ;; MOV cs:stage,SCANX ;; ;; MATCH_DONE : ;; POP BX ;; JMP FTB_LOOP ;; ;; ;=========================================================================== SCAN_CASE : ;; ;; ********************************** ;; * determine whether it the font * ;; * data(TARGET),or the next font * ;; * header(NEXT) that is approaching ;; ********************************** ;; MOV AX,cs:next_low ;; MOV cs:hit_lo,AX ;; MOV AX,cs:next_high ;; MOV cs:hit_hi,AX ;; XOR AX,AX ;; MOV cs:hit_flag,AX ;; ;; MOV DI,cs:hit_hi ;; normalised HIT_HI, HIT_LO MOV AX,DI ;; AND AX,00FFFH ;; PUSH CX ;; MOV CX,4 ;; SHL AX,CL ;; POP CX ;; AND DI,0F000H ;; ADD AX,cs:hit_lo ;; JNC NO_CARRY2 ;; ADD DI,01000H ;; NO_CARRY2 : ;; MOV cs:hit_lo,AX ;; MOV cs:hit_hi,DI ;; ;; MOV DX,cs:num_ftb ;; ;; PUSH BX ;; SCAN_LOOP : ;; MOV AX,FTP.FTB_STATUS ;; CMP AX,FSTAT_MATCH ;; JNE SCAN_NEXT ;; ;; ;; MOV DI,FTP.TARGET_HI ;; NORMALISED TARGET MOV AX,DI ;; AND AX,00FFFH ;; PUSH CX ;; MOV CX,4 ;; SHL AX,CL ;; POP CX ;; AND DI,0F000H ;; ADD AX,FTP.TARGET_LO ;; JNC NO_CARRY1 ;; ADD DI,01000H ;; NO_CARRY1 : ;; DI:AX = NORMALISED TARGET ;; ;; ** compare the TARGET and the NEXT ;; CMP DI,cs:hit_hi ;; JA SCAN_NEXT ;; ;; JE SCAN_EQU ;; JMP NEAR_FONT ;; ;; SCAN_EQU : ;; CMP AX,cs:hit_lo ;; JA SCAN_NEXT ;; JE SCAN_ERROR_CHK ;; ;; ********************************** ;; * the font data is approaching * ;; ********************************** NEAR_FONT : ;; MOV cs:hit_flag,-1 ;; MOV cs:hit_lo,AX ;; MOV cs:hit_hi,DI ;; MOV cs:hit_bx,BX ;; used for BAD_BX and in FOUND_CASE JMP SCAN_NEXT ;; ;; ;; ********************************** ;; * the NEXT header is approaching * ;; ********************************** SCAN_ERROR_CHK : ;; MOV AX,cs:hit_flag ;; AND AX,AX ;; JNZ SCAN_NEXT ;; MOV FTP.FTB_STATUS,STAT_BADATA ;; next header and font cannot be the ;; same ;; SCAN_NEXT : ;; DEC DX ;; AND DX,DX ;; JZ SCAN_DONE ;; ;; ADD BX,FTP.FTB_LENGTH ;; JMP SCAN_LOOP ;; ** is there any closer font data ? ;; ;; ************************************ ;; * the HIT is either font data(TARGET ;; * or the font block (NEXT). * ;; ************************************ SCAN_DONE : ;; POP BX ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MOV DX,cs:hit_hi ;; HIT_FLAG, HIT_LO, HIT_HI defined MOV AX,cs:hit_lo ;; ;; CMP AX,0FFFFH ;; JNE NOT_FFFF_HIT ;; CMP DX,0FFFFH ;; JNE NOT_FFFF_HIT ;; JMP SCAN_MORE ;; stage remained as SCAN, discard data ;; NOT_FFFF_HIT : ;; ;; DX:AX = HIT_HI:HIT_LO (normalised) SUB AX,cs:count_lo ;; JNC NO_BORROW ;; SUB DX,01000H ;; JC SCAN_BAD ;; NO_BORROW: ;; SUB DX,cs:count_hi ;; JC SCAN_BAD ;; ;; INC AX ;; COUNT can be at the HIT, then AX=0 JNC NO_CARRYX ;; INC AX to make AX comparable to CX ADD DX,01000H ;; i.e. AX = offset + 1 ;; NO_CARRYX : ;; CMP AX,CX ;; JA SCAN_MORE ;; ;; PUSH DX ;; AND DX,00FFFH ;; PUSH CX ;; MOV CX,4 ;; SHL DX,CL ;; POP CX ;; ADD AX,DX ;; POP DX ;; JNC NO_CARRY3 ;; ADD DX,01000H ;; NO_CARRY3 : ;; AND DX,0F000H ;; ;; ;; PUSH AX ;; PUSH DX ;; SUB AX,CX ;; JNC NO_BORROW1 ;; SUB DX,1000H ;; JC MORE_CXp ;; NO_BORROW1 : ;; ;; dx:ax >= cx AND AX,AX ;; JNE SCAN_MOREP ;; AND DX,DX ;; JNE SCAN_MOREP ;; ;; ;; offset + 1 = CX ;; MORE_CXP : ;; POP DX ;; POP AX ;; ;; MORE_CX : ;; DX = 0,to have more CX than offset+1 DEC AX ;; = offset : 0 and above SUB CX,AX ;; ADD SI,AX ;; where the first byte is MOV AX,cs:hit_flag ;; AND AX,AX ;; JE NEXT_REACHED ;; ;; MOV cs:stage,MOD_LOBX ;; font-data reached, ;; JMP FTB_LOOP ;; ****** RETURN ******* ;; NEXT_REACHED : ;; MOV cs:stage,PASSX ;; MOV cs:pass_postx,next_lolX ;; MOV cs:pass_cnt,FILE_OFFSET ;; ;; ;; JMP FTB_LOOP ;; ****** RETURN ******* ;; ;; *********************************** SCAN_MOREP : ;; * scan more FTBLK for the nearest * ;; * font data * ;; *********************************** POP DX ;; POP AX ;; ;; SCAN_MORE : ;; ADD SI,CX ;; SUB CX,CX ;; JMP FTB_LOOP ;; more SCAN stage ;; SCAN_BAD: ;; ************************* MOV AX,cs:hit_flag ;; * scan is bad * AND AX,AX ;; ************************* JNZ BAD_BX ;; MOV AX,-1 ;; NEXT is pointing backwards MOV cs:next_low,AX ;; MOV cs:next_high,AX ;; no more NEXT MOV FTP.FTB_STATUS,STAT_BADATA ;; returned at the first FTBLK JMP FTB_LOOP ;; ;; BAD_BX : ;; PUSH BX ;; FONT is pointing backwards MOV BX,cs:hit_bx ;; MOV FTP.FTB_STATUS,STAT_BADATA POP BX ;; JMP FTB_LOOP ;; ;; ;=========================================================================== PRE_FOUND_CASE : ;; ;; extract informations from the font ;; block until font_length is defined ;; MOV DI,cs:stage ;; ;; ADD DI,DI ;; double to index to WORD-offset ;; JMP CS:STAGE_CASES[DI] ;; call routine to process the stage ;; ;=========================================================================== FOUND_CASE : ;; MOV DI,OFFSET FTB_LOOP ;; as FOUND has two places to return to PUSH DI ;; ;=========================================================================== FOUND_DO : ;; ;; define informations into FTBLK of ;; HIT_BX defined in the SCAN case PUSH BX ;; MOV BX,cs:hit_bx ;; ;; FTBLK : MOV AX,cs:mod_word ;; MOV FTP.FTB_MOD,AX ;; MOV AX,cs:fonts_word ;; MOV FTP.FTB_FONTS,AX ;; ;; MOV AX,cs:fdlen_word ;; MOV FTP.FTB_DLEFT,AX ;; MOV FTP.FTB_DLEN,0 ;; MOV FTP.FTB_DALO,0 ;; MOV FTP.FTB_DAHI,0 ;; ;; MOV FTP.FTB_STATUS,FSTAT_FOUND ;; CMP FTP.FTB_TYPE,TYPE_DISPLAY; JNE CHECK_PTR_TYPE ;; CMP cs:pre_font_len,PRE_FONT_D ;; JNE DISPLAY_BAD ;; JMP DISPLAY_DONE ;; ;; CHECK_PTR_TYPE : ;; CMP FTP.FTB_TYPE,TYPE_PRINTER; JNE SET_STAGE ;; CMP cs:ptr_sel_word,0 ;; JNE PRINTER_HAS_SEL ;; CMP cs:pre_font_len,PRE_FONT_P0;; JNE PRINTER_BAD ;; JMP PRINTER_DONE ;; ;; PRINTER_HAS_SEL : ;; CMP cs:pre_font_len,PRE_FONT_P ;; JNE PRINTER_BAD ;; JMP PRINTER_DONE ;; ;; DISPLAY_BAD : ;; ;; MOV FTP.FTB_STATUS,STAT_BADATA ;the FDLEN_WORD should be 0. ;; DISPLAY_DONE : ;; MOV AL,cs:disp_rows ;; MOV FTP.FTB_ROWS,AL ;; MOV AL,cs:disp_cols ;; MOV FTP.FTB_COLS,AL ;; MOV AL,cs:disp_x ;; MOV FTP.FTB_X,AL ;; MOV AL,cs:disp_y ;; MOV FTP.FTB_Y,AL ;; MOV AX,cs:count_word ;; MOV FTP.FTB_COUNT,AX ;; JMP SET_STAGE ;; ;; PRINTER_BAD : ;; ;; MOV FTP.FTB_STATUS,STAT_BADATA ;the FDLEN_WORD should be 0. ;; PRINTER_DONE : ;; MOV AX,cs:ptr_sel_word ;; MOV FTP.FTB_SELECT,AX ;; MOV AX,cs:ptr_len_word ;; MOV FTP.FTB_SELLEN,AX ;; ;; SET_STAGE : ;; STAGE : MOV AX,cs:fdlen_word ;; if no font data to follow AND AX,AX ;; JNZ GET_FDATA ;; MOV cs:stage,SCANX ;; then scan for next header or font JMP FONT_RET ;; ;; GET_FDATA : ;; update the moving target MOV cs:stage,GET_FX ;; MOV AX,cs:pre_font_len ;; ADD FTP.TARGET_LO,AX ;; JNC FONT_RET ;; ADD FTP.TARGET_HI,01000H ;; ;; FONT_RET : ;; POP BX ;; RET ;; ;; ;=========================================================================== GETFONT_CASE : ;; as ES:[SI], at COUNT, there is font ;; data MOV DX,cs:num_ftb ;; PUSH BX ;; ;; MOV cs:hit_hi,0 ;; temp. register MOV cs:hit_flag,0 ;; assumed can be changed to SCAN stage ;; MOV DI,cs:count_hi ;; normalised COUNT_HI,COUNT_LO MOV AX,DI ;; AND AX,00FFFH ;; PUSH CX ;; MOV CX,4 ;; SHL AX,CL ;; POP CX ;; AND DI,0F000H ;; ADD AX,cs:count_lo ;; JNC NO_CARRY4 ;; ADD DI,01000H ;; NO_CARRY4 : ;; MOV cs:count_lo,AX ;; MOV cs:count_hi,DI ;; ;; ;; GETFONT_LOOP : ;; MOV AX,FTP.FTB_STATUS ;; CMP AX,FSTAT_FONT ;; JE GETFONT_CONT ;; ;; CMP AX,FSTAT_FOUND ;; JE GETFONT_FOUND ;; ;; JMP NEXT_GETFONT ;; ;; GETFONT_FOUND : ;; MOV AX,FTP.FTB_DLEFT ;; AND AX,AX ;; JZ NEXT_GF ;; MOV FTP.FTB_STATUS,FSTAT_FONT; JMP GETFONT_CONT1 ;; ;; ;; GETFONT_CONT : ;; MOV AX,FTP.FTB_DLEFT ;; AND AX,AX ;; JNZ GETFONT_CONT1 ;; NEXT_GF : ;; JMP NEXT_GETFONT ;; ;; only on FOUND and DLEFT <> 0 GETFONT_CONT1: ;; MOV DI,FTP.TARGET_HI ;; normalised TARGET MOV AX,DI ;; AND AX,00FFFH ;; PUSH CX ;; MOV CX,4 ;; SHL AX,CL ;; POP CX ;; AND DI,0F000H ;; ADD AX,FTP.TARGET_LO ;; JNC NO_CARRY5 ;; ADD DI,01000H ;; NO_CARRY5 : ;; DI:AX = TARGET (normalised) ;; CMP DI,cs:count_hi ;; JB GETFONT_BAD ;; JNE NEXT_GETFONT ;; CMP AX,cs:count_lo ;; JB GETFONT_BAD ;; JNE NEXT_GETFONT ;; ;; MOV FTP.FTB_DALO,SI ;; where the font data is in the packet MOV FTP.FTB_DAHI,DS ;; ;; MOV AX,FTP.FTB_DLEFT ;; CMP AX,CX ;; JAE UPTO_CX ;; ;; upto FDLEFT MOV FTP.FTB_DLEFT,0 ;; MOV FTP.FTB_DLEN,AX ;; CMP cs:hit_hi,AX ;; JNB NOT_HIGHER0 ;; MOV cs:hit_hi,AX ;; NOT_HIGHER0 : ;; ADD FTP.TARGET_LO,AX ;; JNC NEXT_GETFONT ;; ADD FTP.TARGET_HI,01000H ;; JMP NEXT_GETFONT ;; ;; GETFONT_BAD : ;; MOV FTP.FTB_STATUS,STAT_BADATA ;; pointing backwards JMP NEXT_GETFONT ;; ;; UPTO_CX : ;; SUB AX,CX ;; MOV FTP.FTB_DLEFT,AX ;; MOV FTP.FTB_DLEN,CX ;; MOV cs:hit_hi,CX ;; ADD FTP.TARGET_LO,CX ;; JNC NO_CARRYOVER ;; ADD FTP.TARGET_HI,01000H ;; NO_CARRYOVER : ;; AND AX,AX ;; all data have been returned ? JZ NEXT_GETFONT ;; ;; MOV cs:hit_flag,-1 ;; no ! stay in the GET_FONT stage ;; NEXT_GETFONT : ;; ADD BX,FTP.FTB_LENGTH ;; DEC DX ;; AND DX,DX ;; JZ GETFONT_END ;; JMP GETFONT_LOOP ;; ;; GETFONT_END : ;; MOV AX,cs:hit_hi ;; ADD SI,AX ;; SUB CX,AX ;; ;; CMP cs:hit_flag,0 ;; Jne GETFONT_DONE ;; MOV cs:stage,SCANX ;; no more in the GET_FONT stage ;; ;; GETFONT_DONE : ;; POP BX ;; JMP FTB_LOOP ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; STAGES -- "called by" SERACH_CASE ;; ;; -- DS:[SI] (FPKT) points to PACKET, of DOS's buffer ;; -- CX remaining packet length ;; -- ES:[BX] points to the first FTBLK ;; -- COUNT_LO, COUNT_HI, upto but not including the address pointed by FPKT ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;+++++++++++++++++++++++++++++++++ filetag : ;; ;; ; mov ax,ftag_len ;; cmp cs:ftag_count,ftag_len ;; jB valid_ftag ;; JE FTAG_FAILED ;; ;; mov ftp.ftb_status,stat_deverr mov cs:fp_error,00022H ;; ERROR 0022H ;; FTAG_FAILED : ;; discard all the bytes, while ADD SI,CX ;; stage stays as FTAGX SUB CX,CX ;; JMP FTB_LOOP ;; **** RETURN (bytes discarded) **** ;; VALID_FTAG : ;; MOV AX,FPKT ;; INC SI ;; DEC CX ;; ;; MOV DI,cs:ftag_count ;; CMP AL,cs:ftag_pattern[DI] ;; JE FTAG_NEXTB ;; ;; mov ftp.ftb_status,stat_badata MOV ax,ftag_len ;; stays in FTAGX to consume all bytes MOV cs:ftag_count,ax ;; stays in FTAGX to consume all bytes JMP FTB_LOOP ;; **** RETURN (FAILED !) **** ;; FTAG_NEXTB : ;; INC DI ;; MOV cs:ftag_count,DI ;; ;; CMP DI,ftag_len ;; JE FTAG_DONE ;; ;; JMP FTB_LOOP ;; **** RETURN ( MORE TO COME) **** ;; FTAG_DONE : ;; MOV cs:pass_cnt,0 ;; MOV cs:stage,PASSX ;; MOV cs:pass_postx,fptr_lolx ;; ;; JMP FTB_LOOP ;; **** NEXT STAGE **** ;; ;;+++++++++++++++++++++++++++++++++ fptrLOL : ;; STAGE the low byte of the low fptr MOV AX,FPKT ;; INC SI ;; byte by byte DEC CX ;; AND CX,CX ;; JNZ WORD_fptrLO ;; MOV cs:fptr_lol,AL ;; MOV cs:stage,fptr_lohX ;; JMP FTB_LOOP ;; WORD_fptrLO : ;; INC SI ;; DEC CX ;; MOV cs:fptr_low,AX ;; MOV cs:stage,fptr_HILX ;; JMP FTB_LOOP ;; ;;+++++++++++++++++++++++++++++++++ fptrLOH : ;; STAGE the high byte of the low fptr MOV AX,FPKT ;; INC SI ;; byte by byte DEC CX ;; MOV cs:fptr_loh,AL ;; MOV cs:stage,fptr_HILX ;; JMP FTB_LOOP ;; ;;+++++++++++++++++++++++++++++++++ fptrHIL : ;; STAGE the low byte of the high fptr MOV AX,FPKT ;; INC SI ;; byte by byte DEC CX ;; AND CX,CX ;; JNZ WORD_fptrHI ;; MOV cs:fptr_hil,AL ;; MOV cs:stage,fptr_hihX ;; JMP FTB_LOOP ;; WORD_fptrHI : ;; INC SI ;; DEC CX ;; MOV cs:fptr_high,AX ;; MOV cs:stage,FPTR_SKIPX ;; JMP FTB_LOOP ;; ;;+++++++++++++++++++++++++++++++++ fptrHIH : ;; STAGE the high byte of the high fptr MOV AX,FPKT ;; INC SI ;; byte by byte DEC CX ;; MOV cs:fptr_hih,AL ;; MOV cs:stage,FPTR_SKIPX ;; JMP FTB_LOOP ;; ;;+++++++++++++++++++++++++++++++++ ENTRYLO : ;; STAGE - ENTRY LOW BYTE MOV AX,FPKT ;; INC SI ;; byte by byte DEC CX ;; AND CX,CX ;; JNZ WORD_ENTRY ;; MOV cs:entry_lob,AL ;; MOV cs:stage,ENTRY_HIX ;; JMP FTB_LOOP ;; WORD_ENTRY : ;; INC SI ;; DEC CX ;; MOV cs:entry_word,AX ;; MOV cs:stage,PASSX ;; 2 bytes to be passed MOV cs:pass_postx,NEXT_LOLX ;; JMP FTB_LOOP ;; ;;+++++++++++++++++++++++++++++++++ ENTRYHI : ;; stage - ENTRY HIGN BYTE MOV AX,FPKT ;; INC SI ;; byte by byte DEC CX ;; MOV cs:entry_hib,AL ;; MOV cs:stage,PASSX ;; 2 bytes to be passed MOV cs:pass_postx,NEXT_LOLX ;; AND CX,CX ;; JNZ ENTHI_PASS1 ;; JMP FTB_LOOP ;; ENTHI_PASS1 : ;; INC SI ;; INC cs:pass_cnt ;; DEC CX ;; AND CX,CX ;; JNZ ENTHI_PASS2 ;; JMP FTB_LOOP ;; ENTHI_PASS2 : ;; INC SI ;; INC cs:pass_cnt ;; DEC CX ;; MOV cs:stage,NEXT_LOLX ;; JMP FTB_LOOP ;; ;;+++++++++++++++++++++++++++++++++ NEXTLOL : ;; STAGE the low byte of the low NEXT MOV AX,FPKT ;; INC SI ;; byte by byte DEC CX ;; AND CX,CX ;; JNZ WORD_NEXTLO ;; MOV cs:next_lol,AL ;; MOV cs:stage,NEXT_LOHX ;; JMP FTB_LOOP ;; WORD_NEXTLO : ;; INC SI ;; DEC CX ;; MOV cs:next_low,AX ;; MOV cs:stage,next_hilX ;; JMP FTB_LOOP ;; ;;+++++++++++++++++++++++++++++++++ NEXTLOH : ;; STAGE the high byte of the low NEXT MOV AX,FPKT ;; INC SI ;; byte by byte DEC CX ;; MOV cs:next_loh,AL ;; MOV cs:stage,next_hilX ;; JMP FTB_LOOP ;; ;;+++++++++++++++++++++++++++++++++ NEXTHIL : ;; STAGE the low byte of the high NEXT MOV AX,FPKT ;; INC SI ;; byte by byte DEC CX ;; AND CX,CX ;; JNZ WORD_NEXTHI ;; MOV cs:next_hil,AL ;; MOV cs:stage,NEXT_HIHX ;; JMP FTB_LOOP ;; WORD_NEXTHI : ;; INC SI ;; DEC CX ;; MOV cs:next_high,AX ;; MOV cs:stage,type_lobX ;; JMP FTB_LOOP ;; ;;+++++++++++++++++++++++++++++++++ NEXTHIH : ;; STAGE the high byte of the high NEXT MOV AX,FPKT ;; INC SI ;; byte by byte DEC CX ;; MOV cs:next_hih,AL ;; MOV cs:stage,type_lobX ;; JMP FTB_LOOP ;; ;;+++++++++++++++++++++++++++++++++ TYPELO : ;; STAGE the low byte of the TYPE MOV AX,FPKT ;; INC SI ;; byte by byte DEC CX ;; AND CX,CX ;; JNZ WORD_TYPE ;; MOV cs:type_lob,AL ;; MOV cs:stage,type_hibX ;; JMP FTB_LOOP ;; WORD_TYPE : ;; INC SI ;; DEC CX ;; MOV cs:type_word,AX ;; MOV cs:stage,type_idX ;; MOV cs:tid_cnt,0 ;; JMP FTB_LOOP ;; ;;+++++++++++++++++++++++++++++++++ TYPEHI : ;; STAGE the high byte of the TYPE MOV AX,FPKT ;; INC SI ;; byte by byte DEC CX ;; MOV cs:type_hib,AL ;; MOV cs:stage,TYPE_IDX ;; MOV cs:tid_cnt,0 ;; JMP FTB_LOOP ;; ;;+++++++++++++++++++++++++++++++++ TYPEIDS : ;; STAGE the type id CMP cs:tid_cnt,8 ;; JNA VALID_TID ;; MOV FTP.FTB_STATUS,STAT_DEVERR MOV cs:fp_error,00021H ;; ERROR 0021H ADD SI,CX ;; SUB CX,CX ;; JMP FTB_LOOP ;; ;; VALID_TID : ;; MOV AX,8 ;; SUB AX,cs:tid_cnt ;; CMP CX,AX ;; JNB TID_ALL ;; ;; all data in FPKT are stored PUSH ES ;; PUSH CS ;; POP ES ;; ;; MOV DI,OFFSET TYPE_ID ;; ADD DI,cs:tid_cnt ;; ADD cs:tid_cnt,CX ;; REP MOVSB ;; SI is incremented accordingly POP ES ;; ;; MOV CX,0 ;; STAGE remained JMP FTB_LOOP ;; TID_ALL : ;; PUSH CX ;; ;; PUSH ES ;; PUSH CS ;; POP ES ;; ;; MOV DI,OFFSET TYPE_ID ;; ADD DI,cs:tid_cnt ;; MOV CX,AX ;; REP MOVSB ;; SI is incremented accordingly POP ES ;; ;; ADD cs:tid_cnt,AX ;; POP CX ;; SUB CX,AX ;; ;; MOV cs:stage,CPG_LOBX ;; JMP FTB_LOOP ;; ;;+++++++++++++++++++++++++++++++++ CPGLO : ;; STAGE the low byte of the CODE PAGE MOV AX,FPKT ;; INC SI ;; byte by byte DEC CX ;; AND CX,CX ;; JNZ WORD_CPG ;; MOV cs:cpg_lob,AL ;; MOV cs:stage,CPG_HIBX ;; JMP FTB_LOOP ;; WORD_CPG : ;; INC SI ;; DEC CX ;; MOV cs:cpg_word,AX ;; MOV cs:stage,PASSX ;; MOV cs:pass_postx,font_lolX ;; JMP FTB_LOOP ;; ;;+++++++++++++++++++++++++++++++++ CPGHI : ;; STAGE the high byte of the CODE PAGE MOV AX,FPKT ;; INC SI ;; byte by byte DEC CX ;; MOV cs:cpg_hib,AL ;; MOV cs:stage,PASSX ;; MOV cs:pass_postx,font_lolX ;; JMP FTB_LOOP ;; ;;+++++++++++++++++++++++++++++++++ FONTLOL : ;; STAGE the low byte of the low FONT MOV AX,FPKT ;; INC SI ;; byte by byte DEC CX ;; AND CX,CX ;; JNZ WORD_FONTLO ;; MOV cs:font_lol,AL ;; MOV cs:stage,FONT_LOHX ;; JMP FTB_LOOP ;; WORD_FONTLO : ;; INC SI ;; DEC CX ;; MOV cs:font_low,AX ;; MOV cs:stage,FONT_HILX ;; JMP FTB_LOOP ;; ;;+++++++++++++++++++++++++++++++++ FONTLOH : ;; STAGE the high byte of the low FONT MOV AX,FPKT ;; INC SI ;; byte by byte DEC CX ;; MOV cs:font_loh,AL ;; MOV cs:stage,FONT_HILX ;; JMP FTB_LOOP ;; ;;+++++++++++++++++++++++++++++++++ FONTHIL : ;; STAGE the low byte of the high FONT MOV AX,FPKT ;; INC SI ;; byte by byte DEC CX ;; AND CX,CX ;; JNZ WORD_FONTHI ;; MOV cs:font_hil,AL ;; MOV cs:stage,FONT_HIHX ;; JMP FTB_LOOP ;; WORD_FONTHI : ;; INC SI ;; DEC CX ;; MOV cs:font_high,AX ;; ;;;;;; MOV cs:stage,MOD_LOBX ;; end of SCAN ;; anymore headers to be processed ? MOV cs:stage,MATCHX ;; MOV AX,cs:entry_word ;; DEC AX ;; MOV cs:entry_word,AX ;; AND AX,AX ;; JNZ CHECK_NEXT ;; ;; no more header to be processed ! MOV AX,-1 ;; MOV cs:next_low,AX ;; MOV cs:next_high,AX ;; as ENTRY has been consumed JMP FTB_LOOP ;; ;; CHECK_NEXT : ;; MOV AX,cs:next_low ;; AND AX,AX ;; JNZ MORE_HEADER ;; MOV AX,cs:next_high ;; AND AX,AX ;; JNZ MORE_HEADER ;; ;; no more header to be processed ! MOV AX,-1 ;; MOV cs:next_low,AX ;; as NEXT is nil MOV cs:next_high,AX ;; ;; MORE_HEADER : ;; JMP FTB_LOOP ;; ;;+++++++++++++++++++++++++++++++++ FONTHIH : ;; STAGE the high byte of the high FONT MOV AX,FPKT ;; INC SI ;; byte by byte DEC CX ;; MOV cs:font_hih,AL ;; ;;;;; MOV cs:stage,MOD_LOBX ;; end of SCAN ;; MOV cs:stage,MATCHX ;; ;; anymore headers to be processed ? MOV AX,cs:entry_word ;; DEC AX ;; MOV cs:entry_word,AX ;; AND AX,AX ;; JNZ CHECK_NEXT0 ;; ;; no more header to be processed ! MOV AX,-1 ;; MOV cs:next_low,AX ;; MOV cs:next_high,AX ;; as ENTRY has been consumed JMP FTB_LOOP ;; ;; CHECK_NEXT0 : ;; MOV AX,cs:next_low ;; AND AX,AX ;; JNZ MORE_HEADER0 ;; MOV AX,cs:next_high ;; AND AX,AX ;; JNZ MORE_HEADER0 ;; ;; no more header to be processed ! MOV AX,-1 ;; MOV cs:next_low,AX ;; as NEXT is nil MOV cs:next_high,AX ;; ;; MORE_HEADER0 : ;; JMP FTB_LOOP ;; ;; ;;+++++++++++++++++++++++++++++++++ MODLO : ;; STAGE the low byte of the MODIFIER MOV AX,FPKT ;; INC SI ;; byte by byte DEC CX ;; AND CX,CX ;; JNZ WORD_MOD ;; MOV MOD_LOB,AL ;; MOV cs:stage,MOD_HIBX ;; JMP FTB_LOOP ;; WORD_MOD : ;; INC SI ;; DEC CX ;; MOV cs:mod_word,AX ;; MOV cs:stage,fonts_lobX ;; JMP FTB_LOOP ;; ;;+++++++++++++++++++++++++++++++++ MODHI : ;; STAGE the high byte of the MODIFIER MOV AX,FPKT ;; INC SI ;; byte by byte DEC CX ;; MOV cs:mod_hib,AL ;; MOV cs:stage,FONTS_LOBX ;; JMP FTB_LOOP ;; ;;+++++++++++++++++++++++++++++++++ FONTSLO : ;; STAGE the low byte of the FONTS MOV AX,FPKT ;; INC SI ;; byte by byte DEC CX ;; AND CX,CX ;; JNZ WORD_FONTS ;; MOV cs:fonts_lob,AL ;; MOV cs:stage,FONTS_HIBX ;; JMP FTB_LOOP ;; WORD_FONTS : ;; INC SI ;; DEC CX ;; MOV cs:fonts_word,AX ;; MOV cs:stage,FDLEN_LOBX ;; JMP FTB_LOOP ;; ;;+++++++++++++++++++++++++++++++++ FONTSHI : ;; STAGE the high byte of the FONTS MOV AX,FPKT ;; INC SI ;; byte by byte DEC CX ;; MOV cs:fonts_hib,AL ;; MOV cs:stage,FDLEN_LOBX ;; JMP FTB_LOOP ;; ;;+++++++++++++++++++++++++++++++++ FDLENLO : ;; the low byte of the FONT-LENGTH MOV AX,FPKT ;; INC SI ;; byte by byte DEC CX ;; AND CX,CX ;; JNZ WORD_FDLEN ;; MOV cs:fdlen_lob,AL ;; MOV cs:stage,FDLEN_HIBX ;; JMP FTB_LOOP ;; WORD_FDLEN : ;; INC SI ;; DEC CX ;; MOV cs:pre_font_len,PRE_FONT_ND;; MOV cs:fdlen_word,AX ;; AND AX,AX ;; JZ NO_DISP_PTR ;; CMP cs:type_word,TYPE_DISPLAY ;; JE DISPLAY_TYPE1 ;; CMP cs:type_word,TYPE_PRINTER ;; JE PRINTER_TYPE1 ;; ;; NO_DISP_PTR : ;; MOV cs:stage,FOUNDX ;; FSTAT is to be changed JMP FTB_LOOP ;; DISPLAY_TYPE1 : ;; MOV cs:stage,DISP_ROWSX ;; JMP FTB_LOOP ;; PRINTER_TYPE1 : ;; MOV cs:stage,PTRSELLOX ;; JMP FTB_LOOP ;; ;; ;;+++++++++++++++++++++++++++++++++ FDLENHI : ;; STAGE the high byte of the F-LENGTH MOV cs:pre_font_len,PRE_FONT_ND MOV AX,FPKT ;; INC SI ;; byte by byte DEC CX ;; MOV cs:fdlen_hib,AL ;; MOV AX,cs:fdlen_word ;; AND AX,AX ;; JZ NO_DISP_PTR2 ;; CMP cs:type_word,TYPE_DISPLAY ;; JE DISPLAY_TYPE2 ;; CMP cs:type_word,TYPE_PRINTER ;; JE PRINTER_TYPE2 ;; NO_DISP_PTR2: ;; MOV cs:stage,FOUNDX ;; FSTAT is to be changed JMP FTB_LOOP ;; DISPLAY_TYPE2 : ;; MOV cs:stage,DISP_ROWSX ;; JMP FTB_LOOP ;; PRINTER_TYPE2 : ;; MOV cs:stage,PTRSELLOX ;; JMP FTB_LOOP ;; ;; ;;+++++++++++++++++++++++++++++++++ DSPROWS : ;; STAGE : get the rows XOR AX,AX ;; MOV cs:disp_rows,AL ;; MOV cs:disp_cols,AL ;; MOV cs:DISP_X,AL ;; MOV cs:disp_y,AL ;; MOV cs:count_word,AX ;; ;; INC cs:pre_font_len ;; MOV AX,FPKT ;; INC SI ;; DEC CX ;; MOV cs:disp_rows,AL ;; MOV AX,cs:fdlen_word ;; DEC AX ;; MOV cs:fdlen_word,AX ;; JZ NO_DISP_FONT3 ;; MOV cs:stage,disp_colsX ;; JMP FTB_LOOP ;; NO_DISP_FONT3 : ;; MOV cs:stage,FOUNDX ;; FSTAT is to be changed JMP FTB_LOOP ;; ;;+++++++++++++++++++++++++++++++++ DSPCOLS : ;; STAGE : get the COLS INC cs:pre_font_len ;; MOV AX,FPKT ;; INC SI ;; DEC CX ;; MOV cs:disp_cols,AL ;; MOV AX,cs:fdlen_word ;; DEC AX ;; MOV cs:fdlen_word,AX ;; JZ NO_DISP_FONT3 ;; MOV cs:stage,DISP_XX ;; JMP FTB_LOOP ;; ;;+++++++++++++++++++++++++++++++++ DSPX : ;; STAGE : get the aspect X INC cs:pre_font_len ;; MOV AX,FPKT ;; INC SI ;; DEC CX ;; MOV DISP_X,AL ;; MOV AX,cs:fdlen_word ;; DEC AX ;; MOV cs:fdlen_word,AX ;; JZ NO_DISP_FONT3 ;; MOV cs:stage,DISP_YX ;; JMP FTB_LOOP ;; ;;+++++++++++++++++++++++++++++++++ DSPY : ;; STAGE : get the aspect Y INC cs:pre_font_len ;; MOV AX,FPKT ;; INC SI ;; DEC CX ;; MOV cs:disp_y,AL ;; MOV AX,cs:fdlen_word ;; DEC AX ;; MOV cs:fdlen_word,AX ;; JZ NO_DISP_FONT3 ;; MOV cs:stage,COUNT_LOBX ;; JMP FTB_LOOP ;; ;; ;;+++++++++++++++++++++++++++++++++ DSPCOUNTLO : ;; the low byte of the FONT-LENGTH INC cs:pre_font_len ;; MOV AX,FPKT ;; INC SI ;; byte by byte DEC CX ;; PUSH AX ;; check if length is enough MOV AX,cs:fdlen_word ;; DEC AX ;; MOV cs:fdlen_word,AX ;; POP AX ;; JNZ A_WORD_COUNT ;; JMP NO_DISP_FONT3 ;; A_WORD_COUNT : ;; AND CX,CX ;; JNZ WORD_COUNT ;; MOV cs:count_lob,AL ;; MOV cs:stage,COUNT_HIBX ;; JMP FTB_LOOP ;; WORD_COUNT : ;; INC cs:pre_font_len ;; INC SI ;; DEC CX ;; MOV cs:count_word,AX ;; ; MOV cs:pre_font_len,PRE_FONT_D; ;; MOV AX,cs:fdlen_word ;; DEC AX ;; MOV cs:fdlen_word,AX ;; MOV cs:stage,FOUNDX ;; FSTAT is to be changed JMP FTB_LOOP ;; ;; ;;+++++++++++++++++++++++++++++++++ DSPCOUNTHI : ;; STAGE the high byte of the F-LENGTH INC cs:pre_font_len ;; MOV AX,FPKT ;; INC SI ;; byte by byte DEC CX ;; MOV cs:count_hib,AL ;; ; MOV cs:pre_font_len,PRE_FONT_D; ;; MOV AX,cs:fdlen_word ;; DEC AX ;; MOV cs:fdlen_word,AX ;; MOV cs:stage,FOUNDX ;; FSTAT is to be changed JMP FTB_LOOP ;; ;; ;; ;;+++++++++++++++++++++++++++++++++ PTRSELLO : ;; the low byte of the SELECTION_TYPE INC cs:pre_font_len ;; MOV AX,FPKT ;; INC SI ;; byte by byte DEC CX ;; PUSH AX ;; check if length is enough MOV AX,cs:fdlen_word ;; DEC AX ;; MOV cs:fdlen_word,AX ;; POP AX ;; JNZ A_WORD_SEL ;; JMP NO_PTR_FONT3 ;; A_WORD_SEL : ;; AND CX,CX ;; JNZ WORD_SEL ;; MOV cs:ptr_selob,AL ;; MOV cs:stage,PTRSELHIX ;; JMP FTB_LOOP ;; WORD_SEL : ;; INC cs:pre_font_len ;; INC SI ;; DEC CX ;; MOV cs:ptr_sel_word,AX ;; ;; MOV AX,cs:fdlen_word ;; DEC AX ;; MOV cs:fdlen_word,AX ;; ;; CMP cs:ptr_sel_word,0 ;; JNE PTR_SEL_NOT0 ;; ;; ;; MOV cs:stage,FOUNDX ;; FSTAT is to be changed JMP FTB_LOOP ;; ;; PTR_SEL_NOT0 : ;; MOV cs:stage,PTRLENLOX ;; JMP FTB_LOOP ;; ;; ;;+++++++++++++++++++++++++++++++++ PTRSELHI: ;; STAGE the high byte of SELECT_TYPE INC cs:pre_font_len ;; MOV AX,FPKT ;; INC SI ;; byte by byte DEC CX ;; MOV cs:ptr_sehib,AL ;; ;; MOV AX,cs:fdlen_word ;; DEC AX ;; MOV cs:fdlen_word,AX ;; ;; CMP cs:ptr_sel_word,0 ;; JNE PTR_SEL_NOT0 ;; ;; ;; MOV cs:stage,FOUNDX ;; FSTAT is to be changed JMP FTB_LOOP ;; ;; ;; ;;+++++++++++++++++++++++++++++++++ PTRLENLO : ;; the low byte of SELECTION_LENGTH INC cs:pre_font_len ;; MOV AX,FPKT ;; INC SI ;; byte by byte DEC CX ;; PUSH AX ;; check if length is enough MOV AX,cs:fdlen_word ;; DEC AX ;; MOV cs:fdlen_word,AX ;; POP AX ;; JNZ A_WORD_SELEN ;; JMP NO_PTR_FONT3 ;; A_WORD_SELEN : ;; AND CX,CX ;; JNZ WORD_SELEN ;; MOV cs:ptr_lnlob,AL ;; MOV cs:stage,PTRLENHIX ;; JMP FTB_LOOP ;; WORD_SELEN : ;; INC cs:pre_font_len ;; INC SI ;; DEC CX ;; MOV cs:ptr_len_word,AX ;; ;; MOV AX,cs:fdlen_word ;; DEC AX ;; MOV cs:fdlen_word,AX ;; MOV cs:stage,FOUNDX ;; FSTAT is to be changed JMP FTB_LOOP ;; ;; ;;+++++++++++++++++++++++++++++++++ PTRLENHI : ;; STAGE the high byte of SELECT_LENGTH INC cs:pre_font_len ;; MOV AX,FPKT ;; INC SI ;; byte by byte DEC CX ;; MOV cs:ptr_lnhib,AL ;; ;; MOV AX,cs:fdlen_word ;; DEC AX ;; MOV cs:fdlen_word,AX ;; MOV cs:stage,FOUNDX ;; FSTAT is to be changed JMP FTB_LOOP ;; ;; NO_PTR_FONT3 : ;; MOV cs:stage,FOUNDX ;; FSTAT is to be changed JMP FTB_LOOP ;; ;;+++++++++++++++++++++++++++++++++ PASS : ;; STAGE - PASS DUMMY BYTES ;; PUSH DX ;; PUSH ES ;; PUSH DI ;; ;; PUSH CS ;; POP ES ;; MOV DI,OFFSET PASS_BRK ;; MOV DX,PASS_INDX ;; MOV AX,cs:pass_cnt ;; ;; NEXT_BRK: ;; find the next pass-break CMP AX,ES:[DI] ;; ;; JB UPTO_BRK ;; ;; DEC DX ;; JZ PASS_ERR ;; INC DI ;; INC DI ;; JMP NEXT_BRK ;; ;; UPTO_BRK : ;; next break point found MOV DX,ES:[DI] ;; SUB DX,AX ;; bytes to be skipped CMP CX,DX ;; all to be skipped ? JAE PASS_ALL ;; ;; ADD cs:pass_cnt,CX ;; ADD SI,CX ;; SUB CX,CX ;; JMP PASS_END ;; ;; PASS_ALL : ;; ADD cs:pass_cnt,DX ;; ADD SI,DX ;; SUB CX,DX ;; ;; MOV AX,cs:pass_postx ;; MOV cs:stage,AX ;; ;; ; cmp ax,passx ;; is the next stage a pass-stage ? ; jne not_passx ;; ; mov ax,pass_postxx ;; ; mov pass_postx,ax ;; ; mov pass_postxx,stage_max ;; can support only 2 consecutive pass ;; ;not_passx : ;; ;; JMP PASS_END ;; ;; PASS_ERR : ;; DEVICE ERROR, wrong stage POP DI ;; POP ES ;; POP DX ;; MOV FTP.FTB_STATUS,STAT_DEVERR SUB CX,CX ;; ignore all the input string JMP PASS_DONE ;; ;; PASS_END : ;; POP DI ;; POP ES ;; POP DX ;; PASS_DONE : ;; JMP FTB_LOOP ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; FTB_LPEND : ;; ;; CMP cs:stage,FOUNDX ;; JNE NOT_FOUNDX ;; ;; CALL FOUND_DO ;; ;; NOT_FOUNDX : ;; ;; POP CX ;; STACK -1 ;; FP_RET : ;; POP SI ;; restore registers POP DI ;; POP DX ;; POP CX ;; POP BX ;; POP AX ;; POP ES ;; POP DS ;; ;; RET ;; FONT_PARSER ENDP ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; CSEG ENDS END 
;UNIVERSIDAD DE SAN CARLOS DE GUATEMALA ;FACULTAD DE INGENIERIA ;ARQUITECTURA DE COMPUTADORAS Y ENSAMBLADORES 1 ;PRACTICA 6 ;LESTER EFRAIN AJUCUM SANTOS ;201504510 ;====================================== MY MACROS ================================= %macro print 1 ;this macro will print to screen push ax push dx mov dx, %1 ;refers to the first parameter to the macro call mov ah, 09h ;09h function write string int 21h ;call the interruption pop dx pop ax %endmacro %macro printChar 1 ;this macro will print to screen push ax push dx push bx ;xor dx,dx mov bx,%1 mov dx, bx ;refers to the first parameter to the macro call ;xor ax,ax mov ah, 06h ;09h function write string int 21h ;call the interruption pop bx pop dx pop ax %endmacro %macro readInputChar 0 mov ah, 01h ;Return AL with the ASCII of the read char int 21h ;call the interruption %endmacro %macro fprint 3 ;macro to write in the file ;parameters: %1 data to write, %2 handle, %3 num bytes to write mov bh,[%2] ;copy the high order(8 bits more significant)of handle mov bl,[%2+1] ;copy the low order(8 bits less significant)of handle mov cx,%3 ;copy num of bytes to write mov dx,%1 ;copy the data to write mov ah,40h ;request write to file interruption int 21h ;call interruption %endmacro ;================================VIDEO MODE PROCEDURES ================================================= %macro setVideoMode 1 mov ah,00h mov al,%1 int 10h %endmacro %macro plotPixel 3 ;%1 color, %2 x ,%3 y ;x = x axis Plane (max 320 pixels) ______ x ;y = y axi Planes (max 200 pixels)| ; y| push ax push di push bx ;lexical maph.. ;P(x,y) = x + y(320) mov ax,%3 ;ax = %3 = Y (coordinate) mov bx, 140h ;140h = 320 decimal mul bx ;ax*di = y*320 ;dx ax = result add ax,%2 ;ax = %2 + y*320 mov di,ax mov es,word[vgaStartAddr] ;es ->extra segment =0a000h mov ax,%1 ;color of the pixel mov [es:di],ax pop bx pop di pop ax %endmacro %macro DrawArea 5 ;DRAW AN AREA IN VIDEO MODE 13H ;%1 , %2 , %3 , %4 , %5 ; x , y , width , height , color ;si , di , , %5 push cx push ax push si push di ;printChar %1 ;printChar %2 ;printChar %4 xor di,di mov di,%2 ;y coordinate mov cx,di ;di = Yindex starting at = y add cx,%4 ;bx = Yend = Ystart + height ;printChar %1 ;WARNING. NOTE 1 notebook: if a register is sent as parameter ;and then the same register is use whitin the macro ;the value of the parameter change ;mov [Height],cl ;printChar [Height] ;printChar 32 ;printChar di ;printChar cx %%Height: ;Y coordinate ;printChar di ;printChar cx cmp di,cx ;di = height ? -> Yindex = Yend ? je %%EndHeight ;printChar %1 mov si,%1 ;x coordinate mov ax,si ;si = Xindex starting at = x push cx mov cl,[%3] add ax,cx ;ax = Xend = Xstart + width pop cx %%Width: ;X coordinate cmp si,ax ;si = width ? -> Xindex = Xend ? je %%EndWidth plotPixel %5,si,di inc si ;x = x + 1 jmp %%Width %%EndWidth: inc di ;y = y + 1 jmp %%Height %%EndHeight: pop di pop si pop ax pop cx %endmacro %macro PlotChar 3 ; row, column, Hexanum Ascii Char ; %1 , %2 , %3 push ax push bx push cx mov al,%3 %%SearchChar: cmp al,41h je %%lA cmp al,42h je %%lB cmp al,43h je %%lC cmp al,44h je %%lD cmp al,45h je %%lE cmp al,46h je %%lF cmp al,47h je %%lG cmp al,48h je %%lH cmp al,49h je %%lI cmp al,4ah je %%lJ cmp al,4bh je %%lK cmp al,4ch je %%lL cmp al,4dh je %%lM cmp al,4eh je %%lN cmp al,4fh je %%lO cmp al,50h je %%lP cmp al,51h je %%lQ cmp al,52h je %%lR cmp al,53h je %%lS cmp al,54h je %%lT cmp al,55h je %%lU cmp al,56h je %%lV cmp al,57h je %%lW cmp al,58h je %%lX cmp al,59h je %%lY cmp al,5ah je %%lZ cmp al,30h je %%cero cmp al,31h je %%uno cmp al,32h je %%dos cmp al,33h je %%tres cmp al,34h je %%cuatro cmp al,35h je %%cinco cmp al,36h je %%seis cmp al,37h je %%siete cmp al,38h je %%ocho cmp al,39h je %%nueve cmp al,3ah je %%dospuntos jmp %%End %%lA: drawChar %1,%2,A jmp %%End %%lB: drawChar %1,%2,B jmp %%End %%lC: drawChar %1,%2,C jmp %%End %%lD: drawChar %1,%2,D jmp %%End %%lE: drawChar %1,%2,E jmp %%End %%lF: drawChar %1,%2,F jmp %%End %%lG: drawChar %1,%2,G jmp %%End %%lH: drawChar %1,%2,H jmp %%End %%lI: drawChar %1,%2,I jmp %%End %%lJ: drawChar %1,%2,J jmp %%End %%lK: drawChar %1,%2,K jmp %%End %%lL: drawChar %1,%2,L jmp %%End %%lM: drawChar %1,%2,M jmp %%End %%lN: drawChar %1,%2,N jmp %%End %%lO: drawChar %1,%2,O jmp %%End %%lP: drawChar %1,%2,P jmp %%End %%lQ: drawChar %1,%2,Q jmp %%End %%lR: drawChar %1,%2,R jmp %%End %%lS: drawChar %1,%2,S jmp %%End %%lT: drawChar %1,%2,T jmp %%End %%lU: drawChar %1,%2,U jmp %%End %%lV: drawChar %1,%2,V jmp %%End %%lW: drawChar %1,%2,W jmp %%End %%lX: drawChar %1,%2,X jmp %%End %%lY: drawChar %1,%2,Y jmp %%End %%lZ: drawChar %1,%2,Z jmp %%End %%cero: drawChar %1,%2,ZERO jmp %%End %%uno: drawChar %1,%2,ONE jmp %%End %%dos: drawChar %1,%2,TWO jmp %%End %%tres: drawChar %1,%2,THREE jmp %%End %%cuatro: drawChar %1,%2,FOUR jmp %%End %%cinco: drawChar %1,%2,FIVE jmp %%End %%seis: drawChar %1,%2,SIX jmp %%End %%siete: drawChar %1,%2,SEVEN jmp %%End %%ocho: drawChar %1,%2,EIGHT jmp %%End %%nueve: drawChar %1,%2,NINE jmp %%End %%dospuntos: drawChar %1,%2,COLON jmp %%End %%End: pop cx pop bx pop ax %endmacro %macro drawChar 3 ;DRAW A CHAR IN VIDEO MODE 13H ; row, column, bitArray ; %1 , %2 , %3 ; x , y , end x , end y ;si , di , cx= 4 , bx = 5 push cx push ax push bx push si push di mov bx,0h ;y coordinate = 0 mov di,bx ;di = Yindex starting at = y add bx,05h ;bx = Yend = Ystart + 5(height) %%Height: ;Y coordinate cmp di,bx ;di = height ? -> Yindex = Yend ? je %%EndHeight mov cx,0h ;x coordinate = 0 mov si,cx ;si = Xindex starting at = x add cx,04h ;ax = Xend = Xstart + (4)width %%Width: ;X coordinate cmp si,cx ;si = width ? -> Xindex = Xend ? je %%EndWidth ;LEXICAL MAP for matrix 5*4 -> vector 20 positions ;lexical map.. ;P(x,y) = x + y(4) mov ax,di ;ax = di = Y (coordinate) push di ;save y index mov di, 04h ;04h = 4 decimal mul di ;ax*di = y*4 ;dx ax = result add ax,si ;ax = si + y*4 mov di,ax ;di = ax mov ax,[%3+di] ;ax = bitArray[di] pop di ;di = restore yindex cmp al,0h ;bitArray[di] != 1 je %%PaintBlack ;push di ;push si ;push cx ;push bx ;mov al,%1 ;row ;mov dl,5 ;mul dl ;add di, ax ;mov al,[%2] ;col ;mov dl,4 ;mul dl ;add si,ax ;plotPixel 0fh,si,di ;plotPixel color,x,y ;pop bx ;pop cx ;pop si ;pop di ;jmp %%Next ;je %%Next ;if bitArray[di] = 0 don't paint push di ;save y index push si ;save x index add di,%1*5 ;di = yindex + row*5 push ax push bx mov ax,[%2] mov bl,4 mul bl add si,ax ;si = xindex + column*4 pop bx pop ax plotPixel 0fh,si,di ;plotPixel color,x,y ;%1 color, %2 x ,%3 y pop si ;si = restore yindex pop di ;di = restore xindex %%PaintBlack: ;push di ;push si ;push cx ;push bx ;mov al,%1 ;row ;mov dl,5 ;mul dl ;add di, ax ;mov al,[%2] ;col ;mov dl,4 ;mul dl ;add si,ax ;plotPixel 00h,si,di ;plotPixel color,x,y ;pop bx ;pop cx ;pop si ;pop di %%Next: inc si ;x = x + 1 jmp %%Width %%EndWidth: inc di ;y = y + 1 jmp %%Height %%EndHeight: pop di pop si pop bx pop ax pop cx %endmacro %macro printAt 3 ;PRINT A CHAR AT ROW,COL IN TEXT MODE 03H ; cursor x, cursor y , string ; column , line , data to write push ax push bx push dx ;mov ah,01h ;int 10h mov bh,00h ;Video page mov ch,01h mov cl,01h mov dh,%2 ;set cursor line mov dl,%1 ;set cursor column mov ah,03h int 10h mov dx, %3 ;offset addres of string mov ah, 09h ;request write string int 21h ;call interruption pop dx pop bx pop ax %endmacro %macro DrawBarGraph 2 ; arrayNumbers , sizeOfArray push ax push bx push dx push di xor ah,ah mov al,[%2] xor di,di mov di,00h mov bx,10 push ax mov ax,600 mov cl,[%2] div cl sub al,4 mov [Width],al pop ax ;printChar [%2] %%for: ;cmp di,[%2] ;printChar di ;printChar ax cmp di,ax je %%EndFor mov dl,[%1+di+1] ;%1 , %2 , %3 , %4 , %5 ; x , y , width , height , color mov cl,180 sub cl,dl sub cl,80 mov dl,cl DrawArea bx,11,Width,dx,00h ;paint black the complement of ;height of the bar push bx push ax ;push dx mov ax,bx mov bx,80 mul bx mov dx,00h mov bx,320 div bx mov [charCol],al ;mov dl,al ;printChar dx ;print blankSpace mov bh,[auxArray+di] mov bl,[auxArray+di+1] DecToAscii bx,numCharArray ;print numCharArray PlotChar 39,charCol,[numCharArray] mov al,[charCol] inc al mov [charCol],al PlotChar 39,charCol,[numCharArray+1] pop ax pop bx ;mov bh,[auxArray] ;mov bl,[auxArray+1] ;DecToAscii bx,numCharArray ;print numCharArray ;printChar [numCharArray] ;printChar [numCharArray+1] mov dl,[%1+di+1] mov cl,180 sub cl,dl add cl,11 sub cl,80 push ax mov al,cl cmp dx,21 jb %%Red cmp dx,41 jb %%Blue cmp dx,61 jb %%Yellow cmp dx,81 jb %%Green cmp dx,100 jb %%White ;DrawArea bx,ax,4,dx,02h ;bx = x start position,ax = y start position,dx = height of the bar,color %%Red: add dl,80 DrawArea bx,ax,Width,dx,04h ;bx = x start position,ax = y start position,dx = height of the bar,color jmp %%EndBar %%Blue: add dl,80 DrawArea bx,ax,Width,dx,01h ;bx = x start position,ax = y start position,dx = height of the bar,color jmp %%EndBar %%Yellow: add dl,80 DrawArea bx,ax,Width,dx,0eh ;bx = x start position,ax = y start position,dx = height of the bar,color jmp %%EndBar %%Green: add dl,80 DrawArea bx,ax,Width,dx,02h ;bx = x start position,ax = y start position,dx = height of the bar,color jmp %%EndBar %%White: add dl,80 DrawArea bx,ax,Width,dx,0fh ;bx = x start position,ax = y start position,dx = height of the bar,color jmp %%EndBar %%EndBar: pop ax inc di inc di ;add bx,12 push ax mov al,[Width] add bx,ax add bx,4 pop ax jmp %%for %%EndFor: pop di pop dx pop bx pop ax %endmacro %macro DrawLabels 0 %endmacro ;================================END VIDEO MODE PROCEDURES ============================================= ;== DELAY %macro Delay 1 ;%1 delay Time push si push di mov si,%1 %%lapse1: dec si jz %%EndDelay mov di,%1 %%lapse2: dec di jnz %%lapse2 jmp %%lapse1 %%EndDelay: pop di pop si %endmacro ;============================== REPORT PROCEDURE ======================================================== %macro CreateReport 0 ;Write in the Created File: fprint openRepTg,fileHandle,08h fprint opHeadTg,fileHandle,0dh ;Universidad De San Carlos.. fprint opUTg,fileHandle,0dh fprint unLb,fileHandle,26h fprint clUTg,fileHandle,0fh ;Facultad De Ingenieria... fprint opFacTg,fileHandle,0ah fprint facLb,fileHandle,16h fprint clFacTg,fileHandle,0ch ;Ciencias y Sistemas fprint opSchTg,fileHandle,09h fprint schLb,fileHandle,13h fprint clSchTg,fileHandle,0bh ;<Curso> fprint opCrsTg,fileHandle,08h ;Arquitectura De Computadores... fprint opNmTg,fileHandle,08h fprint crLb,fileHandle,2eh fprint clNmTg,fileHandle,0ah ;Seccion... fprint opSnTg,fileHandle,09h fprint snLb,fileHandle,09h fprint clSnTg,fileHandle,0bh fprint clCrsTg,fileHandle,09h ;</Curso> ;<Ciclo> fprint opCiTg,fileHandle,07h fprint ciLb,fileHandle,14h fprint clCiTg,fileHandle,09h ;</Ciclo> ;fecha...... ;<Fecha> fprint opDtTg,fileHandle,08h ;Dia..... fprint opDdTg,fileHandle,05h fprint clDdTg,fileHandle,07h ;Mes....... fprint opMmTg,fileHandle,05h fprint clMmTg,fileHandle,07h ;Año.... fprint opYyTg,fileHandle,06h fprint clYyTg,fileHandle,08h fprint clDtTg,fileHandle,09h ;</Fecha> ;Hora....... ;<Hora> fprint opTcTg,fileHandle,07h ;Hora..... fprint opHrTg,fileHandle,06h fprint clHrTg,fileHandle,08h ;Minutos... fprint opMnTg,fileHandle,09h fprint clMnTg,fileHandle,0bh ;Segundos... fprint opScTg,fileHandle,0ah fprint clScTg,fileHandle,0ch fprint clTcTg,fileHandle,08h ;</Hora> ;Alumno...... ;<Alumno> fprint opStTg,fileHandle,09h ;Nombre.... fprint opNmTg,fileHandle,08h fprint stLb,fileHandle,1bh fprint clNmTg,fileHandle,0ah ;Carnet.... fprint opIdTg,fileHandle,08h fprint idLb,fileHandle,09h fprint clIdTg,fileHandle,0ah fprint clStTg,fileHandle,0ah ;</Alumno> ;</Encabezado> fprint clHeadTg,fileHandle,0eh ;------ Resultados ----------- ;Resultados..... ;<Resultados> fprint opRsTg,fileHandle,0dh ;ListaEntrada...... fprint opLeTg,fileHandle,0fh fprint clLeTg,fileHandle,11h ;BubbleSort... ;<Ordenamiento_BubbleSort> fprint opBsTg,fileHandle,1ah ;Tipo.... fprint opTyTg,fileHandle,06h fprint clTyTg,fileHandle,08h ;ListaOrdenada fprint opLsTg,fileHandle,10h fprint clLsTg,fileHandle,12h ;Velocidad.... fprint opSpTg,fileHandle,0bh fprint clSpTg,fileHandle,0dh ;Tiempo.... ;<Tiempo> fprint opTmTg,fileHandle,09h ;Minutos.... fprint opMnTg,fileHandle,09h fprint clMnTg,fileHandle,0bh ;Segundos... fprint opScTg,fileHandle,0ah fprint clScTg,fileHandle,0ch ;Milisegundos.. fprint opMsTg,fileHandle,0eh fprint clMsTg,fileHandle,10h ;</Tiempo> fprint clTmTg,fileHandle,0ah ;</Ordenamiento_BubbleSort> fprint clBsTg,fileHandle,1bh ;QuickSort.... ;<Ordenamiento_QuickSort> fprint opQsTg,fileHandle,19h ;Tipo.... fprint opTyTg,fileHandle,06h fprint clTyTg,fileHandle,08h ;ListaOrdenada fprint opLsTg,fileHandle,10h fprint clLsTg,fileHandle,12h ;Velocidad.... fprint opSpTg,fileHandle,0bh fprint clSpTg,fileHandle,0dh ;Tiempo.... ;<Tiempo> fprint opTmTg,fileHandle,09h ;Minutos.... fprint opMnTg,fileHandle,09h fprint clMnTg,fileHandle,0bh ;Segundos... fprint opScTg,fileHandle,0ah fprint clScTg,fileHandle,0ch ;Milisegundos.. fprint opMsTg,fileHandle,0eh fprint clMsTg,fileHandle,10h ;</Tiempo> fprint clTmTg,fileHandle,0ah ;</Ordenamiento_QuickSort> fprint clQsTg,fileHandle,1ah ;ShellSort... ;<Ordenamiento_ShellSort> fprint opSsTg,fileHandle,19h ;Tipo.... fprint opTyTg,fileHandle,06h fprint clTyTg,fileHandle,08h ;ListaOrdenada fprint opLsTg,fileHandle,10h fprint clLsTg,fileHandle,12h ;Velocidad.... fprint opSpTg,fileHandle,0bh fprint clSpTg,fileHandle,0dh ;Tiempo.... ;<Tiempo> fprint opTmTg,fileHandle,09h ;Minutos.... fprint opMnTg,fileHandle,09h fprint clMnTg,fileHandle,0bh ;Segundos... fprint opScTg,fileHandle,0ah fprint clScTg,fileHandle,0ch ;Milisegundos.. fprint opMsTg,fileHandle,0eh fprint clMsTg,fileHandle,10h ;</Tiempo> fprint clTmTg,fileHandle,0ah ;</Ordenamiento_ShellSort> fprint clSsTg,fileHandle,1ah ;</Resultados> fprint clRsTg,fileHandle,0eh ;</Arqui> fprint closeRepTg,fileHandle,08h ;close te file closeFile fileHandle %endmacro ;==============================FILE PROCEDURES=========================================================== %macro openFile 1 mov al, 0h ;access mode (000b = 0h only read) mov dx, %1 ;offset of ascii file name mov ah, 3dh ;request open File interruption int 21h ;call interruption 21h %endmacro %macro readFile 2 mov bx, %1 ;handle mov cx, 400h ;bytes to read UPDATE: may give an error ;if smaller than the bytes in the input file mov dx, %2 mov ah, 3fh ;request reading interruption int 21h %endmacro %macro CreateFile 2 ;parameters %1 ASCIZ filename,%2 handleArray mov cx,00h ;file attribute 00h = normal file or maybe read only mov dx,%1 ;dx = ASCIZ filename mov ah,3ch ;request create file int 21h jc errorCreateFile ;Saving Handle after file created AX = Handle mov [%2],ah mov [%2+1],al print createFileMsg CreateReport %endmacro %macro closeFile 1 mov bh,[%1] ;copy the high order(8 bits more significant)of handle mov bl,[%1+1] ;copy the low order(8 bits less significant)of handle mov ah,3eh ;request close file interruption int 21h ;call 21h interruption %endmacro ;=============================END FILE PROCEDURES====================================== %macro GetTag 1 ;due to procedure getStringOp both use di register. But getStringOp has to keep a sequence ;of the last element add to array opNamesArray we push the index di to the stack ;so that we can use di free to get a string in this procedure getString after the ;procedure ends we restore de past di value push di xor di,di mov di,00h mov al,0h ;state = 0 %%dfa: mov dh, [fileReadBf + si] ;get a character from the file buffer cmp al, 0h ;al = 0 state = 0 je %%So cmp al, 01h ;al = 1 state = 1 je %%S1 %%So: ;STATE = 0 cmp dh, 3ch ;dh = left < jne errorInFile ;if not equal to " then go to error IN File mov [%1+di],dh ;add the first les than <.. mov al,01h ;al = 1 state = 1 jmp %%transition ;jump to transition %%S1: ;STATE = 1 cmp dh, 09h ;dh = 09 (ascii tab) je %%concatenate cmp dh, 20h ;dh < 20 (ascii space) jl errorInFile cmp dh, 7eh ;dh > 7e (ascii ~) jg errorInFile jmp %%concatenate ;either case is a valid char concatenate %%concatenate: inc di mov [%1+di],dh ;add a char after "char.. cmp dh, 3eh ;dh = right > (ascii 3eh) je %%EndString ;go to EndString mov al,01h ;al = 1 state = 1 jmp %%transition %%transition: inc si ;increment to next char jmp %%dfa ;go back to dfa again like an automata %%EndString: inc di mov dh, '$' mov [%1+di],dh pop di %endmacro %macro parea 1 %%CompareChar: mov dh, [fileReadBf + si] ;get a character from the file buffer printChar dh ;printChar %1 cmp dh, 20h ;dh = blankSpace je %%WhiteSpace cmp dh, 9h ;dh = horizontal tab je %%WhiteSpace cmp dh, 0dh ;dh = carriage return CR je %%WhiteSpace cmp dh, 0ah ;dh = carriage return CR je %%WhiteSpace jmp %%TokenChar %%WhiteSpace: inc si ;do nothing just increment in one char jmp %%CompareChar ;jump to CompareChar %%TokenChar: cmp dh,%1 ;compare it with the parameter je %%GetNextChar ;if are equal jmp to GetNextChar jmp errorInFile %%GetNextChar: inc si %endmacro %macro GetNextToken 1 %%CompareChar: mov dh, [fileReadBf + si] ;get a character from the file buffer ;printChar dh ;printChar %1 cmp dh, 20h ;dh = blankSpace je %%WhiteSpace cmp dh, 9h ;dh = horizontal tab je %%WhiteSpace cmp dh, 0dh ;dh = carriage return CR je %%WhiteSpace cmp dh, 0ah ;dh = carriage return CR je %%WhiteSpace jmp %%TokenChar %%WhiteSpace: inc si ;do nothing just increment in one char jmp %%CompareChar ;jump to CompareChar %%TokenChar: cmp dh,%1 ;compare it with the parameter je %%TokenFound ;if are equal jmp to GetNextChar %%TokenFound: inc si %endmacro %macro GetData 0 ;-----------------------------START::=openDocTag LISTOFCHILDS closeDocTag %%StartTag: xor di,di xor si,si mov si,00h ;index for fileReadBf mov di,00h ;index for numArray GetNextToken 3ch ;send character = < (Ascii 3ch) dec si GetTag currentTag ;retrieve the tag < "anything" > print currentTag ;print newline print openTag CmpString currentTag,openTag,09h ;if currentTag = <Numeros> cmp al, 01h ;flag al = 1 (open tag found = true ) jne errorXmlTag ;erro no start tag found <Numeros> inc si ;si + 1 (Next Character) ;---------------------------CHILD::=openTgChild num=<Numero>..</Numero> closeTgChild ; | GetNextToken 3ch ;send character = < (Ascii 3eh) dec si GetTag currentTag ;retrieve the tag < "anything" > print currentTag CmpString currentTag,openTgChild,09h ;if currentTag = <Numero> cmp al,01h ;flag al = 1 (open tag found = true ) jne %%EmptyList ;if not equal jump to EmptyList just the firsTime ;if equal continue to.. TheChilds ;---------------------------LISTOFCHILDS::=LISTCHILDS CHILD ; |CHILD %%TheChilds: GetChild ;Macro Get Childs list of numbers inc si GetNextToken 3ch ;send character = < (Ascii 3eh) dec si GetTag currentTag ;retrieve the tag < "anything" > print currentTag CmpString currentTag,openTgChild,09h ;if currentTag = <Numero> cmp al,01h ;flag al = 1 (open tag found = true ) je %%TheChilds ;jump to The Childs jmp %%EndTag ;No more numbers got to end tag %%EmptyList: print errEmptyListMsg ;print the list is empty %%EndTag: print currentTag print closeTag CmpString currentTag,closeTag,08h ;if currentTag = </Numeros> end tag of xml doc cmp al,01h ;flag al = 1 (open tag found = true ) jne errorXmlTag ;if not equal ->error close tag not found ;--------------------------- GET LENGTH OF ITEMS IN numArray -------------------------- mov ax, di ;copy to ax the array index DI = count of items in array ;use ax because dividend is assumed to be in Ax register ;mov bh,02h ;8 bit divisor ;(decimal num 2 due to each number ;fill 2 byte space in numArray) Eg: 10(byte space)/2 = 5 numbers ;div bh ;div divisor mov [sizeArray],al ; al = quotient ah = remainder ;sizeArray = number of items in array print analysisMsg %endmacro %macro GetChild 0 ;last si value = <Numero>num inc si ;inc si = num %%GetNum: mov dl, [fileReadBf+si+1] ; cmp dl,3ch ;dl = < (Ascii 3ch) je %%GetDigit1 ;is 1 digit number mov dl,[fileReadBf+si+2] cmp dl,3ch ;dl = < (Ascii 3ch) je %%GetDigit2 ;is 2 digit number mov dh, [fileReadBf+si] ;save the current character to print as an error jmp errorInFile ;jump to error file. expected a number %%GetDigit1: mov dl, [fileReadBf+si] ;first digit xor dh,dh ;clean dh = 0 sub dx,30h ;subtract 30h('0') to convert to decimal mov [numArray+di],dh ;copy the high order(8 bits more significant)before mov [numArray+di+1],dl ;copy the low order(8 bits less significant)after add di,02h ;increment DI by 2, de high and low part of number add si,01h ;increment SI by 1, 1 digit number jmp %%EndTag %%GetDigit2: mov al, [fileReadBf+si] ;first digit is the ten(10^1) ;use al register due to MUL instruction xor ah,ah ;clean ah = 0 sub ax,30h ;subtract 30h('0') to convert to decimal mov bl, [fileReadBf+si+1] ;second digit is the unity(10^0) xor bh,bh ;clean bh = 0 sub bx,30h ;subtract 30h('0') to convert to decimal mov cx,0ah ;prepare multiplier (cx= 0ah = 10) mul cx ;multiply(al*cx = Digit1*10^1 = ten = ah al) add ax,bx ;sum ax and bx = ten + unity = digit1*(10^1) + digit2*(10^0) mov [numArray+di],ah ;copy the high order(8 bits more significant)before mov [numArray+di+1],al ;copy the low order(8 bits less significant)after add di,02h ;increment DI by 2, de high and low part of number add si,02h ;increment SI by 2, 2 digit number jmp %%EndTag %%EndTag: GetNextToken 3ch ;send character = < (Ascii 3eh) dec si GetTag currentTag print currentTag print closeTgChild CmpString currentTag,closeTgChild,09h ;if currentTag = </Numero> cmp al,01h ;flag al = 1 (open tag found = true ) jne errorXmlTag ;jne errorPathInput %endmacro %macro CmpString 3 push si ;push SI to save its current value and been able ;to use SI without loose the previous value push di ;push DI to save its current value and been able ;to use DI without loose the previous value push cx mov si,%1 ;first param = string 1 mov di,%2 ;second param = string 2 mov ch,0h cld mov cl,%3 ;third param = length of string comparation ;print reportName repe cmpsb jne %%NoEqual ;jump when ecx is zero print strEqualMsg mov al,01h ;flag al = 01 = equal , jmp %%exit %%NoEqual: dec si dec di print strNoEqualMsg mov al,0h ;flag al = 00 = equal , %%exit: pop cx pop di ;pop out DI previous value pop si ;pop out SI previous value %endmacro %macro CopyArray 3 ;1 size 2 name copy array, 3 actual array ;print %1 ;mov al,00h ;mov ah,00h xor al,al ;clean al xor ah,ah ;clean ah mov di,00h ;di = 0 mov al,[%1] ;al = sizeArray %%for: mov cl,[%3+di] ;cl = actualArray[di] mov [%2+di],cl ;copyArray[di] = cl inc di ;di = di + 1 cmp di,ax ;di = ax ? jne %%for ; di != ax jmp For %endmacro %macro DecToAscii 2 ;%1 number, %2 charArray ;to convert a decimal number of the form: 234.. ;divide decimalnum/10 ;keep dividing quotient/10 till quotient is zero ;using div for 16bit division = dx ax/16 bit divisor ;ax(quotient) dx(remainder) push ax push bx push dx push cx push si push di ;---------counter of positions --------------------------- mov ax,%1 ;save the number to convert in ax register push ax mov bx,0ah ;save dividend in bx = 0ah = 10 xor di,di ;clean di %%counter: xor dx,dx ;clean dx div bx ;divide by 10 inc di ;increment to save in the next position (count how many digits) cmp ax,0h ;if ax(quotient) = 0 stop jne %%counter ;if not continue.. ;end of counter dec di ;start saving at lenght - 1 ;----------- Convert Decimal to Ascii ---------------------- pop ax xor si,si ;clean SI %%while: xor dx,dx ;clean dx div bx ;divide by 10 add dx,30h ;add 30h('0') to remainder to convert to Ascii mov [%2+di],dl ;save 8 lsb bits in numCharArray backwards dec di ;decrement di till get to zero inc si ;increment to save in the next position cmp ax,0h ;if ax(quotient) = 0 stop jne %%while ;if not continue.. mov al,'$' mov [%2+si],al ;save end of string in las postino of array pop di pop si pop cx pop dx pop bx pop ax %endmacro ;-------------------------------------- SORT FUNCTIONS ---------------------------- %macro BubbleSort 2 ; 1 Array to sort,2 size push ax push bx push cx push si push di xor al,al xor ah,ah ;clean ah = 0 xor cx,cx mov di,00h ;i = 0 mov si,00h ;j = 0 mov al,[%2] ;length ;mov cx,02h ;mul cx %%for1: ;print mytest mov si,00h ;j = 0 cmp di,ax ; if di = ax ; i = length je %%EndSort ;if i = length -> then EndSort ;if not continue... add di,02h ; di = di + 2 -> i = i + 1 %%for2: ;add si,02h ; si = si + 2 -> j = j + 1 cmp si,ax ; if j = length - 1 ;cmp si,08h je %%for1 ; then jump back to for1 ;if not equal ;---------------- auxArray[j] = bx ---------------------------------------- mov bh, [%1+si] ;copy the high order(8 bits more significant)before mov bl, [%1+si+1] ;copy the low order(8 bits less significant)after ;---------------- auxArray[j+1] = cx ---------------------------------------- mov ch, [%1+si+2] ;copy the high order(8 bits more significant)before mov cl, [%1+si+3] ;copy the low order(8 bits less significant)after ;---------------- if(auxArray[j] > auxArray[j+1]) --------------------------- cmp bx,cx jg %%Swap ;if true then swap add si,02h ;if not si + 2 -> j + 1 jmp %%for2 %%Swap: mov [%1+si],ch mov [%1+si+1],cl mov [%1+si+2],bh mov [%1+si+3],bl add si,02h DrawBarGraph auxArray,sizeArray Delay 5 jmp %%for2 %%EndSort: pop di pop si pop cx pop bx pop ax %endmacro %macro BubbleSortDesc 2 ; 1 Array to sort,2 size push ax push bx push cx push si push di xor al,al xor ah,ah ;clean ah = 0 xor cx,cx mov di,00h ;i = 0 mov si,00h ;j = 0 mov al,[%2] ;length mov cl,[%2] sub cl,2 ;mov al,4 ;mov cl,2 %%for1: cmp di,ax ;di = length je %%EndSort mov si,00h %%for2: cmp si,cx ;si = length - 1 je %%EndFor2 push cx ;---------------- auxArray[j] = bx ---------------------------------------- mov bh, [%1+si] ;copy the high order(8 bits more significant)before mov bl, [%1+si+1] ;copy the low order(8 bits less significant)after ;---------------- auxArray[j+1] = cx ---------------------------------------- mov ch, [%1+si+2] ;copy the high order(8 bits more significant)before mov cl, [%1+si+3] ;copy the low order(8 bits less significant)after ;---------------- if(auxArray[j] > auxArray[j+1]) --------------------------- cmp bx,cx jl %%Swap jmp %%IncFor2 %%Swap: ;printChar bx ;printChar si ;printChar 31h mov [%1+si],ch mov [%1+si+1],cl mov [%1+si+2],bh mov [%1+si+3],bl pop cx %%IncFor2: ;add si,02h inc si inc si jmp %%for2 DrawBarGraph auxArray,sizeArray Delay 8 %%EndFor2: add di,02h ;inc di ;si = si + 2 jmp %%for1 %%EndSort: pop di pop si pop cx pop bx pop ax %endmacro %macro BubbleSortDec 2 ; 1 Array to sort,2 size push ax push bx push cx push si push di xor al,al xor ah,ah ;clean ah = 0 xor cx,cx mov di,00h ;i = 0 mov si,00h ;j = 0 mov al,[%2] ;length ;mov cx,02h ;mul cx %%for1: ;print mytest mov si,00h ;j = 0 cmp di,ax ; if di = ax ; i = length je %%EndSort ;if i = length -> then EndSort ;if not continue... add di,02h ; di = di + 2 -> i = i + 1 %%for2: ;add si,02h ; si = si + 2 -> j = j + 1 cmp si,ax ; if j = length - 1 ;cmp si,08h je %%for1 ; then jump back to for1 ;if not equal ;---------------- auxArray[j] = bx ---------------------------------------- mov bh, [%1+si] ;copy the high order(8 bits more significant)before mov bl, [%1+si+1] ;copy the low order(8 bits less significant)after ;---------------- auxArray[j+1] = cx ---------------------------------------- mov ch, [%1+si+2] ;copy the high order(8 bits more significant)before mov cl, [%1+si+3] ;copy the low order(8 bits less significant)after ;---------------- if(auxArray[j] > auxArray[j+1]) --------------------------- cmp bx,cx jb %%Swap ;if true then swap add si,02h ;if not si + 2 -> j + 1 jmp %%for2 %%Swap: mov [%1+si],ch mov [%1+si+1],cl mov [%1+si+2],bh mov [%1+si+3],bl add si,02h DrawBarGraph auxArray,sizeArray Delay 5 jmp %%for2 %%EndSort: pop di pop si pop cx pop bx pop ax %endmacro ;=========================================END SORT FUNCTIONS =============================== ;************************************** END MY MACROS ***************************** global Main ;========================== SECTION .DATA ==================== segment .data vgaStartAddr dw 0A000h ;start positon of vga memory ;0a0000h - bffffh headerLabel db 13,13,10 db 'UNIVERSIDAD DE SAN CARLOS DE GUATEMALA',13,10 db 'FACULTAD DE INGENIERIA ',13,10 db 'CIENCIAS Y SISTEMAS',13,10 db 'ARQUITECTURA DE COMPUTADORAS Y ENSAMBLADORES 1',13,10 db 'NOMBRE: LESTER EFRAIN AJUCUM SANTOS',13,10 db 'CARNET: 201504510',13,10 db 'SECCION: A',13,10 db 'PRACTICA 6',13,10,'$' mainMenu db '', 13, 10 db ' _________________________', 13, 10 db '|_________ MENU __________|', 13, 10 db '| 1. Cargar Archivo |', 13, 10 db '| 2. Ordenar |', 13, 10 db '| 3. Salir |', 13, 10 db '| 4. Generar Reporte |', 13, 10 db '|_________________________|',13,10,'$' sortMenu db '', 13, 10 db ' _________________________', 13, 10 db '|_________ MENU __________|', 13, 10 db '| 1. Bubble Sort |', 13, 10 db '| 2. Quick Sort |', 13, 10 db '| 3. Shell Sort |', 13, 10 db '| 4. Regresar |', 13, 10 db '|_________________________|',13,10,'$' loadFileLabel db '=============== CARGAR ARCHIVO ===============',13,10,'$' inputPathLabel db 'Ingrese Ruta: ','$' optionLabel db 'Escoja Opcion: ','$' sortLabel db 'Ordenamiento: ','$' bubbleLabel db 'BubbleSort','$' errPathMsg db 13,10,'Error ruta archivo Intente de nuevo',13,10,'$' errOpenMsg db 13,10,'Error No se puedo Abrir el Archivo',13,10,'$' openFileMsg db 13,10,'Archivo Abierto correctamente',13,10,'$' readFileMsg db 13,10,'Archivo Leido correctamente',13,10,'$' createFileMsg db 13,10,'Archivo Creado correctamente',13,10,'$' errReadFileMsg db 13,10,'Error No se puedo Leer el Archivo',13,10,'$' errCreateFileMsg db 13,10,'Error No se puedo Crear el Archivo',13,10,'$' errSintMsg db 13,10,'Error Caracter no esperado: ','$' ;29 characters errTagMsg db 13,10,'Error etiqueta no esperada','$' ;29 characters errEmptyListMsg db 13,10,'La lista de numeros esta vacia','$' ;29 characters analysisMsg db 13,10,'Analisis realizado correctamente',13,10,'$' bubbleSortMsg db 13,10,'Ordenamiento Burbuja: ',13,10,'$' beforeSortMsg db 13,10,'Antes De Ordenamiento: ',13,10,'$' afterSortMsg db 13,10,'Despues De Ordenamiento: ',13,10,'$' newline db 13,10,'$' blankSpace db 20h,'$' esUno db 0ah,0dh,'es uno',10,'$' esDos db 0ah,0dh,'es dos',10,'$' esTres db 0ah,0dh,'es tres',10,'$' filePath db 50 fileReadBf times 600 db '$' numArray times 100 db '$' sizeArray db 2,'$' Height db 2,'$' Width db 4,'$' charCol db 1,'$' charRow db 1,'$' auxArray times 100 db '$' numCharArray times 10 db '$' arrayTest db 1,'$' arrayTest2 db 1,'$' openTag db '<Numeros>','$' closeTag db '</Numeros>','$' lenTag equ 10 openTgChild db '<Numero>','$' closeTgChild db '</Numero>','$' mytest db '<Numero>','$' currentTag times 10 db '$' ;array to save A tag <Numeros>,</Numeros> ;<Numero>,</Numero> strEqualMsg db 13,10,'Strings son iguales',13,10,'$' strNoEqualMsg db 13,10,'Strings No son iguales',13,10,'$' ;Report Text ________________________________ reportName db 'reporte.xml',0,'$' ;ASCIZ filename fileHandle db 0 ;array to save handle of newfile db '$' unLb db 'Universidad De San Carlos De Guatemala' ;38 bytes facLb db 'Facultad De Ingenieria' ;22 bytes schLb db 'Ciencias Y Sistemas' ;19 bytes crLb db 'Arquitectura De Computadoras Y Ensambladores 1' ;46 bytes snLb db 'Seccion A' ; 9 bytes ciLb db 'Primer Semestre 2019' ;20 bytes stLb db 'Lester Efrain Ajucum Santos' ;27 bytes idLb db '201504510' ; 9 bytes srALb db 'Ascendente' ;10 bytes srDLb db 'Descendete' ;10 bytes openRepTg db '<Arqui>' ,10 ;Open Tag for Report (8 bytes) closeRepTg db '</Arqui>',10 ;Close Tag for Report (8 bytes) opHeadTg db '<Encabezado>',10 ;Open Tag for Header (13 bytes) clHeadTg db '</Encabezado>',10 ;Close Tag for Header (14 bytes) opUTg db '<Universidad>' ;Open Tag (13 bytes) clUTg db '</Universidad>',10 ;Close Tag (15 bytes) opFacTg db '<Facultad>' ;Open Tag (10 bytes) clFacTg db '</Facultad>',10 ;Close Tag (12 bytes) opSchTg db '<Escuela>' ;Open Tag (9 bytes) clSchTg db '</Escuela>',10 ;Close Tag (11 bytes) opCrsTg db '<Curso>',10 ;Open Tag (8 bytes) clCrsTg db '</Curso>',10 ;Close Tag (9 bytes) opNmTg db '<Nombre>' ;Open Tag (8 bytes) clNmTg db '</Nombre>',10 ;Close Tag (10 bytes) opSnTg db '<Seccion>' ;Open Tag (9 bytes) clSnTg db '</Seccion>',10 ;Close Tag (11 bytes) opCiTg db '<Ciclo>' ;Open Tag (7 bytes) clCiTg db '</Ciclo>',10 ;Close Tag (9 bytes) opDtTg db '<Fecha>',10 ;Open Tag (8 bytes) clDtTg db '</Fecha>',10 ;Close Tag (9 bytes) opDdTg db '<Dia>' ;Open Tag (5 bytes) clDdTg db '</Dia>',10 ;Close Tag (7 bytes) opMmTg db '<Mes>' ;Open Tag (5 bytes) clMmTg db '</Mes>',10 ;Close Tag (7 bytes) opYyTg db '<Año>' ;Open Tag (6 bytes) clYyTg db '</Año>',10 ;Close Tag (8 bytes) opTcTg db '<Hora>',10 ;Open Tag (7 bytes) clTcTg db '</Hora>',10 ;Close Tag (8 bytes) opHrTg db '<Hora>' ;Open Tag (6 bytes) clHrTg db '</Hora>',10 ;Close Tag (8 bytes) opMnTg db '<Minutos>' ;Open Tag (9 bytes) clMnTg db '</Minutos>',10 ;Close Tag (11 bytes) opScTg db '<Segundos>' ;Open Tag (10 bytes) clScTg db '</Segundos>',10 ;Close Tag (12 bytes) opStTg db '<Alumno>',10 ;Open Tag (9 bytes) clStTg db '</Alumno>',10 ;Close Tag (10 bytes) opIdTg db '<Carnet>' ;Open Tag (8 bytes) clIdTg db '</Carnet>',10 ;Close Tag (10 bytes) opRsTg db '<Resultados>',10 ;Open Tag (13 bytes) clRsTg db '</Resultados>',10 ;Close Tag (14 bytes) opTyTg db '<Tipo>' ;Open Tag (6 bytes) clTyTg db '</Tipo>',10 ;Close Tag (8 bytes) opLeTg db '<Lista_Entrada>' ;Open Tag (15 bytes) clLeTg db '</Lista_Entrada>',10 ;Close Tag (17 bytes) opLsTg db '<Lista_Ordenada>' ;Open Tag (16 bytes) clLsTg db '</Lista_Ordenada>',10 ;Close Tag (18 bytes) opSpTg db '<Velocidad>' ;Open Tag (11 bytes) clSpTg db '</Velocidad>',10 ;Close Tag (13 bytes) opTmTg db '<Tiempo>',10 ;Open Tag (9 bytes) clTmTg db '</Tiempo>',10 ;Close Tag (10 bytes) opMsTg db '<Milisegundos>' ;Open Tag (14 bytes) clMsTg db '</Milisegundos>',10 ;Close Tag (16 bytes) opBsTg db '<Ordenamiento_BubbleSort>',10 ;Open Tag (26 bytes) clBsTg db '</Ordenamiento_BubbleSort>',10 ;Close Tag (27 bytes) opQsTg db '<Ordenamiento_QuickSort>',10 ;Open Tag (25 bytes) clQsTg db '</Ordenamiento_QuickSort>',10 ;Close Tag (26 bytes) opSsTg db '<Ordenamiento_ShellSort>',10 ;Open Tag (25 bytes) clSsTg db '</Ordenamiento_ShellSort>',10 ;Close Tag (26 bytes) A db 0,0,1,0 db 0,1,0,1 db 0,1,1,1 db 0,1,0,1 db 0,1,0,1 B db 0,1,1,0 db 0,1,0,1 db 0,1,1,0 db 0,1,0,1 db 0,1,1,0 C db 0,0,1,0 db 0,1,0,1 db 0,1,0,0 db 0,1,0,1 db 0,0,1,0 D db 0,1,1,0 db 0,1,0,1 db 0,1,0,1 db 0,1,0,1 db 0,1,1,0 E db 0,1,1,1 db 0,1,0,0 db 0,1,1,0 db 0,1,0,0 db 0,1,1,1 F db 0,1,1,1 db 0,1,0,0 db 0,1,1,1 db 0,1,0,0 db 0,1,0,0 G db 0,0,1,0 db 0,1,0,1 db 0,1,0,0 db 0,1,1,1 db 0,1,1,0 H db 0,1,0,1 db 0,1,0,1 db 0,1,1,1 db 0,1,0,1 db 0,1,0,1 I db 0,0,1,0 db 0,0,1,0 db 0,0,1,0 db 0,0,1,0 db 0,0,1,0 J db 0,0,0,1 db 0,0,0,1 db 0,0,0,1 db 0,1,0,1 db 0,0,1,0 K db 0,1,0,1 db 0,1,0,1 db 0,1,1,0 db 0,1,0,1 db 0,1,0,1 L db 0,1,0,0 db 0,1,0,0 db 0,1,0,0 db 0,1,0,0 db 0,1,1,1 M db 0,1,0,1 db 0,1,0,1 db 0,1,1,1 db 0,1,0,1 db 0,1,0,1 N db 0,1,0,1 db 0,1,0,1 db 0,1,0,1 db 0,1,1,1 db 0,1,0,1 O db 0,0,1,0 db 0,1,0,1 db 0,1,0,1 db 0,1,0,1 db 0,0,1,0 P db 0,1,1,1 db 0,1,0,1 db 0,1,1,1 db 0,1,0,0 db 0,1,0,0 Q db 0,0,1,0 db 0,1,0,1 db 0,1,0,1 db 0,1,0,1 db 0,0,1,1 R db 0,1,1,1 db 0,1,0,1 db 0,1,1,0 db 0,1,0,1 db 0,1,0,1 S db 0,0,1,0 db 0,1,0,1 db 0,0,1,0 db 0,1,0,1 db 0,0,1,0 T db 0,1,1,1 db 0,0,1,0 db 0,0,1,0 db 0,0,1,0 db 0,0,1,0 U db 0,1,0,1 db 0,1,0,1 db 0,1,0,1 db 0,1,0,1 db 0,1,1,1 V db 0,1,0,1 db 0,1,0,1 db 0,1,0,1 db 0,1,0,1 db 0,0,1,0 W db 0,1,0,1 db 0,1,0,1 db 0,1,0,1 db 0,1,1,1 db 0,1,0,1 X db 0,1,0,1 db 0,1,0,1 db 0,0,1,0 db 0,1,0,1 db 0,1,0,1 Y db 0,1,0,1 db 0,1,0,1 db 0,0,1,0 db 0,0,1,0 db 0,0,1,0 Z db 0,1,1,1 db 0,0,0,1 db 0,0,1,0 db 0,1,0,0 db 0,1,1,1 ONE db 0,0,1,0 db 0,1,1,0 db 0,0,1,0 db 0,0,1,0 db 0,0,1,0 TWO db 0,1,1,1 db 0,0,0,1 db 0,1,1,1 db 0,1,0,0 db 0,1,1,1 THREE db 0,1,1,0 db 0,0,0,1 db 0,0,1,0 db 0,0,0,1 db 0,1,1,0 FOUR db 0,1,0,1 db 0,1,0,1 db 0,1,1,1 db 0,0,0,1 db 0,0,0,1 FIVE db 0,1,1,1 db 0,1,0,0 db 0,1,1,1 db 0,0,0,1 db 0,1,1,1 SIX db 0,0,1,1 db 0,1,0,0 db 0,1,1,1 db 0,1,0,1 db 0,0,1,0 SEVEN db 0,1,1,0 db 0,0,1,0 db 0,1,1,1 db 0,0,1,0 db 0,0,1,0 EIGHT db 0,0,1,0 db 0,1,0,1 db 0,0,1,0 db 0,1,0,1 db 0,0,1,0 NINE db 0,1,1,1 db 0,1,0,1 db 0,1,1,1 db 0,0,0,1 db 0,0,0,1 ZERO db 0,1,1,1 db 0,1,0,1 db 0,1,0,1 db 0,1,0,1 db 0,1,1,1 COLON db 0,0,1,0 db 0,0,1,0 db 0,0,0,0 db 0,0,1,0 db 0,0,1,0 ;************************** END SECTION DATA*********************************** ;========================== SECTION .BSS =================================================| ;uninitialized-data sections | segment .bss ;************************** END SECTION BSS ********************************************** ;========================== SECTION .TEXT ======================================================| ;MY CODE GOES HERE. If I left a blank line ;between this line and "segment .text" gives error | segment .text ORG 100h Main: ;non local label ;call clean ;print headerLabel print mainMenu print newline print optionLabel readInputChar cmp al, 49 je Option1 ;Load File (1) cmp al, 50 je Option2 ;Sort (2) cmp al, 51 je Option3 ;Exit (3) cmp al, 52 je Option4 ;Create Report (4) cmp al,53 je Video ;To Test video mode (5) cmp al,54 je Text ;To return text mode (6) jmp Main ;=========================================OPTION 1======================== Option1: print esUno print loadFileLabel print inputPathLabel xor si,si ;SI will be used for index of filePath array mov si,0 ;-------------geth the input path------------------------------- readInputChar cmp al, 25h ; al = % (Ascii 25h) jne errorPathInput ;if is no % then error ask path again GetPath: readInputChar cmp al, 0dh ; al = CR(carriage return) je errorPathInput ; if is CR is an error jump to errorPathInput cmp al, 2eh ; al = DOT(ascii 46) je GetPathExt ; jump to extJSON to check json extension ; use dot as delimitator to end of input file path mov [filePath + si],al ; is a char for file path name inc si ;increment si = si + 1 to the next position of array jmp GetPath ;return to loop GetPath jmp Main ;just a label for return to Main menu ;Get the path extension GetPathExt: ;get the extension of file mov [filePath + si] ,al ;concatenate dot (.) inc si ;increment si to next position in filePath array cmp al, 0dh ; al = CR (carriage return) if key enter je errorPathInput checkExt: ;check json extension - update: any other extension readInputChar ;read a new char for the extension path file cmp al, 0dh ; al = CR (carriage return) if key enter je errorPathInput cmp al, 25h ; al = %(Ascii 25h) if char % pressed end of reading je EndOfFilePath ;if not CR then a char is coming mov [filePath + si] ,al ;concatenate letter (anything) inc si jmp checkExt ;return to checkExt and keep reading EndOfFilePath: mov al, 0 ;null character due to ASCIZ mov [filePath+si],al ;add null character/end of string inc si ;increment si mov al , '$' ; mov [filePath + si],al ;add end of string '$' OpeningFile: ;label open file print newline print filePath ;print the file path input print newline ;========== OPEN THE FILE =========== openFile filePath ;call macro for open the file pass the path input jc errorOpenFile ;if the file couldn't be open jump to error ;push ax ;push handle into stack before print message print openFileMsg ;print the file got open ;pop ax ;retrieve the file handle ;========== READ THE FILE =========== readFile ax,fileReadBf ;call macro readFile and pass the handle and buffer as parameter jc errorReadFile ;if file couldn't be read jump to error print readFileMsg ;print message file read jmp Scanner jmp Main ;================================= OPTION 2 - 4 =========================== Option2: print esDos print beforeSortMsg print numArray jmp SortMenu Option3: print esTres xor cl,cl for: ;printChar cl inc cl cmp cl,165 jne for jmp exit Option4: print esTres ;Create a new File : NAME, array to save handle CreateFile reportName,fileHandle jmp Main Video: setVideoMode 13h mov al,1 mov [charCol],al ;drawChar 1,charCol,P PlotChar 1,charCol,43h mov al,2 mov [charCol],al drawChar 1,charCol,R mov al,3 mov [charCol],al drawChar 1,charCol,O mov al,4 mov [charCol],al drawChar 1,charCol,C mov al,5 mov [charCol],al drawChar 1,charCol,E mov al,6 mov [charCol],al drawChar 1,charCol,D mov al,7 mov [charCol],al drawChar 1,charCol,I mov al,8 mov [charCol],al drawChar 1,charCol,M mov al,9 mov [charCol],al drawChar 1,charCol,I mov al,10 mov [charCol],al drawChar 1,charCol,E mov al,11 mov [charCol],al drawChar 1,charCol,N mov al,12 mov [charCol],al drawChar 1,charCol,T mov al,13 mov [charCol],al drawChar 1,charCol,O mov al,14 mov [charCol],al drawChar 1,charCol,COLON mov al,16 mov [charCol],al drawChar 1,charCol,B mov al,17 mov [charCol],al drawChar 1,charCol,U mov al,18 mov [charCol],al drawChar 1,charCol,B mov al,19 mov [charCol],al drawChar 1,charCol,B mov al,20 mov [charCol],al drawChar 1,charCol,L mov al,21 mov [charCol],al drawChar 1,charCol,E mov al,22 mov [charCol],al drawChar 1,charCol,S mov al,23 mov [charCol],al drawChar 1,charCol,O mov al,24 mov [charCol],al drawChar 1,charCol,R mov al,25 mov [charCol],al drawChar 1,charCol,T mov al,27 mov [charCol],al drawChar 1,charCol,T mov al,28 mov [charCol],al drawChar 1,charCol,I mov al,29 mov [charCol],al drawChar 1,charCol,E mov al,30 mov [charCol],al drawChar 1,charCol,M mov al,31 mov [charCol],al drawChar 1,charCol,P mov al,32 mov [charCol],al drawChar 1,charCol,O mov al,33 mov [charCol],al drawChar 1,charCol,COLON mov al,35 mov [charCol],al drawChar 1,charCol,ZERO mov al,36 mov [charCol],al drawChar 1,charCol,ZERO mov al,37 mov [charCol],al drawChar 1,charCol,COLON mov al,38 mov [charCol],al drawChar 1,charCol,ZERO mov al,39 mov [charCol],al drawChar 1,charCol,ZERO mov al,41 mov [charCol],al drawChar 1,charCol,V mov al,42 mov [charCol],al drawChar 1,charCol,E mov al,43 mov [charCol],al drawChar 1,charCol,L mov al,44 mov [charCol],al drawChar 1,charCol,O mov al,45 mov [charCol],al drawChar 1,charCol,C mov al,46 mov [charCol],al drawChar 1,charCol,I mov al,47 mov [charCol],al drawChar 1,charCol,D mov al,48 mov [charCol],al drawChar 1,charCol,A mov al,49 mov [charCol],al drawChar 1,charCol,D mov al,50 mov [charCol],al drawChar 1,charCol,COLON mov al,51 mov [charCol],al drawChar 1,charCol,ZERO ;===DRAW THE LABELS ;print sizeArray ;BubbleSort auxArray,sizeArray BubbleSortDec auxArray,sizeArray ;Run bubbleSort procedure ;DrawBarGraph auxArray,sizeArray ;DrawArea 156,0,8,200, 03h ;DrawArea 166,50,8,150, 03h ;DrawArea 0,96,320,8,04h readInputChar jmp Main Text: setVideoMode 03h jmp Main ;================================ SORT MENU ========================= SortMenu: print sortMenu print optionLabel readInputChar cmp al, 49 je BubbleSortOp cmp al, 50 je QuickSortOp cmp al, 51 je ShellSortOp cmp al, 52 je BackMain BubbleSortOp: ;SCROLL SCREEN UP mov ah, 06h ;request scroll up mov al, 00h ;number of lines to scroll up mov bh, 07h ;black background mov cx,0000h ;starting row:column mov dx, 194Fh;ending row:column int 10h ;SET CURSOR POSITION mov ah,02h ;request set cursor position mov bh,00h ;number of page mov dh,02h ;row/y = 0 mov dl,0h ;column/x = 0 int 10h ;call interruption setVideoMode 13h mov al,1 mov [charCol],al ;drawChar 1,charCol,P PlotChar 1,charCol,43h mov al,2 mov [charCol],al drawChar 1,charCol,R mov al,3 mov [charCol],al drawChar 1,charCol,O mov al,4 mov [charCol],al drawChar 1,charCol,C mov al,5 mov [charCol],al drawChar 1,charCol,E mov al,6 mov [charCol],al drawChar 1,charCol,D mov al,7 mov [charCol],al drawChar 1,charCol,I mov al,8 mov [charCol],al drawChar 1,charCol,M mov al,9 mov [charCol],al drawChar 1,charCol,I mov al,10 mov [charCol],al drawChar 1,charCol,E mov al,11 mov [charCol],al drawChar 1,charCol,N mov al,12 mov [charCol],al drawChar 1,charCol,T mov al,13 mov [charCol],al drawChar 1,charCol,O mov al,14 mov [charCol],al drawChar 1,charCol,COLON mov al,16 mov [charCol],al drawChar 1,charCol,B mov al,17 mov [charCol],al drawChar 1,charCol,U mov al,18 mov [charCol],al drawChar 1,charCol,B mov al,19 mov [charCol],al drawChar 1,charCol,B mov al,20 mov [charCol],al drawChar 1,charCol,L mov al,21 mov [charCol],al drawChar 1,charCol,E mov al,22 mov [charCol],al drawChar 1,charCol,S mov al,23 mov [charCol],al drawChar 1,charCol,O mov al,24 mov [charCol],al drawChar 1,charCol,R mov al,25 mov [charCol],al drawChar 1,charCol,T mov al,27 mov [charCol],al drawChar 1,charCol,T mov al,28 mov [charCol],al drawChar 1,charCol,I mov al,29 mov [charCol],al drawChar 1,charCol,E mov al,30 mov [charCol],al drawChar 1,charCol,M mov al,31 mov [charCol],al drawChar 1,charCol,P mov al,32 mov [charCol],al drawChar 1,charCol,O mov al,33 mov [charCol],al drawChar 1,charCol,COLON mov al,35 mov [charCol],al drawChar 1,charCol,ZERO mov al,36 mov [charCol],al drawChar 1,charCol,ZERO mov al,37 mov [charCol],al drawChar 1,charCol,COLON mov al,38 mov [charCol],al drawChar 1,charCol,ZERO mov al,39 mov [charCol],al drawChar 1,charCol,ZERO mov al,41 mov [charCol],al drawChar 1,charCol,V mov al,42 mov [charCol],al drawChar 1,charCol,E mov al,43 mov [charCol],al drawChar 1,charCol,L mov al,44 mov [charCol],al drawChar 1,charCol,O mov al,45 mov [charCol],al drawChar 1,charCol,C mov al,46 mov [charCol],al drawChar 1,charCol,I mov al,47 mov [charCol],al drawChar 1,charCol,D mov al,48 mov [charCol],al drawChar 1,charCol,A mov al,49 mov [charCol],al drawChar 1,charCol,D mov al,50 mov [charCol],al drawChar 1,charCol,COLON mov al,51 mov [charCol],al drawChar 1,charCol,EIGHT CopyArray sizeArray,auxArray,numArray ;makes a copy of the data print bubbleSortMsg ;Print Bubble Sort on screen print sizeArray ;Print the size of array as a character print newline print auxArray ;Print each num still not as Ascii BubbleSort auxArray,sizeArray ;Run bubbleSort procedure ;BubbleSortDesc auxArray,sizeArray ;print newline ;Print a newline on screen ;print afterSortMsg ;print auxArray ;Print the num array after BubbleSorted ;mov bh,[auxArray] ;mov bl,[auxArray+1] ;DecToAscii bx,numCharArray ;print numCharArray ;printChar [numCharArray] ;printChar [numCharArray+1] ;mov bh,[auxArray+2] ;mov bl,[auxArray+3] ;DecToAscii bx,numCharArray ;print numCharArray ;mov bh,[auxArray+4] ;mov bl,[auxArray+5] ;DecToAscii bx,numCharArray ;print numCharArray readInputChar jmp Main QuickSortOp: ;DoubleArray print newline ;print auxArray print numCharArray jmp Main ShellSortOp: jmp Main BackMain: jmp Main ;====================== ANALISYS OF THE FILE =============== Scanner: mov al,0h GetData CopyArray sizeArray,auxArray,numArray ;makes a copy of the data jmp Main ;======================== PRINT ERRORS SECTION ======================= errorOpenFile: print errOpenMsg jmp Main errorReadFile: print errReadFileMsg jmp Main errorCreateFile: print errCreateFileMsg jmp Main errorPathInput: print newline print errPathMsg jmp Main errorInFile: print errSintMsg ;printChar dx print newline jmp Main errorXmlTag: print errTagMsg print currentTag print newline jmp Main exit: mov ah, 4ch int 21h ;nasm -f bin prc6.asm -o prc6.com ;prc6 ;************************* END SECTION TEXT ********************************************************
; A315498: Coordination sequence Gal.6.334.3 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings. ; 1,6,11,16,22,28,34,40,46,51,56,62,68,73,78,84,90,96,102,108,113,118,124,130,135,140,146,152,158,164,170,175,180,186,192,197,202,208,214,220,226,232,237,242,248,254,259,264,270,276 mov $4,$0 mov $5,$0 mov $7,$0 add $7,1 lpb $7 mov $0,$5 sub $7,1 sub $0,$7 mov $2,$0 mov $3,1 lpb $0 sub $0,1 trn $0,$3 add $0,3 trn $2,2 mul $0,$2 mod $0,11 div $0,3 mul $6,2 gcd $6,2 add $6,$3 mov $2,$6 mov $3,2 lpe add $6,1 add $1,$6 lpe add $1,$4
; A235796: 2*n - 1 - sigma(n). ; 0,0,1,0,3,-1,5,0,4,1,9,-5,11,3,5,0,15,-4,17,-3,9,7,21,-13,18,9,13,-1,27,-13,29,0,17,13,21,-20,35,15,21,-11,39,-13,41,3,11,19,45,-29,40,6,29,5,51,-13,37,-9,33,25,57,-49,59,27,21,0,45,-13,65,9,41,-5,69,-52,71,33,25,11,57,-13,77,-27,40,37,81,-57,61,39,53,-5,87,-55,69,15,57,43,69,-61,95,24,41,-18 mov $1,$0 seq $1,1065 ; Sum of proper divisors (or aliquot parts) of n: sum of divisors of n that are less than n. sub $0,$1
.global s_prepare_buffers s_prepare_buffers: push %r14 push %r15 push %r8 push %rbp push %rcx push %rdi push %rdx push %rsi lea addresses_A_ht+0x698, %rsi lea addresses_normal_ht+0xd698, %rdi nop nop nop nop inc %r8 mov $121, %rcx rep movsq nop nop nop nop xor %rsi, %rsi lea addresses_WT_ht+0x147f8, %rsi lea addresses_UC_ht+0x1705c, %rdi clflush (%rdi) nop nop nop sub %r14, %r14 mov $92, %rcx rep movsb nop nop cmp $15267, %rsi lea addresses_D_ht+0x199f8, %rsi nop nop sub $6368, %r15 movw $0x6162, (%rsi) nop nop nop nop xor %rcx, %rcx lea addresses_WC_ht+0xb84, %rsi inc %rdi mov (%rsi), %ecx and %rdi, %rdi lea addresses_WC_ht+0x1dfe8, %rcx clflush (%rcx) nop nop nop xor $13174, %rbp mov $0x6162636465666768, %rdi movq %rdi, (%rcx) nop inc %r8 lea addresses_normal_ht+0xdee0, %rsi lea addresses_UC_ht+0x1c698, %rdi nop nop nop nop nop and $40146, %rdx mov $16, %rcx rep movsl nop nop add $57892, %rsi lea addresses_UC_ht+0x1e63a, %rbp nop mfence mov (%rbp), %r15w xor $54193, %r15 pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %r8 pop %r15 pop %r14 ret .global s_faulty_load s_faulty_load: push %r11 push %r13 push %r14 push %r9 push %rcx push %rdi push %rsi // Store lea addresses_D+0x854a, %r13 nop nop nop nop cmp $34, %rdi mov $0x5152535455565758, %r11 movq %r11, %xmm7 vmovups %ymm7, (%r13) nop nop nop cmp %rsi, %rsi // Faulty Load lea addresses_normal+0xa7f8, %rsi nop nop nop nop and %r14, %r14 movups (%rsi), %xmm6 vpextrq $1, %xmm6, %r9 lea oracles, %r14 and $0xff, %r9 shlq $12, %r9 mov (%r14,%r9,1), %r9 pop %rsi pop %rdi pop %rcx pop %r9 pop %r14 pop %r13 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_normal', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_D', 'same': False, 'AVXalign': False, 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_normal', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 5}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 5}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 10}, 'dst': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 1}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 9}} {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_WC_ht', 'same': True, 'AVXalign': False, 'congruent': 2}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 4}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 1}, 'dst': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 5}} {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 0}} {'34': 21829} 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 */
<% from pwnlib.shellcraft.amd64.linux import syscall %> <%page args=""/> <%docstring> Invokes the syscall sched_yield. See 'man 2 sched_yield' for more information. Arguments: </%docstring> ${syscall('SYS_sched_yield')}
/** * Autogenerated by Thrift for src/module.thrift * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @nocommit */ #include "thrift/compiler/test/fixtures/includes/gen-cpp2/module_types.h" #include "thrift/compiler/test/fixtures/includes/gen-cpp2/module_types.tcc" #include <thrift/lib/cpp2/gen/module_types_cpp.h> #include "thrift/compiler/test/fixtures/includes/gen-cpp2/module_data.h" namespace apache { namespace thrift { namespace detail { void TccStructTraits<::cpp2::MyStruct>::translateFieldName( folly::StringPiece _fname, int16_t& fid, apache::thrift::protocol::TType& _ftype) noexcept { using data = apache::thrift::TStructDataStorage<::cpp2::MyStruct>; static const st::translate_field_name_table table{ data::fields_size, data::fields_names.data(), data::fields_ids.data(), data::fields_types.data()}; st::translate_field_name(_fname, fid, _ftype, table); } } // namespace detail } // namespace thrift } // namespace apache namespace cpp2 { THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN MyStruct::MyStruct(const MyStruct&) = default; MyStruct& MyStruct::operator=(const MyStruct&) = default; THRIFT_IGNORE_ISSET_USE_WARNING_END THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN MyStruct::MyStruct(MyStruct&& other) noexcept : MyIncludedField(std::move(other.MyIncludedField)), MyOtherIncludedField(std::move(other.MyOtherIncludedField)), MyIncludedInt(std::move(other.MyIncludedInt)), __isset(other.__isset) {} MyStruct& MyStruct::operator=(FOLLY_MAYBE_UNUSED MyStruct&& other) noexcept { this->MyIncludedField = std::move(other.MyIncludedField); this->MyOtherIncludedField = std::move(other.MyOtherIncludedField); this->MyIncludedInt = std::move(other.MyIncludedInt); __isset = other.__isset; return *this; } THRIFT_IGNORE_ISSET_USE_WARNING_END THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN MyStruct::MyStruct(apache::thrift::FragileConstructor, ::cpp2::Included MyIncludedField__arg, ::cpp2::Included MyOtherIncludedField__arg, ::cpp2::IncludedInt64 MyIncludedInt__arg) : MyIncludedField(std::move(MyIncludedField__arg)), MyOtherIncludedField(std::move(MyOtherIncludedField__arg)), MyIncludedInt(std::move(MyIncludedInt__arg)) { __isset.MyIncludedField = true; __isset.MyOtherIncludedField = true; __isset.MyIncludedInt = true; } THRIFT_IGNORE_ISSET_USE_WARNING_END void MyStruct::__clear() { // clear all fields this->MyIncludedField.__clear(); this->MyOtherIncludedField.__clear(); this->MyIncludedInt = 42LL; THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN __isset = {}; THRIFT_IGNORE_ISSET_USE_WARNING_END } bool MyStruct::operator==(const MyStruct& rhs) const { (void)rhs; auto& lhs = *this; (void)lhs; if (!(lhs.MyIncludedField_ref() == rhs.MyIncludedField_ref())) { return false; } if (!(lhs.MyOtherIncludedField_ref() == rhs.MyOtherIncludedField_ref())) { return false; } if (!(lhs.MyIncludedInt_ref() == rhs.MyIncludedInt_ref())) { return false; } return true; } bool MyStruct::operator<(const MyStruct& rhs) const { (void)rhs; auto& lhs = *this; (void)lhs; if (!(lhs.MyIncludedField_ref() == rhs.MyIncludedField_ref())) { return lhs.MyIncludedField_ref() < rhs.MyIncludedField_ref(); } if (!(lhs.MyOtherIncludedField_ref() == rhs.MyOtherIncludedField_ref())) { return lhs.MyOtherIncludedField_ref() < rhs.MyOtherIncludedField_ref(); } if (!(lhs.MyIncludedInt_ref() == rhs.MyIncludedInt_ref())) { return lhs.MyIncludedInt_ref() < rhs.MyIncludedInt_ref(); } return false; } const ::cpp2::Included& MyStruct::get_MyIncludedField() const& { return MyIncludedField; } ::cpp2::Included MyStruct::get_MyIncludedField() && { return std::move(MyIncludedField); } const ::cpp2::Included& MyStruct::get_MyOtherIncludedField() const& { return MyOtherIncludedField; } ::cpp2::Included MyStruct::get_MyOtherIncludedField() && { return std::move(MyOtherIncludedField); } void swap(MyStruct& a, MyStruct& b) { using ::std::swap; swap(a.MyIncludedField_ref().value(), b.MyIncludedField_ref().value()); swap(a.MyOtherIncludedField_ref().value(), b.MyOtherIncludedField_ref().value()); swap(a.MyIncludedInt_ref().value(), b.MyIncludedInt_ref().value()); THRIFT_IGNORE_ISSET_USE_WARNING_BEGIN swap(a.__isset, b.__isset); THRIFT_IGNORE_ISSET_USE_WARNING_END } template void MyStruct::readNoXfer<>(apache::thrift::BinaryProtocolReader*); template uint32_t MyStruct::write<>(apache::thrift::BinaryProtocolWriter*) const; template uint32_t MyStruct::serializedSize<>(apache::thrift::BinaryProtocolWriter const*) const; template uint32_t MyStruct::serializedSizeZC<>(apache::thrift::BinaryProtocolWriter const*) const; template void MyStruct::readNoXfer<>(apache::thrift::CompactProtocolReader*); template uint32_t MyStruct::write<>(apache::thrift::CompactProtocolWriter*) const; template uint32_t MyStruct::serializedSize<>(apache::thrift::CompactProtocolWriter const*) const; template uint32_t MyStruct::serializedSizeZC<>(apache::thrift::CompactProtocolWriter const*) const; static_assert( ::apache::thrift::detail::st::gen_check_json< MyStruct, ::apache::thrift::type_class::structure, ::cpp2::Included>, "inconsistent use of json option"); static_assert( ::apache::thrift::detail::st::gen_check_json< MyStruct, ::apache::thrift::type_class::structure, ::cpp2::Included>, "inconsistent use of json option"); static_assert( ::apache::thrift::detail::st::gen_check_nimble< MyStruct, ::apache::thrift::type_class::structure, ::cpp2::Included>, "inconsistent use of nimble option"); static_assert( ::apache::thrift::detail::st::gen_check_nimble< MyStruct, ::apache::thrift::type_class::structure, ::cpp2::Included>, "inconsistent use of nimble option"); } // cpp2
; --------------------------------------------------------------------------- ; Sprite mappings - harpoon (LZ) ; --------------------------------------------------------------------------- Map_Harp_internal: dc.w @h_retracted-Map_Harp_internal dc.w @h_middle-Map_Harp_internal dc.w @h_extended-Map_Harp_internal dc.w @v_retracted-Map_Harp_internal dc.w @v_middle-Map_Harp_internal dc.w @v_extended-Map_Harp_internal @h_retracted: dc.b 1 dc.b $FC, 4, 0, 0, $F8 @h_middle: dc.b 1 dc.b $FC, $C, 0, 2, $F8 @h_extended: dc.b 2 dc.b $FC, 8, 0, 6, $F8 dc.b $FC, 8, 0, 3, $10 @v_retracted: dc.b 1 dc.b $F8, 1, 0, 9, $FC @v_middle: dc.b 1 dc.b $E8, 3, 0, $B, $FC @v_extended: dc.b 2 dc.b $D8, 2, 0, $B, $FC dc.b $F0, 2, 0, $F, $FC even
#include "operators/arithmetic/add_op.h" #include "core/workspace.h" #include "utils/math_functions.h" namespace dragon { template <class Context> template <typename T> void RAddOp<Context>::EltwiseRunWithType() { auto* X1data = input(0).template data<T, Context>(); auto* X2data = input(1).template data<T, Context>(); auto* Ydata = output(0)->template mutable_data<T, Context>(); math::Add<T, Context>(output(0)->count(), X1data, X2data, Ydata); } template <class Context> template <typename T> void RAddOp<Context>::BroadcastRunWithType(int type) { TIndex outer_dim, inner_dim; auto* X1data = input(0).template data<T, Context>(); auto* X2data = input(1).template data<T, Context>(); auto* Ydata = output(0)->template mutable_data<T, Context>(); ctx().template Copy<T, Context, Context>(input(1).count(), Ydata, X2data); if (type == 0 || type == 1) { if (type == 0) { outer_dim = input(1).count(); inner_dim = 1; } else { outer_dim = input(1).count(0, input(1).axis(-1)); inner_dim = input(1).dim(-1); } INIT_MULTIPLIER(bcast_multiplier, outer_dim); auto* BMul_data = bcast_multiplier->template data<T, Context>(); math::Gemm<T, Context>(CblasNoTrans, CblasNoTrans, outer_dim, inner_dim, 1, 1.0, bcast_multiplier->template data<T, Context>(), X1data, 1.0, Ydata); } else if (type == 2) { outer_dim = input(1).dim(0); inner_dim = input(1).count(1); INIT_MULTIPLIER(bcast_multiplier, inner_dim); auto* BMul_data = bcast_multiplier->template data<T, Context>(); math::Gemm<T, Context>(CblasNoTrans, CblasNoTrans, outer_dim, inner_dim, 1, 1.0, X1data, bcast_multiplier->template data<T, Context>(), 1.0, Ydata); } } template <class Context> void RAddOp<Context>::RunOnDevice() { output(0)->ReshapeLike(input(1)); if (input(0).dims() == input(1).dims()) { if (input(0).template IsType<float>()) EltwiseRunWithType<float>(); else LOG(FATAL) << "Unsupported input types."; } else if (input(0).dim(0) == input(1).dim(0) && input(0).count(1) == 1) { if (input(0).template IsType<float>()) BroadcastRunWithType<float>(2); #ifdef WITH_CUDA_FP16 else if (input(0).template IsType<float16>()) BroadcastRunWithType<float16>(2); #endif else LOG(FATAL) << "Unsupported input types."; } else if (input(0).dim(-1) == input(1).dim(-1) && input(0).count(0, input(0).axis(-1)) == 1) { if (input(0).template IsType<float>()) BroadcastRunWithType<float>(1); #ifdef WITH_CUDA_FP16 else if (input(0).template IsType<float16>()) BroadcastRunWithType<float16>(1); #endif else LOG(FATAL) << "Unsupported input types."; } else if (input(0).ndim() == 1 && input(0).dim(0) == 1) { if (input(0).template IsType<float>()) BroadcastRunWithType<float>(0); #ifdef WITH_CUDA_FP16 else if (input(0).template IsType<float16>()) BroadcastRunWithType<float16>(0); #endif else LOG(FATAL) << "Unsupported input types."; } else { LOG(FATAL) << "Could not be broadcast together with shapes " << input(0).dim_string() << " " << input(1).dim_string(); } } DEPLOY_CPU(RAdd); #ifdef WITH_CUDA DEPLOY_CUDA(RAdd); #endif OPERATOR_SCHEMA(RAdd).NumInputs(2).NumOutputs(1); template <class Context> template <typename T> void RAddGradientOp<Context>::EltwiseRunWithType() { auto* dYdata = input(-1).template data<T, Context>(); if (output(1)->name() != "ignore") { auto* dX2data = output(1)->template mutable_data<T, Context>(); ctx().template Copy<T, Context, Context>(output(1)->count(), dX2data, dYdata); } if (output(0)->name() != "ignore") { auto* dX1data = output(0)->template mutable_data<T, Context>(); ctx().template Copy<T, Context, Context>(output(0)->count(), dX1data, dYdata); } } template <class Context> template <typename T> void RAddGradientOp<Context>::BroadcastRunWithType(int type) { TIndex outer_dim, inner_dim; auto* dYdata = input(-1).template data<T, Context>(); if (output(0)->name() != "ignore") { auto* dX1data = output(0)->template mutable_data<T, Context>(); if (type == 0 || type == 1) { if (type == 0) { outer_dim = input(-1).count(); inner_dim = 1; } else { outer_dim = input(-1).count(0, input(-1).axis(-1)); inner_dim = input(-1).dim(-1); } INIT_MULTIPLIER(bcast_multiplier, outer_dim); auto* BMul_data = bcast_multiplier->template data<T, Context>(); math::Gemv<T, Context>(CblasTrans, outer_dim, inner_dim, 1.0, dYdata, BMul_data, 0.0, dX1data); } else if (type == 2) { outer_dim = input(-1).dim(0); inner_dim = input(-1).count(1); INIT_MULTIPLIER(bcast_multiplier, inner_dim); auto* BMul_data = bcast_multiplier->template data<T, Context>(); math::Gemv<T, Context>(CblasNoTrans, outer_dim, inner_dim, 1.0, dYdata, BMul_data, 0.0, dX1data); } } if (output(1)->name() != "ignore") { auto* dX2data = output(1)->template mutable_data<T, Context>(); ctx().template Copy<T, Context, Context>(output(1)->count(), dX2data, dYdata); } } template <class Context> void RAddGradientOp<Context>::RunOnDevice() { output(1)->ReshapeLike(input(-1)); output(0)->ReshapeLike(input(0)); if (input(-1).dims() == input(0).dims()) { if (input(0).template IsType<float>()) EltwiseRunWithType<float>(); else LOG(FATAL) << "Unsupported input types."; } else if (input(-1).dim(0) == input(0).dim(0) && input(0).count(1) == 1) { if (input(0).template IsType<float>()) BroadcastRunWithType<float>(2); #ifdef WITH_CUDA_FP16 else if (input(0).template IsType<float16>()) BroadcastRunWithType<float16>(2); #endif else LOG(FATAL) << "Unsupported input types."; } else if (input(-1).dim(-1) == input(0).dim(-1) && input(0).count(0, input(0).axis(-1)) == 1) { if (input(0).template IsType<float>()) BroadcastRunWithType<float>(1); #ifdef WITH_CUDA_FP16 else if (input(0).template IsType<float16>()) BroadcastRunWithType<float16>(1); #endif else LOG(FATAL) << "Unsupported input types."; } else if (input(0).ndim() == 1 && input(0).dim(0) == 1) { if (input(0).template IsType<float>()) BroadcastRunWithType<float>(0); #ifdef WITH_CUDA_FP16 else if (input(0).template IsType<float16>()) BroadcastRunWithType<float16>(0); #endif else LOG(FATAL) << "Unsupported input types."; } else { LOG(FATAL) << "Could not be broadcast together with shapes " << input(-1).dim_string() << " " << input(0).dim_string(); } } template <class Context> void RAddGradientOp<Context>::ShareGradient() { for (int i = (int)OutputSize() - 1; i >= 0; i--) { if (output(i)->name() != "ignore") { Tensor* dX = ws()->GetBuffer("Grad"); ws()->CreateAvatar(output(i), dX); break; } } } DEPLOY_CPU(RAddGradient); #ifdef WITH_CUDA DEPLOY_CUDA(RAddGradient); #endif OPERATOR_SCHEMA(RAddGradient).NumInputs(2).NumOutputs(2); class GetRAddGradient : public GradientMakerBase { public: GRADIENT_MAKER_CTOR(GetRAddGradient); vector<OperatorDef> MakeDefs() override { return SingleDef(def.type() + "Gradient", "", vector<string> {I(0), GO(0)}, vector<string> {GI(0), GI(1)}); } }; REGISTER_GRADIENT(RAdd, GetRAddGradient); } // namespace dragon
; A053838: a(n) = (sum of digits of n written in base 3) modulo 3. ; 0,1,2,1,2,0,2,0,1,1,2,0,2,0,1,0,1,2,2,0,1,0,1,2,1,2,0,1,2,0,2,0,1,0,1,2,2,0,1,0,1,2,1,2,0,0,1,2,1,2,0,2,0,1,2,0,1,0,1,2,1,2,0,0,1,2,1,2,0,2,0,1,1,2,0,2,0,1,0,1,2,1,2,0,2,0,1,0,1,2,2,0,1,0,1,2,1,2,0,0 lpb $0 add $1,$0 div $0,3 lpe mod $1,3 mov $0,$1
/* * TPCC.actor.cpp * * This source file is part of the FoundationDB open source project * * Copyright 2013-2020 Apple Inc. and the FoundationDB project authors * * 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. */ #include "flow/actorcompiler.h" #include "fdbserver/workloads/workloads.actor.h" #include "fdbserver/workloads/TPCCWorkload.h" #include <fdbclient/ReadYourWrites.h> #include "flow/actorcompiler.h" // has to be last include using namespace TPCCWorkload; namespace { struct TPCCMetrics { static constexpr int latenciesStored = 1000; uint64_t successfulStockLevelTransactions, failedStockLevelTransactions, successfulDeliveryTransactions, failedDeliveryTransactions, successfulOrderStatusTransactions, failedOrderStatusTransactions, successfulPaymentTransactions, failedPaymentTransactions, successfulNewOrderTransactions, failedNewOrderTransactions; double stockLevelResponseTime, deliveryResponseTime, orderStatusResponseTime, paymentResponseTime, newOrderResponseTime; std::vector<double> stockLevelLatencies, deliveryLatencies, orderStatusLatencies, paymentLatencies, newOrderLatencies; TPCCMetrics() : successfulStockLevelTransactions(0), successfulDeliveryTransactions(0), successfulOrderStatusTransactions(0), successfulPaymentTransactions(0), successfulNewOrderTransactions(0), failedStockLevelTransactions(0), failedDeliveryTransactions(0), failedOrderStatusTransactions(0), failedPaymentTransactions(0), failedNewOrderTransactions(0), stockLevelResponseTime(0.0), deliveryResponseTime(0.0), orderStatusResponseTime(0.0), paymentResponseTime(0.0), newOrderResponseTime(0.0), stockLevelLatencies(latenciesStored, 0.0), deliveryLatencies(latenciesStored, 0.0), orderStatusLatencies(latenciesStored, 0.0), paymentLatencies(latenciesStored, 0.0), newOrderLatencies(latenciesStored, 0.0) {} void sort() { std::sort(stockLevelLatencies.begin(), stockLevelLatencies.end()); std::sort(deliveryLatencies.begin(), deliveryLatencies.end()); std::sort(orderStatusLatencies.begin(), orderStatusLatencies.end()); std::sort(paymentLatencies.begin(), paymentLatencies.end()); std::sort(newOrderLatencies.begin(), newOrderLatencies.end()); } static double median(const std::vector<double>& latencies) { // assumes latencies is sorted return latencies[latencies.size() / 2]; } static double percentile_90(const std::vector<double>& latencies) { // assumes latencies is sorted return latencies[(9 * latencies.size()) / 10]; } static double percentile_99(const std::vector<double>& latencies) { // assumes latencies is sorted return latencies[(99 * latencies.size()) / 100]; } static void updateMetrics(bool committed, uint64_t& successCounter, uint64_t& failedCounter, double txnStartTime, std::vector<double>& latencies, double& totalLatency, std::string txnType) { auto responseTime = g_network->now() - txnStartTime; if (committed) { totalLatency += responseTime; ++successCounter; if (successCounter <= latenciesStored) latencies[successCounter - 1] = responseTime; else { auto index = deterministicRandom()->randomInt(0, successCounter); if (index < latenciesStored) { latencies[index] = responseTime; } } } else { ++failedCounter; } TraceEvent("TransactionComplete") .detail("TransactionType", txnType) .detail("Latency", responseTime) .detail("Begin", txnStartTime) .detail("End", txnStartTime + responseTime) .detail("Success", committed); } }; struct TPCC : TestWorkload { static constexpr const char* DESCRIPTION = "TPCC"; int warehousesPerClient; int expectedTransactionsPerMinute; int testDuration; int warmupTime; int clientsUsed; double startTime; GlobalState gState; TPCCMetrics metrics; TPCC(WorkloadContext const& ctx) : TestWorkload(ctx) { std::string workloadName = DESCRIPTION; warehousesPerClient = getOption(options, LiteralStringRef("warehousesPerClient"), 100); expectedTransactionsPerMinute = getOption(options, LiteralStringRef("expectedTransactionsPerMinute"), 1000); testDuration = getOption(options, LiteralStringRef("testDuration"), 600); warmupTime = getOption(options, LiteralStringRef("warmupTime"), 30); getOption(options, LiteralStringRef("clientsUsed"), 40); } int NURand(int C, int A, int x, int y) { return (((deterministicRandom()->randomInt(0, A + 1) | deterministicRandom()->randomInt(x, y + 1)) + C) % (y - x + 1)) + x; } StringRef genCLast(Arena& arena, int x) { int l = x % 10; x /= 10; int m = x % 10; x /= 10; int f = x % 10; std::stringstream ss; ss << syllables[f] << syllables[m] << syllables[l]; return StringRef(arena, ss.str()); } // Should call in setup ACTOR static Future<Void> readGlobalState(TPCC* self, Database cx) { state ReadYourWritesTransaction tr(cx); loop { tr.reset(); try { Optional<Value> val = wait(tr.get(self->gState.key())); if (val.present()) { BinaryReader reader(val.get(), IncludeVersion()); serializer(reader, self->gState); } else { wait(delay(1.0)); } return Void(); } catch (Error& e) { wait(tr.onError(e)); } } } virtual std::string description() override { return DESCRIPTION; } // Transactions ACTOR static Future<bool> newOrder(TPCC* self, Database cx, int w_id) { state int d_id = deterministicRandom()->randomInt(0, 10); state int c_id = self->NURand(self->gState.CRun, 1023, 1, 3000) - 1; state int ol_cnt = deterministicRandom()->randomInt(5, 16); state bool willRollback = deterministicRandom()->randomInt(1, 100) == 1; state ReadYourWritesTransaction tr(cx); try { state Warehouse warehouse; warehouse.w_id = w_id; Optional<Value> wValue = wait(tr.get(warehouse.key())); ASSERT(wValue.present()); { BinaryReader r(wValue.get(), IncludeVersion()); serializer(r, warehouse); } state District district; district.d_w_id = w_id; district.d_id = d_id; Optional<Value> dValue = wait(tr.get(district.key())); ASSERT(dValue.present()); { BinaryReader r(dValue.get(), IncludeVersion()); serializer(r, district); } state Customer customer; customer.c_id = c_id; customer.c_w_id = w_id; customer.c_d_id = d_id; Optional<Value> cValue = wait(tr.get(customer.key())); ASSERT(cValue.present()); { BinaryReader r(cValue.get(), IncludeVersion()); serializer(r, customer); } state Order order; order.o_entry_d = g_network->now(); order.o_c_id = c_id; order.o_d_id = d_id; order.o_w_id = w_id; order.o_ol_cnt = ol_cnt; order.o_id = district.d_next_o_id; ++district.d_next_o_id; { BinaryWriter w(IncludeVersion()); serializer(w, district); tr.set(district.key(), w.toValue()); } state NewOrder newOrder; newOrder.no_w_id = w_id; newOrder.no_d_id = d_id; newOrder.no_o_id = order.o_id; state int ol_id = 0; state bool allLocal = true; for (; ol_id < order.o_ol_cnt; ++ol_id) { if (ol_id + 1 == order.o_ol_cnt && willRollback) { // Simulated abort - order item not found return false; } state OrderLine orderLine; orderLine.ol_number = ol_id; orderLine.ol_w_id = w_id; orderLine.ol_d_id = d_id; orderLine.ol_supply_w_id = w_id; orderLine.ol_o_id = order.o_id; orderLine.ol_i_id = self->NURand(self->gState.CRun, 8191, 1, 100000) - 1; orderLine.ol_quantity = deterministicRandom()->randomInt(1, 11); if (deterministicRandom()->randomInt(0, 100) == 0) { orderLine.ol_supply_w_id = deterministicRandom()->randomInt(0, self->clientsUsed * self->warehousesPerClient); } state Item item; item.i_id = orderLine.ol_i_id; orderLine.ol_i_id = item.i_id; Optional<Value> iValue = wait(tr.get(item.key())); ASSERT(iValue.present()); { BinaryReader r(iValue.get(), IncludeVersion()); serializer(r, item); } state Stock stock; stock.s_i_id = item.i_id; stock.s_w_id = orderLine.ol_supply_w_id; Optional<Value> sValue = wait(tr.get(stock.key())); ASSERT(sValue.present()); { BinaryReader r(sValue.get(), IncludeVersion()); serializer(r, stock); } if (stock.s_quantity - orderLine.ol_quantity >= 10) { stock.s_quantity -= orderLine.ol_quantity; } else { stock.s_quantity = (stock.s_quantity - orderLine.ol_quantity) + 91; } stock.s_ytd += orderLine.ol_quantity; stock.s_order_cnt += 1; if (orderLine.ol_supply_w_id != w_id) { stock.s_remote_cnt += 1; allLocal = false; } { BinaryWriter w(IncludeVersion()); serializer(w, stock); tr.set(stock.key(), w.toValue()); } orderLine.ol_amount = orderLine.ol_quantity * item.i_price; switch (orderLine.ol_d_id) { case 0: orderLine.ol_dist_info = stock.s_dist_01; break; case 1: orderLine.ol_dist_info = stock.s_dist_02; break; case 2: orderLine.ol_dist_info = stock.s_dist_03; break; case 3: orderLine.ol_dist_info = stock.s_dist_04; break; case 4: orderLine.ol_dist_info = stock.s_dist_05; break; case 5: orderLine.ol_dist_info = stock.s_dist_06; break; case 6: orderLine.ol_dist_info = stock.s_dist_07; break; case 7: orderLine.ol_dist_info = stock.s_dist_08; break; case 8: orderLine.ol_dist_info = stock.s_dist_09; break; case 9: orderLine.ol_dist_info = stock.s_dist_10; break; } { BinaryWriter w(IncludeVersion()); serializer(w, orderLine); tr.set(orderLine.key(), w.toValue()); } } order.o_all_local = allLocal; { BinaryWriter w(IncludeVersion()); serializer(w, order); tr.set(order.key(), w.toValue()); } { BinaryWriter w(IncludeVersion()); serializer(w, newOrder); tr.set(newOrder.key(), w.toValue()); } wait(tr.commit()); } catch (Error& e) { return false; } return true; } ACTOR static Future<Customer> getRandomCustomer(TPCC* self, ReadYourWritesTransaction* tr, int w_id, int d_id) { state Customer result; result.c_w_id = w_id; result.c_d_id = d_id; if (deterministicRandom()->randomInt(0, 100) >= 85) { result.c_d_id = deterministicRandom()->randomInt(0, 10); result.c_w_id = deterministicRandom()->randomInt(0, self->clientsUsed * self->warehousesPerClient); } if (deterministicRandom()->randomInt(0, 100) < 60) { // select through last name result.c_last = self->genCLast(result.arena, self->NURand(self->gState.CRun, 1023, 1, 3000) - 1); auto s = result.indexLastKey(1); auto begin = new (result.arena) uint8_t[s.size() + 1]; auto end = new (result.arena) uint8_t[s.size() + 1]; memcpy(begin, s.begin(), s.size()); memcpy(end, s.begin(), s.size()); begin[s.size()] = '/'; end[s.size()] = '0'; state Standalone<RangeResultRef> range = wait(tr->getRange(KeyRangeRef(StringRef(begin, s.size() + 1), StringRef(end, s.size() + 1)), 1000)); ASSERT(range.size() > 0); state std::vector<Customer> customers; state int i = 0; for (; i < range.size(); ++i) { Optional<Value> cValue = wait(tr->get(range[i].value)); ASSERT(cValue.present()); BinaryReader r(cValue.get(), IncludeVersion()); state Customer customer; serializer(r, customer); customers.push_back(customer); } // Sort customers by first name and choose median std::sort(customers.begin(), customers.end(), [](const Customer& cus1, const Customer& cus2) { const std::string cus1Name = cus1.c_first.toString(); const std::string cus2Name = cus2.c_first.toString(); return (cus1Name.compare(cus2Name) < 0); }); result = customers[customers.size() / 2]; } else { // select through random id result.c_id = self->NURand(self->gState.CRun, 1023, 1, 3000) - 1; Optional<Value> val = wait(tr->get(result.key())); ASSERT(val.present()); BinaryReader r(val.get(), IncludeVersion()); serializer(r, result); } return result; } ACTOR static Future<bool> payment(TPCC* self, Database cx, int w_id) { state ReadYourWritesTransaction tr(cx); state int d_id = deterministicRandom()->randomInt(0, 10); state History history; state Warehouse warehouse; state District district; history.h_amount = deterministicRandom()->random01() * 4999.0 + 1.0; history.h_date = g_network->now(); try { // get the customer state Customer customer = wait(getRandomCustomer(self, &tr, w_id, d_id)); warehouse.w_id = w_id; Optional<Value> wValue = wait(tr.get(warehouse.key())); ASSERT(wValue.present()); { BinaryReader r(wValue.get(), IncludeVersion()); serializer(r, warehouse); } warehouse.w_ytd += history.h_amount; { BinaryWriter w(IncludeVersion()); serializer(w, warehouse); tr.set(warehouse.key(), w.toValue()); } district.d_w_id = w_id; district.d_id = d_id; Optional<Value> dValue = wait(tr.get(district.key())); ASSERT(dValue.present()); { BinaryReader r(dValue.get(), IncludeVersion()); serializer(r, district); } district.d_ytd += history.h_amount; customer.c_balance -= history.h_amount; customer.c_ytd_payment += history.h_amount; customer.c_payment_cnt += 1; if (customer.c_credit == LiteralStringRef("BC")) { // we must update c_data std::stringstream ss; ss << customer.c_id << "," << customer.c_d_id << "," << customer.c_w_id << "," << district.d_id << "," << w_id << history.h_amount << ";"; auto s = ss.str(); auto len = std::min(int(s.size()) + customer.c_data.size(), 500); auto data = new (customer.arena) uint8_t[len]; std::copy(s.begin(), s.end(), reinterpret_cast<char*>(data)); std::copy(customer.c_data.begin(), customer.c_data.begin() + len - s.size(), data); customer.c_data = StringRef(data, len); } { BinaryWriter w(IncludeVersion()); serializer(w, customer); tr.set(customer.key(), w.toValue()); } std::stringstream ss; ss << warehouse.w_name.toString() << " " << district.d_name.toString(); history.h_data = StringRef(history.arena, ss.str()); history.h_c_id = customer.c_id; history.h_c_d_id = customer.c_d_id; history.h_c_w_id = customer.c_w_id; history.h_d_id = d_id; history.h_w_id = w_id; { BinaryWriter w(IncludeVersion()); serializer(w, history); UID k = deterministicRandom()->randomUniqueID(); BinaryWriter kW(Unversioned()); serializer(kW, k); auto key = kW.toValue().withPrefix(LiteralStringRef("History/")); tr.set(key, w.toValue()); } wait(tr.commit()); } catch (Error& e) { return false; } return true; } ACTOR static Future<bool> orderStatus(TPCC* self, Database cx, int w_id) { state ReadYourWritesTransaction tr(cx); state int d_id = deterministicRandom()->randomInt(0, 10); state int i; state Order order; state std::vector<OrderLine> orderLines; try { state Customer customer = wait(getRandomCustomer(self, &tr, w_id, d_id)); order.o_w_id = customer.c_w_id; order.o_d_id = customer.c_d_id; order.o_c_id = customer.c_id; Standalone<RangeResultRef> range = wait(tr.getRange(order.keyRange(1), 1, false, true)); ASSERT(range.size() > 0); { BinaryReader r(range[0].value, IncludeVersion()); serializer(r, order); } for (i = 0; i < order.o_ol_cnt; ++i) { OrderLine orderLine; orderLine.ol_w_id = order.o_w_id; orderLine.ol_d_id = order.o_d_id; orderLine.ol_o_id = order.o_id; orderLine.ol_number = i; Optional<Value> olValue = wait(tr.get(orderLine.key())); ASSERT(olValue.present()); BinaryReader r(olValue.get(), IncludeVersion()); OrderLine ol; serializer(r, ol); orderLines.push_back(ol); } } catch (Error& e) { return false; } return true; } ACTOR static Future<bool> delivery(TPCC* self, Database cx, int w_id) { state ReadYourWritesTransaction tr(cx); state int carrier_id = deterministicRandom()->randomInt(0, 10); state int d_id; state NewOrder newOrder; state Order order; state double sumAmount = 0.0; state Customer customer; state int i; try { for (d_id = 0; d_id < 10; ++d_id) { newOrder.no_w_id = w_id; newOrder.no_d_id = d_id; Standalone<RangeResultRef> range = wait(tr.getRange(newOrder.keyRange(1), 1)); if (range.size() > 0) { { BinaryReader r(range[0].value, IncludeVersion()); serializer(r, newOrder); } tr.clear(newOrder.key()); order.o_w_id = w_id; order.o_d_id = d_id; order.o_id = newOrder.no_o_id; Optional<Value> oValue = wait(tr.get(order.key())); ASSERT(oValue.present()); { BinaryReader r(oValue.get(), IncludeVersion()); serializer(r, order); } order.o_carrier_id = carrier_id; { BinaryWriter w(IncludeVersion()); serializer(w, order); tr.set(order.key(), w.toValue()); } for (i = 0; i < order.o_ol_cnt; ++i) { state OrderLine orderLine; orderLine.ol_w_id = order.o_w_id; orderLine.ol_d_id = order.o_d_id; orderLine.ol_o_id = order.o_id; orderLine.ol_number = i; Optional<Value> olV = wait(tr.get(orderLine.key())); ASSERT(olV.present()); BinaryReader r(olV.get(), IncludeVersion()); serializer(r, orderLine); orderLine.ol_delivery_d = g_network->now(); sumAmount += orderLine.ol_amount; } customer.c_w_id = w_id; customer.c_d_id = d_id; customer.c_id = order.o_c_id; Optional<Value> cV = wait(tr.get(customer.key())); ASSERT(cV.present()); { BinaryReader r(cV.get(), IncludeVersion()); serializer(r, customer); } customer.c_balance += sumAmount; customer.c_delivery_count += 1; { BinaryWriter w(IncludeVersion()); serializer(w, customer); tr.set(customer.key(), w.toValue()); } wait(tr.commit()); } } } catch (Error& e) { return false; } return true; } ACTOR static Future<bool> stockLevel(TPCC* self, Database cx, int w_id, int d_id) { state int threshold = deterministicRandom()->randomInt(10, 21); state Transaction tr(cx); state District district; state OrderLine orderLine; state Stock stock; state int ol_o_id; state int low_stock = 0; state int i; try { district.d_w_id = w_id; district.d_id = d_id; Optional<Value> dV = wait(tr.get(district.key())); ASSERT(dV.present()); { BinaryReader r(dV.get(), IncludeVersion()); serializer(r, district); } for (ol_o_id = district.d_next_o_id - 20; ol_o_id < district.d_next_o_id; ++ol_o_id) { orderLine.ol_w_id = w_id; orderLine.ol_d_id = d_id; orderLine.ol_o_id = ol_o_id; state Standalone<RangeResultRef> range = wait(tr.getRange(orderLine.keyRange(1), CLIENT_KNOBS->TOO_MANY)); ASSERT(!range.more); ASSERT(range.size() > 0); for (i = 0; i < range.size(); ++i) { { BinaryReader r(range[i].value, IncludeVersion()); serializer(r, orderLine); } stock.s_i_id = orderLine.ol_i_id; stock.s_w_id = orderLine.ol_w_id; Optional<Value> sV = wait(tr.get(stock.key())); ASSERT(sV.present()); { BinaryReader r(sV.get(), IncludeVersion()); serializer(r, stock); } if (stock.s_quantity < threshold) { ++low_stock; } } } } catch (Error& e) { return false; } return true; } ACTOR static Future<Void> emulatedUser(TPCC* self, Database cx, int w_id, int d_id) { // stagger users wait(delay(20.0 * deterministicRandom()->random01())); TraceEvent("StartingEmulatedUser").detail("Warehouse", w_id).detail("District", d_id); loop { auto type = deterministicRandom()->randomInt(0, 100); Future<bool> tx; state double txnStartTime = g_network->now(); if (type < 4) { tx = stockLevel(self, cx, w_id, d_id); bool committed = wait(tx); if (self->recordMetrics()) { TPCCMetrics::updateMetrics(committed, self->metrics.successfulStockLevelTransactions, self->metrics.failedStockLevelTransactions, txnStartTime, self->metrics.stockLevelLatencies, self->metrics.stockLevelResponseTime, "StockLevel"); } wait(delay(2 + deterministicRandom()->random01() * 10)); } else if (type < 8) { tx = delivery(self, cx, w_id); bool committed = wait(tx); if (self->recordMetrics()) { TPCCMetrics::updateMetrics(committed, self->metrics.successfulDeliveryTransactions, self->metrics.failedDeliveryTransactions, txnStartTime, self->metrics.deliveryLatencies, self->metrics.deliveryResponseTime, "Delivery"); } wait(delay(2 + deterministicRandom()->random01() * 10)); } else if (type < 12) { tx = orderStatus(self, cx, w_id); bool committed = wait(tx); if (self->recordMetrics()) { TPCCMetrics::updateMetrics(committed, self->metrics.successfulOrderStatusTransactions, self->metrics.failedOrderStatusTransactions, txnStartTime, self->metrics.orderStatusLatencies, self->metrics.orderStatusResponseTime, "OrderStatus"); } wait(delay(2 + deterministicRandom()->random01() * 20)); } else if (type < 55) { tx = payment(self, cx, w_id); bool committed = wait(tx); if (self->recordMetrics()) { TPCCMetrics::updateMetrics( committed, self->metrics.successfulPaymentTransactions, self->metrics.failedPaymentTransactions, txnStartTime, self->metrics.paymentLatencies, self->metrics.paymentResponseTime, "Payment"); } wait(delay(3 + deterministicRandom()->random01() * 24)); } else { tx = newOrder(self, cx, w_id); bool committed = wait(tx); if (self->recordMetrics()) { TPCCMetrics::updateMetrics(committed, self->metrics.successfulNewOrderTransactions, self->metrics.failedNewOrderTransactions, txnStartTime, self->metrics.newOrderLatencies, self->metrics.newOrderResponseTime, "NewOrder"); } wait(delay(18 + deterministicRandom()->random01() * 24)); } } } double transactionsPerMinute() { return metrics.successfulNewOrderTransactions * 60.0 / (testDuration - 2 * warmupTime); } bool recordMetrics() { auto now = g_network->now(); return (now > startTime + warmupTime && now < startTime + testDuration - warmupTime); } virtual Future<Void> start(Database const& cx) override { if (clientId >= clientsUsed) return Void(); return _start(cx, this); } ACTOR Future<Void> _start(Database cx, TPCC* self) { wait(readGlobalState(self, cx)); self->startTime = g_network->now(); int startWID = self->clientId * self->warehousesPerClient; int endWID = startWID + self->warehousesPerClient; state int w_id; state int d_id; state vector<Future<Void>> emulatedUsers; for (w_id = startWID; w_id < endWID; ++w_id) { for (d_id = 0; d_id < 10; ++d_id) { emulatedUsers.push_back(timeout(emulatedUser(self, cx, w_id, d_id), self->testDuration, Void())); } } wait(waitForAll(emulatedUsers)); return Void(); } virtual Future<bool> check(Database const& cx) override { return (transactionsPerMinute() > expectedTransactionsPerMinute); } virtual void getMetrics(vector<PerfMetric>& m) override { double multiplier = static_cast<double>(clientCount) / static_cast<double>(clientsUsed); m.push_back(PerfMetric("Transactions Per Minute", transactionsPerMinute(), false)); m.push_back(PerfMetric("Successful StockLevel Transactions", metrics.successfulStockLevelTransactions, false)); m.push_back(PerfMetric("Successful Delivery Transactions", metrics.successfulDeliveryTransactions, false)); m.push_back( PerfMetric("Successful OrderStatus Transactions", metrics.successfulOrderStatusTransactions, false)); m.push_back(PerfMetric("Successful Payment Transactions", metrics.successfulPaymentTransactions, false)); m.push_back(PerfMetric("Successful NewOrder Transactions", metrics.successfulNewOrderTransactions, false)); m.push_back(PerfMetric("Failed StockLevel Transactions", metrics.failedStockLevelTransactions, false)); m.push_back(PerfMetric("Failed Delivery Transactions", metrics.failedDeliveryTransactions, false)); m.push_back(PerfMetric("Failed OrderStatus Transactions", metrics.failedOrderStatusTransactions, false)); m.push_back(PerfMetric("Failed Payment Transactions", metrics.failedPaymentTransactions, false)); m.push_back(PerfMetric("Failed NewOrder Transactions", metrics.failedNewOrderTransactions, false)); m.push_back(PerfMetric("Mean StockLevel Latency", (clientId < clientsUsed) ? (multiplier * metrics.stockLevelResponseTime / metrics.successfulStockLevelTransactions) : 0.0, true)); m.push_back(PerfMetric("Mean Delivery Latency", (clientId < clientsUsed) ? (multiplier * metrics.deliveryResponseTime / metrics.successfulDeliveryTransactions) : 0.0, true)); m.push_back(PerfMetric("Mean OrderStatus Repsonse Time", (clientId < clientsUsed) ? (multiplier * metrics.orderStatusResponseTime / metrics.successfulOrderStatusTransactions) : 0.0, true)); m.push_back(PerfMetric("Mean Payment Latency", (clientId < clientsUsed) ? (multiplier * metrics.paymentResponseTime / metrics.successfulPaymentTransactions) : 0.0, true)); m.push_back(PerfMetric("Mean NewOrder Latency", (clientId < clientsUsed) ? (multiplier * metrics.newOrderResponseTime / metrics.successfulNewOrderTransactions) : 0.0, true)); metrics.sort(); m.push_back(PerfMetric("Median StockLevel Latency", multiplier * TPCCMetrics::median(metrics.stockLevelLatencies), true)); m.push_back( PerfMetric("Median Delivery Latency", multiplier * TPCCMetrics::median(metrics.deliveryLatencies), true)); m.push_back(PerfMetric("Median OrderStatus Latency", multiplier * TPCCMetrics::median(metrics.orderStatusLatencies), true)); m.push_back( PerfMetric("Median Payment Latency", multiplier * TPCCMetrics::median(metrics.paymentLatencies), true)); m.push_back( PerfMetric("Median NewOrder Latency", multiplier * TPCCMetrics::median(metrics.newOrderLatencies), true)); m.push_back(PerfMetric("90th Percentile StockLevel Latency", multiplier * TPCCMetrics::percentile_90(metrics.stockLevelLatencies), true)); m.push_back(PerfMetric("90th Percentile Delivery Latency", multiplier * TPCCMetrics::percentile_90(metrics.deliveryLatencies), true)); m.push_back(PerfMetric("90th Percentile OrderStatus Latency", multiplier * TPCCMetrics::percentile_90(metrics.orderStatusLatencies), true)); m.push_back(PerfMetric("90th Percentile Payment Latency", multiplier * TPCCMetrics::percentile_90(metrics.paymentLatencies), true)); m.push_back(PerfMetric("90th Percentile NewOrder Latency", multiplier * TPCCMetrics::percentile_90(metrics.newOrderLatencies), true)); m.push_back(PerfMetric("99th Percentile StockLevel Latency", multiplier * TPCCMetrics::percentile_99(metrics.stockLevelLatencies), true)); m.push_back(PerfMetric("99th Percentile Delivery Latency", multiplier * TPCCMetrics::percentile_99(metrics.deliveryLatencies), true)); m.push_back(PerfMetric("99th Percentile OrderStatus Latency", multiplier * TPCCMetrics::percentile_99(metrics.orderStatusLatencies), true)); m.push_back(PerfMetric("99th Percentile Payment Latency", multiplier * TPCCMetrics::percentile_99(metrics.paymentLatencies), true)); m.push_back(PerfMetric("99th Percentile NewOrder Latency", multiplier * TPCCMetrics::percentile_99(metrics.newOrderLatencies), true)); } }; } // namespace WorkloadFactory<TPCC> TPCCWorkloadFactory(TPCC::DESCRIPTION);
PAGE 60, 132 TITLE Setting 1/4 bits per pel bitmap or 3 planes-1BPP bitmap COMMENT ` Copyright (c) 1990-1991 Microsoft Corporation Module Name: htwbmp.asm Abstract: This module is used to provide set of functions to set the bits into the final destination bitmap, the input to these function are data structures (PRIMMONO_COUNT, PRIMCOLOR_COUNT and other pre-calculated data values). This function is the equivelant codes in the htsetbmp.c Author: 03-Apr-1991 Wed 10:28:50 created -by- Daniel Chou (danielc) [Environment:] Printer Driver. [Notes:] Revision History: 06-Nov-1992 Fri 16:04:18 updated -by- Daniel Chou (danielc) Fixed bug in VarCountOutputToVGA256 which clear 'ah' (xor _AX, _AX) while we still need to use it. 28-Mar-1992 Sat 21:09:42 updated -by- Daniel Chou (danielc) Rewrite all output functions, add in VGA16 support. ` .XLIST INCLUDE i386\i80x86.inc .LIST IF 0 IF HT_ASM_80x86 ;------------------------------------------------------------------------------ .XLIST INCLUDE i386\htp.inc .LIST ;------------------------------------------------------------------------------ DBG_FILENAME i386\htwbmp .CODE VGA16ColorIndex db 000h, 077h, 077h, 088h, 088h, 0ffh ; MONO db 000h, 000h, 000h, 011h, 033h, 077h ; RY 0 db 000h, 000h, 011h, 033h, 077h, 088h ; RY 6 db 000h, 000h, 011h, 033h, 088h, 0ffh ; RY 18 db 000h, 011h, 033h, 099h, 0bbh, 077h ; RY 24 db 011h, 033h, 099h, 0bbh, 077h, 088h ; RY 30 db 011h, 033h, 099h, 0bbh, 088h, 0ffh ; RY 36 db 000h, 000h, 000h, 011h, 055h, 077h ; RM 42 db 000h, 000h, 011h, 055h, 077h, 088h ; RM 48 db 000h, 000h, 011h, 055h, 088h, 0ffh ; RM 54 db 000h, 011h, 055h, 099h, 0ddh, 077h ; RM 60 db 011h, 055h, 099h, 0ddh, 077h, 088h ; RM 66 db 011h, 055h, 099h, 0ddh, 088h, 0ffh ; RM 72 db 000h, 000h, 000h, 022h, 033h, 077h ; GY 78 db 000h, 000h, 022h, 033h, 077h, 088h ; GY 84 db 000h, 000h, 022h, 033h, 088h, 0ffh ; GY 90 db 000h, 022h, 033h, 0aah, 0bbh, 077h ; GY 96 db 022h, 033h, 0aah, 0bbh, 077h, 088h ; GY 102 db 022h, 033h, 0aah, 0bbh, 088h, 0ffh ; GY 108 db 000h, 000h, 000h, 022h, 066h, 077h ; GC 114 db 000h, 000h, 022h, 066h, 077h, 088h ; GC 120 db 000h, 000h, 022h, 066h, 088h, 0ffh ; GC 126 db 000h, 022h, 066h, 0aah, 0eeh, 077h ; GC 132 db 022h, 066h, 0aah, 0eeh, 077h, 088h ; GC 138 db 022h, 066h, 0aah, 0eeh, 088h, 0ffh ; GC 144 db 000h, 000h, 000h, 044h, 055h, 077h ; BM 150 db 000h, 000h, 044h, 055h, 077h, 088h ; BM 156 db 000h, 000h, 044h, 055h, 088h, 0ffh ; BM db 000h, 044h, 055h, 0cch, 0ddh, 077h ; BM 162 db 044h, 055h, 0cch, 0ddh, 077h, 088h ; BM 168 db 044h, 055h, 0cch, 0ddh, 088h, 0ffh ; BM 174 db 000h, 000h, 000h, 044h, 066h, 077h ; BC 180 db 000h, 000h, 044h, 066h, 077h, 088h ; BC 186 db 000h, 000h, 044h, 066h, 088h, 0ffh ; BC 192 db 000h, 044h, 066h, 0cch, 0eeh, 077h ; BC 198 db 044h, 066h, 0cch, 0eeh, 077h, 088h ; BC 204 db 044h, 066h, 0cch, 0eeh, 088h, 0ffh ; BC 210 ;****************************************************************************** ; Following EQUATES and MACROS only used in this file ;****************************************************************************** VGA256_SSSP_XLAT_TABLE equ 0 VGA256_XLATE_TABLE_SIZE equ 256 ; 87654321 ;------------------------------------------ HTPAT_STK_MASK equ (0ffh) HTPAT_NOT_STK_MASK equ (NOT HTPAT_STK_MASK) HTPAT_STK_MASK_SIZE equ (HTPAT_STK_MASK + 1) HTPAT_BP_SIZE equ (REG_MAX_SIZE * 1) HTPAT_BP_OLDSTK equ (REG_MAX_SIZE * 2) HTPAT_BP_DATA1 equ (REG_MAX_SIZE * 3) HTPAT_STK_SIZE_EXTRA equ (REG_MAX_SIZE * 3) HTPAT_SP_SIZE equ (HTPAT_STK_SIZE_EXTRA - HTPAT_BP_SIZE) HTPAT_SP_OLDSTK equ (HTPAT_STK_SIZE_EXTRA - HTPAT_BP_OLDSTK) HTPAT_SP_DATA1 equ (HTPAT_STK_SIZE_EXTRA - HTPAT_BP_DATA1) .XLIST @ENTER_PAT_TO_STK MACRO Format LOCAL StkSizeOk, DoneSetUp __@@VALID_PARAM? <PAT_TO_STK>, 1, Format, <1BPP, 3PLANES, 4BPP, VGA16, VGA256, 16BPP> @ENTER _DS _SI _DI _BP ;; Save environment/registers __@@EMIT <xor > _CX, _CX __@@EMIT <mov > cx, <OutFuncInfo.OFI_PatWidthBytes> __@@EMIT <mov > _AX, _SP ;; get stack location __@@EMIT <mov > _DX, _AX ;; save it __@@EMIT <and > _AX, <HTPAT_STK_MASK> ;; how many bytes avai __@@EMIT <inc > _AX ;; this many bytes __@@EMIT <cmp > _AX, _CX ;; enough for pattern? __@@EMIT <jae > <SHORT StkSizeOk> __@@EMIT <add > _AX, <HTPAT_STK_MASK_SIZE> ;; add this more StkSizeOk: __@@EMIT <dec > _AX ;; back one __@@EMIT <sub > _SP, _AX ;; reduced it __@@EMIT <mov > _DI, _SP ;; _DI point to the pPattern __@@EMIT <sub > _SP, <HTPAT_STK_SIZE_EXTRA> ;; reduced again __@@EMIT <mov > <[_DI-HTPAT_BP_SIZE]>, _CX ;; save the pattern size __@@EMIT <mov > <[_DI-HTPAT_BP_OLDSTK]>, _DX ;; save old stk pointer IFIDNI <Format>,<3PLANES> IFE ExtRegSet __@@EMIT <mov > _AX, <WPTR OutFuncInfo.OFI_BytesPerPlane> ELSE __@@EMIT <mov > _AX, OutFuncInfo.OFI_BytesPerPlane ENDIF __@@EMIT <mov > <[_DI-HTPAT_BP_DATA1]>, _AX ENDIF ; ; now staring coping the pattern to stack ; MOV_SEG es, ss, ax LDS_SI pPattern MOVS_CB _CX, dl ;; copy the pattern __@@EMIT <mov > _BX, _DI ;; _BX point to the pattern start IFIDNI <Format>, <VGA256> IFE ExtRegSet __@@EMIT <mov > _AX, <WPTR OutFuncInfo.OFI_BytesPerPlane + 2> or _AX, _AX jz SHORT DoneXlateTable mov _CX, VGA256_XLATE_TABLE_SIZE sub _SP, _CX mov _DI, _SP LDS_SI OutFuncInfo.OFI_BytesPerPlane MOVS_CB _CX, dl ELSE __@@EMIT <mov > _AX, OutFuncInfo.OFI_BytesPerPlane ENDIF ENDIF DoneXlateTable: IFIDNI <Format>, <1BPP> LDS_SI pPrimMonoCount ELSE LDS_SI pPrimColorCount ;; _SI=pPrimColorCount ENDIF LES_DI pDest __@@EMIT <mov > _BP, _BX ;; _BP=Pattern Start ENDM @EXIT_PAT_STK_RESTORE MACRO __@@EMIT <mov > _BP, _SP __@@EMIT <mov > _SP, <[_BP + HTPAT_SP_OLDSTK]> @EXIT ENDM WRAP_BP_PAT?? MACRO EndWrapLoc Local DoneWrap IFB <EndWrapLoc> __@@EMIT <test > bp, <HTPAT_STK_MASK> __@@EMIT <jnz > <SHORT DoneWrap> __@@EMIT <add > _BP, <[_BP-HTPAT_BP_SIZE]> ;; add in pattern size ELSE __@@EMIT <test > bp, <HTPAT_STK_MASK> __@@EMIT <jnz > <SHORT EndWrapLoc> __@@EMIT <add > _BP, <[_BP-HTPAT_BP_SIZE]> ;; add in pattern size __@@EMIT <jmp > <SHORT EndWrapLoc> ENDIF DoneWrap: ENDM SAVE_1BPP_DEST MACRO ; ; Save Prim1 (DL) to Plane ; __@@EMIT <not > dl ; invert bit __@@EMIT <mov > <BPTR_ES[_DI]>, dl ; Save Dest ENDM SAVE_1BPP_MASKDEST MACRO ; ; Save Prim1 (DL) with Mask (DH, 1=Preserved, 0=Overwrite) to Dest ; __@@EMIT <and > <BPTR_ES[_DI]>, dh ; Mask overwrite bits __@@EMIT <not > dx ; invert bit/mask __@@EMIT <and > dl, dh __@@EMIT <or > <BPTR_ES[_DI]>, dl ; Save Plane1=Prim3 ENDM SAVE_VGA16_DEST MACRO ; ; Save Prim1/2/3 (DL) to Plane ; __@@EMIT <mov > dh, dl __@@EMIT <add > dh, 11h __@@EMIT <and > dh, 88h __@@EMIT <or > dl, dh __@@EMIT <not > dl __@@EMIT <mov > <BPTR_ES[_DI]>, dl ; Save Dest ENDM SAVE_VGA16_DEST_HIGH MACRO ; ; Save Prim1 (DL) high nibble only, preserved low nibble ; __@@EMIT <and > <BPTR_ES[_DI]>, 0fh ; Mask overwrite bits __@@EMIT <mov > dh, dl __@@EMIT <inc > dh __@@EMIT <and > dh, 08h __@@EMIT <or > dl, dh __@@EMIT <not > dl ; invert bit/mask __@@EMIT <shl > dl, 4 __@@EMIT <or > <BPTR_ES[_DI]>, dl ; Save Plane1=Prim3 ENDM SAVE_VGA16_DEST_LOW MACRO ; ; Save Prim1 (DL) low nibble only, preserved high nibble ; __@@EMIT <and > <BPTR_ES[_DI]>, 0f0h ; Mask overwrite bits __@@EMIT <mov > dh, dl __@@EMIT <inc > dh __@@EMIT <and > dh, 08h __@@EMIT <or > dl, dh __@@EMIT <xor > dl, 0fh ; invert bit/mask __@@EMIT <or > <BPTR_ES[_DI]>, dl ; Save Plane1=Prim3 ENDM SAVE_4BPP_DEST MACRO ; ; Save Prim1/2/3 (DL) to Plane ; __@@EMIT <xor > dl, 77h __@@EMIT <mov > <BPTR_ES[_DI]>, dl ; Save Dest ENDM SAVE_4BPP_DEST_HIGH MACRO LOCAL DoneVGA ; ; Save Prim1 (DL) high nibble only, preserved low nibble ; __@@EMIT <and > <BPTR_ES[_DI]>, 0fh ; Mask overwrite bits __@@EMIT <xor > dl, 07h ; Invert bits __@@EMIT <shl > dl, 4 ; move to high nibble __@@EMIT <or > <BPTR_ES[_DI]>, dl ; Save Plane1=Prim3 ENDM SAVE_4BPP_DEST_LOW MACRO LOCAL DoneVGA ; ; Save Prim1 (DL) low nibble only, preserved high nibble ; __@@EMIT <and > <BPTR_ES[_DI]>, 0f0h ; Mask overwrite bits __@@EMIT <xor > dl, 07h ; invert bit/mask __@@EMIT <or > <BPTR_ES[_DI]>, dl ; Save Plane1=Prim3 ENDM SAVE_3PLANES_DEST MACRO UseAX ; ; Save Prim1/2/3 (CL:CH:DL) to Plane3/2/1 ; IFB <UseAX> __@@EMIT <push > _BP ; save Prim1/2 ELSE __@@EMIT <mov > _AX, _BP ; save _BP ENDIF __@@EMIT <and > _BP, <HTPAT_NOT_STK_MASK> ; to HTPAT_BP_xxx __@@EMIT <mov > _BP, <[_BP - HTPAT_BP_DATA1]> ; size of plane __@@EMIT <not > cx ; invert the bits __@@EMIT <not > dl ; invert bit __@@EMIT <mov > <BPTR_ES[ _DI]>, dl ; Save Plane1=Prim3 __@@EMIT <mov > <BPTR_ES[_BP + _DI]>, ch ; save Plane2=Prim2 IFE ExtRegSet __@@EMIT <add > _BP, _BP ; goto plane3 __@@EMIT <mov > <BPTR_ES[_BP+_DI]>, cl ; save Plane3=Prim1 ELSE __@@EMIT <mov > <BPTR_ES[(_BP*2)+_DI]>, cl ; save Plane3=Prim1 ENDIF IFB <UseAX> __@@EMIT <pop > _BP ; restore _BP ELSE __@@EMIT <mov > _BP, _AX ; restore _BP ENDIF ENDM SAVE_3PLANES_MASKDEST MACRO UseAX ; ; Save Prim1/2/3 (CL:CH:DL) with Mask (DH, 1=Preserved, 0=Overwrite) to ; Plane3/2/1 ; IFB <UseAX> __@@EMIT <push > _BP ; save Prim1/2 ELSE __@@EMIT <mov > _AX, _BP ; save _BP ENDIF __@@EMIT <and > _BP, <HTPAT_NOT_STK_MASK> ; to HTPAT_BP_xxx __@@EMIT <mov > _BP, <[_BP - HTPAT_BP_DATA1]> ; size of plane __@@EMIT <not > cx ; invert the bits __@@EMIT <not > dx ; invert bit/mask __@@EMIT <and > cl, dh ; mask preserved bits __@@EMIT <and > ch, dh __@@EMIT <and > dl, dh __@@EMIT <not > dh ; for dest mask __@@EMIT <and > <BPTR_ES[ _DI]>, dh ; Mask overwrite bits __@@EMIT <or > <BPTR_ES[ _DI]>, dl ; Save Plane1=Prim3 __@@EMIT <and > <BPTR_ES[_BP + _DI]>, dh ; Mask overwrite bits __@@EMIT <or > <BPTR_ES[_BP + _DI]>, ch ; save Plane2=Prim2 IFE ExtRegSet __@@EMIT <add > _BP, _BP ; goto plane3 __@@EMIT <and > <BPTR_ES[_BP + _DI]>, dh ; Mask overwrite bits __@@EMIT <or > <BPTR_ES[_BP + _DI]>, cl ; save Plane3=Prim1 ELSE __@@EMIT <and > <BPTR_ES[(_BP*2) + _DI]>, dh ; Mask overwrite bits __@@EMIT <or > <BPTR_ES[(_BP*2) + _DI]>, cl ; save Plane3=Prim1 ENDIF IFB <UseAX> __@@EMIT <pop > _BP ; restore _BP ELSE __@@EMIT <mov > _BP, _AX ; restore _BP ENDIF ENDM .LIST SUBTTL SingleCountOutputTo1BPP PAGE COMMENT ` Routine Description: This function output to the BMF_1BPP destination surface from PRIMMONO_COUNT data structure array. Arguments: pPrimMonoCount - Pointer to the PRIMMONO_COUNT data structure array. pDest - Pointer to first modified destination byte pPattern - Pointer to the starting pattern byte for the current destination scan line. OutFuncInfo - OUTFUNCINFO data structure. Return Value: No return value. Author: 24-Jan-1991 Thu 11:47:08 created -by- Daniel Chou (danielc) Revision History: ` @BEG_PROC SingleCountOutputTo1BPP <pPrimMonoCount:DWORD, \ pDest:DWORD, \ pPattern:DWORD, \ OutFuncInfo:QWORD> ; ; Register Usage: ; ; _SI = pPrimMonoCount ; _DI = pDestination ; _BP = Self host pPattern ; al:ah = Prim1/2 ; dl = DestByte ; dh = DestMask @ENTER_PAT_TO_STK <1BPP> ; _BP=Pat location, fall throug to load ;============================================================================= ; the DH has two uses, it contains the mask bits (1 bit=Mask), and it also ; contains an extra bit to do a byte boundary test, every time we shift the ; mask left by one, the boundary bit get shift to left, when first time a ; carry is produced then we know we finished one byte. at here we set up the ; dh=FirstMask + Aligned boundary bit ;============================================================================= mov _DX, 1ffh ; dh=Mask (1=Mask, 0=Not Mask) MOVZX_W _CX, <WPTR [_SI]> ; load extended sub _BP, _CX ; back the _BP shl _DX, cl ; set first mask xor dl, dl ; clear Prim1 jmp short LoadByte ;============================================================================ ; EOF encountered, if Mask (DH) is equal to 0x01 then we just starting the new ; byte, which we just have exactly end at last byte boundary (no last byte ; mask), otherwise, shift all destination byte to left by count, then mask it ;============================================================================ ; EOF encountered, if count is 0, then there is no last byte mask, so just ; exit, otherwise, shift all destination byte to left by count, then mask it ;============================================================================ EOFDest: cmp dh, 1 jz short AllDone ; finished EOFDestMask: mov cx, WPTR [_SI] ; get LastByteSkips xor ah, ah ; ax=0xffff now, clear ah shl ax, cl ; ah=LastByteMask shl dx, cl ; shift Mask+Prim1 or dh, ah ; add in dh=mask cmp dh, 0ffh ; if dh=0xff then all masked jz short AllDone SAVE_1BPP_MASKDEST ; save last byte AllDone: @EXIT_PAT_STK_RESTORE ;========================================================================== ; An invalid density is encountered, (0xff to indicate the stretch must not ; update to the destination), if this is the last stretch then do 'EOFDest' ; otherwise set mask bits until the byte boundary is encountered then fall ; through to load next byte, if a byte boundary is before count are exausted ; then save that mask byte and it will automatically skip rest of the pels. ;========================================================================== InvDensity: cmp al, ah jz short EOFDest ; EOF add dx, dx inc dh ; add in mask, 'C' not changed jc short DoneOneByte ; finished? if not fall through LoadByte: add _SI, SIZE_PMC ; sizeof(PRIMMONO_COUNT) mov ax, WPTR [_SI+2] ; al:ah=Prim 1/2 dec _BP ; ready to access pattern cmp al, PRIM_INVALID_DENSITY jz short InvDensity cmp al, BPTR[_BP] ; check with pattern adc dx, dx jnc short LoadByte DoneOneByte: or dh, dh ; any mask? jnz short HasDestMask SAVE_1BPP_DEST ; save it, no jmp ReadyNextByte: inc _DI mov _DX, 0100h ; dh=0x01=Boundary test bit WRAP_BP_PAT?? <LoadByte> HasDestMask: cmp dh, 0ffh jz short ReadyNextByte ; SAVE_1BPP_MASKDEST ; save it with DH=mask jmp short ReadyNextByte @END_PROC SUBTTL VarCountOutputTo1BPP PAGE COMMENT ` Routine Description: This function output to the BMF_1BPP destination surface from PRIMMONO_COUNT data structure array. Arguments: pPrimMonoCount - Pointer to the PRIMMONO_COUNT data structure array. pDest - Pointer to first modified destination byte pPattern - Pointer to the starting pattern byte for the current destination scan line. OutFuncInfo - OUTFUNCINFO data structure. Return Value: No return value. Author: 24-Jan-1991 Thu 11:47:08 created -by- Daniel Chou (danielc) Revision History: ` @BEG_PROC VarCountOutputTo1BPP <pPrimMonoCount:DWORD, \ pDest:DWORD, \ pPattern:DWORD, \ OutFuncInfo:QWORD> ; ; Register Usage: ; ; _SI = pPrimMonoCount ; _DI = pDestination ; _BP = Self host pPattern ; cx = PrimMonoCount.Count ; al:ah = Prim1/2 ; dl = DestByte ; dh = DestMask ; @ENTER_PAT_TO_STK <1BPP> ; _BP=Pat location ;============================================================================= ; the DH has two uses, it contains the mask bits (1 bit=Mask), and it also ; contains an extra bit to do a byte boundary test, every time we shift the ; mask left by one, the boundary bit get shift to left, when first time a ; carry is produced then we know we finished one byte. at here we set up the ; dh=FirstMask + Aligned boundary bit ;============================================================================= mov _DX, 1ffh ; dh=Mask (1=Mask, 0=Not Mask) MOVZX_W _CX, <WPTR [_SI]> ; load extended sub _BP, _CX ; back the _BP shl _DX, cl ; set first mask xor dl, dl ; clear Prim1 jmp short LoadByte ;============================================================================ ; EOF encountered, if Mask (DH) is equal to 0x01 then we just starting the new ; byte, which we just have exactly end at last byte boundary (no last byte ; mask), otherwise, shift all destination byte to left by count, then mask it ;============================================================================ ; EOF encountered, if count is 0, then there is no last byte mask, so just ; exit, otherwise, shift all destination byte to left by count, then mask it ;============================================================================ EOFDest: jcxz short AllDone ; if cx=0 then done EOFDestMask: xor ah, ah ; ax=0xffff now, clear ah shl ax, cl ; ah=LastByteMask shl dx, cl ; shift Mask+Prim1 or dh, ah ; add in dh=mask cmp dh, 0ffh ; if dh=0xff then all masked jz short AllDone SAVE_1BPP_MASKDEST ; save it with DH=mask AllDone: @EXIT_PAT_STK_RESTORE ; restore original SP ;========================================================================== ; An invalid density is encountered, (0xff to indicate the stretch must not ; update to the destination), if this is the last stretch then do 'EOFDest' ; otherwise set mask bits until the byte boundary is encountered then fall ; through to load next byte, if a byte boundary is before count are exausted ; then save that mask byte and it will automatically skip rest of the pels. ;========================================================================== InvDensity: cmp al, ah jz short EOFDest ; done InvDensityLoop: dec _BP add dx, dx inc dh ; add in mask, 'C' not changed jc short DoneOneByte dec cx jnz short InvDensityLoop ; !!! FALL THROUGH LoadByte: add _SI, SIZE_PMC ; sizeof(PRIMMONO_COUNT) mov cx, WPTR [_SI] ; cx=Count mov ax, WPTR [_SI+2] ; al:ah=Prim1/2 cmp al, PRIM_INVALID_DENSITY ; a skip?, if yes go do it jz short InvDensity inc cx ; make it no jump MakeByte: dec cx jz short LoadByte dec _BP ; ready to access pattern mov ah, BPTR[_BP] ; get pattern cmp al, ah adc dx, dx jnc short MakeByte ; if carry then byte boundary DoneOneByte: or dh, dh ; any mask? jnz short HasDestMask ; yes SAVE_1BPP_DEST ; save it ReadyNextByte: inc _DI ; ++pDest mov _DX, 0100h ; dh=0x01, dl=0x00 WRAP_BP_PAT?? <MakeByte> ;============================================================================= ; Mask the destination by DH mask, (1 bit=Mask), if whole destiantion byte is ; masked then just increment the pDest ;============================================================================= HasDestMask: cmp dh, 0ffh jz short DoneDestMask SAVE_1BPP_MASKDEST ; save it with DH=mask DoneDestMask: cmp al, PRIM_INVALID_DENSITY ; is last one a skip stretch? jnz short ReadyNextByte cmp cx, 1 ; more than 0 count? jbe short ReadyNextByte ; no, continue ; ;*** FALL THROUGH ; ;============================================================================ ; skip the 'cx-1' count of pels on the destination (SI is post decrement so ; we must only skip 'cxi-1' count), it will skip the 'pDest', set up next ; pDest mask, also it will aligned the destination pattern pointer (_BP) ;=========================================================================== SkipDestPels: inc _DI ; update to current pDest dec cx ; back one WZXE cx ; zero extended mov _AX, _CX ; _AX=_CX=Count and cl, 7 ;=============================================================== mov _DX, 1ffh ; ready to shift shl _DX, cl ; Boundary Bit + MASK xor dl, dl ; clear Prim1 ;================================================================ mov _CX, _AX ; get count again shr _CX, 3 add _DI, _CX ; pDest += (Count >> 3) mov _CX, _BP ; align pattern now and _CX, HTPAT_STK_MASK ; how many pat avai.? xor _BP, _CX ; clear _BP mask=pPattern sub _CX, _AX ; see if > 0? (_AX=Count) jg short DoneSkipDestPels ; still not used up yet! mov _AX, [_BP - HTPAT_BP_SIZE] ; get pattern size SkipDestPelsLoop: add _CX, _AX jle short SkipDestPelsLoop ; do until > 0 DoneSkipDestPels: add _BP, _CX ; _BP=pCurPat jmp LoadByte @END_PROC SUBTTL SingleCountOutputTo3Planes PAGE COMMENT ` Routine Description: This function output to the BMF_1BPP_3PLANES destination surface from PRIMCOLOR_COUNT data structure array. Arguments: pPrimColorCount - Pointer to the PRIMCOLOR_COUNT data structure array. pDest - Pointer to the destination planes pointers. pPattern - Pointer to the starting pattern byte for the current destination scan line. OutFuncInfo - OUTFUNCINFO data structure. Return Value: No return value. Author: 24-Jan-1991 Thu 11:47:08 created -by- Daniel Chou (danielc) Revision History: 18-Jun-1991 Tue 12:00:35 updated -by- Daniel Chou (danielc) Fixed destination masking bugs, it should be 0xff/0x00 rather 0x77 ` @BEG_PROC SingleCountOutputTo3Planes <pPrimColorCount:DWORD, \ pDest:DWORD, \ pPattern:DWORD, \ OutFuncInfo:QWORD> ; ; Register Usage: ; ; _SI = pPrimMonoCount ; _BP = Self host pPattern ; _SP = Some saved environment (Old BP to get to the local variable) ; bl:bh:al = Prim 1/2/3 ; cl:ch:dl = Current Destination Byte, 0x88 is the mask bit indicator ; dh = Dest Mask ; ; Prim1 -> pPlane3 <---- Highest bit ; Prim2 -> pPlane2 ; Prim3 -> pPlane1 <---- Lowest bit ; ; Local Variable access from Old BP, BytesPerPlane ; @ENTER_PAT_TO_STK <3PLANES> ; _BP=Pat location, fall throug to load ;============================================================================= ; the DH has two uses, it contains the mask bits (1 bit=Mask), and it also ; contains an extra bit to do a byte boundary test, every time we shift the ; mask left by one, the boundary bit get shift to left, when first time a ; carry is produced then we know we finished one byte. at here we set up the ; dh=FirstMask + Aligned boundary bit ;============================================================================= mov _DX, 1ffh ; dh=Mask (1=Mask, 0=Not Mask) MOVZX_W _CX, <WPTR [_SI]> ; load extended sub _BP, _CX ; back the _BP shl _DX, cl ; set first mask xor dl, dl xor _CX, _CX ; clear cx now jmp short LoadByte ;============================================================================ ; EOF encountered, if Mask (DH) is equal to 0x01 then we just starting the new ; byte, which we just have exactly end at last byte boundary (no last byte ; mask), otherwise, shift all destination byte to left by count, then mask it ;============================================================================ ; EOF encountered, if count is 0, then there is no last byte mask, so just ; exit, otherwise, shift all destination byte to left by count, then mask it ;============================================================================ EOFDest: cmp dh, 1 jz short AllDone ; finished EOFDestMask: mov ax, cx ; save Prim1/2=al:ah mov cx, WPTR [_SI] ; get LastByteSkips xor bh, bh ; bx=0xffff now, clear bh shl bx, cl ; bh=LastByteMask shl dx, cl ; shift Mask+Prim3 or dh, bh ; add in dh=mask cmp dh, 0ffh ; if dh=0xff then all masked jz short AllDone shl ax, cl ; shift Prim1/2 mov cx, ax ; restore cl:ch=Prim1/2 SAVE_3PLANES_MASKDEST <UseAX> ; save last byte AllDone: @EXIT_PAT_STK_RESTORE ; exit/restore env/stack ;========================================================================== ; An invalid density is encountered, (0xff to indicate the stretch must not ; update to the destination), if this is the last stretch then do 'EOFDest' ; otherwise set mask bits until the byte boundary is encountered then fall ; through to load next byte, if a byte boundary is before count are exausted ; then save that mask byte and it will automatically skip rest of the pels. ;========================================================================== InvDensity: cmp bl, bh jz short EOFDest ; EOF add cx, cx add dx, dx inc dh ; add in mask, 'C' not changed jc short DoneOneByte ; finished? if not fall through LoadByte: add _SI, SIZE_PCC ; sizeof(PRIMCOLOR_COUNT) mov bx, WPTR [_SI+2] ; bl:bh:al:ah=Prim 1/2/3/4 mov ax, WPTR [_SI+4] dec _BP ; ready to access pattern cmp bl, PRIM_INVALID_DENSITY jz short InvDensity mov ah, BPTR[_BP] ; get pattern cmp bl, ah adc cl, cl cmp bh, ah adc ch, ch cmp al, ah adc dx, dx jnc short LoadByte DoneOneByte: or dh, dh ; any mask? jnz short HasDestMask SAVE_3PLANES_DEST <UseAX> ; save it, no jmp ReadyNextByte: inc _DI xor _CX, _CX ; clear destination mov _DX, 0100h ; dh=0x01=Boundary test bit WRAP_BP_PAT?? <LoadByte> HasDestMask: cmp dh, 0ffh jz short ReadyNextByte ; SAVE_3PLANES_MASKDEST <UseAX> ; save it with DH=mask jmp short ReadyNextByte @END_PROC SUBTTL VarCountOutputTo3Planes PAGE COMMENT ` Routine Description: This function output to the BMF_1BPP_3PLANES destination surface from PRIMCOLOR_COUNT data structure array. Arguments: pPrimColorCount - Pointer to the PRIMCOLOR_COUNT data structure array. pDest - Pointer to the destination planes pointers. pPattern - Pointer to the starting pattern byte for the current destination scan line. OutFuncInfo - OUTFUNCINFO data structure. Return Value: No return value. Author: 24-Jan-1991 Thu 11:47:08 created -by- Daniel Chou (danielc) Revision History: 18-Jun-1991 Tue 12:00:35 updated -by- Daniel Chou (danielc) Fixed destination masking bugs, it should be 0xff/0x00 rather 0x77 ` @BEG_PROC VarCountOutputTo3Planes <pPrimColorCount:DWORD, \ pDest:DWORD, \ pPattern:DWORD, \ OutFuncInfo:QWORD> ; ; Register Usage: ; ; _SI = pPrimColorCount ; _BP = Self host pPattern ; _SP = Some saved environment (Old BP to get to the local variable) ; di = pPlane1 ; bl:bh:al = Prim 1/2/3 ; cl:ch:dl = Current Destination Byte, 0x88 is the mask bit indicator ; dh = Dest Mask ; ; Prim1 -> pPlane3 <---- Highest bit ; Prim2 -> pPlane2 ; Prim3 -> pPlane1 <---- Lowest bit ; ; Local Variable access from Old BP, BytesPerPlane ; @ENTER_PAT_TO_STK <3PLANES> ; _BP=Pat location ;============================================================================= ; the DH has two uses, it contains the mask bits (1 bit=Mask), and it also ; contains an extra bit to do a byte boundary test, every time we shift the ; mask left by one, the boundary bit get shift to left, when first time a ; carry is produced then we know we finished one byte. at here we set up the ; dh=FirstMask + Aligned boundary bit ;============================================================================= mov _DX, 1ffh ; dh=Mask (1=Mask, 0=Not Mask) MOVZX_W _CX, <WPTR [_SI]> ; load extended sub _BP, _CX ; back the _BP shl _DX, cl ; set first mask xor dl, dl xor _CX, _CX ; clear cx now jmp short FirstLoadByte ;============================================================================ ; EOF encountered, if Mask (DH) is equal to 0x01 then we just starting the new ; byte, which we just have exactly end at last byte boundary (no last byte ; mask), otherwise, shift all destination byte to left by count, then mask it ;============================================================================ ; EOF encountered, if count is 0, then there is no last byte mask, so just ; exit, otherwise, shift all destination byte to left by count, then mask it ;============================================================================ EOFDest: or si, si jz short AllDone EOFDestMask: xchg si, cx ; si=Prim1/2, cx=Last Skips xor bh, bh ; bx=0xffff now, clear bh shl bx, cl ; bh=LastByteMask shl dx, cl ; shift Mask+Prim3 or dh, bh ; add in dh=mask cmp dh, 0ffh ; if dh=0xff then all masked jz short AllDone shl si, cl ; shift Prim1/2 mov cx, si ; restore cl:ch=Prim1/2 SAVE_3PLANES_MASKDEST ; save it with DH=mask AllDone: pop _SI ; pop the source pointer push @EXIT_PAT_STK_RESTORE ; restore original SP ;========================================================================== ; An invalid density is encountered, (0xff to indicate the stretch must not ; update to the destination), if this is the last stretch then do 'EOFDest' ; otherwise set mask bits until the byte boundary is encountered then fall ; through to load next byte, if a byte boundary is before count are exausted ; then save that mask byte and it will automatically skip rest of the pels. ;========================================================================== InvDensity: cmp bl, bh jz short EOFDest ; done InvDensityLoop: dec _BP add cx, cx add dx, dx inc dh ; add in mask, 'C' not changed jc short DoneOneByte dec si jnz short InvDensityLoop ; !!! FALL THROUGH LoadByte: pop _SI ; restore _SI FirstLoadByte: add _SI, SIZE_PCC ; sizeof(PRIMCOLOR_COUNT) push _SI ; save _SI mov bx, WPTR [_SI+2] ; bl:bh=Prim1/2 mov ax, WPTR [_SI+4] ; al:ah=Prim3/4 mov si, WPTR [_SI] ; si=Count cmp bl, PRIM_INVALID_DENSITY ; a skip?, if yes go do it jz short InvDensity inc si ; make it no jump MakeByte: dec si jz short LoadByte dec _BP ; ready to access pattern mov ah, BPTR[_BP] ; get pattern cmp bl, ah adc cl, cl cmp bh, ah adc ch, ch cmp al, ah adc dx, dx jnc short MakeByte ; if carry then byte boundary DoneOneByte: or dh, dh ; any mask? jnz short HasDestMask ; yes SAVE_3PLANES_DEST ; save it ReadyNextByte: inc _DI ; ++pDest xor _CX, _CX ; clear destination mov _DX, 0100h ; dh=0x01, dl=0x00 WRAP_BP_PAT?? <MakeByte> ;============================================================================= ; Mask the destination by DH mask, (1 bit=Mask), if whole destiantion byte is ; masked then just increment the pDest ;============================================================================= HasDestMask: cmp dh, 0ffh jz short DoneDestMask SAVE_3PLANES_MASKDEST ; save it with DH=mask DoneDestMask: cmp bl, PRIM_INVALID_DENSITY ; is last one a skip stretch? jnz short ReadyNextByte cmp si, 1 ; more than 0 count? jbe short ReadyNextByte ; no, continue ; ;*** FALL THROUGH ; ;============================================================================ ; skip the 'si-1' count of pels on the destination (SI is post decrement so ; we must only skip 'si-1' count), it will skip the 'pDest', set up next ; pDest mask, also it will aligned the destination pattern pointer (_BP) ;=========================================================================== SkipDestPels: inc _DI ; update to current pDest dec si ; back one WZXE si ; zero extended mov cx, si and cl, 7 ;=============================================================== mov _DX, 1ffh ; ready to shift shl _DX, cl xor dl, dl ; clear Prim3 xor _CX, _CX ; clear Prim1/2 ;================================================================ mov _BX, _SI shr _BX, 3 add _DI, _BX mov _BX, _BP and _BX, HTPAT_STK_MASK ; how many pat avai.? xor _BP, _BX ; clear _BP mask=pPattern sub _BX, _SI ; see if > 0? jg short DoneSkipDestPels mov _SI, [_BP - HTPAT_BP_SIZE] ; get pattern size SkipDestPelsLoop: add _BX, _SI jle short SkipDestPelsLoop ; do until > 0 DoneSkipDestPels: add _BP, _BX ; _BP=pCurPat jmp LoadByte @END_PROC SUBTTL SingleCountOutputTo4BPP PAGE COMMENT ` Routine Description: This function output to the BMF_4BPP destination surface from PRIMCOLOR_COUNT data structure array. Arguments: pPrimColorCount - Pointer to the PRIMCOLOR_COUNT data structure array. pDest - Pointer to the destination planes pointers. pPattern - Pointer to the starting pattern byte for the current destination scan line. OutFuncInfo - OUTFUNCINFO data structure. Return Value: No return value. Author: 24-Jan-1991 Thu 11:47:08 created -by- Daniel Chou (danielc) Revision History: ` @BEG_PROC SingleCountOutputTo4BPP <pPrimColorCount:DWORD, \ pDest:DWORD, \ pPattern:DWORD, \ OutFuncInfo:QWORD> ;========================================== ; Register Usage: ; ; _SI : pPrimColorCount ; _DI : pDest ; _BP : Current pPattern, self wrappable ; bl:bh:al:ah : Prim 1/2/3/4 =====> Bit 2:1:0 ; dl : DestByte ; dh : scratch register ; ch : PRIM_INVALID_DENSITY ; cl : PRIM_INVALID_DENSITY --> CX = PRIMCOUNT_EOF ;========================================== @ENTER_PAT_TO_STK <4BPP> ; _BP=Pat location ;============================================================================= ; the DH has two uses, it contains the mask bits (1 bit=Mask), and it also ; contains an extra bit to do a byte boundary test, every time we shift the ; mask left by one, the boundary bit get shift to left, when first time a ; carry is produced then we know we finished one byte. at here we set up the ; dh=FirstMask + Aligned boundary bit ;============================================================================= mov _CX, PRIMCOUNT_EOF xor _DX, _DX ; clear mask/dest cmp WPTR [_SI], dx ; check if begin with skip jnz short InvDensityHStart ; has first skip LoadByteH: add _SI, SIZE_PCC ; sizeof(PRIMCOLOR_COUNT) mov bx, WPTR [_SI+2] ; bl:bh=Prim 1/2 cmp bl, ch ; invalid? jz short InvDensityH mov ax, WPTR [_SI+4] ; al:ah=Prim 3/4 MakeByteH: dec _BP mov dh, BPTR [_BP] cmp bl, dh adc dl, dl cmp bh, dh adc dl, dl cmp al, dh adc dl, dl LoadByteL: add _SI, SIZE_PCC ; sizeof(PRIMCOLOR_COUNT) mov bx, WPTR [_SI+2] ; bl:bh=Prim 1/2 cmp bl, ch ; invalid? jz short InvDensityL mov ax, WPTR [_SI+4] ; al:ah=Prim 3/4 MakeByteL: add dl, dl dec _BP mov dh, BPTR [_BP] cmp bl, dh adc dl, dl cmp bh, dh adc dl, dl cmp al, dh adc dl, dl SAVE_4BPP_DEST ReadyNextByte: inc _DI xor _DX, _DX WRAP_BP_PAT?? <LoadByteH> ;============================================================================= ; The high nibble need to be skipped, (byte boundary now), if bl=bh=INVALID ; then we are done else set the mask=0xf0 (high nibble) and if count > 1 then ; continune load LOW nibble ;============================================================================= InvDensityH: cmp bl, bh ; end? jz short AllDone ; exactly byte boundary InvDensityHStart: dec _BP ; update pCurPat LoadByteL2: add _SI, SIZE_PCC ; sizeof(PRIMCOLOR_COUNT) mov bx, WPTR [_SI+2] ; bl:bh=Prim 1/2 cmp bl, ch ; invalid? jz short DoneDestMask mov ax, WPTR [_SI+4] ; al:ah=Prim 3/4 MakeByteL2: add dl, dl ; skip high bit mov dh, BPTR [_BP-1] ; load next pattern cmp bl, dh adc dl, dl cmp bh, dh adc dl, dl cmp al, dh adc dl, dl SAVE_4BPP_DEST_LOW ; fall through DoneDestMask: dec _BP cmp bx, cx ; done? jnz short ReadyNextByte jmp short AllDone InvDensityL: SAVE_4BPP_DEST_HIGH dec _BP cmp bx, cx jnz short ReadyNextByte AllDone: @EXIT_PAT_STK_RESTORE @END_PROC SUBTTL VarCountOutputTo4BPP PAGE COMMENT ` Routine Description: This function output to the BMF_4BPP destination surface from PRIMCOLOR_COUNT data structure array. Arguments: pPrimColorCount - Pointer to the PRIMCOLOR_COUNT data structure array. pDest - Pointer to the destination plane. pPattern - Pointer to the starting pattern byte for the current destination scan line. OutFuncInfo - OUTFUNCINFO data structure. Return Value: No return value. Author: 24-Jan-1991 Thu 11:47:08 created -by- Daniel Chou (danielc) Revision History: ` @BEG_PROC VarCountOutputTo4BPP <pPrimColorCount:DWORD, \ pDest:DWORD, \ pPattern:DWORD, \ OutFuncInfo:QWORD> ;========================================== ; Register Usage: ; ; _SI : pPrimColorCount ; _DI : pDest ; _BP : Current pPattern, self wrappable ; cx : PrimColorCount.Count ; bl:bh:al:ah : Prim 1/2/3/4 =====> Bit 2:1:0 ; dl : DestByte ; dh : Scratch Register ;========================================== @ENTER_PAT_TO_STK <4BPP> ; _BP=Pat location ;============================================================================= ; the DH has two uses, it contains the mask bits (1 bit=Mask), and it also ; contains an extra bit to do a byte boundary test, every time we shift the ; mask left by one, the boundary bit get shift to left, when first time a ; carry is produced then we know we finished one byte. at here we set up the ; dh=FirstMask + Aligned boundary bit ;============================================================================= xor _DX, _DX ; clear mask/dest mov cx, WPTR [_SI] or cx, cx jnz short InvDensityHStart ; has first skip LoadByteH: add _SI, SIZE_PCC ; sizeof(PRIMCOLOR_COUNT) mov cx, WPTR [_SI] ; cx=count mov bx, WPTR [_SI+2] ; bl:bh=Prim 1/2 cmp bl, PRIM_INVALID_DENSITY ; invalid? jz short InvDensityH mov ax, WPTR [_SI+4] ; al:ah=Prim 3/4 inc cx LoadByteH1: dec cx jz short LoadByteH MakeByteH: dec _BP mov dh, BPTR [_BP] cmp bl, dh adc dl, dl cmp bh, dh adc dl, dl cmp al, dh adc dl, dl dec cx ; jz short LoadByteL MakeByteL: add dl, dl ; skip high bit dec _BP mov dh, BPTR [_BP] cmp bl, dh adc dl, dl cmp bh, dh adc dl, dl cmp al, dh adc dl, dl SAVE_4BPP_DEST ReadyNextByte: inc _DI xor _DX, _DX WRAP_BP_PAT?? <LoadByteH1> ;============================================================================= ; The high nibble need to be skipped, (byte boundary now), if bl=bh=INVALID ; then we are done else set the mask=0xf0 (high nibble) and if count > 1 then ; continune load LOW nibble ;============================================================================= LoadByteL: add _SI, SIZE_PCC ; sizeof(PRIMCOLOR_COUNT) mov cx, WPTR [_SI] ; cx=count mov bx, WPTR [_SI+2] ; bl:bh=Prim 1/2 mov ax, WPTR [_SI+4] ; al:ah=Prim 3/4 cmp bl, PRIM_INVALID_DENSITY ; invalid? jnz short MakeByteL SAVE_4BPP_DEST_HIGH ; save only high nibble jmp short DoneDestMask InvDensityH: cmp bl, bh ; end? jz short AllDone ; exactly byte boundary InvDensityHStart: dec _BP ; update pCurPat dec cx jnz short DoneDestMask LoadByteL2: add _SI, SIZE_PCC ; sizeof(PRIMCOLOR_COUNT) mov cx, WPTR [_SI] ; cx=count mov bx, WPTR [_SI+2] ; bl:bh=Prim 1/2 cmp bl, PRIM_INVALID_DENSITY ; invalid? jz short DoneDestMask mov ax, WPTR [_SI+4] ; al:ah=Prim 3/4 MakeByteL2: add dl, dl ; skip high bit mov dh, BPTR [_BP-1] ; load next pattern cmp bl, dh adc dl, dl cmp bh, dh adc dl, dl cmp al, dh adc dl, dl SAVE_4BPP_DEST_LOW ; fall through DoneDestMask: dec _BP cmp bl, PRIM_INVALID_DENSITY ; is last one a skip stretch? jnz short ReadyNextByte cmp bl, bh ; end? jz short AllDone cmp cx, 1 jbe short ReadyNextByte ;============================================================================ ; skip the 'cx-1' count of pels on the destination (SI is post decrement so ; we must only skip 'cx-1' count), it will skip the 'pDest', set up next ; pDest mask, also it will aligned the destination pattern pointer (_BP) ;=========================================================================== SkipDestPels: inc _DI ; update to current pDest xor _DX, _DX ; dec cx WZXE cx ; zero extended mov _AX, _CX shr _CX, 1 ; see if carry sbb dh, dh ; -1=skip high nibble add _DI, _CX ; 2 pels per byte mov _CX, _BP ; align pattern now and _CX, HTPAT_STK_MASK ; how many pat avai.? xor _BP, _CX ; clear _BP mask=pPattern sub _CX, _AX ; see if > 0? (_AX=Count) jg short DoneSkipDestPels ; still not used up yet! mov _AX, [_BP - HTPAT_BP_SIZE] ; get pattern size SkipDestPelsLoop: add _CX, _AX jle short SkipDestPelsLoop ; do until > 0 DoneSkipDestPels: add _BP, _CX ; _BP=pCurPat or dh, dh jnz short LoadByteL2 jmp LoadByteH AllDone: @EXIT_PAT_STK_RESTORE @END_PROC SUBTTL SingleCountOutputToVGA16 PAGE COMMENT ` Routine Description: This function output to the BMF_VGA16 destination surface from PRIMCOLOR_COUNT data structure array. Arguments: pPrimColorCount - Pointer to the PRIMCOLOR_COUNT data structure array. pDest - Pointer to the destination planes pointers. pPattern - Pointer to the starting pattern byte for the current destination scan line. OutFuncInfo - OUTFUNCINFO data structure. Return Value: No return value. Author: 24-Jan-1991 Thu 11:47:08 created -by- Daniel Chou (danielc) Revision History: ` @BEG_PROC SingleCountOutputToVGA16 <pPrimColorCount:DWORD, \ pDest:DWORD, \ pPattern:DWORD, \ OutFuncInfo:QWORD> ; ; VGA 16 Standard table ; ; 0, 0, 0, 0000 0 Black ; 0, ,0, 0x80 0001 1 Dark Red ; 0, 0x80,0, 0010 2 Dark Green ; 0, ,0x80,0x80 0011 3 Dark Yellow ; 0x80 0, 0, 0100 4 Dark Blue ; 0x80,0, 0x80 0101 5 Dark Magenta ; 0x80 0x80,0, 0110 6 Dark Cyan ; 0x80,0x80,0x80 0111 7 Gray 50% ; ; 0xC0,0xC0,0xC0 1000 8 Gray 75% ; 0, ,0, 0xFF 1001 9 Red ; 0, 0xFF,0, 1010 10 Green ; 0, ,0xFF,0xFF 1011 11 Yellow ; 0xFF 0, 0, 1100 12 Blue ; 0xFF,0, 0xFF 1101 13 Magenta ; 0xFF 0xFF,0, 1110 14 Cyan ; 0xFF,0xFF,0xFF 1111 15 White ; ;========================================== ; Register Usage: ; ; _SI : pPrimColorCount ; _DI : pDest ; _BP : Current pPattern, self wrappable ; bl:bh:dl:dh : Prim 1/2/5/6 Prim6 is Index for VGA16ColorIndex[] ; cl : PRIM_INVALID_DENSITY ; ch : ZERO (0) ; al : Pattern/Low Nibble ; ah : High nibble ; ; Prim1 = Initial VGA16ColorIndex[] ; Prim2 = Color Thresholds for VGA16ColorIndex[Prim1] ; Prim3 = Color Thresholds for VGA16ColorIndex[Prim1-1] ; Prim4 = Color Thresholds for VGA16ColorIndex[Prim1-2] ; Prim5 = Color Thresholds for VGA16ColorIndex[Prim1-3] ; Prim6 = Color Thresholds for VGA16ColorIndex[Prim1-4] ; ELSE VGA16ColorIndex[Prim1-5] ;========================================================================= ; @ENTER_PAT_TO_STK <VGA16> ; _BP=Pat location ;============================================================================= ; the DH has two uses, it contains the mask bits (1 bit=Mask), and it also ; contains an extra bit to do a byte boundary test, every time we shift the ; mask left by one, the boundary bit get shift to left, when first time a ; carry is produced then we know we finished one byte. at here we set up the ; dh=FirstMask + Aligned boundary bit ;============================================================================= xor _BX, _BX ; clear high word sub _SI, SIZE_PCC cmp WPTR [_SI + SIZE_PCC], bx ; check if begin with skip mov cl, PRIM_INVALID_DENSITY jz SHORT DoHNibble add _SI, SIZE_PCC jmp SHORT SkipPelsH_2 ; skip from the first pel AllDone: @EXIT_PAT_STK_RESTORE SkipPelsH: add _SI, (SIZE_PCC * 2) mov bx, WPTR [_SI+2] cmp bl, PRIM_INVALID_DENSITY jnz SHORT LoadHNibble SkipPelsH_1: cmp bl, bh jz SHORT AllDone SkipPelsH_2: sub _BP, 2 SkipPelsL: mov bx, WPTR [_SI+SIZE_PCC+2] cmp bl, PRIM_INVALID_DENSITY jz SHORT SkipPelsL_1 mov ah, BPTR_ES[_DI] ; start from Low nibble so mov cl, BPTR [_BP] ; get pattern jmp SHORT LoadLNibble ; we must load current dest SaveLNibbleAndSkip: and BPTR_ES[_DI], 0fh ; clear high nibble and ah, 0f0h ; clear low nibble or BPTR_ES[_DI], ah ; save it in SkipPelsL_1: cmp bl, bh jz SHORT AllDone inc _DI ; skip the destination WRAP_BP_PAT?? <SkipPelsH> ; repeat until no more skips DoHNibble: add _SI, (SIZE_PCC * 2) mov bx, WPTR [_SI+2] ; bl:bh=Prim 1/2 cmp bl, PRIM_INVALID_DENSITY jz SHORT SkipPelsH_1 LoadHNibble: sub _BP, 2 mov cx, WPTR [_BP] ; ;=================================================================== ; 2 4 6 ; +-+ +--+ +--+ ; 1 2 3 4 5 ; bh:cl:ch:dl:dh ;-------------------------- IFE ExtRegSet mov dx, WPTR [_SI+4] ; Color 2/3 cmp dh, ch ; first split in the middle jae SHORT GetH1 ; [ie. binary search/compare] mov dx, WPTR [_SI+6] ; now check if Prim4/5 ELSE mov _DX, DPTR [_SI+4] cmp dh, ch ; first split in the middle jae SHORT GetH1 ; [ie. binary search/compare] shr _DX, 16 ENDIF cmp dl, ch sbb bl, 3 ; one of -3/-4/-5 cmp dh, ch jmp SHORT GetH2 GetH1: cmp bh, ch ; it is white jae SHORT GetHNibble dec bl cmp dl, ch GetH2: sbb bl, 0 ; ;=================================================================== ; GetHNibble: xor bh, bh mov ah, BPTR cs:VGA16ColorIndex[_BX] DoLNibble: mov bx, WPTR [_SI+SIZE_PCC+2] ; bl:bh=Prim 1/2 cmp bl, PRIM_INVALID_DENSITY jz SHORT SaveLNibbleAndSkip LoadLNibble: ; ;=================================================================== ; 2 4 6 ; +-+ +--+ +--+ ; 1 2 3 4 5 ; bh:cl:ch:dl:dh ;-------------------------- IFE ExtRegSet mov dx, WPTR [_SI+SIZE+PCC+4] ; Color 2/3 cmp dh, cl ; first split in the middle jae SHORT GetL1 ; [ie. binary search/compare] mov dx, WPTR [_SI+SIZE+PCC+6] ; now check if Prim4/5 ELSE mov _DX, DPTR [_SI+SIZE_PCC+4] cmp dh, cl ; first split in the middle jae SHORT GetL1 ; [ie. binary search/compare] shr _DX, 16 ENDIF cmp dl, cl sbb bl, 3 ; one of -3/-4/-5 cmp dh, cl jmp SHORT GetL2 GetL1: cmp bh, cl ; it is white jae SHORT GetLNibble dec bl cmp dl, cl GetL2: sbb bl, 0 ; ;=================================================================== ; GetLNibble: xor bh, bh mov al, BPTR cs:VGA16ColorIndex[_BX] and ax, 0f00fh or al, ah stosb WRAP_BP_PAT?? <DoHNibble> @END_PROC SUBTTL VarCountOutputToVGA16 PAGE COMMENT ` Routine Description: This function output to the BMF_4BPP destination surface from PRIMCOLOR_COUNT data structure array. Arguments: pPrimColorCount - Pointer to the PRIMCOLOR_COUNT data structure array. pDest - Pointer to the destination plane. pPattern - Pointer to the starting pattern byte for the current destination scan line. OutFuncInfo - OUTFUNCINFO data structure. Return Value: No return value. Author: 24-Jan-1991 Thu 11:47:08 created -by- Daniel Chou (danielc) Revision History: ` @BEG_PROC VarCountOutputToVGA16 <pPrimColorCount:DWORD, \ pDest:DWORD, \ pPattern:DWORD, \ OutFuncInfo:QWORD> ; ; VGA 16 Standard table ; ; 0, 0, 0, 0000 0 Black ; 0, ,0, 0x80 0001 1 Dark Red ; 0, 0x80,0, 0010 2 Dark Green ; 0, ,0x80,0x80 0011 3 Dark Yellow ; 0x80 0, 0, 0100 4 Dark Blue ; 0x80,0, 0x80 0101 5 Dark Magenta ; 0x80 0x80,0, 0110 6 Dark Cyan ; 0x80,0x80,0x80 0111 7 Gray 50% ; ; 0xC0,0xC0,0xC0 1000 8 Gray 75% ; 0, ,0, 0xFF 1001 9 Red ; 0, 0xFF,0, 1010 10 Green ; 0, ,0xFF,0xFF 1011 11 Yellow ; 0xFF 0, 0, 1100 12 Blue ; 0xFF,0, 0xFF 1101 13 Magenta ; 0xFF 0xFF,0, 1110 14 Cyan ; 0xFF,0xFF,0xFF 1111 15 White ; ;========================================== ; Register Usage: ; ; _SI : pPrimColorCount ; _DI : pDest ; _BP : Current pPattern, self wrappable ; ax : PrimColorCount.Count ; bl:bh:cl:ch:dl:dh : Prim 1/2/3/4/5/6 ;========================================== ; Prim1 = Initial VGA16ColorIndex[] ; Prim2 = Color Thresholds for VGA16ColorIndex[Prim1] ; Prim3 = Color Thresholds for VGA16ColorIndex[Prim1-1] ; Prim4 = Color Thresholds for VGA16ColorIndex[Prim1-2] ; Prim5 = Color Thresholds for VGA16ColorIndex[Prim1-3] ; Prim6 = Color Thresholds for VGA16ColorIndex[Prim1-4] ; ELSE VGA16ColorIndex[Prim1-5] ;========================================================================= ; @ENTER_PAT_TO_STK <VGA16> ; _BP=Pat location ;============================================================================= ; the DH has two uses, it contains the mask bits (1 bit=Mask), and it also ; contains an extra bit to do a byte boundary test, every time we shift the ; mask left by one, the boundary bit get shift to left, when first time a ; carry is produced then we know we finished one byte. at here we set up the ; dh=FirstMask + Aligned boundary bit ;============================================================================= xor _BX, _BX cmp WPTR [_SI], 0 jnz SHORT SkipPelsH_2 JMP LoadPrimH ; start the process SkipPelsContinue: or dh, dh jz SHORT SkipPelsH SkipPelsL: cmp bl, bh jz SHORT AllDone xor dh, dh ; clear indicator dec _BP WRAP_BP_PAT?? inc _DI MOVZX_W _BX, <WPTR [_SI]> ; get skip count dec _BX ; only one jz SHORT TrySkipNext jmp SHORT SkipBXPels AllDone: @EXIT_PAT_STK_RESTORE SkipPelsH: cmp bl, bh ; end? jz SHORT AllDone SkipPelsH_2: MOVZX_W _BX, <WPTR [_SI]> ; get skip count SkipBXPels: mov _CX, _BX shr _CX, 1 ; see if carry sbb dh, dh ; -1=skip high nibble add _DI, _CX ; 2 pels per byte mov _CX, _BP ; align pattern now and _CX, HTPAT_STK_MASK ; how many pat avai.? xor _BP, _CX ; clear _BP mask=pPattern sub _CX, _BX ; see if > 0? (_BX=Count) jg short DoneSkipDestPels ; still not used up yet! mov _BX, [_BP - HTPAT_BP_SIZE] ; get pattern size SkipDestPelsLoop: add _CX, _BX jle short SkipDestPelsLoop ; do until > 0 DoneSkipDestPels: add _BP, _CX ; _BP=pCurPat TrySkipNext: add _SI, SIZE_PCC mov bx, WPTR [_SI+2] cmp bl, PRIM_INVALID_DENSITY ; still invalid ? jz SHORT SkipPelsContinue or dh, dh ; skip high nibble? jz SHORT LoadPrimHStart ; no mov cx, WPTR [_SI+4] ; cl:ch=Prim 3/4 mov dx, WPTR [_SI+6] ; dl:dh=Prim 5/6 push _SI mov si, WPTR [_SI] ; si=count and BPTR_ES[_DI], 0f0h ; clear low nibble first!!! jmp SHORT DoLNibble PopSI_LoadPrimH: pop _SI LoadPrimH: add _SI, SIZE_PCC ; sizeof(PRIMCOLOR_COUNT) mov bx, WPTR [_SI+2] ; bl:bh=Prim 1/2 cmp bl, PRIM_INVALID_DENSITY ; invalid? jz SHORT SkipPelsH LoadPrimHStart: mov cx, WPTR [_SI+4] ; dl:dh=Prim 3/4 mov dx, WPTR [_SI+6] ; al:ah=Prim 5/6 push _SI mov si, WPTR [_SI] ; si=count inc si DoHNibble: dec si jz SHORT PopSI_LoadPrimH dec _BP mov ah, BPTR [_BP] mov al, bl ; initial condition ; ; 1 2 3 4 5 ; bh:cl:ch:dl:dh ;---------------------- cmp ch, ah jae SHORT GetH1 cmp dl, ah sbb al, 3 cmp dh, ah jmp SHORT GetH2 GetH1: cmp bh, ah jae SHORT GetHNibble dec al cmp cl, ah GetH2: sbb al, 0 GetHNibble: BZXEAX al mov al, BPTR cs:VGA16ColorIndex[_AX] and al, 0f0h dec si jz SHORT PopSI_LoadPrimL SaveHNibbleL0: mov BPTR_ES[_DI], al ; save high nibble DoLNibble: dec _BP mov ah, BPTR [_BP] mov al, bl ; initial condition ; ; 1 2 3 4 5 ; bh:cl:ch:dl:dh ;---------------------- cmp ch, ah jae SHORT GetL1 cmp dl, ah sbb al, 3 cmp dh, ah jmp SHORT GetL2 GetL1: cmp bh, ah jae SHORT GetLNibble dec al cmp cl, ah GetL2: sbb al, 0 GetLNibble: BZXEAX al mov al, BPTR cs:VGA16ColorIndex[_AX] and al, 0fh or BPTR_ES[_DI], al ; or in the low nibble inc _DI WRAP_BP_PAT?? <DoHNibble> PopSI_LoadPrimL: pop _SI add _SI, SIZE_PCC ; sizeof(PRIMCOLOR_COUNT) mov bx, WPTR [_SI+2] ; bl:bh=Prim 1/2 cmp bl, PRIM_INVALID_DENSITY jz SHORT SaveAH_SkipPelsL mov cx, WPTR [_SI+4] ; dl:dh=Prim 3/4 mov dx, WPTR [_SI+6] ; al:ah=Prim 5/6 push _SI mov si, WPTR [_SI] ; si=count jmp SHORT SaveHNibbleL0 SaveAH_SkipPelsL: ; need to save current AL and BPTR_ES[_DI], 0fh ; clear high nibble or BPTR_ES[_DI], al ; move high nibble in jmp SkipPelsL @END_PROC SUBTTL SingleCountOutputToVGA256 PAGE COMMENT ` Routine Description: This function output to the BMF_VGA256 destination surface from PRIMCOLOR_COUNT data structure array. Arguments: pPrimColorCount - Pointer to the PRIMCOLOR_COUNT data structure array. pDest - Pointer to the destination planes pointers. pPattern - Pointer to the starting pattern byte for the current destination scan line. OutFuncInfo - OUTFUNCINFO data structure. Return Value: No return value. Author: 24-Jan-1991 Thu 11:47:08 created -by- Daniel Chou (danielc) Revision History: 01-Jun-1992 Mon 15:32:00 updated -by- Daniel Chou (danielc) 1. Fixed so that Prims match the device's BGR color table format rather than RGB format ` @BEG_PROC SingleCountOutputToVGA256 <pPrimColorCount:DWORD, \ pDest:DWORD, \ pPattern:DWORD, \ OutFuncInfo:QWORD> ;========================================== ; Register Usage: ; ; _SI : pPrimColorCount ; _DI : pDest ; _BP : Current pPattern, self wrappable ; cl:ch:dl:dh : Prim 1/2/3/4 ====> R/G/B/IDX ; _BX : Scratch register ; _AX : Scratch register ;========================================== ; @ENTER_PAT_TO_STK <VGA256> ; _BP=Pat location ;============================================================================ ; Since we are in byte boundary, we should never have an invalid density to ; start with ; ; The VGA256's color table is constructed as BGR and 6 steps for each primary ; color. ; ; The BGR Mask = 0x24:0x06:0x01 ;============================================================================ cld ; clear direction or _AX, _AX jz SHORT V256_NoXlate V256_HasXlate: IFE ExtRegSet mov _BX, _SP ; the table on the stack ELSE mov _BX, _AX ; _AX point to xlate table ENDIF V256_XlateByteLoop: dec _BP ; do this one first add _SI, SIZE_PCC ; sizeof(PRIMCOLOR_COUNT) mov cx, WPTR [_SI+2] ; bl:bh=Prim 1/2 B/G cmp cl, PRIM_INVALID_DENSITY ; invalid? jz short V256_XlateInvDensity mov dh, BPTR [_BP] ; al=pattern dec dh ; make it cmp al, cl work cmp dh, cl sbb ah, ah ; al=0xff or 0 cmp dh, ch sbb al, al and ax, ((VGA256_B_CUBE_INC shl 8) or VGA256_G_CUBE_INC) ; dh:dl=36:6 mov cx, WPTR [_SI+4] ; cl:ch=Prim 3/4 R/I cmp dh, cl adc al, ah add al, ch ; ; for extended register set _BX point to the translation table ; otherwise ss:bx point to the translation table ; IFE ExtRegSet xlat _SS:VGA256_SSSP_XLAT_TABLE ELSE xlatb ENDIF stosb WRAP_BP_PAT?? <V256_XlateByteLoop> V256_XlateInvDensity: cmp cl, ch jz short V256_XlateAllDone inc _DI WRAP_BP_PAT?? <V256_XlateByteLoop> V256_XlateAllDone: IFE ExtRegSet add _SP, VGA256_XLATE_TABLE_SIZE ENDIF ;=================================================================== AllDone: @EXIT_PAT_STK_RESTORE ;=================================================================== V256_NoXlate: mov bx, ((VGA256_B_CUBE_INC shl 8) or VGA256_G_CUBE_INC) V256_ByteLoop: dec _BP ; do this one first add _SI, SIZE_PCC ; sizeof(PRIMCOLOR_COUNT) mov cx, WPTR [_SI+2] ; cl:ch=Prim 1/2 B/G cmp cl, PRIM_INVALID_DENSITY ; invalid? jz short V256_InvDensity mov dh, BPTR [_BP] ; dh=pattern dec dh ; make it cmp dh, T work cmp dh, cl sbb ah, ah ; ah=0xff or 0 cmp dh, ch sbb al, al ; al=0xff or 0x00 and ax, bx ; bh:bl=36:6 mov cx, WPTR [_SI+4] ; cl:ch=Prim 3/4 R/I cmp dh, cl adc al, ah add al, ch stosb WRAP_BP_PAT?? <V256_ByteLoop> V256_InvDensity: cmp cl, ch jz short AllDone inc _DI WRAP_BP_PAT?? <V256_ByteLoop> @END_PROC SUBTTL VarCountOutputToVGA256 PAGE COMMENT ` Routine Description: This function output to the BMF_4BPP destination surface from PRIMCOLOR_COUNT data structure array. Arguments: pPrimColorCount - Pointer to the PRIMCOLOR_COUNT data structure array. pDest - Pointer to the destination plane. pPattern - Pointer to the starting pattern byte for the current destination scan line. OutFuncInfo - OUTFUNCINFO data structure. Return Value: No return value. Author: 24-Jan-1991 Thu 11:47:08 created -by- Daniel Chou (danielc) Revision History: 01-Jun-1992 Mon 15:32:00 updated -by- Daniel Chou (danielc) 1. Fixed so that Prims match the device's BGR color table format rather than RGB format 19-Mar-1993 Fri 18:53:56 updated -by- Daniel Chou (danielc) 1. When we push _SI and jmp to VGA256_InvDensity we fogot to that si now is run as count rather than _CX ` @BEG_PROC VarCountOutputToVGA256 <pPrimColorCount:DWORD, \ pDest:DWORD, \ pPattern:DWORD, \ OutFuncInfo:QWORD> ;========================================== ; Register Usage: ; ; _SI : pPrimColorCount ; _DI : pDest ; _BP : Current pPattern, self wrappable ; cx : PrimColorCount.Count ; bl:bh:dl:dh : Prim 1/2/3/4 ====> R/G/B/IDX ; al : DestByte ; ah : Scratch Register ;========================================== ; @ENTER_PAT_TO_STK <VGA256> ; _BP=Pat location ;============================================================================ ; Since we are in byte boundary, we should never have an invalid density to ; start with ; ; The VGA256's color table is constructed as BGR and 6 steps for each primary ; color. ;============================================================================ cld ; clear direction IFE ExtRegSet mov _BX, _SP ; the table on the stack ELSE mov _BX, _AX ; _AX point to xlate table ENDIF or _AX, _AX jnz SHORT V256_XlateStart jmp V256_NoXlate ;======== THIS PORTION is for xlate table V256_XlateByteLoop: pop _SI ; restore SI V256_XlateStart: add _SI, SIZE_PCC ; sizeof(PRIMCOLOR_COUNT) push _SI ; save again mov cx, WPTR [_SI+2] ; cl:ch=Prim 1/2 B/G cmp cl, PRIM_INVALID_DENSITY ; invalid? jz short V256_XlateInvDensity mov dx, WPTR [_SI+4] ; dl:dh=Prim 3/4 R/I mov si, WPTR [_SI] ; count inc si V256_XlateCountLoop: dec si jz short V256_XlateByteLoop dec _BP mov ah, BPTR [_BP] ; ah=Pattern dec ah ; make cmp ah, bl works cmp ah, cl sbb al, al and al, VGA256_B_CUBE_INC ; AL=0 or 36 Prim1 cmp ah, dl ; Do Prim 3 first adc al, dh ; al=InitValue+Prim1+Prim3 cmp ah, ch ; do Prim 2 now sbb ah, ah and ah, VGA256_G_CUBE_INC add al, ah ; ; for extended register set _BX point to the translation table ; otherwise ss:bx point to the translation table ; IFE ExtRegSet xlat _SS:VGA256_SSSP_XLAT_TABLE ELSE xlatb ENDIF stosb V256_XlateReadyNextByte: WRAP_BP_PAT?? <V256_XlateCountLoop> V256_XlateInvDensity: cmp cl, ch ; all done? jz SHORT V256_XlateAllDone dec _BP inc _DI MOVZX_W _CX, <WPTR [_SI]> mov _SI, _CX ; we expect count in si cmp _CX, 1 jbe short V256_XlateReadyNextByte ;========= dec _CX mov _AX, _CX add _DI, _CX ; 1 pel per byte mov _CX, _BP ; align pattern now and _CX, HTPAT_STK_MASK ; how many pat avai.? xor _BP, _CX ; clear _BP mask=pPattern sub _CX, _AX ; see if > 0? (_AX=Count) jg short V256_XlateDoneSkipPels ; still not used up yet! mov _AX, [_BP - HTPAT_BP_SIZE] ; get pattern size V256_XlateSkipLoop: add _CX, _AX jle short V256_XlateSkipLoop ; do until > 0 V256_XlateDoneSkipPels: add _BP, _CX ; _BP=pCurPat jmp V256_XlateByteLoop ; repeat the process V256_XlateAllDone: pop _SI ; restore last _SI IFE ExtRegSet add _SP, VGA256_XLATE_TABLE_SIZE ENDIF ;====================================================================== AllDone: @EXIT_PAT_STK_RESTORE ;====================================================================== V256_NoXlate: V256_ByteLoop: add _SI, SIZE_PCC ; sizeof(PRIMCOLOR_COUNT) mov cx, WPTR [_SI] ; cx=count mov bx, WPTR [_SI+2] ; bl:bh=Prim 1/2 B/G cmp bl, PRIM_INVALID_DENSITY ; invalid? jz short V256_InvDensity mov dx, WPTR [_SI+4] ; dl:dh=Prim 3/4 R/I inc cx V256_CountLoop: dec cx jz short V256_ByteLoop dec _BP mov ah, BPTR [_BP] ; ah=Pattern dec ah ; make cmp ah, bl works cmp ah, bl sbb al, al and al, VGA256_B_CUBE_INC ; AL=0 or 36 Prim1 cmp ah, dl ; Do Prim 3 first adc al, dh ; al=InitValue+Prim1+Prim3 cmp ah, bh ; do Prim 2 now sbb ah, ah and ah, VGA256_G_CUBE_INC add al, ah stosb ReadyNextByte: WRAP_BP_PAT?? <V256_CountLoop> V256_InvDensity: cmp bl, bh ; all done? jz short AllDone dec _BP inc _DI cmp cx, 1 jbe short ReadyNextByte SkipDestPels: dec cx WZXE cx ; zero extended mov _AX, _CX add _DI, _CX ; 1 pel per byte mov _CX, _BP ; align pattern now and _CX, HTPAT_STK_MASK ; how many pat avai.? xor _BP, _CX ; clear _BP mask=pPattern sub _CX, _AX ; see if > 0? (_AX=Count) jg short DoneSkipDestPels ; still not used up yet! mov _AX, [_BP - HTPAT_BP_SIZE] ; get pattern size SkipDestPelsLoop: add _CX, _AX jle short SkipDestPelsLoop ; do until > 0 DoneSkipDestPels: add _BP, _CX ; _BP=pCurPat jmp V256_ByteLoop ; repeat the process @END_PROC SUBTTL SingleCountOutputTo16BPP_555 PAGE COMMENT ` Routine Description: This function output to the BMF_16BPP_555 destination surface from PRIMCOLOR_COUNT data structure array. Arguments: pPrimColorCount - Pointer to the PRIMCOLOR_COUNT data structure array. pDest - Pointer to the destination planes pointers. pPattern - Pointer to the starting pattern byte for the current destination scan line. OutFuncInfo - OUTFUNCINFO data structure. Return Value: No return value. Author: 24-Jan-1991 Thu 11:47:08 created -by- Daniel Chou (danielc) Revision History: 01-Jun-1992 Mon 15:32:00 updated -by- Daniel Chou (danielc) 1. Fixed so that Prims match the device's BGR color table format rather than RGB format ` @BEG_PROC SingleCountOutputTo16BPP_555 <pPrimColorCount:DWORD, \ pDest:DWORD, \ pPattern:DWORD, \ OutFuncInfo:QWORD> ;========================================== ; Register Usage: ; ; _SI : pPrimColorCount ; _DI : pDest ; _BP : Current pPattern, self wrappable ; ax : Initial RGB color range from 0-32k (15 bits as 5:5:5) ; dh : pattern ; bl:bh:dl : Prim1/2/3 ; ch : PRIM_INVALID_DENSITY ; cl : PRIM_INVALID_DENSITY --> CX = PRIMCOUNT_EOF ;-------------------------------------------------------------------- ; @ENTER_PAT_TO_STK <16BPP> ; _BP=Pat location ;============================================================================ ; Since we are in WORD boundary, we should never have an invalid density to ; start with ; ; The 16BPP_555's color table is constructed as 32 steps for each primary color ;============================================================================ cld ; clear direction mov cx, (RGB555_R_CUBE_INC or RGB555_G_CUBE_INC) WordLoop: dec _BP ; do this one first add _SI, SIZE_PCC ; sizeof(PRIMCOLOR_COUNT) mov bx, WPTR [_SI+2] ; bl:bh=Prim 1/2 cmp bl, PRIM_INVALID_DENSITY ; invalid? jz short InvalidDensity mov dh, BPTR [_BP] ; dh=pattern dec dh ; make 'cmp dh, bl' works cmp dh, bl sbb ah, ah ; ah=0x00 or 0x04 cmp dh, bh sbb al, al ; al=0x00 or 0x20 ax=0x420 and ax, cx ; mask with cx= 0x0420 cmp dh, BPTR [_SI+4] adc ax, WPTR [_SI+6] ; ax+carry+initial index stosw WRAP_BP_PAT?? <WordLoop> InvalidDensity: cmp bl, bh jz short AllDone inc _DI WRAP_BP_PAT?? <WordLoop> AllDone: @EXIT_PAT_STK_RESTORE @END_PROC SUBTTL VarCountOutputTo16BPP_555 PAGE COMMENT ` Routine Description: This function output to the BMF_4BPP destination surface from PRIMCOLOR_COUNT data structure array. Arguments: pPrimColorCount - Pointer to the PRIMCOLOR_COUNT data structure array. pDest - Pointer to the destination plane. pPattern - Pointer to the starting pattern byte for the current destination scan line. OutFuncInfo - OUTFUNCINFO data structure. Return Value: No return value. Author: 24-Jan-1991 Thu 11:47:08 created -by- Daniel Chou (danielc) Revision History: 01-Jun-1992 Mon 15:32:00 updated -by- Daniel Chou (danielc) 1. Fixed so that Prims match the device's BGR color table format rather than RGB format ` @BEG_PROC VarCountOutputTo16BPP_555 <pPrimColorCount:DWORD, \ pDest:DWORD, \ pPattern:DWORD, \ OutFuncInfo:QWORD> ;========================================== ; Register Usage: ; ; _SI : pPrimColorCount, si=Temp Init Index ; _DI : pDest ; _BP : Current pPattern, self wrappable ; ax : Initial RGB color range from 0-32k (15 bits as 5:5:5) ; dh : pattern ; bl:bh:dl : Prim1/2/3 ; cx : PrimColorCount.Count ;========================================== ; @ENTER_PAT_TO_STK <16BPP> ; _BP=Pat location ;============================================================================ ; Since we are in byte boundary, we should never have an invalid density to ; start with ; ; The 16BPP_555's color table is constructed as BGR and 6 steps for each ; primary color. ;============================================================================ cld ; clear direction jmp short InitStart WordLoop: pop _SI ; restore _SI InitStart: add _SI, SIZE_PCC ; sizeof(PRIMCOLOR_COUNT) push _SI ; save _SI mov cx, WPTR [_SI] ; cx=count mov bx, WPTR [_SI+2] ; bx=Prim 1/2/3 cmp bl, PRIM_INVALID_DENSITY ; invalid? jz short InvalidDensity mov dx, WPTR [_SI+4] ; dl:dh=Prim 3/4 mov si, WPTR [_SI+6] ; si=initial index inc cx ; pre-enter CountLoop: dec cx jz SHORT WordLoop dec _BP mov dh, BPTR [_BP] ; bl=pattern dec dh ; make cmp bl, dh works cmp dh, bl sbb ah, ah ; ah=0/0x40 cmp dh, bh sbb al, al and ax, (RGB555_R_CUBE_INC or RGB555_G_CUBE_INC) ; mask=0x420 cmp dh, dl adc ax, si ; carry+ax+initial index stosw ReadyNextByte: WRAP_BP_PAT?? <CountLoop> InvalidDensity: cmp bl, bh ; all done? jz short AllDone dec _BP add _DI, 2 ; 16-bit per pel cmp cx, 1 jbe SHORT ReadyNextByte SkipDestPels: dec cx WZXE cx ; zero extended mov _AX, _CX add _DI, _CX ; 16-bit per pel add _DI, _CX ; mov _CX, _BP ; align pattern now and _CX, HTPAT_STK_MASK ; how many pat avai.? xor _BP, _CX ; clear _BP mask=pPattern sub _CX, _AX ; see if > 0? (_AX=Count) jg short DoneSkipDestPels ; still not used up yet! mov _AX, [_BP - HTPAT_BP_SIZE] ; get pattern size SkipDestPelsLoop: add _CX, _AX jle short SkipDestPelsLoop ; do until > 0 DoneSkipDestPels: add _BP, _CX ; _BP=pCurPat jmp WordLoop ; repeat the process, AllDone: pop _SI ; restore _SI @EXIT_PAT_STK_RESTORE @END_PROC ENDIF ; HT_ASM_80x86 ENDIF ; 0 END VOID HTENTRY VarCountOutputToVGA256( PPRIMCOLOR_COUNT pPrimColorCount, LPBYTE pDest, LPBYTE pPattern, OUTFUNCINFO OutFuncInfo ) /*++ Routine Description: This function output to the BMF_4BPP destination surface from PRIMCOLOR_COUNT data structure array. Arguments: pPrimColorCount - Pointer to the PRIMCOLOR_COUNT data structure array. ppDest - Pointer to the destination planes pointers. pPattern - Pointer to the starting pattern byte for the current destination scan line. OutFuncInfo - OUTFUNCINFO data structure. Return Value: No return value. Author: 24-Jan-1991 Thu 11:47:08 created -by- Daniel Chou (danielc) Revision History: --*/ { LPBYTE pCurPatA; LPBYTE pEndPatA; LPBYTE pCurPatB; LPBYTE pCurPatC; LPBYTE pXlate; PRIMCOLOR_COUNT PCC; LPBYTE pCur555Pat; LPBYTE pEnd555Pat; BYTE bTmp; WORD Idx; PRIMCOLOR_COUNT PCCX; // // Since we are in byte boundary, we should never get the first one is // invalid // if (!(pXlate = (LPBYTE)OutFuncInfo.pXlate8BPP)) { pXlate = (LPBYTE)DefHTXlate8BPP; } SET_555PAT; if (pPattern) { LPBYTE pRotPatA; BYTE bPat; SET_ROTPAT; while (TRUE) { PCC = *(++pPrimColorCount); if (PCC.Count >= PRIM_COUNT_SPECIAL) { if (PCC.Count == PRIM_COUNT_END_SCAN) { return; // EOF } pDest += PCC.cSkip; // advance destination SKIP_ROTPAT(PCC.cSkip); SKIP_555PAT(PCC.cSkip); } else { GET_555_COLOR_IDXPCC(PCCX); while (PCC.Count--) { GET_555_COLOR(PCCX, FALSE); *pDest++ = GET_VGA256_INDEX(PCCX, ROTPAT_A, ROTPAT_B, ROTPAT_C); WRAP_ROTPAT; } } } } else { UINT SkipCount; SET_PATABC(TRUE); while (TRUE) { PCC = *(++pPrimColorCount); if (PCC.Count >= PRIM_COUNT_SPECIAL) { if (PCC.Count == PRIM_COUNT_END_SCAN) { return; // EOF } pDest += PCC.cSkip; // advance destination SKIP_PATABC(PCC.cSkip, SkipCount); SKIP_555PAT(PCC.cSkip); } else { GET_555_COLOR_IDXPCC(PCCX); while (PCC.Count--) { GET_555_COLOR(PCCX, FALSE); *pDest++ = GET_VGA256_INDEX(PCCX, *pCurPatA, *pCurPatB, *pCurPatC); WRAP_PATABC; } } } } } VOID HTENTRY SingleCountOutputToVGA256( PPRIMCOLOR_COUNT pPrimColorCount, LPBYTE pDest, LPBYTE pPattern, OUTFUNCINFO OutFuncInfo ) /*++ Routine Description: This function output to the BMF_4BPP destination surface from PRIMCOLOR_COUNT data structure array. Arguments: pPrimColorCount - Pointer to the PRIMCOLOR_COUNT data structure array. pDest - Pointer to the destination planes pointers. pPattern - Pointer to the starting pattern byte for the current destination scan line. OutFuncInfo - OUTFUNCINFO data structure. Return Value: No return value. Author: 24-Jan-1991 Thu 11:47:08 created -by- Daniel Chou (danielc) Revision History: 01-Jun-1992 Mon 15:32:00 updated -by- Daniel Chou (danielc) 1. Fixed the first 'Dest = Prim1234.b[4]' to 'Dest = Prim1234.b[3]' mistake. --*/ { LPBYTE pCurPatA; LPBYTE pEndPatA; LPBYTE pCurPatB; LPBYTE pCurPatC; LPBYTE pXlate; PRIMCOLOR_COUNT PCC; LPBYTE pCur555Pat; LPBYTE pEnd555Pat; BYTE bTmp; WORD Idx; PRIMCOLOR_COUNT PCCX; // // Since we are in byte boundary, we should never get the first one is // invalid // if (!(pXlate = (LPBYTE)OutFuncInfo.pXlate8BPP)) { pXlate = (LPBYTE)DefHTXlate8BPP; } SET_555PAT; if (pPattern) { LPBYTE pRotPatA; BYTE bPat; SET_ROTPAT; while (TRUE) { PCC = *(++pPrimColorCount); if (PCC.Count >= PRIM_COUNT_SPECIAL) { if (PCC.Count == PRIM_COUNT_END_SCAN) { return; // EOF } } else { GET_555_COLOR(PCCX, TRUE); *pDest = GET_VGA256_INDEX(PCCX, ROTPAT_A, ROTPAT_B, ROTPAT_C); } ++pDest; WRAP_ROTPAT; } } else { SET_PATABC(TRUE); while (TRUE) { PCC = *(++pPrimColorCount); if (PCC.Count >= PRIM_COUNT_SPECIAL) { if (PCC.Count == PRIM_COUNT_END_SCAN) { return; // EOF } } else { GET_555_COLOR(PCCX, TRUE); *pDest = GET_VGA256_INDEX(PCCX, *pCurPatA, *pCurPatB, *pCurPatC); } ++pDest; WRAP_PATABC; } } } @BEG_PROC SingleCountOutputToVGA256 <pPrimColorCount:DWORD, \ pDest:DWORD, \ pPattern:DWORD, \ OutFuncInfo:QWORD> OUTFUNCINFO STRUC OFI_pXlate8BPP DD ? OFI_pPrimMap DD ? OFI_p555Pat DD ? OFI_PatWidthBytes DW ? OFI_PatOrgX DW ? OFI_pPatA DD ? OFI_pPatB DD ? OFI_pPatC DD ? OUTFUNCINFO ENDS #define ROTPAT_A (pCurPatA[bPat = *pRotPatA]) #define ROTPAT_B (pCurPatB[bPat]) #define ROTPAT_C (pCurPatC[bPat]) SET_ROTPAT MACRO __@@EMIT <mov > _AX, pPattern __@@EMIT <mov > _BP, _AX __@@EMIT <movzx> _BX, OutFuncInfo.PatWidthBytes __@@EMIT <add > _AX, _BX __@@EMIT <mov > pEndPatA, _AX __@@EMIT <movzx> _AX, OutFuncInfo.PatOrgX __@@EMIT <add > _BP, _AX ENDM SKIP_ROTPAT MACRO Count Local DoneSkip __@@EMIT <xor > _DX, _DX, __@@EMIT <movzx> _AX, WPTR Count __@@EMIT <div > OutFuncInfo.PatWidthBytes __@@EMIT <add > _BP, _DX __@@EMIT <cmp > _BP, pEndPatA __@@EMIT <jb > <SHORT DoneWrap> __@@EMIT <sub > _BP, OutFuncInfo.PatWidthBytes DoneSkip: ENDM WRAP_ROTPAT MACRO EndWrapLoc Local DoneWrap IFB <EndWrapLoc> __@@EMIT <inc > _BP __@@EMIT <cmp > _BP, pEndPatA __@@EMIT <jb > <SHORT DoneWrap> __@@EMIT <sub > _BP, OutFuncInfo.PatWidthBytes ELSE __@@EMIT <inc > _BP __@@EMIT <cmp > _BP, pEndPatA __@@EMIT <jb > <SHORT EndWrapLoc> __@@EMIT <sub > _BP, OutFuncInfo.PatWidthBytes __@@EMIT <jmp > <SHORT EndWrapLoc> ENDIF DoneWrap: ENDM #define GET_555_COLOR(pc, GetPCCIdx) \ { \ if (OutFuncInfo.cx555Pat) { \ \ if (PCC.Color.Prim1 > (bTmp = *pCur555Pat)) { \ \ Idx = PCC.Color.w2b.wPrim + HT_RGB_B_INC; \ \ } else { \ \ Idx = PCC.Color.w2b.wPrim; \ } \ \ if (PCC.Color.Prim2 > bTmp) { \ \ Idx += HT_RGB_G_INC; \ } \ \ if (PCC.Color.Prim3 > bTmp) { \ \ Idx += HT_RGB_R_INC; \ } \ \ if (++pCur555Pat >= pEnd555Pat) { \ \ pCur555Pat -= OutFuncInfo.cx555Pat; \ } \ \ if (Idx >= HT_RGB_CUBE_COUNT) { \ \ DBGP("Idx = %04x, wPrim=%04x (%u:%u:%u) [%u]" \ ARGU(Idx) ARGU(PCC.Color.w2b.wPrim) \ ARGU(PCC.Color.Prim1) \ ARGU(PCC.Color.Prim2) \ ARGU(PCC.Color.Prim3) \ ARGU(bTmp)); \ \ Idx = HT_RGB_CUBE_COUNT; \ } \ \ pc.Color = *((PPRIMCOLOR)OutFuncInfo.pPrimMap + Idx); \ \ } else if (GetPCCIdx) { \ \ pc.Color = *((PPRIMCOLOR)OutFuncInfo.pPrimMap+PCC.Color.w2b.wPrim); \ } \ } ;========================================== ; Register Usage: ; ; _SI : pPrimColorCount ; _DI : pDest ; _BP : Current pPattern, self wrappable ; ecx, edx ; color and count ; _BX ; 555 pattern, self wrap able ; _AX : Scratch register ;========================================== cl = Prim1 ch = Prim2 ecl = Prim3 ech = Flags GET_V256_IDX MACRO __@@EMIT <movzx> eax, BPTR [_BP] __@@EMIT <cmp > al, cl __@@EMIT <sbb > bh, bh ; al=0xff or 0 __@@EMIT <cmp > al, ch __@@EMIT <sbb > bl, bl __@@EMIT <and > bx, ((VGA256_B_CUBE_INC shl 8) or VGA256_G_CUBE_INC) ; dh:dl=36:6 __@@EMIT <cmp > al, ecl __@@EMIT <adc > bl, bh __@@EMIT <add > al, ch __@@EMIT <rol > ecx, 16 __@@EMIT <rcr > _BX, 5 __@@EMIT <cmp > al, ch __@@EMIT <rcr > _BX, 5 __@@EMIT <cmp > al, cl __@@EMIT <rcr > _BX, 6 __@@EMIT <add > _BX, _DX __@@EMIT <add > _BX, _DX __@@EMIT <shl > _BX, 1 ENDM GET_555_COLOR MACRO <IsGetIdx> __@@EMIT <or > _BX, _BX __@@EMIT <jnc > GetIndex __@@EMIT <mov > al, BPTR [_BX] __@@EMIT <ror > ecx, 16 __@@EMIT <cmp > al, cl __@@EMIT <rcr > _BX, 5 __@@EMIT <rol > ecx, 16 __@@EMIT <cmp > al, ch __@@EMIT <rcr > _BX, 5 __@@EMIT <cmp > al, cl __@@EMIT <rcr > _BX, 6 __@@EMIT <movzx) _AX, dx __@@EMIT <add > _BX, _AX __@@EMIT <shl > _BX, 1 __@@EMIT <mov > DPTR [_BX + (_BX * 2)] ENDM GET_555_COLOR <TRUE> ;========================================== ; Register Usage: ; ; _SI : pPrimColorCount ; _DI : pDest ; _BP : Current pPattern, self wrappable ; cl:ch:dl:dh : Prim 1/2/3/4 ====> R/G/B/IDX ; _BX : Scratch register ; _AX : Scratch register ;========================================== ; @ENTER_PAT_TO_STK <VGA256> ; _BP=Pat location ;============================================================================ ; Since we are in byte boundary, we should never have an invalid density to ; start with ; ; The VGA256's color table is constructed as BGR and 6 steps for each primary ; color. ; ; The BGR Mask = 0x24:0x06:0x01 ;============================================================================ cld ; clear direction LDS_SI pPrimColorCount ;; _SI=pPrimColorCount LES_DI pDest or _AX, _AX jz SHORT V256_NoXlate V256_XlateByteLoop: add _SI, SIZE_PCC ; sizeof(PRIMCOLOR_COUNT) mov ecx, DPTR [SI] cmp cx, PRIM_COUNT_SPECIAL jae V256_Skip GET_555_COLOR <TRUE> GET_V256_IDX xlatb WRAP_ROTPAT <V256_XlateByteLoop> V256_Skip: cmp cx, PRIM_COUNT_END_SCAN jz short V256_XlateAllDone inc _DI WRAP_ROTPAT <V256_XlateByteLoop> V256_XlateAllDone: IFE ExtRegSet mov _BX, _SP ; the table on the stack ELSE mov _BX, _AX ; _AX point to xlate table ENDIF V256_XlateByteLoop: dec _BP ; do this one first add _SI, SIZE_PCC ; sizeof(PRIMCOLOR_COUNT) mov cx, WPTR [_SI+2] ; bl:bh=Prim 1/2 B/G cmp cl, PRIM_INVALID_DENSITY ; invalid? jz short V256_XlateInvDensity mov dh, BPTR [_BP] ; al=pattern dec dh ; make it cmp al, cl work cmp dh, cl sbb ah, ah ; al=0xff or 0 cmp dh, ch sbb al, al and ax, ((VGA256_B_CUBE_INC shl 8) or VGA256_G_CUBE_INC) ; dh:dl=36:6 mov cx, WPTR [_SI+4] ; cl:ch=Prim 3/4 R/I cmp dh, cl adc al, ah add al, ch ; ; for extended register set _BX point to the translation table ; otherwise ss:bx point to the translation table ; IFE ExtRegSet xlat _SS:VGA256_SSSP_XLAT_TABLE ELSE xlatb ENDIF stosb WRAP_BP_PAT?? <V256_XlateByteLoop> V256_XlateInvDensity: cmp cl, ch jz short V256_XlateAllDone inc _DI WRAP_BP_PAT?? <V256_XlateByteLoop> V256_XlateAllDone: IFE ExtRegSet add _SP, VGA256_XLATE_TABLE_SIZE ENDIF ;=================================================================== AllDone: @EXIT_PAT_STK_RESTORE ;=================================================================== V256_NoXlate: mov bx, ((VGA256_B_CUBE_INC shl 8) or VGA256_G_CUBE_INC) V256_ByteLoop: dec _BP ; do this one first add _SI, SIZE_PCC ; sizeof(PRIMCOLOR_COUNT) mov cx, WPTR [_SI+2] ; cl:ch=Prim 1/2 B/G cmp cl, PRIM_INVALID_DENSITY ; invalid? jz short V256_InvDensity mov dh, BPTR [_BP] ; dh=pattern dec dh ; make it cmp dh, T work cmp dh, cl sbb ah, ah ; ah=0xff or 0 cmp dh, ch sbb al, al ; al=0xff or 0x00 and ax, bx ; bh:bl=36:6 mov cx, WPTR [_SI+4] ; cl:ch=Prim 3/4 R/I cmp dh, cl adc al, ah add al, ch stosb WRAP_BP_PAT?? <V256_ByteLoop> V256_InvDensity: cmp cl, ch jz short AllDone inc _DI WRAP_BP_PAT?? <V256_ByteLoop> @END_PROC SUBTTL VarCountOutputToVGA256 PAGE COMMENT ` Routine Description: This function output to the BMF_4BPP destination surface from PRIMCOLOR_COUNT data structure array. Arguments: pPrimColorCount - Pointer to the PRIMCOLOR_COUNT data structure array. pDest - Pointer to the destination plane. pPattern - Pointer to the starting pattern byte for the current destination scan line. OutFuncInfo - OUTFUNCINFO data structure. Return Value: No return value. Author: 24-Jan-1991 Thu 11:47:08 created -by- Daniel Chou (danielc) Revision History: 01-Jun-1992 Mon 15:32:00 updated -by- Daniel Chou (danielc) 1. Fixed so that Prims match the device's BGR color table format rather than RGB format 19-Mar-1993 Fri 18:53:56 updated -by- Daniel Chou (danielc) 1. When we push _SI and jmp to VGA256_InvDensity we fogot to that si now is run as count rather than _CX ` @BEG_PROC VarCountOutputToVGA256 <pPrimColorCount:DWORD, \ pDest:DWORD, \ pPattern:DWORD, \ OutFuncInfo:QWORD> ;========================================== ; Register Usage: ; ; _SI : pPrimColorCount ; _DI : pDest ; _BP : Current pPattern, self wrappable ; cx : PrimColorCount.Count ; bl:bh:dl:dh : Prim 1/2/3/4 ====> R/G/B/IDX ; al : DestByte ; ah : Scratch Register ;========================================== ; @ENTER_PAT_TO_STK <VGA256> ; _BP=Pat location ;============================================================================ ; Since we are in byte boundary, we should never have an invalid density to ; start with ; ; The VGA256's color table is constructed as BGR and 6 steps for each primary ; color. ;============================================================================ cld ; clear direction IFE ExtRegSet mov _BX, _SP ; the table on the stack ELSE mov _BX, _AX ; _AX point to xlate table ENDIF or _AX, _AX jnz SHORT V256_XlateStart jmp V256_NoXlate ;======== THIS PORTION is for xlate table V256_XlateByteLoop: pop _SI ; restore SI V256_XlateStart: add _SI, SIZE_PCC ; sizeof(PRIMCOLOR_COUNT) push _SI ; save again mov cx, WPTR [_SI+2] ; cl:ch=Prim 1/2 B/G cmp cl, PRIM_INVALID_DENSITY ; invalid? jz short V256_XlateInvDensity mov dx, WPTR [_SI+4] ; dl:dh=Prim 3/4 R/I mov si, WPTR [_SI] ; count inc si V256_XlateCountLoop: dec si jz short V256_XlateByteLoop dec _BP mov ah, BPTR [_BP] ; ah=Pattern dec ah ; make cmp ah, bl works cmp ah, cl sbb al, al and al, VGA256_B_CUBE_INC ; AL=0 or 36 Prim1 cmp ah, dl ; Do Prim 3 first adc al, dh ; al=InitValue+Prim1+Prim3 cmp ah, ch ; do Prim 2 now sbb ah, ah and ah, VGA256_G_CUBE_INC add al, ah ; ; for extended register set _BX point to the translation table ; otherwise ss:bx point to the translation table ; IFE ExtRegSet xlat _SS:VGA256_SSSP_XLAT_TABLE ELSE xlatb ENDIF stosb V256_XlateReadyNextByte: WRAP_BP_PAT?? <V256_XlateCountLoop> V256_XlateInvDensity: cmp cl, ch ; all done? jz SHORT V256_XlateAllDone dec _BP inc _DI MOVZX_W _CX, <WPTR [_SI]> mov _SI, _CX ; we expect count in si cmp _CX, 1 jbe short V256_XlateReadyNextByte ;========= dec _CX mov _AX, _CX add _DI, _CX ; 1 pel per byte mov _CX, _BP ; align pattern now and _CX, HTPAT_STK_MASK ; how many pat avai.? xor _BP, _CX ; clear _BP mask=pPattern sub _CX, _AX ; see if > 0? (_AX=Count) jg short V256_XlateDoneSkipPels ; still not used up yet! mov _AX, [_BP - HTPAT_BP_SIZE] ; get pattern size V256_XlateSkipLoop: add _CX, _AX jle short V256_XlateSkipLoop ; do until > 0 V256_XlateDoneSkipPels: add _BP, _CX ; _BP=pCurPat jmp V256_XlateByteLoop ; repeat the process V256_XlateAllDone: pop _SI ; restore last _SI IFE ExtRegSet add _SP, VGA256_XLATE_TABLE_SIZE ENDIF ;====================================================================== AllDone: @EXIT_PAT_STK_RESTORE ;====================================================================== V256_NoXlate: V256_ByteLoop: add _SI, SIZE_PCC ; sizeof(PRIMCOLOR_COUNT) mov cx, WPTR [_SI] ; cx=count mov bx, WPTR [_SI+2] ; bl:bh=Prim 1/2 B/G cmp bl, PRIM_INVALID_DENSITY ; invalid? jz short V256_InvDensity mov dx, WPTR [_SI+4] ; dl:dh=Prim 3/4 R/I inc cx V256_CountLoop: dec cx jz short V256_ByteLoop dec _BP mov ah, BPTR [_BP] ; ah=Pattern dec ah ; make cmp ah, bl works cmp ah, bl sbb al, al and al, VGA256_B_CUBE_INC ; AL=0 or 36 Prim1 cmp ah, dl ; Do Prim 3 first adc al, dh ; al=InitValue+Prim1+Prim3 cmp ah, bh ; do Prim 2 now sbb ah, ah and ah, VGA256_G_CUBE_INC add al, ah stosb ReadyNextByte: WRAP_BP_PAT?? <V256_CountLoop> V256_InvDensity: cmp bl, bh ; all done? jz short AllDone dec _BP inc _DI cmp cx, 1 jbe short ReadyNextByte SkipDestPels: dec cx WZXE cx ; zero extended mov _AX, _CX add _DI, _CX ; 1 pel per byte mov _CX, _BP ; align pattern now and _CX, HTPAT_STK_MASK ; how many pat avai.? xor _BP, _CX ; clear _BP mask=pPattern sub _CX, _AX ; see if > 0? (_AX=Count) jg short DoneSkipDestPels ; still not used up yet! mov _AX, [_BP - HTPAT_BP_SIZE] ; get pattern size SkipDestPelsLoop: add _CX, _AX jle short SkipDestPelsLoop ; do until > 0 DoneSkipDestPels: add _BP, _CX ; _BP=pCurPat jmp V256_ByteLoop ; repeat the process @END_PROC
; A204000: Symmetric matrix based on f(i,j)=min{i(j+1)-1,j(i+1)-1}, by antidiagonals. ; Submitted by Jon Maiga ; 1,2,2,3,5,3,4,7,7,4,5,9,11,9,5,6,11,14,14,11,6,7,13,17,19,17,13,7,8,15,20,23,23,20,15,8,9,17,23,27,29,27,23,17,9,10,19,26,31,34,34,31,26,19,10,11,21,29,35,39,41,39,35,29,21,11,12,23,32,39,44,47,47 lpb $0 add $1,1 sub $0,$1 mov $2,$1 sub $2,$0 lpe min $0,$2 add $1,2 sub $1,$0 mov $2,$1 mul $2,$0 add $2,$1 mov $0,$2 sub $0,1
cpu 1802 r0 = 0 r1 = 1 r2 = 2 r3 = 3 r4 = 4 r5 = 5 r6 = 6 rc = 12 re = 14 rf = 15 screen = 0700h idl ; switch to P = 3 ghi r0 phi r3 ldi start & 255 plo r3 sep r3 start: ldi 6 ; set stack to 6FFh phi r2 ldi 0FFh plo r2 ldi screen/256 ; R0 points to screen phi r0 ldi 0 plo r0 phi r1 ; set interrupt ldi interruptRoutine & 255 plo r1 sex r3 ; X = P = 3 out 1 db 2 ; select device 2 out 2 db 1 ; command 3 (TV on) out 1 ; select device 1 db 1 out 2 ; command 1 (keypad on) db 1 ldi 0C0h ; set R4 to 0xC0 plo r4 ghi r0 phi r4 loop: bn1 loop ; wait for key press wait: sex r2 db 068h ; INP 0 reads it to M(2) lda r2 ; read it. dec r2 str r4 ; copy to R4. inc r4 ldi 2 phi rf plo rf ldi 31 phi re ; ; Mark is 2 + RE.1 x 2 instructions. [15 = 32] ; Space is 8 instructions. FEL-1 coding. [15 = 40] ; tonegeneration: sex r3 ; set index [8] out 3 ; go logic 1 here [1] db 5 ghi re ; fetch pitch count [2] ; ; Delay for RE x 2 x 16 = RE x 32 cycles. ; delay: smi 1 ; decrement delay count [1] bnz delay ; bnz delay [2] ; out 3 ; turn back on again [1] db 1 dec rf ; decrement counter [2] inc rc ; this counts as SEP R6 [3] inc rc ; [4] inc rc ; [5] ghi rf ; get counter [6] bnz tonegeneration ; loop back if non zero [7] br loop interruptExit: lda r2 ; restore D and return. ret interruptRoutine: dec r2 ; save XP on stack sav dec r2 ; save D on stack. str r2 ldi screen/256 ; reset screen address ldi 0 phi r0 ldi 0 plo r0 br interruptExit org 0C0h dec r2 ; save XP on stack sav dec r2 ; save D on stack. str r2 ldi screen/256 ; reset screen address ldi 0 phi r0 ldi 0 plo r0 br interruptExit
; ; Get the pixel address for Timex hires mode ; SECTION code_graphics PUBLIC pixeladdress_MODE6 EXTERN __zx_screenmode ; ****************************************************************** ; ; Get absolute pixel address in map of virtual (x,y) coordinate. ; ; in: hl = x ; de = y ; ; out: de = hl = address of pixel byte ; a = bit number of byte where pixel is to be placed ; fz = 1 if bit number is 0 of pixel position ; ; registers changed after return: ; ......../ixiy same ; afbcdehl/.... different pixeladdress_MODE6: ld a,e ld b,a and a rra scf ; Set Carry Flag rra and a rra xor b and @11111000 xor b ld d,a ld a,l bit 3,a jp z,isfirst set 5,d .isfirst rr h rra rlca rlca rlca xor b and @11000111 xor b rlca rlca ld e,a ld a,l and @00000111 xor @00000111 ld h,d ld l,e ret
// Test signed word comparisons // Commodore 64 PRG executable file .file [name="test-comparisons-sword.prg", type="prg", segments="Program"] .segmentdef Program [segments="Basic, Code, Data"] .segmentdef Basic [start=$0801] .segmentdef Code [start=$80d] .segmentdef Data [startAfter="Code"] .segment Basic :BasicUpstart(main) .const LT = 0 .const LE = 1 .const GT = 2 .const GE = 3 .const EQ = 4 .const NE = 5 // empty circle .const FF = $57 // filled circle .const TT = $51 .label print_screen = $400 .label print_line_cursor = 6 .label print_char_cursor = 2 .segment Code main: { .label w1 = $10 .label w2 = $b .label s = $d .label op = $e .label j = $f .label i = $12 // print_cls() jsr print_cls lda #<print_screen sta.z print_line_cursor lda #>print_screen sta.z print_line_cursor+1 lda #0 sta.z s lda #<print_screen sta.z print_char_cursor lda #>print_screen sta.z print_char_cursor+1 lda #0 sta.z i __b1: // signed word w1 = swords[i] lda.z i asl tay lda swords,y sta.z w1 lda swords+1,y sta.z w1+1 lda #0 sta.z j __b2: // signed word w2 = swords[j] lda.z j asl tay lda swords,y sta.z w2 lda swords+1,y sta.z w2+1 lda #0 sta.z op __b3: // compare(w1,w2,op) lda.z w1 sta.z compare.w1 lda.z w1+1 sta.z compare.w1+1 lda.z op jsr compare // if(++s==3) inc.z s lda #3 cmp.z s bne __b4 // print_ln() jsr print_ln lda.z print_line_cursor sta.z print_char_cursor lda.z print_line_cursor+1 sta.z print_char_cursor+1 lda #0 sta.z s __b4: // for( byte op: 0..5 ) inc.z op lda #6 cmp.z op bne __b3 // for( byte j: 0..2) inc.z j lda #3 cmp.z j bne __b2 // for( byte i: 0..2) inc.z i cmp.z i bne __b1 __b5: // loop forever jmp __b5 } // Clear the screen. Also resets current line/char cursor. print_cls: { // memset(print_screen, ' ', 1000) jsr memset // } rts } // Compare two words using an operator // void compare(__zp(8) int w1, __zp($b) int w2, __register(A) char op) compare: { .label w1 = 8 .label w2 = $b .label ops = 4 .label r = $a // if(op==LT) cmp #LT bne !__b1+ jmp __b1 !__b1: // if(op==LE) cmp #LE bne !__b2+ jmp __b2 !__b2: // if(op==GT) cmp #GT bne !__b3+ jmp __b3 !__b3: // if(op==GE) cmp #GE beq __b4 // if(op==EQ) cmp #EQ beq __b5 // if(op==NE) cmp #NE bne __b8 // if(w1!=w2) lda.z w1 cmp.z w2 bne !+ lda.z w1+1 cmp.z w2+1 beq __b7 !: lda #TT sta.z r jmp __b19 __b7: lda #FF sta.z r __b19: lda #<ops_1 sta.z ops lda #>ops_1 sta.z ops+1 jmp __b6 __b8: lda #FF sta.z r lda #<0 sta.z ops sta.z ops+1 __b6: // print_sint(w1) jsr print_sint // print_str(ops) jsr print_str // print_sint(w2) lda.z w2 sta.z print_sint.w lda.z w2+1 sta.z print_sint.w+1 jsr print_sint // print_char(r) lda.z r jsr print_char // } rts __b5: // if(w1==w2) lda.z w1+1 cmp.z w2+1 bne __b9 lda.z w1 cmp.z w2 bne __b9 lda #TT sta.z r jmp __b20 __b9: lda #FF sta.z r __b20: lda #<ops_2 sta.z ops lda #>ops_2 sta.z ops+1 jmp __b6 __b4: // if(w1>=w2) lda.z w1 cmp.z w2 lda.z w1+1 sbc.z w2+1 bvc !+ eor #$80 !: bmi __b10 lda #TT sta.z r jmp __b21 __b10: lda #FF sta.z r __b21: lda #<ops_3 sta.z ops lda #>ops_3 sta.z ops+1 jmp __b6 __b3: // if(w1>w2) lda.z w2 cmp.z w1 lda.z w2+1 sbc.z w1+1 bvc !+ eor #$80 !: bpl __b11 lda #TT sta.z r jmp __b22 __b11: lda #FF sta.z r __b22: lda #<ops_4 sta.z ops lda #>ops_4 sta.z ops+1 jmp __b6 __b2: // if(w1<=w2) lda.z w2 cmp.z w1 lda.z w2+1 sbc.z w1+1 bvc !+ eor #$80 !: bmi __b12 lda #TT sta.z r jmp __b23 __b12: lda #FF sta.z r __b23: lda #<ops_5 sta.z ops lda #>ops_5 sta.z ops+1 jmp __b6 __b1: // if(w1<w2) lda.z w1 cmp.z w2 lda.z w1+1 sbc.z w2+1 bvc !+ eor #$80 !: bpl __b13 lda #TT sta.z r jmp __b24 __b13: lda #FF sta.z r __b24: lda #<ops_6 sta.z ops lda #>ops_6 sta.z ops+1 jmp __b6 .segment Data ops_1: .text "!=" .byte 0 ops_2: .text "==" .byte 0 ops_3: .text ">=" .byte 0 ops_4: .text "> " .byte 0 ops_5: .text "<=" .byte 0 ops_6: .text "< " .byte 0 } .segment Code // Print a newline print_ln: { __b1: // print_line_cursor + $28 lda #$28 clc adc.z print_line_cursor sta.z print_line_cursor bcc !+ inc.z print_line_cursor+1 !: // while (print_line_cursor<print_char_cursor) lda.z print_line_cursor+1 cmp.z print_char_cursor+1 bcc __b1 bne !+ lda.z print_line_cursor cmp.z print_char_cursor bcc __b1 !: // } rts } // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str. // void * memset(void *str, char c, unsigned int num) memset: { .const c = ' ' .const num = $3e8 .label str = print_screen .label end = str+num .label dst = 4 lda #<str sta.z dst lda #>str sta.z dst+1 __b1: // for(char* dst = str; dst!=end; dst++) lda.z dst+1 cmp #>end bne __b2 lda.z dst cmp #<end bne __b2 // } rts __b2: // *dst = c lda #c ldy #0 sta (dst),y // for(char* dst = str; dst!=end; dst++) inc.z dst bne !+ inc.z dst+1 !: jmp __b1 } // Print a signed int as HEX // void print_sint(__zp(8) int w) print_sint: { .label w = 8 // if(w<0) lda.z w+1 bmi __b1 // print_char(' ') lda #' ' jsr print_char __b2: // print_uint((unsigned int)w) jsr print_uint // } rts __b1: // print_char('-') lda #'-' jsr print_char // w = -w lda #0 sec sbc.z w sta.z w lda #0 sbc.z w+1 sta.z w+1 jmp __b2 } // Print a zero-terminated string // void print_str(__zp(4) char *str) print_str: { .label str = 4 __b1: // while(*str) ldy #0 lda (str),y cmp #0 bne __b2 // } rts __b2: // print_char(*(str++)) ldy #0 lda (str),y jsr print_char // print_char(*(str++)); inc.z str bne !+ inc.z str+1 !: jmp __b1 } // Print a single char // void print_char(__register(A) char ch) print_char: { // *(print_char_cursor++) = ch ldy #0 sta (print_char_cursor),y // *(print_char_cursor++) = ch; inc.z print_char_cursor bne !+ inc.z print_char_cursor+1 !: // } rts } // Print a unsigned int as HEX // void print_uint(__zp(8) unsigned int w) print_uint: { .label w = 8 // print_uchar(BYTE1(w)) ldx.z w+1 jsr print_uchar // print_uchar(BYTE0(w)) ldx.z w jsr print_uchar // } rts } // Print a char as HEX // void print_uchar(__register(X) char b) print_uchar: { // b>>4 txa lsr lsr lsr lsr // print_char(print_hextab[b>>4]) tay lda print_hextab,y // Table of hexadecimal digits jsr print_char // b&$f lda #$f axs #0 // print_char(print_hextab[b&$f]) lda print_hextab,x jsr print_char // } rts } .segment Data print_hextab: .text "0123456789abcdef" swords: .word -$6fed, $12, $7fed
; ; jfdctint.asm - accurate integer FDCT (64-bit SSE2) ; ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB ; Copyright (C) 2009, D. R. Commander. ; ; Based on the x86 SIMD extension for IJG JPEG library ; Copyright (C) 1999-2006, MIYASAKA Masaru. ; For conditions of distribution and use, see copyright notice in jsimdext.inc ; ; This file should be assembled with NASM (Netwide Assembler), ; can *not* be assembled with Microsoft's MASM or any compatible ; assembler (including Borland's Turbo Assembler). ; NASM is available from http://nasm.sourceforge.net/ or ; http://sourceforge.net/project/showfiles.php?group_id=6208 ; ; This file contains a slow-but-accurate integer implementation of the ; forward DCT (Discrete Cosine Transform). The following code is based ; directly on the IJG's original jfdctint.c; see the jfdctint.c for ; more details. ; ; [TAB8] %include "jsimdext.inc" %include "jdct.inc" ; -------------------------------------------------------------------------- %define CONST_BITS 13 %define PASS1_BITS 2 %define DESCALE_P1 (CONST_BITS-PASS1_BITS) %define DESCALE_P2 (CONST_BITS+PASS1_BITS) %if CONST_BITS == 13 F_0_298 equ 2446 ; FIX(0.298631336) F_0_390 equ 3196 ; FIX(0.390180644) F_0_541 equ 4433 ; FIX(0.541196100) F_0_765 equ 6270 ; FIX(0.765366865) F_0_899 equ 7373 ; FIX(0.899976223) F_1_175 equ 9633 ; FIX(1.175875602) F_1_501 equ 12299 ; FIX(1.501321110) F_1_847 equ 15137 ; FIX(1.847759065) F_1_961 equ 16069 ; FIX(1.961570560) F_2_053 equ 16819 ; FIX(2.053119869) F_2_562 equ 20995 ; FIX(2.562915447) F_3_072 equ 25172 ; FIX(3.072711026) %else ; NASM cannot do compile-time arithmetic on floating-point constants. %define DESCALE(x,n) (((x)+(1<<((n)-1)))>>(n)) F_0_298 equ DESCALE( 320652955,30-CONST_BITS) ; FIX(0.298631336) F_0_390 equ DESCALE( 418953276,30-CONST_BITS) ; FIX(0.390180644) F_0_541 equ DESCALE( 581104887,30-CONST_BITS) ; FIX(0.541196100) F_0_765 equ DESCALE( 821806413,30-CONST_BITS) ; FIX(0.765366865) F_0_899 equ DESCALE( 966342111,30-CONST_BITS) ; FIX(0.899976223) F_1_175 equ DESCALE(1262586813,30-CONST_BITS) ; FIX(1.175875602) F_1_501 equ DESCALE(1612031267,30-CONST_BITS) ; FIX(1.501321110) F_1_847 equ DESCALE(1984016188,30-CONST_BITS) ; FIX(1.847759065) F_1_961 equ DESCALE(2106220350,30-CONST_BITS) ; FIX(1.961570560) F_2_053 equ DESCALE(2204520673,30-CONST_BITS) ; FIX(2.053119869) F_2_562 equ DESCALE(2751909506,30-CONST_BITS) ; FIX(2.562915447) F_3_072 equ DESCALE(3299298341,30-CONST_BITS) ; FIX(3.072711026) %endif ; -------------------------------------------------------------------------- SECTION SEG_CONST alignz 16 global EXTN(jconst_fdct_islow_sse2) EXTN(jconst_fdct_islow_sse2): PW_F130_F054 times 4 dw (F_0_541+F_0_765), F_0_541 PW_F054_MF130 times 4 dw F_0_541, (F_0_541-F_1_847) PW_MF078_F117 times 4 dw (F_1_175-F_1_961), F_1_175 PW_F117_F078 times 4 dw F_1_175, (F_1_175-F_0_390) PW_MF060_MF089 times 4 dw (F_0_298-F_0_899),-F_0_899 PW_MF089_F060 times 4 dw -F_0_899, (F_1_501-F_0_899) PW_MF050_MF256 times 4 dw (F_2_053-F_2_562),-F_2_562 PW_MF256_F050 times 4 dw -F_2_562, (F_3_072-F_2_562) PD_DESCALE_P1 times 4 dd 1 << (DESCALE_P1-1) PD_DESCALE_P2 times 4 dd 1 << (DESCALE_P2-1) PW_DESCALE_P2X times 8 dw 1 << (PASS1_BITS-1) alignz 16 ; -------------------------------------------------------------------------- SECTION SEG_TEXT BITS 64 ; ; Perform the forward DCT on one block of samples. ; ; GLOBAL(void) ; jsimd_fdct_islow_sse2 (DCTELEM *data) ; ; r10 = DCTELEM *data %define wk(i) rbp-(WK_NUM-(i))*SIZEOF_XMMWORD ; xmmword wk[WK_NUM] %define WK_NUM 6 align 16 global EXTN(jsimd_fdct_islow_sse2) EXTN(jsimd_fdct_islow_sse2): push rbp mov rax,rsp ; rax = original rbp sub rsp, byte 4 and rsp, byte (-SIZEOF_XMMWORD) ; align to 128 bits mov [rsp],rax mov rbp,rsp ; rbp = aligned rbp lea rsp, [wk(0)] collect_args ; ---- Pass 1: process rows. mov rdx, r10 ; (DCTELEM *) movdqa xmm0, XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_DCTELEM)] movdqa xmm1, XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_DCTELEM)] movdqa xmm2, XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_DCTELEM)] movdqa xmm3, XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_DCTELEM)] ; xmm0=(00 01 02 03 04 05 06 07), xmm2=(20 21 22 23 24 25 26 27) ; xmm1=(10 11 12 13 14 15 16 17), xmm3=(30 31 32 33 34 35 36 37) movdqa xmm4,xmm0 ; transpose coefficients(phase 1) punpcklwd xmm0,xmm1 ; xmm0=(00 10 01 11 02 12 03 13) punpckhwd xmm4,xmm1 ; xmm4=(04 14 05 15 06 16 07 17) movdqa xmm5,xmm2 ; transpose coefficients(phase 1) punpcklwd xmm2,xmm3 ; xmm2=(20 30 21 31 22 32 23 33) punpckhwd xmm5,xmm3 ; xmm5=(24 34 25 35 26 36 27 37) movdqa xmm6, XMMWORD [XMMBLOCK(4,0,rdx,SIZEOF_DCTELEM)] movdqa xmm7, XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_DCTELEM)] movdqa xmm1, XMMWORD [XMMBLOCK(6,0,rdx,SIZEOF_DCTELEM)] movdqa xmm3, XMMWORD [XMMBLOCK(7,0,rdx,SIZEOF_DCTELEM)] ; xmm6=( 4 12 20 28 36 44 52 60), xmm1=( 6 14 22 30 38 46 54 62) ; xmm7=( 5 13 21 29 37 45 53 61), xmm3=( 7 15 23 31 39 47 55 63) movdqa XMMWORD [wk(0)], xmm2 ; wk(0)=(20 30 21 31 22 32 23 33) movdqa XMMWORD [wk(1)], xmm5 ; wk(1)=(24 34 25 35 26 36 27 37) movdqa xmm2,xmm6 ; transpose coefficients(phase 1) punpcklwd xmm6,xmm7 ; xmm6=(40 50 41 51 42 52 43 53) punpckhwd xmm2,xmm7 ; xmm2=(44 54 45 55 46 56 47 57) movdqa xmm5,xmm1 ; transpose coefficients(phase 1) punpcklwd xmm1,xmm3 ; xmm1=(60 70 61 71 62 72 63 73) punpckhwd xmm5,xmm3 ; xmm5=(64 74 65 75 66 76 67 77) movdqa xmm7,xmm6 ; transpose coefficients(phase 2) punpckldq xmm6,xmm1 ; xmm6=(40 50 60 70 41 51 61 71) punpckhdq xmm7,xmm1 ; xmm7=(42 52 62 72 43 53 63 73) movdqa xmm3,xmm2 ; transpose coefficients(phase 2) punpckldq xmm2,xmm5 ; xmm2=(44 54 64 74 45 55 65 75) punpckhdq xmm3,xmm5 ; xmm3=(46 56 66 76 47 57 67 77) movdqa xmm1, XMMWORD [wk(0)] ; xmm1=(20 30 21 31 22 32 23 33) movdqa xmm5, XMMWORD [wk(1)] ; xmm5=(24 34 25 35 26 36 27 37) movdqa XMMWORD [wk(2)], xmm7 ; wk(2)=(42 52 62 72 43 53 63 73) movdqa XMMWORD [wk(3)], xmm2 ; wk(3)=(44 54 64 74 45 55 65 75) movdqa xmm7,xmm0 ; transpose coefficients(phase 2) punpckldq xmm0,xmm1 ; xmm0=(00 10 20 30 01 11 21 31) punpckhdq xmm7,xmm1 ; xmm7=(02 12 22 32 03 13 23 33) movdqa xmm2,xmm4 ; transpose coefficients(phase 2) punpckldq xmm4,xmm5 ; xmm4=(04 14 24 34 05 15 25 35) punpckhdq xmm2,xmm5 ; xmm2=(06 16 26 36 07 17 27 37) movdqa xmm1,xmm0 ; transpose coefficients(phase 3) punpcklqdq xmm0,xmm6 ; xmm0=(00 10 20 30 40 50 60 70)=data0 punpckhqdq xmm1,xmm6 ; xmm1=(01 11 21 31 41 51 61 71)=data1 movdqa xmm5,xmm2 ; transpose coefficients(phase 3) punpcklqdq xmm2,xmm3 ; xmm2=(06 16 26 36 46 56 66 76)=data6 punpckhqdq xmm5,xmm3 ; xmm5=(07 17 27 37 47 57 67 77)=data7 movdqa xmm6,xmm1 movdqa xmm3,xmm0 psubw xmm1,xmm2 ; xmm1=data1-data6=tmp6 psubw xmm0,xmm5 ; xmm0=data0-data7=tmp7 paddw xmm6,xmm2 ; xmm6=data1+data6=tmp1 paddw xmm3,xmm5 ; xmm3=data0+data7=tmp0 movdqa xmm2, XMMWORD [wk(2)] ; xmm2=(42 52 62 72 43 53 63 73) movdqa xmm5, XMMWORD [wk(3)] ; xmm5=(44 54 64 74 45 55 65 75) movdqa XMMWORD [wk(0)], xmm1 ; wk(0)=tmp6 movdqa XMMWORD [wk(1)], xmm0 ; wk(1)=tmp7 movdqa xmm1,xmm7 ; transpose coefficients(phase 3) punpcklqdq xmm7,xmm2 ; xmm7=(02 12 22 32 42 52 62 72)=data2 punpckhqdq xmm1,xmm2 ; xmm1=(03 13 23 33 43 53 63 73)=data3 movdqa xmm0,xmm4 ; transpose coefficients(phase 3) punpcklqdq xmm4,xmm5 ; xmm4=(04 14 24 34 44 54 64 74)=data4 punpckhqdq xmm0,xmm5 ; xmm0=(05 15 25 35 45 55 65 75)=data5 movdqa xmm2,xmm1 movdqa xmm5,xmm7 paddw xmm1,xmm4 ; xmm1=data3+data4=tmp3 paddw xmm7,xmm0 ; xmm7=data2+data5=tmp2 psubw xmm2,xmm4 ; xmm2=data3-data4=tmp4 psubw xmm5,xmm0 ; xmm5=data2-data5=tmp5 ; -- Even part movdqa xmm4,xmm3 movdqa xmm0,xmm6 paddw xmm3,xmm1 ; xmm3=tmp10 paddw xmm6,xmm7 ; xmm6=tmp11 psubw xmm4,xmm1 ; xmm4=tmp13 psubw xmm0,xmm7 ; xmm0=tmp12 movdqa xmm1,xmm3 paddw xmm3,xmm6 ; xmm3=tmp10+tmp11 psubw xmm1,xmm6 ; xmm1=tmp10-tmp11 psllw xmm3,PASS1_BITS ; xmm3=data0 psllw xmm1,PASS1_BITS ; xmm1=data4 movdqa XMMWORD [wk(2)], xmm3 ; wk(2)=data0 movdqa XMMWORD [wk(3)], xmm1 ; wk(3)=data4 ; (Original) ; z1 = (tmp12 + tmp13) * 0.541196100; ; data2 = z1 + tmp13 * 0.765366865; ; data6 = z1 + tmp12 * -1.847759065; ; ; (This implementation) ; data2 = tmp13 * (0.541196100 + 0.765366865) + tmp12 * 0.541196100; ; data6 = tmp13 * 0.541196100 + tmp12 * (0.541196100 - 1.847759065); movdqa xmm7,xmm4 ; xmm4=tmp13 movdqa xmm6,xmm4 punpcklwd xmm7,xmm0 ; xmm0=tmp12 punpckhwd xmm6,xmm0 movdqa xmm4,xmm7 movdqa xmm0,xmm6 pmaddwd xmm7,[rel PW_F130_F054] ; xmm7=data2L pmaddwd xmm6,[rel PW_F130_F054] ; xmm6=data2H pmaddwd xmm4,[rel PW_F054_MF130] ; xmm4=data6L pmaddwd xmm0,[rel PW_F054_MF130] ; xmm0=data6H paddd xmm7,[rel PD_DESCALE_P1] paddd xmm6,[rel PD_DESCALE_P1] psrad xmm7,DESCALE_P1 psrad xmm6,DESCALE_P1 paddd xmm4,[rel PD_DESCALE_P1] paddd xmm0,[rel PD_DESCALE_P1] psrad xmm4,DESCALE_P1 psrad xmm0,DESCALE_P1 packssdw xmm7,xmm6 ; xmm7=data2 packssdw xmm4,xmm0 ; xmm4=data6 movdqa XMMWORD [wk(4)], xmm7 ; wk(4)=data2 movdqa XMMWORD [wk(5)], xmm4 ; wk(5)=data6 ; -- Odd part movdqa xmm3, XMMWORD [wk(0)] ; xmm3=tmp6 movdqa xmm1, XMMWORD [wk(1)] ; xmm1=tmp7 movdqa xmm6,xmm2 ; xmm2=tmp4 movdqa xmm0,xmm5 ; xmm5=tmp5 paddw xmm6,xmm3 ; xmm6=z3 paddw xmm0,xmm1 ; xmm0=z4 ; (Original) ; z5 = (z3 + z4) * 1.175875602; ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644; ; z3 += z5; z4 += z5; ; ; (This implementation) ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602; ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644); movdqa xmm7,xmm6 movdqa xmm4,xmm6 punpcklwd xmm7,xmm0 punpckhwd xmm4,xmm0 movdqa xmm6,xmm7 movdqa xmm0,xmm4 pmaddwd xmm7,[rel PW_MF078_F117] ; xmm7=z3L pmaddwd xmm4,[rel PW_MF078_F117] ; xmm4=z3H pmaddwd xmm6,[rel PW_F117_F078] ; xmm6=z4L pmaddwd xmm0,[rel PW_F117_F078] ; xmm0=z4H movdqa XMMWORD [wk(0)], xmm7 ; wk(0)=z3L movdqa XMMWORD [wk(1)], xmm4 ; wk(1)=z3H ; (Original) ; z1 = tmp4 + tmp7; z2 = tmp5 + tmp6; ; tmp4 = tmp4 * 0.298631336; tmp5 = tmp5 * 2.053119869; ; tmp6 = tmp6 * 3.072711026; tmp7 = tmp7 * 1.501321110; ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447; ; data7 = tmp4 + z1 + z3; data5 = tmp5 + z2 + z4; ; data3 = tmp6 + z2 + z3; data1 = tmp7 + z1 + z4; ; ; (This implementation) ; tmp4 = tmp4 * (0.298631336 - 0.899976223) + tmp7 * -0.899976223; ; tmp5 = tmp5 * (2.053119869 - 2.562915447) + tmp6 * -2.562915447; ; tmp6 = tmp5 * -2.562915447 + tmp6 * (3.072711026 - 2.562915447); ; tmp7 = tmp4 * -0.899976223 + tmp7 * (1.501321110 - 0.899976223); ; data7 = tmp4 + z3; data5 = tmp5 + z4; ; data3 = tmp6 + z3; data1 = tmp7 + z4; movdqa xmm7,xmm2 movdqa xmm4,xmm2 punpcklwd xmm7,xmm1 punpckhwd xmm4,xmm1 movdqa xmm2,xmm7 movdqa xmm1,xmm4 pmaddwd xmm7,[rel PW_MF060_MF089] ; xmm7=tmp4L pmaddwd xmm4,[rel PW_MF060_MF089] ; xmm4=tmp4H pmaddwd xmm2,[rel PW_MF089_F060] ; xmm2=tmp7L pmaddwd xmm1,[rel PW_MF089_F060] ; xmm1=tmp7H paddd xmm7, XMMWORD [wk(0)] ; xmm7=data7L paddd xmm4, XMMWORD [wk(1)] ; xmm4=data7H paddd xmm2,xmm6 ; xmm2=data1L paddd xmm1,xmm0 ; xmm1=data1H paddd xmm7,[rel PD_DESCALE_P1] paddd xmm4,[rel PD_DESCALE_P1] psrad xmm7,DESCALE_P1 psrad xmm4,DESCALE_P1 paddd xmm2,[rel PD_DESCALE_P1] paddd xmm1,[rel PD_DESCALE_P1] psrad xmm2,DESCALE_P1 psrad xmm1,DESCALE_P1 packssdw xmm7,xmm4 ; xmm7=data7 packssdw xmm2,xmm1 ; xmm2=data1 movdqa xmm4,xmm5 movdqa xmm1,xmm5 punpcklwd xmm4,xmm3 punpckhwd xmm1,xmm3 movdqa xmm5,xmm4 movdqa xmm3,xmm1 pmaddwd xmm4,[rel PW_MF050_MF256] ; xmm4=tmp5L pmaddwd xmm1,[rel PW_MF050_MF256] ; xmm1=tmp5H pmaddwd xmm5,[rel PW_MF256_F050] ; xmm5=tmp6L pmaddwd xmm3,[rel PW_MF256_F050] ; xmm3=tmp6H paddd xmm4,xmm6 ; xmm4=data5L paddd xmm1,xmm0 ; xmm1=data5H paddd xmm5, XMMWORD [wk(0)] ; xmm5=data3L paddd xmm3, XMMWORD [wk(1)] ; xmm3=data3H paddd xmm4,[rel PD_DESCALE_P1] paddd xmm1,[rel PD_DESCALE_P1] psrad xmm4,DESCALE_P1 psrad xmm1,DESCALE_P1 paddd xmm5,[rel PD_DESCALE_P1] paddd xmm3,[rel PD_DESCALE_P1] psrad xmm5,DESCALE_P1 psrad xmm3,DESCALE_P1 packssdw xmm4,xmm1 ; xmm4=data5 packssdw xmm5,xmm3 ; xmm5=data3 ; ---- Pass 2: process columns. movdqa xmm6, XMMWORD [wk(2)] ; xmm6=col0 movdqa xmm0, XMMWORD [wk(4)] ; xmm0=col2 ; xmm6=(00 10 20 30 40 50 60 70), xmm0=(02 12 22 32 42 52 62 72) ; xmm2=(01 11 21 31 41 51 61 71), xmm5=(03 13 23 33 43 53 63 73) movdqa xmm1,xmm6 ; transpose coefficients(phase 1) punpcklwd xmm6,xmm2 ; xmm6=(00 01 10 11 20 21 30 31) punpckhwd xmm1,xmm2 ; xmm1=(40 41 50 51 60 61 70 71) movdqa xmm3,xmm0 ; transpose coefficients(phase 1) punpcklwd xmm0,xmm5 ; xmm0=(02 03 12 13 22 23 32 33) punpckhwd xmm3,xmm5 ; xmm3=(42 43 52 53 62 63 72 73) movdqa xmm2, XMMWORD [wk(3)] ; xmm2=col4 movdqa xmm5, XMMWORD [wk(5)] ; xmm5=col6 ; xmm2=(04 14 24 34 44 54 64 74), xmm5=(06 16 26 36 46 56 66 76) ; xmm4=(05 15 25 35 45 55 65 75), xmm7=(07 17 27 37 47 57 67 77) movdqa XMMWORD [wk(0)], xmm0 ; wk(0)=(02 03 12 13 22 23 32 33) movdqa XMMWORD [wk(1)], xmm3 ; wk(1)=(42 43 52 53 62 63 72 73) movdqa xmm0,xmm2 ; transpose coefficients(phase 1) punpcklwd xmm2,xmm4 ; xmm2=(04 05 14 15 24 25 34 35) punpckhwd xmm0,xmm4 ; xmm0=(44 45 54 55 64 65 74 75) movdqa xmm3,xmm5 ; transpose coefficients(phase 1) punpcklwd xmm5,xmm7 ; xmm5=(06 07 16 17 26 27 36 37) punpckhwd xmm3,xmm7 ; xmm3=(46 47 56 57 66 67 76 77) movdqa xmm4,xmm2 ; transpose coefficients(phase 2) punpckldq xmm2,xmm5 ; xmm2=(04 05 06 07 14 15 16 17) punpckhdq xmm4,xmm5 ; xmm4=(24 25 26 27 34 35 36 37) movdqa xmm7,xmm0 ; transpose coefficients(phase 2) punpckldq xmm0,xmm3 ; xmm0=(44 45 46 47 54 55 56 57) punpckhdq xmm7,xmm3 ; xmm7=(64 65 66 67 74 75 76 77) movdqa xmm5, XMMWORD [wk(0)] ; xmm5=(02 03 12 13 22 23 32 33) movdqa xmm3, XMMWORD [wk(1)] ; xmm3=(42 43 52 53 62 63 72 73) movdqa XMMWORD [wk(2)], xmm4 ; wk(2)=(24 25 26 27 34 35 36 37) movdqa XMMWORD [wk(3)], xmm0 ; wk(3)=(44 45 46 47 54 55 56 57) movdqa xmm4,xmm6 ; transpose coefficients(phase 2) punpckldq xmm6,xmm5 ; xmm6=(00 01 02 03 10 11 12 13) punpckhdq xmm4,xmm5 ; xmm4=(20 21 22 23 30 31 32 33) movdqa xmm0,xmm1 ; transpose coefficients(phase 2) punpckldq xmm1,xmm3 ; xmm1=(40 41 42 43 50 51 52 53) punpckhdq xmm0,xmm3 ; xmm0=(60 61 62 63 70 71 72 73) movdqa xmm5,xmm6 ; transpose coefficients(phase 3) punpcklqdq xmm6,xmm2 ; xmm6=(00 01 02 03 04 05 06 07)=data0 punpckhqdq xmm5,xmm2 ; xmm5=(10 11 12 13 14 15 16 17)=data1 movdqa xmm3,xmm0 ; transpose coefficients(phase 3) punpcklqdq xmm0,xmm7 ; xmm0=(60 61 62 63 64 65 66 67)=data6 punpckhqdq xmm3,xmm7 ; xmm3=(70 71 72 73 74 75 76 77)=data7 movdqa xmm2,xmm5 movdqa xmm7,xmm6 psubw xmm5,xmm0 ; xmm5=data1-data6=tmp6 psubw xmm6,xmm3 ; xmm6=data0-data7=tmp7 paddw xmm2,xmm0 ; xmm2=data1+data6=tmp1 paddw xmm7,xmm3 ; xmm7=data0+data7=tmp0 movdqa xmm0, XMMWORD [wk(2)] ; xmm0=(24 25 26 27 34 35 36 37) movdqa xmm3, XMMWORD [wk(3)] ; xmm3=(44 45 46 47 54 55 56 57) movdqa XMMWORD [wk(0)], xmm5 ; wk(0)=tmp6 movdqa XMMWORD [wk(1)], xmm6 ; wk(1)=tmp7 movdqa xmm5,xmm4 ; transpose coefficients(phase 3) punpcklqdq xmm4,xmm0 ; xmm4=(20 21 22 23 24 25 26 27)=data2 punpckhqdq xmm5,xmm0 ; xmm5=(30 31 32 33 34 35 36 37)=data3 movdqa xmm6,xmm1 ; transpose coefficients(phase 3) punpcklqdq xmm1,xmm3 ; xmm1=(40 41 42 43 44 45 46 47)=data4 punpckhqdq xmm6,xmm3 ; xmm6=(50 51 52 53 54 55 56 57)=data5 movdqa xmm0,xmm5 movdqa xmm3,xmm4 paddw xmm5,xmm1 ; xmm5=data3+data4=tmp3 paddw xmm4,xmm6 ; xmm4=data2+data5=tmp2 psubw xmm0,xmm1 ; xmm0=data3-data4=tmp4 psubw xmm3,xmm6 ; xmm3=data2-data5=tmp5 ; -- Even part movdqa xmm1,xmm7 movdqa xmm6,xmm2 paddw xmm7,xmm5 ; xmm7=tmp10 paddw xmm2,xmm4 ; xmm2=tmp11 psubw xmm1,xmm5 ; xmm1=tmp13 psubw xmm6,xmm4 ; xmm6=tmp12 movdqa xmm5,xmm7 paddw xmm7,xmm2 ; xmm7=tmp10+tmp11 psubw xmm5,xmm2 ; xmm5=tmp10-tmp11 paddw xmm7,[rel PW_DESCALE_P2X] paddw xmm5,[rel PW_DESCALE_P2X] psraw xmm7,PASS1_BITS ; xmm7=data0 psraw xmm5,PASS1_BITS ; xmm5=data4 movdqa XMMWORD [XMMBLOCK(0,0,rdx,SIZEOF_DCTELEM)], xmm7 movdqa XMMWORD [XMMBLOCK(4,0,rdx,SIZEOF_DCTELEM)], xmm5 ; (Original) ; z1 = (tmp12 + tmp13) * 0.541196100; ; data2 = z1 + tmp13 * 0.765366865; ; data6 = z1 + tmp12 * -1.847759065; ; ; (This implementation) ; data2 = tmp13 * (0.541196100 + 0.765366865) + tmp12 * 0.541196100; ; data6 = tmp13 * 0.541196100 + tmp12 * (0.541196100 - 1.847759065); movdqa xmm4,xmm1 ; xmm1=tmp13 movdqa xmm2,xmm1 punpcklwd xmm4,xmm6 ; xmm6=tmp12 punpckhwd xmm2,xmm6 movdqa xmm1,xmm4 movdqa xmm6,xmm2 pmaddwd xmm4,[rel PW_F130_F054] ; xmm4=data2L pmaddwd xmm2,[rel PW_F130_F054] ; xmm2=data2H pmaddwd xmm1,[rel PW_F054_MF130] ; xmm1=data6L pmaddwd xmm6,[rel PW_F054_MF130] ; xmm6=data6H paddd xmm4,[rel PD_DESCALE_P2] paddd xmm2,[rel PD_DESCALE_P2] psrad xmm4,DESCALE_P2 psrad xmm2,DESCALE_P2 paddd xmm1,[rel PD_DESCALE_P2] paddd xmm6,[rel PD_DESCALE_P2] psrad xmm1,DESCALE_P2 psrad xmm6,DESCALE_P2 packssdw xmm4,xmm2 ; xmm4=data2 packssdw xmm1,xmm6 ; xmm1=data6 movdqa XMMWORD [XMMBLOCK(2,0,rdx,SIZEOF_DCTELEM)], xmm4 movdqa XMMWORD [XMMBLOCK(6,0,rdx,SIZEOF_DCTELEM)], xmm1 ; -- Odd part movdqa xmm7, XMMWORD [wk(0)] ; xmm7=tmp6 movdqa xmm5, XMMWORD [wk(1)] ; xmm5=tmp7 movdqa xmm2,xmm0 ; xmm0=tmp4 movdqa xmm6,xmm3 ; xmm3=tmp5 paddw xmm2,xmm7 ; xmm2=z3 paddw xmm6,xmm5 ; xmm6=z4 ; (Original) ; z5 = (z3 + z4) * 1.175875602; ; z3 = z3 * -1.961570560; z4 = z4 * -0.390180644; ; z3 += z5; z4 += z5; ; ; (This implementation) ; z3 = z3 * (1.175875602 - 1.961570560) + z4 * 1.175875602; ; z4 = z3 * 1.175875602 + z4 * (1.175875602 - 0.390180644); movdqa xmm4,xmm2 movdqa xmm1,xmm2 punpcklwd xmm4,xmm6 punpckhwd xmm1,xmm6 movdqa xmm2,xmm4 movdqa xmm6,xmm1 pmaddwd xmm4,[rel PW_MF078_F117] ; xmm4=z3L pmaddwd xmm1,[rel PW_MF078_F117] ; xmm1=z3H pmaddwd xmm2,[rel PW_F117_F078] ; xmm2=z4L pmaddwd xmm6,[rel PW_F117_F078] ; xmm6=z4H movdqa XMMWORD [wk(0)], xmm4 ; wk(0)=z3L movdqa XMMWORD [wk(1)], xmm1 ; wk(1)=z3H ; (Original) ; z1 = tmp4 + tmp7; z2 = tmp5 + tmp6; ; tmp4 = tmp4 * 0.298631336; tmp5 = tmp5 * 2.053119869; ; tmp6 = tmp6 * 3.072711026; tmp7 = tmp7 * 1.501321110; ; z1 = z1 * -0.899976223; z2 = z2 * -2.562915447; ; data7 = tmp4 + z1 + z3; data5 = tmp5 + z2 + z4; ; data3 = tmp6 + z2 + z3; data1 = tmp7 + z1 + z4; ; ; (This implementation) ; tmp4 = tmp4 * (0.298631336 - 0.899976223) + tmp7 * -0.899976223; ; tmp5 = tmp5 * (2.053119869 - 2.562915447) + tmp6 * -2.562915447; ; tmp6 = tmp5 * -2.562915447 + tmp6 * (3.072711026 - 2.562915447); ; tmp7 = tmp4 * -0.899976223 + tmp7 * (1.501321110 - 0.899976223); ; data7 = tmp4 + z3; data5 = tmp5 + z4; ; data3 = tmp6 + z3; data1 = tmp7 + z4; movdqa xmm4,xmm0 movdqa xmm1,xmm0 punpcklwd xmm4,xmm5 punpckhwd xmm1,xmm5 movdqa xmm0,xmm4 movdqa xmm5,xmm1 pmaddwd xmm4,[rel PW_MF060_MF089] ; xmm4=tmp4L pmaddwd xmm1,[rel PW_MF060_MF089] ; xmm1=tmp4H pmaddwd xmm0,[rel PW_MF089_F060] ; xmm0=tmp7L pmaddwd xmm5,[rel PW_MF089_F060] ; xmm5=tmp7H paddd xmm4, XMMWORD [wk(0)] ; xmm4=data7L paddd xmm1, XMMWORD [wk(1)] ; xmm1=data7H paddd xmm0,xmm2 ; xmm0=data1L paddd xmm5,xmm6 ; xmm5=data1H paddd xmm4,[rel PD_DESCALE_P2] paddd xmm1,[rel PD_DESCALE_P2] psrad xmm4,DESCALE_P2 psrad xmm1,DESCALE_P2 paddd xmm0,[rel PD_DESCALE_P2] paddd xmm5,[rel PD_DESCALE_P2] psrad xmm0,DESCALE_P2 psrad xmm5,DESCALE_P2 packssdw xmm4,xmm1 ; xmm4=data7 packssdw xmm0,xmm5 ; xmm0=data1 movdqa XMMWORD [XMMBLOCK(7,0,rdx,SIZEOF_DCTELEM)], xmm4 movdqa XMMWORD [XMMBLOCK(1,0,rdx,SIZEOF_DCTELEM)], xmm0 movdqa xmm1,xmm3 movdqa xmm5,xmm3 punpcklwd xmm1,xmm7 punpckhwd xmm5,xmm7 movdqa xmm3,xmm1 movdqa xmm7,xmm5 pmaddwd xmm1,[rel PW_MF050_MF256] ; xmm1=tmp5L pmaddwd xmm5,[rel PW_MF050_MF256] ; xmm5=tmp5H pmaddwd xmm3,[rel PW_MF256_F050] ; xmm3=tmp6L pmaddwd xmm7,[rel PW_MF256_F050] ; xmm7=tmp6H paddd xmm1,xmm2 ; xmm1=data5L paddd xmm5,xmm6 ; xmm5=data5H paddd xmm3, XMMWORD [wk(0)] ; xmm3=data3L paddd xmm7, XMMWORD [wk(1)] ; xmm7=data3H paddd xmm1,[rel PD_DESCALE_P2] paddd xmm5,[rel PD_DESCALE_P2] psrad xmm1,DESCALE_P2 psrad xmm5,DESCALE_P2 paddd xmm3,[rel PD_DESCALE_P2] paddd xmm7,[rel PD_DESCALE_P2] psrad xmm3,DESCALE_P2 psrad xmm7,DESCALE_P2 packssdw xmm1,xmm5 ; xmm1=data5 packssdw xmm3,xmm7 ; xmm3=data3 movdqa XMMWORD [XMMBLOCK(5,0,rdx,SIZEOF_DCTELEM)], xmm1 movdqa XMMWORD [XMMBLOCK(3,0,rdx,SIZEOF_DCTELEM)], xmm3 uncollect_args mov rsp,rbp ; rsp <- aligned rbp pop rsp ; rsp <- original rbp pop rbp ret ; For some reason, the OS X linker does not honor the request to align the ; segment unless we do this. align 16
.data words: .asciiz "is the result of factorial(1).\n" .text main: #Call Fact(4) addi $a0, $zero, 1 jal fact #Print 4! add $a0, $zero, $v0 addi $v0, $zero, 1 syscall #Print some words li $v0, 4 la $a0, words syscall #Exit Code li $v0, 10 syscall fact: addi $sp, $sp,-8 #Create two spots on the stack sw $ra, 4($sp) #Preserve the return address on the stack (this is necassary for recursion) sw $a0, 0($s0) #Preserve the argument of the current iteration addi $t1, $zero, 1 slt $t0, $a0, $t1 #Create flag at t0 = (a0 < 1) beq $t0, $zero, IfThen #If t0 flag is true, then go to label IfThen #Else, addi $v0 $zero, 1 #Load 1 into return register addi $sp, $sp, 8 #Pop the top two items off the stack to return it to its original state jr $ra #return to address which called the routine IfThen: #Call fact(n-1) addi $a0, $a0, -1 jal fact #restore the prior state data before leaving the function lw $a0, 0($sp) #return the argument register lw $a0, 4($sp) #return the retunr address addi $sp, $sp, 8 #pop the two items off the stack since they aren't needed anymore mul $v0, $a0, $v0 #compute the multiplication part of v0 = fact(n) * fact(n-1) jr $ra #return to the address which called the routine
/* ============================================================================ * Copyright (c) 2009-2016 BlueQuartz Software, LLC * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, this * list of conditions and the following disclaimer in the documentation and/or * other materials provided with the distribution. * * Neither the name of BlueQuartz Software, the US Air Force, nor the names of its * contributors may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * The code contained herein was partially funded by the following contracts: * United States Air Force Prime Contract FA8650-07-D-5800 * United States Air Force Prime Contract FA8650-10-D-5210 * United States Prime Contract Navy N00173-07-C-2068 * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include <stdio.h> #include <stdlib.h> #include <QtCore/QDebug> #include <QtCore/QDir> #include <QtCore/QFile> #include <QtCore/QString> #include <QtCore/QVector> #include "SIMPLib/SIMPLib.h" #include "SIMPLib/Common/ScopedFileMonitor.hpp" #include "SIMPLib/CoreFilters/RawBinaryReader.h" #include "SIMPLib/DataContainers/DataContainer.h" #include "SIMPLib/DataContainers/DataContainerArray.h" #include "SIMPLib/Testing/SIMPLTestFileLocations.h" #include "SIMPLib/Testing/UnitTestSupport.hpp" /* Testing Notes: * * testCase1: This tests when the file size is equal to the allocated size, and checks to see if the data read is the same as the data written. * * testCase2: This tests when the file size is smaller than the allocated size. (Reading past the end of the file) * * testCase3: This tests when the file size is larger than the allocated size and there is junk at the end of the file. * * testCase4: This tests when the file size is larger than the allocated size and there is junk at the beginning of the file. * * testCase5: This tests when the file size is larger than the allocated size and there is junk at the beginning and end of the file. * * testCase6: This tests when skipHeaderBytes equals the file size */ /** we are going to use a fairly large array size because we want to exercise the * possibilty that we can not write the data or read the data from the file in one * step in the filter */ #define RBRT_FILE_NOT_OPEN -1000 #define RBRT_FILE_TOO_SMALL -1010 #define RBRT_READ_EOF -1030 #define RBRT_NO_ERROR 0 namespace Detail { enum Endian { Little = 0, Big }; enum JunkPlacement { None = 0, Start, End, Both }; } // namespace Detail class RawBinaryReaderTest { public: const size_t k_XDim = 100; const size_t k_YDim = 100; const size_t k_ZDim = 1000; const size_t k_ArraySize = k_XDim * k_YDim * k_ZDim; RawBinaryReaderTest() = default; ~RawBinaryReaderTest() = default; // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void RemoveTestFiles() { #if REMOVE_TEST_FILES QFile::remove(UnitTest::RawBinaryReaderTest::OutputFile); #endif } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- template <typename T> bool createAndWriteToFile(T* dataArray, size_t dataSize, T* junkArray, size_t junkSize, Detail::JunkPlacement junkPlacement) { /* Any of these combinations will return failure: * If the junkArray has values and junkPlacement is set to NONE * If junkArray is nullptr and junkPlacement is not set to NONE * If junkPlacement is set to an invalid value * If the dataArray is nullptr */ if((nullptr != junkArray && junkPlacement <= 0) || (nullptr == junkArray && junkPlacement > 0) || junkPlacement < 0 || dataArray == nullptr) { return false; } // Create the output file to dump some data into FILE* f = fopen(UnitTest::RawBinaryReaderTest::OutputFile.toLatin1().data(), "wb"); // If junkPlacement is set to START or BOTH, write junk to file size_t numWritten = 0; if(junkPlacement == Detail::Start || junkPlacement == Detail::Both) { while(1) { numWritten += fwrite(junkArray, sizeof(T), junkSize, f); if(numWritten == junkSize) { break; } junkArray = junkArray + numWritten; } } // Write the data to the file numWritten = 0; T* dataArrayFront = dataArray; while(1) { numWritten += fwrite(dataArray, sizeof(T), dataSize, f); if(numWritten == dataSize) { break; } dataArray = dataArray + numWritten; } // Reset the pointer back to the front of the array, and set dataArrayFront to nullptr dataArrayFront = nullptr; // If junkPlacement is set to END or BOTH, write junk to file numWritten = 0; if(junkPlacement == Detail::End || junkPlacement == Detail::Both) { while(1) { numWritten += fwrite(junkArray, sizeof(T), junkSize, f); if(numWritten == junkSize) { break; } junkArray = junkArray + numWritten; } } // Close the file fclose(f); // Return successful return true; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- RawBinaryReader::Pointer createRawBinaryReaderFilter(SIMPL::NumericTypes::Type scalarType, size_t N, int skipBytes) { RawBinaryReader::Pointer filt = RawBinaryReader::New(); filt->setInputFile(UnitTest::RawBinaryReaderTest::OutputFile); filt->setScalarType(scalarType); filt->setEndian(Detail::Little); // filt->setDimensionality(3); filt->setNumberOfComponents(N); filt->setSkipHeaderBytes(skipBytes); // IntVec3Widget_t dims; // dims.x = k_XDim; // dims.y = k_YDim; // dims.z = k_ZDim; // filt->setDimensions(dims); // FloatVec3Widget_t origin; // origin.x = origin.y = origin.z = 1.0f; // filt->setOrigin(origin); // FloatVec3Widget_t spacing; // spacing.x = spacing.y = spacing.z = 0.55f; // filt->setSpacing(spacing); filt->setCreatedAttributeArrayPath(DataArrayPath("DataContainer", "AttributeMatrix", "Test_Array")); return filt; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // testCase1: This tests when the file size is equal to the allocated size, and checks to see if the data read is the same as the data written. template <typename T, size_t N> int testCase1_Execute(SIMPL::NumericTypes::Type scalarType) { size_t dataArraySize = k_ArraySize * N; size_t junkArraySize = 0; size_t skipHeaderBytes = 0; int err = 0; // Allocate an array, and get the dataArray from that array typename DataArray<T>::Pointer array = DataArray<T>::CreateArray(dataArraySize, std::string("_Temp_"), true); T* dataArray = array->getPointer(0); // Write some data into the data array for(size_t i = 0; i < dataArraySize; ++i) { dataArray[i] = static_cast<T>(i); } // Create junkArray and set it to nullptr because there is no junk in this test case T* junkArray = nullptr; // Create the file and write to it. If any of the information is wrong, the result will be false bool result = createAndWriteToFile(dataArray, dataArraySize, junkArray, junkArraySize, Detail::None); // Test to make sure that the file was created and written to successfully DREAM3D_REQUIRED(result, ==, true) // Create the attribute matrix std::vector<size_t> dims(1, k_ArraySize); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); // Create the data container DataContainer::Pointer m = DataContainer::New(SIMPL::Defaults::DataContainerName); m->addOrReplaceAttributeMatrix(am); DataContainerArray::Pointer dca = DataContainerArray::New(); dca->addOrReplaceDataContainer(m); // Create the filter, passing in the skipHeaderBytes RawBinaryReader::Pointer filt = createRawBinaryReaderFilter(scalarType, N, skipHeaderBytes); filt->setDataContainerArray(dca); // Preflight, get the error condition, and check that there are no errors filt->preflight(); err = filt->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) am->clearAttributeArrays(); // Execute the filter, check that there are no errors, and compare the data filt->execute(); err = filt->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) IDataArray::Pointer iData = am->getAttributeArray("Test_Array"); T* data = reinterpret_cast<T*>(iData->getVoidPointer(0)); T d, p; for(size_t i = 0; i < dataArraySize; ++i) { d = data[i]; p = dataArray[i]; DREAM3D_REQUIRE_EQUAL(d, p) } return err; } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- template <typename T> void testCase1_TestPrimitives(SIMPL::NumericTypes::Type scalarType) { testCase1_Execute<T, 1>(scalarType); testCase1_Execute<T, 2>(scalarType); testCase1_Execute<T, 3>(scalarType); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void testCase1() { // Make sure any directory path is also available as the user may have just typed // in a path without actually creating the full path QDir dir(UnitTest::RawBinaryReaderTest::TestDir); if(!dir.mkpath(".")) { // qDebug() << "Error creating parent path '" << UnitTest::RawBinaryReaderTest::TestDir << "'"; return; } testCase1_TestPrimitives<int8_t>(SIMPL::NumericTypes::Type::Int8); testCase1_TestPrimitives<uint8_t>(SIMPL::NumericTypes::Type::UInt8); testCase1_TestPrimitives<int16_t>(SIMPL::NumericTypes::Type::Int16); testCase1_TestPrimitives<uint16_t>(SIMPL::NumericTypes::Type::UInt16); testCase1_TestPrimitives<int32_t>(SIMPL::NumericTypes::Type::Int32); testCase1_TestPrimitives<uint32_t>(SIMPL::NumericTypes::Type::UInt32); testCase1_TestPrimitives<int64_t>(SIMPL::NumericTypes::Type::Int64); testCase1_TestPrimitives<uint64_t>(SIMPL::NumericTypes::Type::UInt64); testCase1_TestPrimitives<float>(SIMPL::NumericTypes::Type::Float); testCase1_TestPrimitives<double>(SIMPL::NumericTypes::Type::Double); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // testCase2: This tests when the file size is smaller than the allocated size. (Reading past the end of the file) template <typename T, size_t N> void testCase2_Execute(SIMPL::NumericTypes::Type scalarType) { size_t dataArraySize = k_ArraySize * N / 2; // We don't care what is written...we just need the data array size to be less than the file size size_t junkArraySize = 0; size_t skipHeaderBytes = junkArraySize * sizeof(T); int err = 0; // qDebug() << "Testing case 2: " << name << " with num comps " << N; // Allocate an array, and get the dataArray from that array typename DataArray<T>::Pointer array = DataArray<T>::CreateArray(dataArraySize, std::string("_Temp_"), true); // This makes sure our allocated array is deleted when we leave T* dataArray = array->getPointer(0); // Write some data into the data array for(size_t i = 0; i < dataArraySize; ++i) { dataArray[i] = static_cast<T>(i); } // Create junkArray and set it to nullptr because there is no junk in this test case T* junkArray = nullptr; // Create the file and write to it. If any of the information is wrong, the result will be false bool result = createAndWriteToFile(dataArray, dataArraySize, junkArray, junkArraySize, Detail::None); // Test to make sure that the file was created and written to successfully DREAM3D_REQUIRED(result, ==, true) // Create the attribute matrix std::vector<size_t> dims(1, k_ArraySize); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); // Create the data container DataContainer::Pointer m = DataContainer::New(SIMPL::Defaults::DataContainerName); m->addOrReplaceAttributeMatrix(am); DataContainerArray::Pointer dca = DataContainerArray::New(); dca->addOrReplaceDataContainer(m); // Create the filter, passing in the skipHeaderBytes RawBinaryReader::Pointer filt = createRawBinaryReaderFilter(scalarType, N, skipHeaderBytes); filt->setDataContainerArray(dca); // Preflight, get error condition, and check that the "file is too small" error is returned filt->preflight(); err = filt->getErrorCode(); DREAM3D_REQUIRED(err, ==, RBRT_FILE_TOO_SMALL) am->clearAttributeArrays(); // Execute, get error condition, and check that the "file is too small" error is returned filt->execute(); err = filt->getErrorCode(); DREAM3D_REQUIRED(err, ==, RBRT_FILE_TOO_SMALL) } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- template <typename T> void testCase2_TestPrimitives(SIMPL::NumericTypes::Type scalarType) { testCase2_Execute<T, 1>(scalarType); testCase2_Execute<T, 2>(scalarType); testCase2_Execute<T, 3>(scalarType); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void testCase2() { // Make sure any directory path is also available as the user may have just typed // in a path without actually creating the full path QDir dir(UnitTest::RawBinaryReaderTest::TestDir); if(!dir.mkpath(".")) { // qDebug() << "Error creating parent path '" << UnitTest::RawBinaryReaderTest::TestDir << "'"; return; } testCase2_TestPrimitives<int8_t>(SIMPL::NumericTypes::Type::Int8); testCase2_TestPrimitives<uint8_t>(SIMPL::NumericTypes::Type::UInt8); testCase2_TestPrimitives<int16_t>(SIMPL::NumericTypes::Type::Int16); testCase2_TestPrimitives<uint16_t>(SIMPL::NumericTypes::Type::UInt16); testCase2_TestPrimitives<int32_t>(SIMPL::NumericTypes::Type::Int32); testCase2_TestPrimitives<uint32_t>(SIMPL::NumericTypes::Type::UInt32); testCase2_TestPrimitives<int64_t>(SIMPL::NumericTypes::Type::Int64); testCase2_TestPrimitives<uint64_t>(SIMPL::NumericTypes::Type::UInt64); testCase2_TestPrimitives<float>(SIMPL::NumericTypes::Type::Float); testCase2_TestPrimitives<double>(SIMPL::NumericTypes::Type::Double); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // testCase3: This tests when the file size is larger than the allocated size and there is junk at the end of the file. template <typename T, size_t N> void testCase3_Execute(SIMPL::NumericTypes::Type scalarType) { size_t dataArraySize = k_ArraySize * N; size_t junkArraySize = 10; size_t skipHeaderBytes = 0; int err = 0; // qDebug() << "Testing case 3: " << name << " with num comps " << N; // Allocate an array, and get the dataArray from that array typename DataArray<T>::Pointer array = DataArray<T>::CreateArray(dataArraySize, std::string("_Temp__"), true); // This makes sure our allocated array is deleted when we leave T* dataArray = array->getPointer(0); // Write some data into the data array for(size_t i = 0; i < dataArraySize; ++i) { dataArray[i] = static_cast<T>(i); } // Create junkArray std::vector<T> junkArray(junkArraySize); // Write a pattern into junkArray std::memset(junkArray.data(), 0xAB, junkArray.size() * sizeof(T)); // Create the file and write to it. If any of the information is wrong, the result will be false bool result = createAndWriteToFile(dataArray, dataArraySize, junkArray.data(), junkArraySize, Detail::End); // Test to make sure that the file was created and written to successfully DREAM3D_REQUIRED(result, ==, true) // Create the attribute matrix std::vector<size_t> dims(1, k_ArraySize); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); // Create the data container DataContainer::Pointer m = DataContainer::New(SIMPL::Defaults::DataContainerName); m->addOrReplaceAttributeMatrix(am); DataContainerArray::Pointer dca = DataContainerArray::New(); dca->addOrReplaceDataContainer(m); // Create the filter, passing in the skipHeaderBytes RawBinaryReader::Pointer filt = createRawBinaryReaderFilter(scalarType, N, skipHeaderBytes); filt->setDataContainerArray(dca); // Preflight, get the error condition, and check that there are no errors filt->preflight(); err = filt->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) am->clearAttributeArrays(); // Execute, get the error condition, check that there are no errors, and compare the data filt->execute(); err = filt->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) IDataArray::Pointer iData = am->getAttributeArray("Test_Array"); T* readData = reinterpret_cast<T*>(iData->getVoidPointer(0)); T d, p; for(size_t i = 0; i < dataArraySize; ++i) { d = readData[i]; p = dataArray[i]; DREAM3D_REQUIRE_EQUAL(d, p) } } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- template <typename T> void testCase3_TestPrimitives(SIMPL::NumericTypes::Type scalarType) { testCase3_Execute<T, 1>(scalarType); testCase3_Execute<T, 2>(scalarType); testCase3_Execute<T, 3>(scalarType); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void testCase3() { // Make sure any directory path is also available as the user may have just typed // in a path without actually creating the full path QDir dir(UnitTest::RawBinaryReaderTest::TestDir); if(!dir.mkpath(".")) { // qDebug() << "Error creating parent path '" << UnitTest::RawBinaryReaderTest::TestDir << "'"; return; } testCase3_TestPrimitives<int8_t>(SIMPL::NumericTypes::Type::Int8); testCase3_TestPrimitives<uint8_t>(SIMPL::NumericTypes::Type::UInt8); testCase3_TestPrimitives<int16_t>(SIMPL::NumericTypes::Type::Int16); testCase3_TestPrimitives<uint16_t>(SIMPL::NumericTypes::Type::UInt16); testCase3_TestPrimitives<int32_t>(SIMPL::NumericTypes::Type::Int32); testCase3_TestPrimitives<uint32_t>(SIMPL::NumericTypes::Type::UInt32); testCase3_TestPrimitives<int64_t>(SIMPL::NumericTypes::Type::Int64); testCase3_TestPrimitives<uint64_t>(SIMPL::NumericTypes::Type::UInt64); testCase3_TestPrimitives<float>(SIMPL::NumericTypes::Type::Float); testCase3_TestPrimitives<double>(SIMPL::NumericTypes::Type::Double); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // testCase4: This tests when the file size is larger than the allocated size and there is junk at the beginning of the file. template <typename T, size_t N> void testCase4_Execute(SIMPL::NumericTypes::Type scalarType) { size_t dataArraySize = k_ArraySize * N; size_t junkArraySize = 5; size_t skipHeaderBytes = junkArraySize * sizeof(T); int err = 0; // qDebug() << "Testing case 4: " << name << " with num comps " << N; // Allocate an array, and get the dataArray from that array typename DataArray<T>::Pointer array = DataArray<T>::CreateArray(dataArraySize, std::string("_Temp_"), true); T* dataArray = array->getPointer(0); // Write some data into the data array for(size_t i = 0; i < dataArraySize; ++i) { dataArray[i] = static_cast<T>(i); } // Create junkArray std::vector<T> junkArray(junkArraySize, 0xAB); // Write a pattern into junkArray std::memset(junkArray.data(), 0xAB, junkArray.size() * sizeof(T)); // Create the file and write to it. If any of the information is wrong, the result will be false bool result = createAndWriteToFile(dataArray, dataArraySize, junkArray.data(), junkArray.size(), Detail::Start); // Test to make sure that the file was created and written to successfully DREAM3D_REQUIRED(result, ==, true) // Create the attribute matrix std::vector<size_t> dims(1, k_ArraySize); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); // Create the data container DataContainer::Pointer m = DataContainer::New(SIMPL::Defaults::DataContainerName); m->addOrReplaceAttributeMatrix(am); DataContainerArray::Pointer dca = DataContainerArray::New(); dca->addOrReplaceDataContainer(m); // Create the filter, passing in the skipHeaderBytes RawBinaryReader::Pointer filt = createRawBinaryReaderFilter(scalarType, N, skipHeaderBytes); filt->setDataContainerArray(dca); // Preflight, get error condition, and check that there are no errors filt->preflight(); err = filt->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) am->clearAttributeArrays(); // Execute, get error condition, check that there are no errors, and compare the data filt->execute(); err = filt->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) IDataArray::Pointer iData = m->getAttributeMatrix(SIMPL::Defaults::AttributeMatrixName)->getAttributeArray("Test_Array"); T* data = reinterpret_cast<T*>(iData->getVoidPointer(0)); T d, p; for(size_t i = 0; i < dataArraySize; ++i) { d = data[i]; p = dataArray[i]; DREAM3D_REQUIRE_EQUAL(d, p) } /* * SUBTEST: Test when skipHeaderBytes is larger than expected */ // Create another data container DataContainer::Pointer m2 = DataContainer::New(SIMPL::Defaults::DataContainerName); m2->addOrReplaceAttributeMatrix(am); DataContainerArray::Pointer dca2 = DataContainerArray::New(); dca2->addOrReplaceDataContainer(m2); // Create another filter, passing in the skipHeaderBytes + 1 RawBinaryReader::Pointer filt2 = createRawBinaryReaderFilter(scalarType, N, skipHeaderBytes + 1); filt2->setDataContainerArray(dca2); am->clearAttributeArrays(); // Preflight, get error condition, and check that there are errors filt2->preflight(); err = filt2->getErrorCode(); DREAM3D_REQUIRED(err, <, 0) am->clearAttributeArrays(); // Execute, get error condition, and check that the "file too small" error occurred filt2->execute(); err = filt2->getErrorCode(); DREAM3D_REQUIRED(err, ==, RBRT_FILE_TOO_SMALL) } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- template <typename T> void testCase4_TestPrimitives(SIMPL::NumericTypes::Type scalarType) { testCase4_Execute<T, 1>(scalarType); testCase4_Execute<T, 2>(scalarType); testCase4_Execute<T, 3>(scalarType); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void testCase4() { // Make sure any directory path is also available as the user may have just typed // in a path without actually creating the full path QDir dir(UnitTest::RawBinaryReaderTest::TestDir); if(!dir.mkpath(".")) { // qDebug() << "Error creating parent path '" << UnitTest::RawBinaryReaderTest::TestDir << "'"; return; } testCase4_TestPrimitives<int8_t>(SIMPL::NumericTypes::Type::Int8); testCase4_TestPrimitives<uint8_t>(SIMPL::NumericTypes::Type::UInt8); testCase4_TestPrimitives<int16_t>(SIMPL::NumericTypes::Type::Int16); testCase4_TestPrimitives<uint16_t>(SIMPL::NumericTypes::Type::UInt16); testCase4_TestPrimitives<int32_t>(SIMPL::NumericTypes::Type::Int32); testCase4_TestPrimitives<uint32_t>(SIMPL::NumericTypes::Type::UInt32); testCase4_TestPrimitives<int64_t>(SIMPL::NumericTypes::Type::Int64); testCase4_TestPrimitives<uint64_t>(SIMPL::NumericTypes::Type::UInt64); testCase4_TestPrimitives<float>(SIMPL::NumericTypes::Type::Float); testCase4_TestPrimitives<double>(SIMPL::NumericTypes::Type::Double); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // testCase5: This tests when the file size is larger than the allocated size and there is junk both at the beginning and end of the file. template <typename T, size_t N> void testCase5_Execute(SIMPL::NumericTypes::Type scalarType) { size_t dataArraySize = k_ArraySize * N; size_t junkArraySize = 10; size_t skipHeaderBytes = junkArraySize * sizeof(T); int err = 0; // qDebug() << "Testing case 5: " << name << " with num comps " << N; // Allocate an array, and get the dataArray from that array typename DataArray<T>::Pointer array = DataArray<T>::CreateArray(dataArraySize, std::string("_Temp_"), true); // This makes sure our allocated array is deleted when we leave T* dataArray = array->getPointer(0); // Write some data into the data array for(size_t i = 0; i < dataArraySize; ++i) { dataArray[i] = static_cast<T>(i); } // Create junkArray std::vector<T> junkArray(junkArraySize, 0xAB); // Write a pattern into junkArray std::memset(junkArray.data(), 0xAB, junkArray.size() * sizeof(T)); // Create the file and write to it. If any of the information is wrong, the result will be false bool result = createAndWriteToFile(dataArray, dataArraySize, junkArray.data(), junkArray.size(), Detail::Both); // Test to make sure that the file was created and written to successfully DREAM3D_REQUIRED(result, ==, true) // Create the attribute matrix std::vector<size_t> dims(1, k_ArraySize); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); // Create the data container DataContainer::Pointer m = DataContainer::New(SIMPL::Defaults::DataContainerName); m->addOrReplaceAttributeMatrix(am); DataContainerArray::Pointer dca = DataContainerArray::New(); dca->addOrReplaceDataContainer(m); // Create the filter, passing in the skipHeaderBytes RawBinaryReader::Pointer filt = createRawBinaryReaderFilter(scalarType, N, skipHeaderBytes); filt->setDataContainerArray(dca); // Preflight, get error condition, and check that there are no errors filt->preflight(); err = filt->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) am->clearAttributeArrays(); // Execute, get error condition, check that there are no errors, and compare the data filt->execute(); err = filt->getErrorCode(); DREAM3D_REQUIRED(err, >=, 0) IDataArray::Pointer iData = m->getAttributeMatrix(SIMPL::Defaults::AttributeMatrixName)->getAttributeArray("Test_Array"); T* data = reinterpret_cast<T*>(iData->getVoidPointer(0)); T d, p; for(size_t i = 0; i < dataArraySize; ++i) { d = data[i]; p = dataArray[i]; DREAM3D_REQUIRE_EQUAL(d, p) } } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- template <typename T> void testCase5_TestPrimitives(SIMPL::NumericTypes::Type scalarType) { testCase5_Execute<T, 1>(scalarType); testCase5_Execute<T, 2>(scalarType); testCase5_Execute<T, 3>(scalarType); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void testCase5() { // Make sure any directory path is also available as the user may have just typed // in a path without actually creating the full path QDir dir(UnitTest::RawBinaryReaderTest::TestDir); if(!dir.mkpath(".")) { // qDebug() << "Error creating parent path '" << UnitTest::RawBinaryReaderTest::TestDir << "'"; return; } testCase5_TestPrimitives<int8_t>(SIMPL::NumericTypes::Type::Int8); testCase5_TestPrimitives<uint8_t>(SIMPL::NumericTypes::Type::UInt8); testCase5_TestPrimitives<int16_t>(SIMPL::NumericTypes::Type::Int16); testCase5_TestPrimitives<uint16_t>(SIMPL::NumericTypes::Type::UInt16); testCase5_TestPrimitives<int32_t>(SIMPL::NumericTypes::Type::Int32); testCase5_TestPrimitives<uint32_t>(SIMPL::NumericTypes::Type::UInt32); testCase5_TestPrimitives<int64_t>(SIMPL::NumericTypes::Type::Int64); testCase5_TestPrimitives<uint64_t>(SIMPL::NumericTypes::Type::UInt64); testCase5_TestPrimitives<float>(SIMPL::NumericTypes::Type::Float); testCase5_TestPrimitives<double>(SIMPL::NumericTypes::Type::Double); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // testCase6: This tests when skipHeaderBytes equals the file size template <typename T, size_t N> void testCase6_Execute(SIMPL::NumericTypes::Type scalarType) { size_t dataArraySize = 1000; size_t junkArraySize = k_ArraySize * N; int skipHeaderBytes = junkArraySize * sizeof(T); int err = 0; // qDebug() << "Testing case 6: " << name << " with num comps " << N; // Allocate an array, and get the dataArray from that array typename DataArray<T>::Pointer array = DataArray<T>::CreateArray(dataArraySize, std::string("_Temp_"), true); // This makes sure our allocated array is deleted when we leave T* dataArray = array->getPointer(0); // Write some data into the data array for(size_t i = 0; i < dataArraySize; ++i) { dataArray[i] = static_cast<T>(i); } // Create junkArray std::vector<T> junkArray(junkArraySize, 0xAB); // Write a pattern into junkArray std::memset(junkArray.data(), 0xAB, junkArray.size() * sizeof(T)); // Create the file and write to it. If any of the information is wrong, the result will be false bool result = createAndWriteToFile(dataArray, dataArraySize, junkArray.data(), junkArraySize, Detail::Start); // Test to make sure that the file was created and written to successfully DREAM3D_REQUIRED(result, ==, true) // Create the attribute matrix std::vector<size_t> dims(1, k_ArraySize); AttributeMatrix::Pointer am = AttributeMatrix::New(dims, "AttributeMatrix", AttributeMatrix::Type::Any); // Create the data container DataContainer::Pointer m = DataContainer::New(SIMPL::Defaults::DataContainerName); m->addOrReplaceAttributeMatrix(am); DataContainerArray::Pointer dca = DataContainerArray::New(); dca->addOrReplaceDataContainer(m); // Create the filter, passing in the skipHeaderBytes RawBinaryReader::Pointer filt = createRawBinaryReaderFilter(scalarType, N, skipHeaderBytes); filt->setDataContainerArray(dca); // Preflight, get error condition, and check that the "file too small" error has occurred filt->preflight(); err = filt->getErrorCode(); DREAM3D_REQUIRED(err, ==, RBRT_FILE_TOO_SMALL) // Execute, get error condition, and check that there are errors filt->execute(); err = filt->getErrorCode(); DREAM3D_REQUIRED(err, <, 0) } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- template <typename T> void testCase6_TestPrimitives(SIMPL::NumericTypes::Type scalarType) { testCase6_Execute<T, 1>(scalarType); testCase6_Execute<T, 2>(scalarType); testCase6_Execute<T, 3>(scalarType); } // ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void testCase6() { // Make sure any directory path is also available as the user may have just typed // in a path without actually creating the full path QDir dir(UnitTest::RawBinaryReaderTest::TestDir); if(!dir.mkpath(".")) { // qDebug() << "Error creating parent path '" << UnitTest::RawBinaryReaderTest::TestDir << "'"; return; } testCase6_TestPrimitives<int8_t>(SIMPL::NumericTypes::Type::Int8); testCase6_TestPrimitives<uint8_t>(SIMPL::NumericTypes::Type::UInt8); testCase6_TestPrimitives<int16_t>(SIMPL::NumericTypes::Type::Int16); testCase6_TestPrimitives<uint16_t>(SIMPL::NumericTypes::Type::UInt16); testCase6_TestPrimitives<int32_t>(SIMPL::NumericTypes::Type::Int32); testCase6_TestPrimitives<uint32_t>(SIMPL::NumericTypes::Type::UInt32); testCase6_TestPrimitives<int64_t>(SIMPL::NumericTypes::Type::Int64); testCase6_TestPrimitives<uint64_t>(SIMPL::NumericTypes::Type::UInt64); testCase6_TestPrimitives<float>(SIMPL::NumericTypes::Type::Float); testCase6_TestPrimitives<double>(SIMPL::NumericTypes::Type::Double); } // ----------------------------------------------------------------------------- // Use unit test framework // ----------------------------------------------------------------------------- void operator()() { std::cout << "#### RawBinaryReaderTest Starting ####" << std::endl; int err = EXIT_SUCCESS; #if !REMOVE_TEST_FILES DREAM3D_REGISTER_TEST(RemoveTestFiles()) #endif DREAM3D_REGISTER_TEST(testCase1()) DREAM3D_REGISTER_TEST(testCase2()) DREAM3D_REGISTER_TEST(testCase3()) DREAM3D_REGISTER_TEST(testCase4()) DREAM3D_REGISTER_TEST(testCase5()) DREAM3D_REGISTER_TEST(testCase6()) #if REMOVE_TEST_FILES DREAM3D_REGISTER_TEST(RemoveTestFiles()) #endif } private: RawBinaryReaderTest(const RawBinaryReaderTest&); // Copy Constructor Not Implemented void operator=(const RawBinaryReaderTest&); // Move assignment Not Implemented };
/*========================================================================= * * Copyright Insight Software Consortium * * 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.txt * * 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. * *=========================================================================*/ #ifndef itkImageRegionReverseIterator_hxx #define itkImageRegionReverseIterator_hxx #include "itkImageRegionReverseIterator.h" namespace itk { template< typename TImage > ImageRegionReverseIterator< TImage > ::ImageRegionReverseIterator(): ImageRegionReverseConstIterator< TImage >() {} template< typename TImage > ImageRegionReverseIterator< TImage > ::ImageRegionReverseIterator(ImageType *ptr, const RegionType & region): ImageRegionReverseConstIterator< TImage >(ptr, region) {} template< typename TImage > ImageRegionReverseIterator< TImage > ::ImageRegionReverseIterator(const ImageConstIterator< TImage > & it):Superclass(it) {} template< typename TImage > ImageRegionReverseIterator< TImage > ::ImageRegionReverseIterator(const ImageRegionReverseConstIterator< TImage > & it): Superclass(it) {} template< typename TImage > ImageRegionReverseIterator< TImage > & ImageRegionReverseIterator< TImage > ::operator=(const ImageRegionReverseConstIterator< TImage > & it) { this->Superclass::operator=(it); return *this; } } // end namespace itk #endif
; A262267: Number of (n+2) X (1+2) 0..1 arrays with each row and column divisible by 5, read as a binary number with top and left being the most significant bits. ; 2,4,7,13,26,52,103,205,410,820,1639,3277,6554,13108,26215,52429,104858,209716,419431,838861,1677722,3355444,6710887,13421773,26843546,53687092,107374183,214748365,429496730,858993460,1717986919,3435973837,6871947674,13743895348,27487790695,54975581389,109951162778,219902325556,439804651111,879609302221,1759218604442,3518437208884,7036874417767,14073748835533,28147497671066,56294995342132,112589990684263,225179981368525,450359962737050,900719925474100,1801439850948199,3602879701896397,7205759403792794 mov $1,2 pow $1,$0 mul $1,8 div $1,5 add $1,1
page ,132 title xtoa - convert integers/longs to ASCII string ;*** ;xtoa.asm - convert integers/longs to ASCII string ; ; Copyright (c) 1985-1991, Microsoft Corporation. All rights reserved. ; ;Purpose: ; The module has code to convert integers/longs to ASCII strings. ; ;Revision History: ; 01-06-85 GFW initial version ; 02-01-85 RN fixed itoa so not sign-extended to 32 bits if radix ; is not 10 (-1 in base 16 should be "ffff", not ; "ffffffff") ; 02-05-85 RN split itoa, ltoa, and ultoa out into separate modules ; so user can redefine any or all of them without ; running into 'bundling' problems and naming conflicts ; when s/he links ; 11-22-89 GJF Fixed copyright ; ; 06-05-91 MD Stolen from C runtime for use with POWER.EXE ; ;******************************************************************************* Trans_Code segment word public 'CODE' Trans_Code ends Trans_Data segment word public 'DATA' Trans_Data ends Trans_Code segment assume cs:Trans_Code, ds:Trans_Data get_dec proc near public get_dec mov cx,10 xor bl,bl ; ds:di = buffer ; dx:ax = value ; cx = radix ; bl = 1 if signed, 0 if unsigned push di ; save start of buffer push ds pop es ; ds = es = segment of buffer cld xchg bx,ax ; dx:bx = number , ax = signed or al,al jz uxtoa ; unsigned conversion cmp cx,10 ; check for radix = 10 jne uxtoa ; no - treat as unsigned or dx,dx ; test for negative number jns uxtoa mov al,'-' stosb ; stuff out - neg bx ; negate dx:bx adc dx,0 neg dx uxtoa: mov si,di ; save start of number divdown: xchg ax,dx ; divide hi xor dx,dx or ax,ax jz nohigh ; save a divide div cx ; dx = rem, ax = hi div nohigh: xchg ax,bx ; ax = lo, bx = hi div div cx ; dx = rem, bx:ax = div xchg ax,dx ; ax = rem, bx:dx = div xchg dx,bx ; ax = rem, dx:bx = div (tight!!!!) add al,'0' cmp al,'9' jbe isadig ; is a digit already add al,'a'-'0'-10 ; convert to letter isadig: stosb mov ax,dx or ax,bx jnz divdown ; crack out next digit ; reverse digits mov [di],al ; stuff string terminator revloop: dec di ; point back to last char lodsb ; exchange bytes xchg [di],al mov [si-1],al ; The following is equivalent to "cmp si,(di-1)" ; but avoids segment wrap in case DI == 0 lea ax,[si+1] cmp ax,di ; are we halfway? jb revloop ; no pop ax ; buffer offset ret get_dec endp Trans_Code ends end
; A028195: Expansion of 1/((1-5x)(1-8x)(1-11x)(1-12x)). ; Submitted by Christian Krause ; 1,36,825,15380,254721,3910596,56993545,800115060,10923586641,145981963556,1918518760665,24879137417940,319158529241761,4058064014390916,51218264422582185,642449405949396020 mov $1,1 mov $2,$0 mov $3,$0 lpb $2 mov $0,$3 sub $2,1 sub $0,$2 seq $0,20981 ; Expansion of 1/((1-8*x)*(1-11*x)*(1-12*x)). sub $0,$1 mul $1,6 add $1,$0 lpe mov $0,$1
; A315312: Coordination sequence Gal.6.639.4 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings. ; Submitted by Simon Strandgaard ; 1,6,10,16,20,26,32,38,42,48,52,58,64,68,74,78,84,90,96,100,106,110,116,122,126,132,136,142,148,154,158,164,168,174,180,184,190,194,200,206,212,216,222,226,232,238,242,248,252,258 mov $1,$0 mov $2,$0 mul $0,12 sub $0,1 seq $1,312927 ; Coordination sequence Gal.6.149.5 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings. mod $0,$1 add $0,1 mul $2,2 add $0,$2
; A214861: First differences of round(n*sqrt(5)) (A022848). ; 2,2,3,2,2,2,3,2,2,2,3,2,2,2,3,2,2,2,2,3,2,2,2,3,2,2,2,3,2,2,2,3,2,2,2,2,3,2,2,2,3,2,2,2,3,2,2,2,3,2,2,2,3,2,2,2,2,3,2,2,2,3,2,2,2,3,2,2,2,3,2,2,2,2,3,2,2,2,3,2,2,2,3,2,2,2,3 mov $12,$0 mov $14,2 lpb $14,1 clr $0,12 mov $0,$12 sub $14,1 add $0,$14 sub $0,1 mov $6,$0 mov $9,$0 add $0,3 add $4,$6 add $0,$4 sub $4,2 add $7,7 lpb $0,1 mul $0,11 sub $4,4 sub $4,$0 sub $0,$4 div $0,$4 pow $0,2 sub $0,1 div $0,2 add $4,1 mov $7,-89 mov $8,$4 sub $8,13 lpe mov $3,$8 div $3,$7 mov $1,$3 add $1,1 add $1,$9 mov $15,$14 lpb $15,1 mov $13,$1 sub $15,1 lpe lpe lpb $12,1 mov $12,0 sub $13,$1 lpe mov $1,$13 add $1,1
; Input: ; peak_x: [bp + 8] -> [bp + triangle_x] ; peak_y: [bp + 6] -> [bp + triangle_y] ; height: [bp + 4] -> [bp + triangle_h] Triangle_Obtuse_Algorithm: push bp mov bp, sp sub sp, 4 push es push di push ax push cx push si ;____________________ ; Setup mov si, 0A000h ; Segment of display memory mov es, si ; Offset on screen: di = 320*y + x -> di = 256*y + 64*y + x mov di, [bp + triangle_y] shl di, 8 ; di *= 2**8 -> di *= 256 mov si, [bp + triangle_y] shl si, 6 ; si *= 2**6 -> si *= 64 add di, si ; di = 256y + 64y add di, [bp + triangle_x] ; di += x mov [bp - tri_line_ln], word 1d ; Peak's length mov [bp - tri_line_st], word 318d xor si, si ; Loop index mov al, 0Ch ; Colour cld ; Clear direction flag -- stos increments CX by 1 ;____________________ Triangle_Obtuse_Repeat: mov cx, [bp - tri_line_ln] rep stosb sub [bp - tri_line_st], word 2d ; Next row add di, [bp - tri_line_st] add [bp - tri_line_ln], word 2d ; Increase the line's length inc si cmp si, word [bp + triangle_h] jl Triangle_Obtuse_Repeat ;____________________ pop si pop cx pop ax pop di pop es leave ret 6
#include <QGuiApplication> #include <QCoreApplication> #include <QQmlApplicationEngine> // #include <QMessageBox> #include <QTextCodec> #include <QtWebView/QtWebView> #include <QtWebEngine/qtwebengineglobal.h> #include <QWebEngineSettings> #include <QIcon> #include <QtGlobal> #include <QtDebug> #include <QTextStream> #include <QTextCodec> #include <QLocale> #include <QTime> #include <QFile> #include <QLockFile> #include <QOperatingSystemVersion> #include <windows.h> #include "openetworkaccessmanagerfactory.h" #include "appmodule.h" #include "customlogger.h" // Needed to pull in windows functions #pragma comment(lib,"user32.lib") int main(int argc, char *argv[]) { // Hide the console window #if defined( Q_OS_WIN ) ShowWindow( GetConsoleWindow(), SW_HIDE ); //hide console window // SW_NORMAL - to show console #endif //QRegularExpression regex("(\\\"\\s*:\\s*)([0-9.]+)(\\s*[,])"); //QString json = "{\"id\": 230842309483209, \"test\": \"test2\"}"; //json = json.replace(regex, "\\1\"\\2\"\\3"); // :\"\\1\","); //qDebug() << json; //return 0; // Set global app parameters - used by settings later QCoreApplication::setOrganizationName("OPE"); QCoreApplication::setOrganizationDomain("openprisoneducation.com"); QCoreApplication::setApplicationName("OPELMS"); //QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // Possible help for high contrast refresh? QGuiApplication::setAttribute(Qt::AA_UseOpenGLES); QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts); //QApplication::setAttribute(Qt::AA_DisableWindowContextHelpButton); // NOTE: Need before now? - - Need this right after GUI App creation //QtWebEngine::initialize(); //QtWebView::initialize(); log_file_path = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/lms_app_debug.log"; // In windows - put it in programdata/ope/tmp/logs/debug.log if (QOperatingSystemVersion::currentType() == QOperatingSystemVersion::Windows) { // returns ("c:/users/<USER>/AppData/Local/<APPNAME>", "c:/programdata/<APPNAME>") // NOTE - Will need to adjust this if QDir d = QDir(QStandardPaths::standardLocations(QStandardPaths::AppConfigLocation).at(1)); //qDebug() << "AppConfigLocation: " << d.path(); d.cdUp(); // Move back to c:/programdata log_file_path = d.path() + "/tmp/log/lms_app_debug.log"; } qDebug() << "Logging to: " << log_file_path; // Are we running in the Qt Creator IDE? QByteArray envVar = qgetenv("QTDIR"); if (envVar.isEmpty()) { //qDebug() << "Running outside IDE"; is_in_IDE = false; log_to_file = true; // Install custom log handler qInstallMessageHandler(customLogOutput); } else { qDebug() << "Running within IDE"; is_in_IDE = true; log_to_file = false; } // Prevent app from running twice QString tmp_dir = QDir::tempPath(); QLockFile lf(tmp_dir + "/ope_lms.lock"); if (!lf.tryLock(100)) { qDebug() << "=====================================================\n" << "WARNING - App already running, exiting...\n" << "only one instance allowed to run. If this is an " << " error, remove the temp/ope_lms.lock file and try again" << "=====================================================\n"; out << "App already running..." << Qt::endl; return 1; } // Show SSL info //qDebug() << "SSL Library Info: " << QSslSocket::supportsSsl() << QSslSocket::sslLibraryBuildVersionString() << QSslSocket::sslLibraryVersionString(); // Relax ssl config as we will be running through test certs QSslConfiguration sslconf = QSslConfiguration::defaultConfiguration(); QList<QSslCertificate> cert_list = sslconf.caCertificates(); QList<QSslCertificate> cert_new = QSslCertificate::fromData("CaCertificates"); cert_list += cert_new; sslconf.setCaCertificates(cert_list); sslconf.setProtocol(QSsl::AnyProtocol); sslconf.setPeerVerifyMode(QSslSocket::VerifyNone); sslconf.setSslOption(QSsl::SslOptionDisableServerNameIndication,true); QSslConfiguration::setDefaultConfiguration(sslconf); QString last_arg = ""; //QCoreApplication::arguments().last(); last_arg = argv[argc-1]; //qDebug() << "Last arg: " << last_arg; //out << "Testing stdout..." << Qt::endl; // Do we need to run headless (quiet_sync?) if (last_arg == "quiet_sync") { quiet_mode = true; // Show the console window #if defined( Q_OS_WIN ) ShowWindow( GetConsoleWindow(), SW_NORMAL ); //hide console window // SW_NORMAL - to show console #endif qDebug() << "Running quiet_sync - headless mode..."; QCoreApplication cmd_app(argc, argv); QQmlApplicationEngine cmd_engine; // -- Setup our app module which deals with QML/C++ integration AppModule *cmd_appModule = new AppModule(&cmd_engine); // Sync from command line, then exit. if (cmd_appModule->isAppCredentialed() != true) { // Can't sync if app not credentialed. qDebug() << "ERROR - Can't sync app when not credentialed!"; return -1; } qDebug() << "Launching syncLMSQuiet..."; // Run sync in quiet mode then exit. QTimer::singleShot(1, cmd_appModule, SLOT(syncLMSQuiet())); return cmd_app.exec(); } QGuiApplication app(argc, argv); // Put our local folder as first path to look at for dlls QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath()); qDebug() << "Library Paths: " << QCoreApplication::libraryPaths(); // NOTE: Need this right after GUI App creation? QtWebengine init earlier? QtWebView::initialize(); app.setWindowIcon(QIcon(":/images/logo_icon.ico")); QLoggingCategory::setFilterRules(QStringLiteral("qt.qml.binding.removal.info=true")); // Init webview settings QWebEngineSettings::defaultSettings()->setAttribute(QWebEngineSettings::PluginsEnabled, true); QWebEngineSettings::defaultSettings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true); QWebEngineSettings::defaultSettings()->setAttribute(QWebEngineSettings::AllowWindowActivationFromJavaScript, true); QWebEngineSettings::defaultSettings()->setAttribute(QWebEngineSettings::PdfViewerEnabled, true); QQmlApplicationEngine engine; // -- Setup our app module which deals with QML/C++ integration AppModule *appModule = new AppModule(&engine); QString loadPage = "qrc:/lms.qml"; //loadPage = "qrc:/websockettest.qml"; // bool is_app_credentialed = appModule->isAppCredentialed(); if (is_app_credentialed != true) { // Load the error page for non credentialed apps loadPage = "qrc:/not_credentialed.qml"; } bool need_sync = false; if (last_arg == "sync" || appModule->hasAppSycnedWithCanvas() != true) { need_sync = true; } // Set the need_sync attribute QQmlContext *context = engine.rootContext(); context->setContextProperty(QStringLiteral("need_sync"), need_sync); //engine.load(QUrl(QLatin1String("qrc:/dropTest.qml"))); engine.load(QUrl(loadPage)); int e = app.exec(); // Needed to exit when a console window exists but is hidden // Don't kill parent console - it kills process too? // exit(e); return e; } //////////////////
; A118738: Number of ones in binary expansion of 5^n. ; 1,2,3,6,5,6,7,8,12,13,11,15,13,14,17,20,20,20,24,19,26,29,25,27,30,19,31,33,29,36,37,33,39,34,42,40,44,42,38,46,53,54,49,52,52,53,50,49,54,60,58,60,54,64,58,74,61,67,74,65,61,77,74,81,86,78,87,85,82,89,83,79,90,83,85,93,90,107,94,94,106,100,86,89,97,94,105,87,105,94,104,107,102,105,107,114,112,110,116,116 seq $0,199684 ; 4*10^n+1. seq $0,120 ; 1's-counting sequence: number of 1's in binary expansion of n (or the binary weight of n). sub $0,1
############################################################################### # Copyright 2018 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material ("Material") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # "License"), the following terms apply: # # 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. ############################################################################### .section .note.GNU-stack,"",%progbits .text .p2align 5, 0x90 .globl EncryptOFB_RIJ128_AES_NI .type EncryptOFB_RIJ128_AES_NI, @function EncryptOFB_RIJ128_AES_NI: push %r12 push %r15 sub $(168), %rsp mov (192)(%rsp), %rax movdqu (%rax), %xmm0 movdqa %xmm0, (%rsp) movslq %r8d, %r8 movslq %r9d, %r9 mov %rcx, %r15 lea (,%rdx,4), %rax lea (-144)(%r15,%rax,4), %rax lea (,%r9,4), %r10 .p2align 5, 0x90 .Lblks_loopgas_1: cmp %r10, %r8 cmovl %r8, %r10 xor %rcx, %rcx .L__0009gas_1: movb (%rdi,%rcx), %r11b movb %r11b, (96)(%rsp,%rcx) add $(1), %rcx cmp %r10, %rcx jl .L__0009gas_1 mov %r10, %r12 xor %r11, %r11 .p2align 5, 0x90 .Lsingle_blkgas_1: pxor (%r15), %xmm0 cmp $(12), %rdx jl .Lkey_128_sgas_1 jz .Lkey_192_sgas_1 .Lkey_256_sgas_1: aesenc (-64)(%rax), %xmm0 aesenc (-48)(%rax), %xmm0 .Lkey_192_sgas_1: aesenc (-32)(%rax), %xmm0 aesenc (-16)(%rax), %xmm0 .Lkey_128_sgas_1: aesenc (%rax), %xmm0 aesenc (16)(%rax), %xmm0 aesenc (32)(%rax), %xmm0 aesenc (48)(%rax), %xmm0 aesenc (64)(%rax), %xmm0 aesenc (80)(%rax), %xmm0 aesenc (96)(%rax), %xmm0 aesenc (112)(%rax), %xmm0 aesenc (128)(%rax), %xmm0 aesenclast (144)(%rax), %xmm0 movdqa %xmm0, (16)(%rsp) movdqu (96)(%rsp,%r11), %xmm1 pxor %xmm0, %xmm1 movdqu %xmm1, (32)(%rsp,%r11) movdqu (%rsp,%r9), %xmm0 movdqa %xmm0, (%rsp) add %r9, %r11 sub %r9, %r12 jg .Lsingle_blkgas_1 xor %rcx, %rcx .L__000Agas_1: movb (32)(%rsp,%rcx), %r11b movb %r11b, (%rsi,%rcx) add $(1), %rcx cmp %r10, %rcx jl .L__000Agas_1 add %r10, %rdi add %r10, %rsi sub %r10, %r8 jg .Lblks_loopgas_1 mov (192)(%rsp), %rax movdqa (%rsp), %xmm0 movdqu %xmm0, (%rax) add $(168), %rsp vzeroupper pop %r15 pop %r12 ret .Lfe1: .size EncryptOFB_RIJ128_AES_NI, .Lfe1-(EncryptOFB_RIJ128_AES_NI) .p2align 5, 0x90 .globl EncryptOFB128_RIJ128_AES_NI .type EncryptOFB128_RIJ128_AES_NI, @function EncryptOFB128_RIJ128_AES_NI: movdqu (%r9), %xmm0 movslq %r8d, %r8 lea (,%rdx,4), %rax lea (-144)(%rcx,%rax,4), %rax .Lblks_loopgas_2: pxor (%rcx), %xmm0 movdqu (%rdi), %xmm1 cmp $(12), %rdx jl .Lkey_128_sgas_2 jz .Lkey_192_sgas_2 .Lkey_256_sgas_2: aesenc (-64)(%rax), %xmm0 aesenc (-48)(%rax), %xmm0 .Lkey_192_sgas_2: aesenc (-32)(%rax), %xmm0 aesenc (-16)(%rax), %xmm0 .Lkey_128_sgas_2: aesenc (%rax), %xmm0 aesenc (16)(%rax), %xmm0 aesenc (32)(%rax), %xmm0 aesenc (48)(%rax), %xmm0 aesenc (64)(%rax), %xmm0 aesenc (80)(%rax), %xmm0 aesenc (96)(%rax), %xmm0 aesenc (112)(%rax), %xmm0 aesenc (128)(%rax), %xmm0 aesenclast (144)(%rax), %xmm0 pxor %xmm0, %xmm1 movdqu %xmm1, (%rsi) add $(16), %rdi add $(16), %rsi sub $(16), %r8 jg .Lblks_loopgas_2 movdqu %xmm0, (%r9) vzeroupper ret .Lfe2: .size EncryptOFB128_RIJ128_AES_NI, .Lfe2-(EncryptOFB128_RIJ128_AES_NI)
// Test that address vars are turned into load/store and located at hardcoded addresses // Hard-coded zero-page address - local variable // Commodore 64 PRG executable file .file [name="address-1.prg", type="prg", segments="Program"] .segmentdef Program [segments="Basic, Code, Data"] .segmentdef Basic [start=$0801] .segmentdef Code [start=$80d] .segmentdef Data [startAfter="Code"] .segment Basic :BasicUpstart(main) .label SCREEN = $400 .segment Code main: { .label i = 2 // char __address(0x02) i = 3 lda #3 sta.z i __b1: // while(i<7) lda.z i cmp #7 bcc __b2 // } rts __b2: // SCREEN[i++] = i ldy.z i tya sta SCREEN,y // SCREEN[i++] = i; inc.z i jmp __b1 }
; A204443: Symmetric matrix: f(i,j)=floor[(i+j+3)/4]-floor[(i+j)/4], by (constant) antidiagonals. ; 1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 cal $0,204255 ; Symmetric matrix given by f(i,j)=1+[(i+j) mod 4]. mov $1,1 div $1,$0 cmp $1,0
InitList: ld a, [wInitListType] cp INIT_ENEMYOT_LIST jr nz, .check_party_ot_name ld hl, wOTPartyCount ld a, ENEMY_OT_NAME jr .done .check_party_ot_name cp INIT_PLAYEROT_LIST jr nz, .check_mon_name ld hl, wPartyCount ld a, PARTY_OT_NAME jr .done .check_mon_name cp INIT_MON_LIST jr nz, .check_item_name ld hl, wCurMart ld a, MON_NAME jr .done .check_item_name cp INIT_BAG_ITEM_LIST jr nz, .check_ob_item_name ld hl, wNumItems ld a, ITEM_NAME jr .done .check_ob_item_name ld hl, wCurMart ld a, ITEM_NAME .done ld [wNamedObjectTypeBuffer], a ld a, l ld [wListPointer], a ld a, h ld [wListPointer + 1], a ld bc, ItemAttributes ld a, c ld [wItemAttributesPtr], a ld a, b ld [wItemAttributesPtr + 1], a ret
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %rax push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_A_ht+0xa43e, %rsi lea addresses_normal_ht+0x19851, %rdi nop add %rax, %rax mov $42, %rcx rep movsl nop and $49452, %rbp lea addresses_D_ht+0x1b451, %r12 cmp %rbx, %rbx mov $0x6162636465666768, %rdi movq %rdi, (%r12) nop nop nop nop nop xor $18865, %rcx lea addresses_A_ht+0x3f51, %rdi nop nop nop sub $27279, %r12 mov (%rdi), %cx nop nop nop nop nop and $15340, %rax lea addresses_WT_ht+0x15d1, %rsi nop nop nop nop add $50295, %rax mov $0x6162636465666768, %rdi movq %rdi, %xmm3 and $0xffffffffffffffc0, %rsi vmovaps %ymm3, (%rsi) nop nop xor $34570, %rbp lea addresses_UC_ht+0xee11, %rdi nop nop nop nop nop xor %r12, %r12 mov (%rdi), %ax xor $60236, %rcx lea addresses_UC_ht+0x164a1, %rsi nop nop nop and %rbp, %rbp mov (%rsi), %r12d nop nop nop inc %rsi lea addresses_UC_ht+0x1b151, %rcx nop nop nop dec %rdi movw $0x6162, (%rcx) nop nop nop nop nop and %rbx, %rbx lea addresses_WC_ht+0xd21, %rsi nop nop nop inc %rax movb $0x61, (%rsi) sub %rcx, %rcx lea addresses_WT_ht+0xd51, %rsi lea addresses_D_ht+0x13422, %rdi nop sub $40441, %r11 mov $6, %rcx rep movsq cmp %rbx, %rbx lea addresses_UC_ht+0x9b1, %rsi nop nop nop xor $48454, %r12 vmovups (%rsi), %ymm6 vextracti128 $1, %ymm6, %xmm6 vpextrq $1, %xmm6, %rcx nop nop nop nop nop xor $20345, %rbx lea addresses_WC_ht+0xc751, %rax nop nop nop nop lfence mov (%rax), %rcx nop nop nop sub %r12, %r12 lea addresses_A_ht+0x13e51, %rsi nop nop sub $28, %r12 mov (%rsi), %ecx nop dec %rcx lea addresses_D_ht+0x1cb51, %rcx nop nop nop nop nop add $62619, %rdi mov $0x6162636465666768, %r12 movq %r12, %xmm3 movups %xmm3, (%rcx) add %rdi, %rdi lea addresses_D_ht+0x19da3, %rdi nop nop nop nop nop add $9092, %rbp vmovups (%rdi), %ymm0 vextracti128 $1, %ymm0, %xmm0 vpextrq $1, %xmm0, %rbx nop nop nop nop nop cmp %rbp, %rbp pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %rax pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r14 push %r15 push %r8 push %r9 push %rax push %rdi // Store mov $0x9b1, %r14 nop nop nop xor %rdi, %rdi movb $0x51, (%r14) nop nop nop nop sub %r10, %r10 // Faulty Load lea addresses_US+0x6351, %r15 nop xor $20672, %rax movb (%r15), %r9b lea oracles, %r14 and $0xff, %r9 shlq $12, %r9 mov (%r14,%r9,1), %r9 pop %rdi pop %rax pop %r9 pop %r8 pop %r15 pop %r14 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_US', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_P', 'NT': True, 'AVXalign': False, 'size': 1, 'congruent': 4}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_US', 'NT': False, 'AVXalign': True, 'size': 1, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'same': False, 'congruent': 0, 'type': 'addresses_A_ht'}, 'dst': {'same': False, 'congruent': 8, 'type': 'addresses_normal_ht'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': True, 'size': 8, 'congruent': 8}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 10}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': True, 'size': 32, 'congruent': 7}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 5}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 3}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 9}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 4}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 8, 'type': 'addresses_WT_ht'}, 'dst': {'same': False, 'congruent': 0, 'type': 'addresses_D_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 10}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 8}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 10}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 1}} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
SECTION code_clib PUBLIC xorpixl EXTERN xor_MODE0 EXTERN xor_MODE1 EXTERN __gal_mode xorpixl: ld a,(__gal_mode) cp 1 jp z,xor_MODE1 and a ret nz jp xor_MODE0
.global s_prepare_buffers s_prepare_buffers: push %r14 push %r8 push %r9 push %rax push %rbx push %rcx push %rdi push %rsi lea addresses_normal_ht+0xe8bb, %r14 nop and $8613, %rax mov $0x6162636465666768, %rbx movq %rbx, %xmm4 vmovups %ymm4, (%r14) nop nop nop nop nop cmp %r8, %r8 lea addresses_UC_ht+0x1835b, %rsi lea addresses_A_ht+0x19db7, %rdi nop nop add %r9, %r9 mov $45, %rcx rep movsb xor %rsi, %rsi lea addresses_D_ht+0x8edb, %rsi lea addresses_D_ht+0x1777b, %rdi nop nop nop cmp %rax, %rax mov $4, %rcx rep movsb nop nop add %r9, %r9 lea addresses_D_ht+0x1935b, %rsi lea addresses_UC_ht+0x11769, %rdi nop nop xor $12259, %rbx mov $40, %rcx rep movsl nop nop and %rdi, %rdi lea addresses_D_ht+0x11bb, %rsi lea addresses_normal_ht+0xa6db, %rdi nop nop nop nop nop add $19794, %rax mov $76, %rcx rep movsq sub %rdi, %rdi lea addresses_D_ht+0x1d0db, %rsi lea addresses_D_ht+0x5c5b, %rdi nop nop nop nop nop inc %rbx mov $10, %rcx rep movsl nop inc %rbx lea addresses_normal_ht+0x1935b, %rsi lea addresses_UC_ht+0x1550e, %rdi clflush (%rsi) and %r14, %r14 mov $69, %rcx rep movsw nop nop nop nop nop add %r9, %r9 lea addresses_UC_ht+0x3b5b, %rcx nop dec %r14 movl $0x61626364, (%rcx) cmp %rcx, %rcx lea addresses_WT_ht+0x435b, %rsi lea addresses_UC_ht+0xe9dd, %rdi nop sub %r8, %r8 mov $21, %rcx rep movsl nop nop nop inc %rax lea addresses_A_ht+0x1e55b, %rcx nop nop nop and %r8, %r8 mov $0x6162636465666768, %r9 movq %r9, (%rcx) dec %rsi lea addresses_UC_ht+0x6f4b, %rax nop nop dec %rcx movb (%rax), %r8b nop nop nop nop add %rbx, %rbx lea addresses_WT_ht+0x18ca3, %rsi lea addresses_WC_ht+0xd8ab, %rdi nop nop nop nop nop cmp %rbx, %rbx mov $11, %rcx rep movsl nop nop nop nop nop add $14931, %r8 pop %rsi pop %rdi pop %rcx pop %rbx pop %rax pop %r9 pop %r8 pop %r14 ret .global s_faulty_load s_faulty_load: push %r11 push %rax push %rbp push %rdi push %rsi // Faulty Load lea addresses_D+0xab5b, %rbp nop nop nop nop inc %rdi movb (%rbp), %al lea oracles, %rsi and $0xff, %rax shlq $12, %rax mov (%rsi,%rax,1), %rax pop %rsi pop %rdi pop %rbp pop %rax pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_D', 'AVXalign': True, 'size': 16, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'} [Faulty Load] {'src': {'type': 'addresses_D', 'AVXalign': False, 'size': 1, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 1}} {'src': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 1, 'same': False}} {'src': {'type': 'addresses_D_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 2, 'same': False}} {'src': {'type': 'addresses_D_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 1, 'same': False}} {'src': {'type': 'addresses_D_ht', 'congruent': 5, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 7, 'same': False}} {'src': {'type': 'addresses_D_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 8, 'same': False}} {'src': {'type': 'addresses_normal_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 4, 'NT': True, 'same': False, 'congruent': 11}} {'src': {'type': 'addresses_WT_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 1, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': True, 'size': 8, 'NT': False, 'same': False, 'congruent': 9}} {'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 1}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WT_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': False}} {'36': 21829} 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 */
STACKSG SEGMENT STACK GLOBAL_BUILTIN_GETS_BUF DW 129 DUP(0) GLOBAL_BUILTIN_GETS_CHARCOUNT DW 1 DUP(0) GLOBAL_BUILTIN_COMPACT_BUF DW 129 DUP(0) DW 70,65,73,76,32,84,79,32,79,80 DW 69,78,70,73,76,69,10,0 DW 70,65,73,76,32,84,79,32,67,76 DW 79,83,69,70,73,76,69,10,0 GLOBAL_actId DW 1 GLOBAL_lstOp DW 0 GLOBAL_knowledge DW 0 GLOBAL_comunication DW 0 GLOBAL_emotion DW 5 GLOBAL_tiredness DW 0 GLOBAL_timeNow DW 0 GLOBAL_programGame DW 0 GLOBAL_homeworkCnt DW 3 GLOBAL_homeworkFin DW 0 GLOBAL_onLineClassCnt DW 0 DW 10,84,73,80,83,58,32,80,114,101 DW 115,115,32,116,104,101,32,115,112,97 DW 99,101,98,97,114,32,116,111,32,99 DW 111,110,116,105,110,117,101,32,114,101 DW 97,100,105,110,103,32,98,101,108,111 DW 119,46,10,0 DW 10,89,111,117,32,97,114,101,32,97 DW 32,115,116,117,100,101,110,116,32,111 DW 102,32,116,104,101,32,99,111,108,108 DW 101,103,101,32,111,102,32,99,111,109 DW 112,117,116,101,114,32,115,99,105,101 DW 110,99,101,32,97,110,100,32,116,101 DW 99,104,110,111,108,111,103,121,32,111 DW 102,32,74,105,108,105,110,32,85,110 DW 105,118,101,114,115,105,116,121,46,10 DW 0 DW 10,68,117,114,105,110,103,32,116,104 DW 101,32,110,111,118,101,108,32,99,111 DW 114,111,110,97,118,105,114,117,115,32 DW 112,110,101,117,109,111,110,105,97,44 DW 32,121,111,117,32,119,101,114,101,32 DW 97,114,114,97,110,103,101,100,32,105 DW 110,32,97,32,100,111,114,109,105,116 DW 111,114,121,32,98,117,105,108,100,105 DW 110,103,32,102,111,114,32,97,32,99 DW 111,110,99,101,110,116,114,97,116,101 DW 100,32,105,115,111,108,97,116,105,111 DW 110,46,10,0 DW 10,84,105,114,101,100,32,111,102,32 DW 116,104,101,32,100,97,121,32,97,110 DW 100,32,110,105,103,104,116,32,99,121 DW 99,108,101,32,111,102,32,111,110,108 DW 105,110,101,32,99,108,97,115,115,101 DW 115,44,32,104,111,109,101,119,111,114 DW 107,32,97,110,100,32,98,111,120,101 DW 100,32,108,117,110,99,104,44,32,121 DW 111,117,39,114,101,32,103,111,105,110 DW 103,32,116,111,32,100,111,32,115,111 DW 109,101,116,104,105,110,103,32,105,110 DW 116,101,114,101,115,116,105,110,103,46 DW 10,0 DW 10,87,65,82,78,73,78,71,58,32 DW 84,104,101,32,99,117,114,114,101,110 DW 116,32,115,99,101,110,101,32,105,115 DW 32,115,116,105,108,108,32,117,110,100 DW 101,114,32,99,111,110,115,116,114,117 DW 99,116,105,111,110,46,32,80,108,101 DW 97,115,101,32,99,111,110,116,97,99 DW 116,32,116,104,101,32,103,97,109,101 DW 32,112,114,111,100,117,99,101,114,32 DW 102,111,114,32,109,111,114,101,32,105 DW 110,102,111,114,109,97,116,105,111,110 DW 46,10,0 DW 10,69,82,82,79,82,76,69,86,69 DW 76,58,32,0 DW 10,0 DW 10,32,45,45,45,45,45,45,45,45 DW 45,45,32,68,65,89,32,0 DW 44,32,84,73,77,69,32,0 DW 58,48,48,32,45,45,45,45,45,45 DW 45,45,45,45,32,10,0 GLOBAL_psyCounseling DW 0 GLOBAL_selfTest DW 0 DW 10,87,104,97,116,32,119,111,117,108 DW 100,32,121,111,117,32,100,111,32,110 DW 101,120,116,63,10,0 DW 10,48,46,32,69,120,105,116,32,116 DW 104,101,32,103,97,109,101,46,10,0 DW 10,49,46,32,68,111,32,104,111,109 DW 101,119,111,114,107,46,10,0 DW 10,50,46,32,87,97,116,99,104,32 DW 111,110,108,105,110,101,32,99,108,97 DW 115,115,101,115,46,10,0 DW 10,51,46,32,80,108,97,121,32,103 DW 97,109,101,115,46,10,0 DW 10,52,46,32,87,97,116,99,104,32 DW 74,97,112,97,110,101,115,101,32,97 DW 110,105,109,97,116,105,111,110,46,10 DW 0 DW 10,53,46,32,67,104,97,116,32,119 DW 105,116,104,32,99,108,97,115,115,109 DW 97,116,101,115,32,111,110,108,105,110 DW 101,46,10,0 DW 10,54,46,32,87,114,105,116,101,32 DW 112,114,111,103,114,97,109,46,10,0 DW 10,55,46,32,72,97,118,101,32,97 DW 32,115,108,101,101,112,10,0 DW 10,120,46,32,65,115,107,32,102,111 DW 114,32,97,32,112,115,121,99,104,111 DW 108,111,103,105,99,97,108,32,99,111 DW 117,110,115,101,108,105,110,103,10,0 DW 10,121,46,32,84,101,115,116,32,121 DW 111,117,114,32,108,101,97,114,110,105 DW 110,103,32,97,99,104,105,101,118,101 DW 109,101,110,116,115,46,10,0 DW 10,79,112,116,105,111,110,32,100,111 DW 101,115,32,110,111,116,32,101,120,105 DW 115,116,44,32,112,108,101,97,115,101 DW 32,114,101,115,101,108,101,99,116,46 DW 10,10,0 DW 10,66,121,32,99,104,97,110,99,101 DW 44,32,121,111,117,32,102,111,117,110 DW 100,32,116,104,101,32,112,115,121,99 DW 104,111,108,111,103,105,99,97,108,32 DW 99,111,117,110,115,101,108,105,110,103 DW 32,119,101,98,115,105,116,101,32,112 DW 114,111,118,105,100,101,100,32,98,121 DW 32,116,104,101,32,85,110,105,118,101 DW 114,115,105,116,121,32,102,111,114,32 DW 115,116,117,100,101,110,116,115,46,32 DW 89,111,117,32,114,101,99,111,114,100 DW 101,100,32,116,104,105,115,32,119,101 DW 98,115,105,116,101,46,10,0 DW 10,89,111,117,32,104,97,118,101,32 DW 99,111,109,109,117,110,105,99,97,116 DW 101,100,32,119,105,116,104,32,116,104 DW 101,32,99,111,117,110,115,101,108,111 DW 114,32,102,111,114,32,97,32,108,111 DW 110,103,32,116,105,109,101,44,32,97 DW 110,100,32,102,105,110,97,108,108,121 DW 32,121,111,117,32,117,110,100,101,114 DW 115,116,97,110,100,32,121,111,117,114 DW 32,109,101,110,116,97,108,32,115,116 DW 97,116,101,46,10,0 DW 10,32,101,109,111,116,105,111,110,32 DW 40,48,32,116,111,32,57,41,58,32 DW 0 DW 10,32,116,105,114,101,100,110,101,115 DW 115,32,40,48,32,116,111,32,57,41 DW 58,32,0 DW 10,32,99,111,109,117,110,105,99,97 DW 116,105,111,110,32,97,98,105,108,105 DW 116,121,58,32,0 DW 10,84,104,101,32,99,111,110,116,101 DW 110,116,32,111,102,32,116,104,105,115 DW 32,111,110,108,105,110,101,32,99,108 DW 97,115,115,32,105,115,32,116,104,101 DW 32,111,112,101,114,97,116,105,110,103 DW 32,115,121,115,116,101,109,46,32,89 DW 111,117,32,116,104,105,110,107,32,116 DW 104,101,32,111,108,100,32,116,101,97 DW 99,104,101,114,39,115,32,99,108,97 DW 115,115,32,105,115,32,113,117,105,116 DW 101,32,105,110,116,101,114,101,115,116 DW 105,110,103,46,10,0 DW 10,84,104,101,32,99,111,110,116,101 DW 110,116,32,111,102,32,116,104,105,115 DW 32,111,110,108,105,110,101,32,99,111 DW 117,114,115,101,32,105,115,32,106,97 DW 118,97,32,112,114,111,103,114,97,109 DW 109,105,110,103,46,32,89,111,117,32 DW 102,101,101,108,32,116,104,97,116,32 DW 105,116,32,105,115,32,110,111,32,100 DW 105,102,102,101,114,101,110,116,32,102 DW 114,111,109,32,67,32,43,32,43,46 DW 10,0 DW 10,84,104,105,115,32,105,115,32,97 DW 110,32,111,110,108,105,110,101,32,99 DW 111,117,114,115,101,32,111,110,32,77 DW 73,80,83,32,112,114,111,99,101,115 DW 115,111,114,32,100,101,115,105,103,110 DW 46,32,65,108,116,104,111,117,103,104 DW 32,121,111,117,32,100,111,110,39,116 DW 32,107,110,111,119,32,119,104,97,116 DW 32,77,73,80,83,32,105,115,44,32 DW 121,111,117,32,115,116,105,108,108,32 DW 108,101,97,114,110,32,97,32,108,111 DW 116,32,111,102,32,110,101,119,32,116 DW 104,105,110,103,115,46,10,0 DW 10,84,104,101,114,101,32,97,114,101 DW 32,110,111,32,111,110,108,105,110,101 DW 32,99,108,97,115,115,101,115,32,116 DW 111,32,119,97,116,99,104,44,32,115 DW 111,32,121,111,117,32,99,104,101,99 DW 107,101,100,32,115,111,109,101,32,99 DW 111,109,112,117,116,101,114,32,114,101 DW 108,97,116,101,100,32,105,110,102,111 DW 114,109,97,116,105,111,110,32,111,110 DW 32,116,104,101,32,73,110,116,101,114 DW 110,101,116,46,10,0 DW 10,89,111,117,32,115,101,101,109,32 DW 116,111,32,104,97,118,101,32,108,101 DW 97,114,110,101,100,32,115,111,109,101 DW 116,104,105,110,103,32,102,114,111,109 DW 32,116,104,101,32,105,110,102,111,114 DW 109,97,116,105,111,110,32,111,110,32 DW 116,104,101,32,73,110,116,101,114,110 DW 101,116,46,32,73,116,32,115,101,101 DW 109,115,32,116,104,97,116,32,66,105 DW 108,105,66,105,108,105,32,105,115,32 DW 114,101,97,108,108,121,32,97,32,103 DW 111,111,100,32,119,101,98,115,105,116 DW 101,46,10,0 DW 10,89,111,117,32,97,114,101,32,97 DW 100,100,105,99,116,101,100,32,116,111 DW 32,116,104,101,32,112,114,111,103,114 DW 97,109,109,101,114,32,106,111,107,101 DW 115,32,111,110,32,67,83,68,78,32 DW 97,110,100,32,99,97,110,39,116,32 DW 101,120,116,114,105,99,97,116,101,32 DW 121,111,117,114,115,101,108,102,46,32 DW 85,110,107,110,111,119,105,110,103,108 DW 121,44,32,104,111,117,114,115,32,102 DW 108,121,32,98,121,46,10,0 DW 10,89,111,117,32,97,114,101,32,115 DW 111,32,115,108,101,101,112,121,32,110 DW 111,119,32,116,104,97,116,32,121,111 DW 117,32,102,101,101,108,32,115,108,101 DW 101,112,121,32,119,104,105,108,101,32 DW 108,105,115,116,101,110,105,110,103,32 DW 116,111,32,116,104,101,32,99,108,97 DW 115,115,46,32,89,111,117,32,102,97 DW 108,108,32,97,115,108,101,101,112,32 DW 98,101,102,111,114,101,32,121,111,117 DW 32,107,110,111,119,32,105,116,46,32 DW 87,104,101,110,32,121,111,117,32,119 DW 97,107,101,32,117,112,44,32,116,104 DW 101,32,111,110,108,105,110,101,32,99 DW 108,97,115,115,32,105,115,32,111,118 DW 101,114,46,10,0 DW 10,89,111,117,39,114,101,32,105,110 DW 32,97,32,116,101,114,114,105,98,108 DW 101,32,109,111,111,100,46,32,76,105 DW 115,116,101,110,105,110,103,32,116,111 DW 32,116,104,101,32,114,111,98,111,116 DW 32,108,105,107,101,32,101,120,112,114 DW 101,115,115,105,111,110,108,101,115,115 DW 32,116,101,97,99,104,105,110,103,32 DW 105,110,32,116,104,101,32,118,105,100 DW 101,111,44,32,121,111,117,32,99,97 DW 110,39,116,32,119,97,105,116,32,116 DW 111,32,115,109,97,115,104,32,116,104 DW 101,32,99,111,109,112,117,116,101,114 DW 32,115,99,114,101,101,110,46,10,0 DW 10,84,104,105,115,32,105,115,32,116 DW 104,101,32,102,105,114,115,116,32,97 DW 115,115,105,103,110,109,101,110,116,32 DW 111,102,32,99,111,109,112,117,116,101 DW 114,32,99,111,109,112,111,115,105,116 DW 105,111,110,32,112,114,105,110,99,105 DW 112,108,101,46,32,89,111,117,32,114 DW 101,118,105,101,119,101,100,32,97,32 DW 108,111,116,32,111,102,32,104,97,114 DW 100,119,97,114,101,32,114,101,108,97 DW 116,101,100,32,107,110,111,119,108,101 DW 100,103,101,46,10,0 DW 10,84,104,105,115,32,105,115,32,116 DW 104,101,32,102,105,114,115,116,32,97 DW 115,115,105,103,110,109,101,110,116,32 DW 111,102,32,99,111,109,98,105,110,97 DW 116,111,114,105,97,108,32,109,97,116 DW 104,101,109,97,116,105,99,115,46,32 DW 84,104,101,114,101,32,97,114,101,32 DW 111,110,108,121,32,116,119,111,32,113 DW 117,101,115,116,105,111,110,115,46,32 DW 65,102,116,101,114,32,97,32,119,104 DW 105,108,101,44,32,121,111,117,32,102 DW 105,110,105,115,104,32,105,116,46,32 DW 73,116,32,115,101,101,109,115,32,116 DW 104,97,116,32,121,111,117,32,104,97 DW 118,101,110,39,116,32,108,101,97,114 DW 110,101,100,32,97,110,121,116,104,105 DW 110,103,32,110,101,119,46,10,0 DW 10,89,111,117,32,102,105,110,105,115 DW 104,101,100,32,121,111,117,114,32,104 DW 111,109,101,119,111,114,107,32,98,101 DW 102,111,114,101,32,121,111,117,32,104 DW 97,100,32,116,105,109,101,32,116,111 DW 32,97,102,116,101,114,116,97,115,116 DW 101,32,105,116,46,32,89,111,117,32 DW 100,111,110,39,116,32,115,101,101,109 DW 32,116,111,32,104,97,118,101,32,108 DW 101,97,114,110,101,100,32,97,110,121 DW 116,104,105,110,103,32,102,114,111,109 DW 32,116,104,105,115,32,97,115,115,105 DW 103,110,109,101,110,116,46,10,0 DW 10,89,111,117,32,98,114,111,119,115 DW 101,32,116,104,101,32,115,117,112,101 DW 114,115,116,97,114,32,111,110,108,105 DW 110,101,32,99,108,97,115,115,32,112 DW 108,97,116,102,111,114,109,32,102,114 DW 111,109,32,98,101,103,105,110,110,105 DW 110,103,32,116,111,32,101,110,100,32 DW 97,110,100,32,102,105,110,100,32,116 DW 104,97,116,32,116,104,101,32,116,101 DW 97,99,104,101,114,115,32,104,97,118 DW 101,110,39,116,32,97,115,115,105,103 DW 110,101,100,32,104,111,109,101,119,111 DW 114,107,32,121,101,116,46,10,0 DW 10,89,111,117,32,97,114,101,32,116 DW 111,111,32,116,105,114,101,100,32,116 DW 111,32,99,111,110,99,101,110,116,114 DW 97,116,101,32,111,110,32,121,111,117 DW 114,32,104,111,109,101,119,111,114,107 DW 46,10,0 DW 10,84,105,109,101,32,102,108,105,101 DW 115,32,98,121,44,32,121,111,117,32 DW 102,101,101,108,32,118,101,114,121,32 DW 115,97,100,44,32,98,117,116,32,121 DW 111,117,32,104,97,118,101,110,39,116 DW 32,101,118,101,110,32,102,105,110,105 DW 115,104,101,100,32,111,110,101,32,111 DW 102,32,121,111,117,114,32,104,111,109 DW 101,119,111,114,107,46,10,0 DW 10,89,111,117,39,114,101,32,105,110 DW 32,97,32,98,97,100,32,109,111,111 DW 100,46,32,89,111,117,32,99,97,110 DW 39,116,32,99,111,110,99,101,110,116 DW 114,97,116,101,32,119,104,105,108,101 DW 32,119,97,116,99,104,105,110,103,32 DW 121,111,117,114,32,99,108,97,115,115 DW 109,97,116,101,115,32,115,116,117,100 DW 121,32,104,97,114,100,46,10,0 DW 10,89,111,117,32,116,111,114,101,32 DW 116,104,101,32,100,114,97,102,116,32 DW 112,97,112,101,114,32,116,111,32,112 DW 105,101,99,101,115,32,97,110,100,32 DW 100,105,100,110,39,116,32,102,105,110 DW 105,115,104,32,97,110,121,32,104,111 DW 109,101,119,111,114,107,46,10,0 DW 10,89,111,117,32,115,116,97,114,116 DW 32,116,111,32,100,111,32,121,111,117 DW 114,32,104,111,109,101,119,111,114,107 DW 46,32,73,116,32,102,101,101,108,115 DW 32,108,105,107,101,32,105,116,39,115 DW 32,110,111,116,32,97,115,32,100,105 DW 102,102,105,99,117,108,116,32,97,115 DW 32,121,111,117,32,116,104,111,117,103 DW 104,116,32,98,101,102,111,114,101,46 DW 10,0 DW 10,89,111,117,32,104,97,118,101,32 DW 102,105,110,105,115,104,101,100,32,97 DW 110,32,97,115,115,105,103,110,109,101 DW 110,116,46,10,0 DW 10,89,111,117,32,102,101,101,108,32 DW 115,111,32,116,105,114,101,100,32,116 DW 104,97,116,32,121,111,117,32,100,111 DW 110,39,116,32,119,97,110,116,32,116 DW 111,32,100,111,32,121,111,117,114,32 DW 104,111,109,101,119,111,114,107,32,97 DW 110,121,109,111,114,101,46,10,0 DW 10,34,87,104,121,32,105,115,32,116 DW 104,101,114,101,32,97,108,119,97,121 DW 115,32,115,111,32,109,117,99,104,32 DW 104,111,109,101,119,111,114,107,32,116 DW 111,32,100,111,63,34,32,89,111,117 DW 32,97,115,107,32,121,111,117,114,115 DW 101,108,102,46,10,0 DW 10,73,102,32,121,111,117,32,119,101 DW 114,101,32,98,111,114,110,32,116,111 DW 32,100,111,32,121,111,117,114,32,104 DW 111,109,101,119,111,114,107,44,32,121 DW 111,117,32,109,105,103,104,116,32,97 DW 115,32,119,101,108,108,32,100,105,101 DW 46,10,0 DW 10,65,108,116,104,111,117,103,104,32 DW 121,111,117,114,32,98,111,100,121,32 DW 97,108,114,101,97,100,121,32,102,101 DW 101,108,115,32,97,32,108,105,116,116 DW 108,101,32,116,105,114,101,100,46,10 DW 0 DW 10,89,111,117,32,97,114,101,32,115 DW 111,32,101,120,99,105,116,101,100,32 DW 116,104,97,116,32,121,111,117,32,99 DW 97,110,39,116,32,115,108,101,101,112 DW 32,97,116,32,97,108,108,46,10,0 DW 10,84,104,101,114,101,32,97,114,101 DW 32,109,97,110,121,32,104,97,112,112 DW 121,32,112,105,99,116,117,114,101,115 DW 32,105,110,32,121,111,117,114,32,109 DW 105,110,100,46,10,0 DW 10,89,111,117,32,100,111,110,39,116 DW 32,119,97,110,116,32,116,111,32,115 DW 108,101,101,112,32,97,116,32,97,108 DW 108,46,32,73,116,39,115,32,108,105 DW 107,101,32,119,97,107,105,110,103,32 DW 117,112,32,97,102,116,101,114,32,97 DW 32,110,97,116,117,114,97,108,32,115 DW 108,101,101,112,46,10,0 DW 10,89,111,117,32,104,97,100,32,97 DW 32,103,111,111,100,32,115,108,101,101 DW 112,32,97,110,100,32,102,101,108,116 DW 32,97,32,108,111,116,32,111,102,32 DW 101,109,111,116,105,111,110,97,108,32 DW 114,101,99,111,118,101,114,121,46,10 DW 0 DW 10,78,111,119,32,121,111,117,32,100 DW 111,110,39,116,32,102,101,101,108,32 DW 116,105,114,101,100,32,97,116,32,97 DW 108,108,46,10,0 DW 10,89,111,117,32,119,105,115,104,32 DW 121,111,117,32,99,111,117,108,100,32 DW 100,111,32,115,111,109,101,116,104,105 DW 110,103,32,105,110,116,101,114,101,115 DW 116,105,110,103,46,10,0 GLOBAL_playCnt DW 0 GLOBAL_gameCnt DW 3 DW 10,80,108,97,121,105,110,103,32,116 DW 104,101,32,115,97,109,101,32,103,97 DW 109,101,32,111,118,101,114,32,97,110 DW 100,32,111,118,101,114,44,32,121,111 DW 117,32,103,101,116,32,98,111,114,101 DW 100,46,32,89,111,117,32,109,97,121 DW 32,104,97,118,101,32,116,111,32,97 DW 115,107,32,121,111,117,114,32,99,108 DW 97,115,115,109,97,116,101,115,32,97 DW 98,111,117,116,32,110,101,119,32,103 DW 97,109,101,115,32,116,111,32,112,108 DW 97,121,46,10,0 DW 10,89,111,117,32,108,111,115,101,32 DW 116,114,97,99,107,32,111,102,32,116 DW 105,109,101,32,97,110,100,32,102,101 DW 101,108,32,116,105,114,101,100,46,10 DW 0 DW 10,89,111,117,32,97,114,101,32,116 DW 111,111,32,115,108,101,101,112,121,32 DW 116,111,32,99,111,110,99,101,110,116 DW 114,97,116,101,32,111,110,32,116,104 DW 101,32,103,97,109,101,46,32,10,0 DW 10,89,111,117,32,104,97,110,103,32 DW 117,112,32,119,104,105,108,101,32,108 DW 121,105,110,103,32,111,110,32,116,104 DW 101,32,116,97,98,108,101,32,116,111 DW 32,115,108,101,101,112,46,32,10,0 DW 10,89,111,117,32,112,108,97,121,32 DW 67,83,71,79,32,102,111,114,32,97 DW 32,108,111,110,103,32,116,105,109,101 DW 32,97,110,100,32,102,101,101,108,32 DW 97,32,108,105,116,116,108,101,32,100 DW 105,122,122,121,46,32,10,0 DW 10,89,111,117,32,112,108,97,121,101 DW 100,32,116,104,101,32,103,97,109,101 DW 32,34,77,105,110,101,99,114,97,102 DW 116,34,32,97,110,100,32,102,111,117 DW 110,100,32,105,116,32,118,101,114,121 DW 32,105,110,116,101,114,101,115,116,105 DW 110,103,32,116,111,32,98,117,105,108 DW 100,32,97,32,104,111,117,115,101,32 DW 105,110,32,97,32,115,97,110,100,98 DW 111,120,46,10,0 DW 10,89,111,117,32,102,111,117,110,100 DW 32,97,110,32,97,98,97,110,100,111 DW 110,101,100,32,109,105,110,101,32,119 DW 104,105,108,101,32,100,105,103,103,105 DW 110,103,46,32,89,111,117,32,97,114 DW 101,32,118,101,114,121,32,104,97,112 DW 112,121,46,10,0 DW 10,89,111,117,32,115,117,100,100,101 DW 110,108,121,32,114,101,99,97,108,108 DW 101,100,32,116,104,101,32,68,70,83 DW 32,97,108,103,111,114,105,116,104,109 DW 32,105,110,32,116,104,101,32,97,108 DW 103,111,114,105,116,104,109,32,99,108 DW 97,115,115,44,32,115,111,32,121,111 DW 117,32,100,105,100,110,39,116,32,103 DW 101,116,32,108,111,115,116,32,105,110 DW 32,116,104,101,32,109,105,110,101,46 DW 10,0 DW 10,89,111,117,32,108,111,115,116,32 DW 121,111,117,114,32,119,97,121,32,105 DW 110,32,116,104,101,32,109,105,110,101 DW 32,98,101,99,97,117,115,101,32,121 DW 111,117,32,100,105,100,110,39,116,32 DW 115,116,117,100,121,32,116,104,101,32 DW 97,108,103,111,114,105,116,104,109,32 DW 99,111,117,114,115,101,32,99,97,114 DW 101,102,117,108,108,121,46,10,0 DW 10,89,111,117,32,115,116,97,114,116 DW 32,112,108,97,121,105,110,103,32,119 DW 105,116,104,32,39,78,101,101,100,121 DW 32,71,105,114,108,32,79,118,101,114 DW 100,111,115,101,39,46,10,0 DW 10,89,111,117,32,108,101,100,32,116 DW 104,101,32,104,111,115,116,101,115,115 DW 32,116,111,32,116,97,107,101,32,100 DW 114,117,103,115,32,97,108,108,32,116 DW 104,101,32,116,105,109,101,46,32,76 DW 97,116,101,114,44,32,116,104,101,32 DW 104,111,115,116,101,115,115,32,119,101 DW 110,116,32,99,114,97,122,121,32,97 DW 110,100,32,121,111,117,32,119,101,114 DW 101,32,118,101,114,121,32,117,110,104 DW 97,112,112,121,46,10,0 DW 10,89,111,117,32,108,101,97,114,110 DW 101,100,32,115,111,109,101,32,116,105 DW 109,101,32,109,97,110,97,103,101,109 DW 101,110,116,32,115,107,105,108,108,115 DW 32,105,110,32,116,104,101,32,103,97 DW 109,101,46,10,0 DW 10,89,111,117,32,116,104,105,110,107 DW 32,116,104,101,32,119,111,114,108,100 DW 32,105,110,32,116,104,101,32,103,97 DW 109,101,32,105,115,32,118,101,114,121 DW 32,100,97,114,107,44,32,97,115,32 DW 105,102,32,105,116,32,105,115,32,116 DW 104,101,32,115,97,109,101,32,105,110 DW 32,114,101,97,108,32,108,105,102,101 DW 46,10,0 DW 10,65,110,105,109,101,32,97,108,119 DW 97,121,115,32,115,101,101,109,115,32 DW 116,111,32,98,101,32,118,101,114,121 DW 32,105,110,116,101,114,101,115,116,105 DW 110,103,44,32,121,111,117,32,115,112 DW 101,110,100,32,97,32,108,111,110,103 DW 32,116,105,109,101,32,119,97,116,99 DW 104,105,110,103,32,97,110,32,101,110 DW 116,105,114,101,32,97,110,105,109,101 DW 46,10,0 DW 10,89,111,117,32,102,101,101,108,32 DW 118,101,114,121,32,116,105,114,101,100 DW 44,32,118,101,114,121,32,116,105,114 DW 101,100,44,32,97,110,100,32,102,97 DW 108,108,32,97,115,108,101,101,112,32 DW 119,104,105,108,101,32,119,97,116,99 DW 104,105,110,103,32,116,104,101,32,97 DW 110,105,109,101,46,32,10,0 DW 10,84,104,101,32,99,104,97,114,97 DW 99,116,101,114,115,32,105,110,32,116 DW 104,101,32,97,110,105,109,101,32,115 DW 101,101,109,32,116,111,32,104,97,118 DW 101,32,104,105,103,104,32,101,109,111 DW 116,105,111,110,97,108,32,105,110,116 DW 101,108,108,105,103,101,110,99,101,44 DW 32,97,110,100,32,121,111,117,32,108 DW 101,97,114,110,32,97,32,108,111,116 DW 32,111,102,32,99,111,109,109,117,110 DW 105,99,97,116,105,111,110,32,115,107 DW 105,108,108,115,32,97,110,100,32,116 DW 111,105,108,101,116,32,115,101,97,116 DW 115,46,10,0 DW 10,65,114,101,32,121,111,117,32,115 DW 117,114,101,32,116,111,32,113,117,105 DW 116,32,116,104,101,32,103,97,109,101 DW 63,40,121,58,32,89,101,115,44,32 DW 101,108,115,101,58,32,78,111,41,10 DW 0 DW 10,71,97,109,101,32,69,120,105,116 DW 46,10,0 DW 11045 DUP(0) STACKSG ENDS CODESG SEGMENT ASSUME CS:CODESG, DS:STACKSG, SS:STACKSG FUNC_actChooseBehaviour: ; localVar: 0, arguCnt: 0 PUSH BP MOV BP, SP CALL FUNC_outputDate MOV AX, 1724 PUSH AX CALL FUNC_print ADD SP, 2 MOV AX, 1776 PUSH AX CALL FUNC_print ADD SP, 2 MOV AX, 1816 PUSH AX CALL FUNC_print ADD SP, 2 MOV AX, 1852 PUSH AX CALL FUNC_print ADD SP, 2 MOV AX, 1906 PUSH AX CALL FUNC_print ADD SP, 2 MOV AX, 1940 PUSH AX CALL FUNC_print ADD SP, 2 MOV AX, 2002 PUSH AX CALL FUNC_print ADD SP, 2 MOV AX, 2070 PUSH AX CALL FUNC_print ADD SP, 2 MOV AX, 2110 PUSH AX CALL FUNC_print ADD SP, 2 MOV SI, 1720 MOV AX, WORD PTR [SI] ;optimized by O1 AND AX, AX JNZ JUMP_54 JMP ENDIF_15 JUMP_54: MOV AX, 2146 PUSH AX CALL FUNC_print ADD SP, 2 ENDIF_15: MOV SI, 596 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 10 ;optimized by O1 MOV CX, 1 SUB AX, BX JGE JUMP_55 MOV CX, 0 JUMP_55: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_56 JMP ENDIF_16 JUMP_56: MOV AX, 2226 PUSH AX CALL FUNC_print ADD SP, 2 ENDIF_16: MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV SI, 596 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 10 ;optimized by O1 MOV CX, 1 SUB AX, BX JGE JUMP_57 MOV CX, 0 JUMP_57: PUSH CX MOV SI, 594 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 121 ;optimized by O1 MOV CX, 1 SUB AX, BX JE JUMP_58 MOV CX, 0 JUMP_58: MOV BX, CX ;optimized by O1 AND BX, BX JZ JUMP_59 MOV BX, 1 JUMP_59: POP AX AND AX, AX JZ JUMP_60 MOV AX, 1 JUMP_60: AND AX, BX AND AX, AX JNZ JUMP_61 JMP ENDIF_17 JUMP_61: MOV AX, 11 MOV SI, 592 MOV [SI], AX MOV AX, 0 JMP ENDFUNC_actChooseBehaviour ENDIF_17: MOV SI, 594 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 48 ;optimized by O1 MOV CX, 1 SUB AX, BX JE JUMP_62 MOV CX, 0 JUMP_62: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_63 JMP ELSE_18 JUMP_63: MOV AX, 0 MOV SI, 592 MOV [SI], AX JMP ENDIF_18 ELSE_18: MOV AX, 49 MOV SI, 594 MOV BX, WORD PTR [SI] ;optimized by O1 MOV CX, 1 SUB AX, BX JLE JUMP_64 MOV CX, 0 JUMP_64: PUSH CX MOV SI, 594 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 55 ;optimized by O1 MOV CX, 1 SUB AX, BX JLE JUMP_65 MOV CX, 0 JUMP_65: MOV BX, CX ;optimized by O1 AND BX, BX JZ JUMP_66 MOV BX, 1 JUMP_66: POP AX AND AX, AX JZ JUMP_67 MOV AX, 1 JUMP_67: AND AX, BX AND AX, AX JNZ JUMP_68 JMP ELSE_19 JUMP_68: MOV SI, 594 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 49 ;optimized by O1 SUB AX, BX MOV BX, 3 ;optimized by O1 ADD AX, BX MOV SI, 592 MOV [SI], AX JMP ENDIF_19 ELSE_19: MOV SI, 594 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 120 ;optimized by O1 MOV CX, 1 SUB AX, BX JE JUMP_69 MOV CX, 0 JUMP_69: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_70 JMP ELSE_20 JUMP_70: MOV AX, 10 MOV SI, 592 MOV [SI], AX JMP ENDIF_20 ELSE_20: MOV AX, 2302 PUSH AX CALL FUNC_print ADD SP, 2 ENDIF_20: ENDIF_19: ENDIF_18: ENDFUNC_actChooseBehaviour: POP BP RET FUNC_actDoHomework: ; localVar: 0, arguCnt: 0 PUSH BP MOV BP, SP MOV SI, 610 MOV AX, WORD PTR [SI] ;optimized by O1 MOV SI, 608 MOV BX, WORD PTR [SI] ;optimized by O1 MOV CX, 1 SUB AX, BX JGE JUMP_98 MOV CX, 0 JUMP_98: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_99 JMP ELSE_34 JUMP_99: MOV AX, 5780 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX JMP ENDIF_34 ELSE_34: MOV SI, 602 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 8 ;optimized by O1 MOV CX, 1 SUB AX, BX JGE JUMP_100 MOV CX, 0 JUMP_100: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_101 JMP ELSE_35 JUMP_101: MOV AX, 6038 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV AX, 6144 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX JMP ENDIF_35 ELSE_35: MOV SI, 600 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 MOV CX, 1 SUB AX, BX JLE JUMP_102 MOV CX, 0 JUMP_102: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_103 JMP ELSE_36 JUMP_103: MOV AX, 6320 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV AX, 6498 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX JMP ENDIF_36 ELSE_36: MOV AX, 6636 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV AX, 6820 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV SI, 610 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 ADD AX, BX MOV SI, 610 MOV [SI], AX CALL FUNC_showHomeworkDetail ENDIF_36: ENDIF_35: MOV SI, 600 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 2 ;optimized by O1 SUB AX, BX MOV SI, 600 MOV [SI], AX MOV SI, 602 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 2 ;optimized by O1 ADD AX, BX MOV SI, 602 MOV [SI], AX MOV SI, 604 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 ADD AX, BX MOV SI, 604 MOV [SI], AX CALL FUNC_unifyEmotionAndTiredness MOV SI, 602 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 8 ;optimized by O1 MOV CX, 1 SUB AX, BX JGE JUMP_104 MOV CX, 0 JUMP_104: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_105 JMP ELSE_37 JUMP_105: MOV AX, 6890 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX JMP ENDIF_37 ELSE_37: MOV SI, 600 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 2 ;optimized by O1 MOV CX, 1 SUB AX, BX JLE JUMP_106 MOV CX, 0 JUMP_106: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_107 JMP ENDIF_38 JUMP_107: MOV AX, 7028 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV AX, 7160 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX ENDIF_38: ENDIF_37: ENDIF_34: MOV AX, 2 MOV SI, 592 MOV [SI], AX ENDFUNC_actDoHomework: POP BP RET FUNC_actGameBegin: ; localVar: 0, arguCnt: 0 PUSH BP MOV BP, SP MOV AX, 614 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV AX, 722 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV AX, 904 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV AX, 1132 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV AX, 2 MOV SI, 592 MOV [SI], AX ENDFUNC_actGameBegin: POP BP RET FUNC_actPlayGames: ; localVar: 1, arguCnt: 0 PUSH BP MOV BP, SP SUB SP, 2 MOV SI, 8020 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 ADD AX, BX MOV SI, 8020 MOV [SI], AX MOV SI, 604 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 ADD AX, BX MOV SI, 604 MOV [SI], AX MOV SI, 602 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 2 ;optimized by O1 ADD AX, BX MOV SI, 602 MOV [SI], AX MOV SI, 8020 MOV AX, WORD PTR [SI] ;optimized by O1 MOV SI, 8022 MOV BX, WORD PTR [SI] ;optimized by O1 MOV DX, 0 CMP AX, 0 JGE JUMP_118 MOV DX, 0FFFFH JUMP_118: IDIV BX MOV AX, DX ;optimized by O1 MOV [BP-2], AX MOV AX, 2 MOV SI, 592 MOV [SI], AX MOV SI, 8022 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 3 ;optimized by O1 MOV CX, 1 SUB AX, BX JLE JUMP_119 MOV CX, 0 JUMP_119: PUSH CX MOV SI, 8020 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 5 ;optimized by O1 MOV CX, 1 SUB AX, BX JGE JUMP_120 MOV CX, 0 JUMP_120: MOV BX, CX ;optimized by O1 AND BX, BX JZ JUMP_121 MOV BX, 1 JUMP_121: POP AX AND AX, AX JZ JUMP_122 MOV AX, 1 JUMP_122: AND AX, BX AND AX, AX JNZ JUMP_123 JMP ENDIF_44 JUMP_123: MOV AX, 8024 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV AX, 8254 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV SI, 602 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 2 ;optimized by O1 ADD AX, BX MOV SI, 602 MOV [SI], AX MOV AX, 0 JMP ENDFUNC_actPlayGames ENDIF_44: MOV SI, 602 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 8 ;optimized by O1 MOV CX, 1 SUB AX, BX JGE JUMP_124 MOV CX, 0 JUMP_124: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_125 JMP ENDIF_45 JUMP_125: MOV AX, 8336 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV AX, 8436 PUSH AX CALL FUNC_print ADD SP, 2 MOV SI, 602 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 SUB AX, BX MOV SI, 602 MOV [SI], AX MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV AX, 0 JMP ENDFUNC_actPlayGames ENDIF_45: MOV AX, WORD PTR [BP-2] ;optimized by O1 MOV BX, 0 ;optimized by O1 MOV CX, 1 SUB AX, BX JE JUMP_126 MOV CX, 0 JUMP_126: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_127 JMP ENDIF_46 JUMP_127: MOV AX, 8536 PUSH AX CALL FUNC_print ADD SP, 2 MOV SI, 600 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 ADD AX, BX MOV SI, 600 MOV [SI], AX CALL FUNC_unifyEmotionAndTiredness MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV AX, 0 JMP ENDFUNC_actPlayGames ENDIF_46: MOV AX, WORD PTR [BP-2] ;optimized by O1 MOV BX, 1 ;optimized by O1 MOV CX, 1 SUB AX, BX JE JUMP_128 MOV CX, 0 JUMP_128: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_129 JMP ENDIF_47 JUMP_129: MOV AX, 8652 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV AX, 8842 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV SI, 596 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 3 ;optimized by O1 MOV CX, 1 SUB AX, BX JGE JUMP_130 MOV CX, 0 JUMP_130: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_131 JMP ELSE_48 JUMP_131: MOV AX, 8972 PUSH AX CALL FUNC_print ADD SP, 2 MOV SI, 600 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 2 ;optimized by O1 ADD AX, BX MOV SI, 600 MOV [SI], AX JMP ENDIF_48 ELSE_48: MOV AX, 9176 PUSH AX CALL FUNC_print ADD SP, 2 MOV SI, 600 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 ADD AX, BX MOV SI, 600 MOV [SI], AX ENDIF_48: MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX CALL FUNC_unifyEmotionAndTiredness MOV AX, 0 JMP ENDFUNC_actPlayGames ENDIF_47: MOV AX, WORD PTR [BP-2] ;optimized by O1 MOV BX, 2 ;optimized by O1 MOV CX, 1 SUB AX, BX JE JUMP_132 MOV CX, 0 JUMP_132: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_133 JMP ENDIF_49 JUMP_133: MOV AX, 9354 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV SI, 600 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 2 ;optimized by O1 MOV CX, 1 SUB AX, BX JLE JUMP_134 MOV CX, 0 JUMP_134: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_135 JMP ELSE_50 JUMP_135: MOV AX, 9450 PUSH AX CALL FUNC_print ADD SP, 2 MOV SI, 600 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 ADD AX, BX MOV SI, 600 MOV [SI], AX JMP ENDIF_50 ELSE_50: MOV SI, 596 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 MOV CX, 1 SUB AX, BX JGE JUMP_136 MOV CX, 0 JUMP_136: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_137 JMP ELSE_51 JUMP_137: MOV AX, 9664 PUSH AX CALL FUNC_print ADD SP, 2 MOV SI, 596 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 ADD AX, BX MOV SI, 596 MOV [SI], AX JMP ENDIF_51 ELSE_51: MOV AX, 9774 PUSH AX CALL FUNC_print ADD SP, 2 ENDIF_51: MOV SI, 600 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 2 ;optimized by O1 ADD AX, BX MOV SI, 600 MOV [SI], AX ENDIF_50: MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX CALL FUNC_unifyEmotionAndTiredness MOV AX, 0 JMP ENDFUNC_actPlayGames ENDIF_49: ENDFUNC_actPlayGames: ADD SP, 2 POP BP RET FUNC_actPsyCounseling: ; localVar: 0, arguCnt: 0 PUSH BP MOV BP, SP MOV SI, 1720 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 0 ;optimized by O1 MOV CX, 1 SUB AX, BX JE JUMP_71 MOV CX, 0 JUMP_71: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_72 JMP ENDIF_21 JUMP_72: MOV AX, 2388 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV AX, 1 MOV SI, 1720 MOV [SI], AX ENDIF_21: MOV SI, 602 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 7 ;optimized by O1 MOV CX, 1 SUB AX, BX JLE JUMP_73 MOV CX, 0 JUMP_73: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_74 JMP ENDIF_22 JUMP_74: MOV SI, 602 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 ADD AX, BX MOV SI, 602 MOV [SI], AX ENDIF_22: MOV SI, 600 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 3 ;optimized by O1 MOV CX, 1 SUB AX, BX JGE JUMP_75 MOV CX, 0 JUMP_75: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_76 JMP ENDIF_23 JUMP_76: MOV SI, 600 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 SUB AX, BX MOV SI, 600 MOV [SI], AX ENDIF_23: CALL FUNC_unifyEmotionAndTiredness MOV AX, 2644 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV AX, 2856 PUSH AX CALL FUNC_print ADD SP, 2 MOV SI, 600 PUSH WORD PTR [SI] CALL FUNC_printInt ADD SP, 2 MOV DX, 10 ;optimized by O1 MOV AH, 2 INT 21H MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV AX, 2898 PUSH AX CALL FUNC_print ADD SP, 2 MOV SI, 602 PUSH WORD PTR [SI] CALL FUNC_printInt ADD SP, 2 MOV DX, 10 ;optimized by O1 MOV AH, 2 INT 21H MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV AX, 2944 PUSH AX CALL FUNC_print ADD SP, 2 MOV SI, 598 PUSH WORD PTR [SI] CALL FUNC_printInt ADD SP, 2 MOV DX, 10 ;optimized by O1 MOV AH, 2 INT 21H MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV SI, 604 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 ADD AX, BX MOV SI, 604 MOV [SI], AX MOV AX, 2 MOV SI, 592 MOV [SI], AX ENDFUNC_actPsyCounseling: POP BP RET FUNC_actSleep: ; localVar: 0, arguCnt: 0 PUSH BP MOV BP, SP MOV SI, 600 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 9 ;optimized by O1 MOV CX, 1 SUB AX, BX JE JUMP_108 MOV CX, 0 JUMP_108: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_109 JMP ELSE_39 JUMP_109: MOV SI, 602 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 7 ;optimized by O1 MOV CX, 1 SUB AX, BX JGE JUMP_110 MOV CX, 0 JUMP_110: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_111 JMP ENDIF_40 JUMP_111: MOV AX, 7286 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX ENDIF_40: MOV AX, 7388 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV AX, 7488 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV AX, 2 MOV SI, 592 MOV [SI], AX JMP ENDIF_39 ELSE_39: MOV SI, 602 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 0 ;optimized by O1 MOV CX, 1 SUB AX, BX JE JUMP_112 MOV CX, 0 JUMP_112: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_113 JMP ELSE_41 JUMP_113: MOV AX, 7580 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV AX, 2 MOV SI, 592 MOV [SI], AX JMP ENDIF_41 ELSE_41: MOV SI, 600 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 2 ;optimized by O1 ADD AX, BX MOV SI, 600 MOV [SI], AX MOV SI, 602 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 5 ;optimized by O1 SUB AX, BX MOV SI, 602 MOV [SI], AX MOV SI, 604 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 ADD AX, BX MOV SI, 604 MOV [SI], AX CALL FUNC_unifyEmotionAndTiredness MOV SI, 600 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 7 ;optimized by O1 MOV CX, 1 SUB AX, BX JG JUMP_114 MOV CX, 0 JUMP_114: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_115 JMP ENDIF_42 JUMP_115: MOV AX, 7 MOV SI, 600 MOV [SI], AX ENDIF_42: MOV AX, 7734 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV SI, 602 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 MOV CX, 1 SUB AX, BX JLE JUMP_116 MOV CX, 0 JUMP_116: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_117 JMP ENDIF_43 JUMP_117: MOV AX, 7856 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV AX, 7926 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX ENDIF_43: MOV AX, 2 MOV SI, 592 MOV [SI], AX ENDIF_41: ENDIF_39: ENDFUNC_actSleep: POP BP RET FUNC_actUnfinished: ; localVar: 0, arguCnt: 0 PUSH BP MOV BP, SP MOV AX, 1376 PUSH AX CALL FUNC_print ADD SP, 2 MOV AX, 1602 PUSH AX CALL FUNC_print ADD SP, 2 MOV SI, 592 PUSH WORD PTR [SI] CALL FUNC_printInt ADD SP, 2 MOV AX, 1630 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV AX, 2 MOV SI, 592 MOV [SI], AX ENDFUNC_actUnfinished: POP BP RET FUNC_actWatchJapaneseAnimation: ; localVar: 0, arguCnt: 0 PUSH BP MOV BP, SP MOV AX, 9940 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV AX, 2 MOV SI, 592 MOV [SI], AX MOV SI, 602 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 9 ;optimized by O1 MOV CX, 1 SUB AX, BX JGE JUMP_138 MOV CX, 0 JUMP_138: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_139 JMP ENDIF_52 JUMP_139: MOV AX, 10126 PUSH AX CALL FUNC_print ADD SP, 2 MOV SI, 602 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 SUB AX, BX MOV SI, 602 MOV [SI], AX MOV AX, 0 JMP ENDFUNC_actWatchJapaneseAnimation ENDIF_52: MOV SI, 600 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 2 ;optimized by O1 ADD AX, BX MOV SI, 600 MOV [SI], AX MOV SI, 598 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 0 ;optimized by O1 MOV CX, 1 SUB AX, BX JE JUMP_140 MOV CX, 0 JUMP_140: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_141 JMP ENDIF_53 JUMP_141: MOV AX, 10282 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV SI, 598 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 ADD AX, BX MOV SI, 598 MOV [SI], AX ENDIF_53: MOV SI, 602 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 ADD AX, BX MOV SI, 602 MOV [SI], AX CALL FUNC_unifyEmotionAndTiredness ENDFUNC_actWatchJapaneseAnimation: POP BP RET FUNC_actWatchOnlineClasses: ; localVar: 0, arguCnt: 0 PUSH BP MOV BP, SP MOV SI, 602 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 8 ;optimized by O1 MOV CX, 1 SUB AX, BX JGE JUMP_88 MOV CX, 0 JUMP_88: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_89 JMP ENDIF_29 JUMP_89: MOV AX, 4362 PUSH AX CALL FUNC_print ADD SP, 2 MOV SI, 602 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 SUB AX, BX MOV SI, 602 MOV [SI], AX MOV SI, 604 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 ADD AX, BX MOV SI, 604 MOV [SI], AX MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV AX, 2 MOV SI, 592 MOV [SI], AX MOV AX, 0 JMP ENDFUNC_actWatchOnlineClasses ENDIF_29: MOV SI, 600 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 MOV CX, 1 SUB AX, BX JLE JUMP_90 MOV CX, 0 JUMP_90: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_91 JMP ENDIF_30 JUMP_91: MOV AX, 4672 PUSH AX CALL FUNC_print ADD SP, 2 MOV SI, 602 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 ADD AX, BX MOV SI, 602 MOV [SI], AX MOV SI, 604 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 ADD AX, BX MOV SI, 604 MOV [SI], AX CALL FUNC_unifyEmotionAndTiredness MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV AX, 2 MOV SI, 592 MOV [SI], AX MOV AX, 0 JMP ENDFUNC_actWatchOnlineClasses ENDIF_30: MOV SI, 602 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 ADD AX, BX MOV SI, 602 MOV [SI], AX CALL FUNC_unifyEmotionAndTiredness MOV SI, 604 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 ADD AX, BX MOV SI, 604 MOV [SI], AX MOV SI, 612 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 ADD AX, BX MOV SI, 612 MOV [SI], AX CALL FUNC_showOnlineClassDetail MOV AX, 2 MOV SI, 592 MOV [SI], AX ENDFUNC_actWatchOnlineClasses: POP BP RET FUNC_main: ; localVar: 1, arguCnt: 0 PUSH BP MOV BP, SP SUB SP, 2 MOV AX, 0 MOV [BP-2], AX WHILE_9: MOV AX, 1 AND AX, AX JNZ JUMP_142 JMP ENDWHILE_9 JUMP_142: MOV AX, 0 MOV [BP-2], AX MOV SI, 592 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 0 ;optimized by O1 MOV CX, 1 SUB AX, BX JE JUMP_143 MOV CX, 0 JUMP_143: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_144 JMP ENDIF_54 JUMP_144: MOV AX, 10550 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV SI, 594 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 121 ;optimized by O1 MOV CX, 1 SUB AX, BX JE JUMP_145 MOV CX, 0 JUMP_145: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_146 JMP ELSE_55 JUMP_146: JMP ENDWHILE_9 JMP ENDIF_55 ELSE_55: MOV AX, 2 MOV SI, 592 MOV [SI], AX ENDIF_55: ENDIF_54: MOV SI, 592 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 MOV CX, 1 SUB AX, BX JE JUMP_147 MOV CX, 0 JUMP_147: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_148 JMP ENDIF_56 JUMP_148: CALL FUNC_actGameBegin MOV AX, 1 MOV [BP-2], AX ENDIF_56: MOV SI, 592 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 2 ;optimized by O1 MOV CX, 1 SUB AX, BX JE JUMP_149 MOV CX, 0 JUMP_149: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_150 JMP ENDIF_57 JUMP_150: CALL FUNC_actChooseBehaviour MOV AX, 1 MOV [BP-2], AX ENDIF_57: MOV SI, 592 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 3 ;optimized by O1 MOV CX, 1 SUB AX, BX JE JUMP_151 MOV CX, 0 JUMP_151: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_152 JMP ENDIF_58 JUMP_152: CALL FUNC_actDoHomework MOV AX, 1 MOV [BP-2], AX ENDIF_58: MOV SI, 592 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 4 ;optimized by O1 MOV CX, 1 SUB AX, BX JE JUMP_153 MOV CX, 0 JUMP_153: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_154 JMP ENDIF_59 JUMP_154: CALL FUNC_actWatchOnlineClasses MOV AX, 1 MOV [BP-2], AX ENDIF_59: MOV SI, 592 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 5 ;optimized by O1 MOV CX, 1 SUB AX, BX JE JUMP_155 MOV CX, 0 JUMP_155: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_156 JMP ENDIF_60 JUMP_156: CALL FUNC_actPlayGames MOV AX, 1 MOV [BP-2], AX ENDIF_60: MOV SI, 592 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 6 ;optimized by O1 MOV CX, 1 SUB AX, BX JE JUMP_157 MOV CX, 0 JUMP_157: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_158 JMP ENDIF_61 JUMP_158: CALL FUNC_actWatchJapaneseAnimation MOV AX, 1 MOV [BP-2], AX ENDIF_61: MOV SI, 592 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 9 ;optimized by O1 MOV CX, 1 SUB AX, BX JE JUMP_159 MOV CX, 0 JUMP_159: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_160 JMP ENDIF_62 JUMP_160: CALL FUNC_actSleep MOV AX, 1 MOV [BP-2], AX ENDIF_62: MOV SI, 592 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 10 ;optimized by O1 MOV CX, 1 SUB AX, BX JE JUMP_161 MOV CX, 0 JUMP_161: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_162 JMP ENDIF_63 JUMP_162: CALL FUNC_actPsyCounseling MOV AX, 1 MOV [BP-2], AX ENDIF_63: MOV AX, WORD PTR [BP-2] ;optimized by O1 MOV BX, 0 ;optimized by O1 MOV CX, 1 SUB AX, BX JE JUMP_163 MOV CX, 0 JUMP_163: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_164 JMP ENDIF_64 JUMP_164: CALL FUNC_actUnfinished ENDIF_64: JMP WHILE_9 ENDWHILE_9: MOV AX, 10652 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX ENDFUNC_main: ADD SP, 2 POP BP RET FUNC_outputDate: ; localVar: 0, arguCnt: 0 PUSH BP MOV BP, SP MOV AX, 1634 PUSH AX CALL FUNC_print ADD SP, 2 MOV SI, 604 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 4 ;optimized by O1 MOV DX, 0 CMP AX, 0 JGE JUMP_52 MOV DX, 0FFFFH JUMP_52: IDIV BX MOV BX, 1 ;optimized by O1 ADD AX, BX PUSH AX CALL FUNC_printInt ADD SP, 2 MOV AX, 1670 PUSH AX CALL FUNC_print ADD SP, 2 MOV SI, 604 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 4 ;optimized by O1 MOV DX, 0 CMP AX, 0 JGE JUMP_53 MOV DX, 0FFFFH JUMP_53: IDIV BX MOV AX, DX ;optimized by O1 MOV BX, 1 ;optimized by O1 ADD AX, BX MOV BX, 6 ;optimized by O1 IMUL BX MOV BX, 1 ;optimized by O1 SUB AX, BX PUSH AX CALL FUNC_printInt ADD SP, 2 MOV AX, 1686 PUSH AX CALL FUNC_print ADD SP, 2 ENDFUNC_outputDate: POP BP RET FUNC_print: ; localVar: 2, arguCnt: 1 PUSH BP MOV BP, SP SUB SP, 4 MOV AX, [BP+4] MOV [BP-2], AX MOV AX, 0 MOV [BP-4], AX WHILE_2: PUSH WORD PTR [BP-2] MOV AX, 2 MOV BX, WORD PTR [BP-4] ;optimized by O1 IMUL BX MOV BX, AX ;optimized by O1 POP AX ADD AX, BX MOV BX, AX ;optimized by O1 MOV AX, WORD PTR [BX] ;optimized by O1 MOV BX, 0 ;optimized by O1 MOV CX, 1 SUB AX, BX JNE JUMP_12 MOV CX, 0 JUMP_12: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_13 JMP ENDWHILE_2 JUMP_13: PUSH WORD PTR [BP-2] MOV AX, 2 MOV BX, WORD PTR [BP-4] ;optimized by O1 IMUL BX MOV BX, AX ;optimized by O1 POP AX ADD AX, BX MOV BX, AX ;optimized by O1 MOV DX, WORD PTR [BX] ;optimized by O1 MOV AH, 2 INT 21H MOV AX, WORD PTR [BP-4] ;optimized by O1 MOV BX, 1 ;optimized by O1 ADD AX, BX MOV [BP-4], AX JMP WHILE_2 ENDWHILE_2: ENDFUNC_print: ADD SP, 4 POP BP RET FUNC_printInt: ; localVar: 12, arguCnt: 1 PUSH BP MOV BP, SP SUB SP, 24 MOV AX, [BP+4] MOV [BP-2], AX MOV AX, 0 MOV [BP-24], AX MOV AX, WORD PTR [BP-2] ;optimized by O1 MOV BX, 0 ;optimized by O1 MOV CX, 1 SUB AX, BX JL JUMP_26 MOV CX, 0 JUMP_26: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_27 JMP ENDIF_7 JUMP_27: MOV AX, WORD PTR [BP-2] ;optimized by O1 NEG AX MOV [BP-2], AX MOV DX, 45 ;optimized by O1 MOV AH, 2 INT 21H ENDIF_7: MOV AX, WORD PTR [BP-2] ;optimized by O1 MOV BX, 0 ;optimized by O1 MOV CX, 1 SUB AX, BX JE JUMP_28 MOV CX, 0 JUMP_28: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_29 JMP ELSE_8 JUMP_29: MOV DX, 48 ;optimized by O1 MOV AH, 2 INT 21H JMP ENDIF_8 ELSE_8: WHILE_5: MOV AX, WORD PTR [BP-2] ;optimized by O1 MOV BX, 0 ;optimized by O1 MOV CX, 1 SUB AX, BX JNE JUMP_30 MOV CX, 0 JUMP_30: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_31 JMP ENDWHILE_5 JUMP_31: MOV AX, BP SUB AX, 22 PUSH AX PUSH WORD PTR [BP-24] MOV AX, WORD PTR [BP-2] ;optimized by O1 MOV BX, 10 ;optimized by O1 MOV DX, 0 CMP AX, 0 JGE JUMP_32 MOV DX, 0FFFFH JUMP_32: IDIV BX MOV CX, DX ;optimized by O1 POP BX POP AX ADD BX, BX ADD BX, AX MOV [BX], CX MOV AX, WORD PTR [BP-2] ;optimized by O1 MOV BX, 10 ;optimized by O1 MOV DX, 0 CMP AX, 0 JGE JUMP_33 MOV DX, 0FFFFH JUMP_33: IDIV BX MOV [BP-2], AX MOV AX, WORD PTR [BP-24] ;optimized by O1 MOV BX, 1 ;optimized by O1 ADD AX, BX MOV [BP-24], AX JMP WHILE_5 ENDWHILE_5: WHILE_6: MOV AX, WORD PTR [BP-24] ;optimized by O1 MOV BX, 0 ;optimized by O1 MOV CX, 1 SUB AX, BX JG JUMP_34 MOV CX, 0 JUMP_34: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_35 JMP ENDWHILE_6 JUMP_35: MOV AX, BP SUB AX, 22 PUSH AX MOV AX, WORD PTR [BP-24] ;optimized by O1 MOV BX, 1 ;optimized by O1 SUB AX, BX MOV BX, AX ;optimized by O1 POP AX ADD BX, BX ADD BX, AX MOV AX, WORD PTR [BX] ;optimized by O1 MOV BX, 48 ;optimized by O1 ADD AX, BX MOV DX, AX ;optimized by O1 MOV AH, 2 INT 21H MOV AX, WORD PTR [BP-24] ;optimized by O1 MOV BX, 1 ;optimized by O1 SUB AX, BX MOV [BP-24], AX JMP WHILE_6 ENDWHILE_6: ENDIF_8: ENDFUNC_printInt: ADD SP, 24 POP BP RET FUNC_showHomeworkDetail: ; localVar: 0, arguCnt: 0 PUSH BP MOV BP, SP MOV SI, 610 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 MOV CX, 1 SUB AX, BX JE JUMP_92 MOV CX, 0 JUMP_92: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_93 JMP ENDIF_31 JUMP_93: MOV AX, 4952 PUSH AX CALL FUNC_print ADD SP, 2 MOV SI, 596 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 ADD AX, BX MOV SI, 596 MOV [SI], AX MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX ENDIF_31: MOV SI, 610 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 2 ;optimized by O1 MOV CX, 1 SUB AX, BX JE JUMP_94 MOV CX, 0 JUMP_94: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_95 JMP ENDIF_32 JUMP_95: MOV AX, 5184 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX ENDIF_32: MOV SI, 610 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 2 ;optimized by O1 MOV CX, 1 SUB AX, BX JG JUMP_96 MOV CX, 0 JUMP_96: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_97 JMP ENDIF_33 JUMP_97: MOV AX, 5522 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX ENDIF_33: ENDFUNC_showHomeworkDetail: POP BP RET FUNC_showOnlineClassDetail: ; localVar: 0, arguCnt: 0 PUSH BP MOV BP, SP MOV SI, 612 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 MOV CX, 1 SUB AX, BX JE JUMP_77 MOV CX, 0 JUMP_77: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_78 JMP ENDIF_24 JUMP_78: MOV AX, 2994 PUSH AX CALL FUNC_print ADD SP, 2 MOV SI, 596 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 ADD AX, BX MOV SI, 596 MOV [SI], AX MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX ENDIF_24: MOV SI, 612 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 2 ;optimized by O1 MOV CX, 1 SUB AX, BX JE JUMP_79 MOV CX, 0 JUMP_79: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_80 JMP ENDIF_25 JUMP_80: MOV AX, 3226 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX ENDIF_25: MOV SI, 612 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 3 ;optimized by O1 MOV CX, 1 SUB AX, BX JE JUMP_81 MOV CX, 0 JUMP_81: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_82 JMP ENDIF_26 JUMP_82: MOV AX, 3430 PUSH AX CALL FUNC_print ADD SP, 2 MOV SI, 596 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 ADD AX, BX MOV SI, 596 MOV [SI], AX MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX ENDIF_26: MOV SI, 612 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 3 ;optimized by O1 MOV CX, 1 SUB AX, BX JG JUMP_83 MOV CX, 0 JUMP_83: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_84 JMP ENDIF_27 JUMP_84: MOV AX, 3686 PUSH AX CALL FUNC_print ADD SP, 2 MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX MOV SI, 612 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 4 ;optimized by O1 MOV DX, 0 CMP AX, 0 JGE JUMP_85 MOV DX, 0FFFFH JUMP_85: IDIV BX MOV AX, DX ;optimized by O1 MOV BX, 0 ;optimized by O1 MOV CX, 1 SUB AX, BX JE JUMP_86 MOV CX, 0 JUMP_86: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_87 JMP ELSE_28 JUMP_87: MOV AX, 3898 PUSH AX CALL FUNC_print ADD SP, 2 MOV SI, 596 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 ADD AX, BX MOV SI, 596 MOV [SI], AX MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX JMP ENDIF_28 ELSE_28: MOV AX, 4146 PUSH AX CALL FUNC_print ADD SP, 2 MOV SI, 600 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 1 ;optimized by O1 ADD AX, BX MOV SI, 600 MOV [SI], AX CALL FUNC_unifyEmotionAndTiredness MOV AH, 1 INT 21H MOV AH, 0 MOV SI, 594 MOV [SI], AX ENDIF_28: ENDIF_27: ENDFUNC_showOnlineClassDetail: POP BP RET FUNC_unifyEmotionAndTiredness: ; localVar: 0, arguCnt: 0 PUSH BP MOV BP, SP MOV SI, 600 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 0 ;optimized by O1 MOV CX, 1 SUB AX, BX JL JUMP_44 MOV CX, 0 JUMP_44: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_45 JMP ENDIF_11 JUMP_45: MOV AX, 0 MOV SI, 600 MOV [SI], AX ENDIF_11: MOV SI, 600 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 9 ;optimized by O1 MOV CX, 1 SUB AX, BX JG JUMP_46 MOV CX, 0 JUMP_46: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_47 JMP ENDIF_12 JUMP_47: MOV AX, 9 MOV SI, 600 MOV [SI], AX ENDIF_12: MOV SI, 602 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 0 ;optimized by O1 MOV CX, 1 SUB AX, BX JL JUMP_48 MOV CX, 0 JUMP_48: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_49 JMP ENDIF_13 JUMP_49: MOV AX, 0 MOV SI, 602 MOV [SI], AX ENDIF_13: MOV SI, 602 MOV AX, WORD PTR [SI] ;optimized by O1 MOV BX, 9 ;optimized by O1 MOV CX, 1 SUB AX, BX JG JUMP_50 MOV CX, 0 JUMP_50: MOV AX, CX ;optimized by O1 AND AX, AX JNZ JUMP_51 JMP ENDIF_14 JUMP_51: MOV AX, 9 MOV SI, 602 MOV [SI], AX ENDIF_14: ENDFUNC_unifyEmotionAndTiredness: POP BP RET ENTER_POINT: MOV AX, STACKSG MOV DS, AX MOV SS, AX MOV SP, 32768 CALL FUNC_main MOV AH, 4CH INT 21H CODESG ENDS END ENTER_POINT
#include "Platform.inc" #include "FarCalls.inc" #include "PowerManagement.inc" #include "TestFixture.inc" radix decimal NoSleepWhenPreventedTest code global testArrange testArrange: fcall initialisePowerManagement clrwdt banksel WDTCON bsf WDTCON, SWDTEN testAct: fcall preventSleep fcall pollPowerManagement testAssert: banksel STATUS btfsc STATUS, NOT_PD goto assertSuccess assertFailure: .assert "false, 'Sleep was executed.'" return assertSuccess: .assert "true, 'No sleep was executed.'" return end
; A060635: a(n) is the number of 2 X 1 domino tilings of the set S in the plane R^2 consisting of the union of the following two rectangles: rectangle1: |x| <= n, |y| <= 1, rectangle2: |x| <= 1, |y| <= n. ; 2,8,72,450,3200,21632,149058,1019592,6993800,47922050,328499712,2251473408,15432082562,105772401800,724976569800,4969058770242,34058447431808,233440040239232,1600021920672450,10966713178192200,75166970919070472,515202081704384258,3531247605071972352,24203531143169280000,165893470424943061250,1137050761758572070152,7793461862075811592008,53417182272272718665922,366126814045140640131200,2509470516040288889475200,17200166798245842783465282,117891697071657149875748808,808041712703415627306605192,5538400291852091439110034050,37960760330261645431985164800,260186922019978324430381978112,1783347693809589511058379574658,12223246934647140698699606507912,83779380848720415157197180697800,574232419006395713623884382762050,3935847552196049715766024010763392,26976700446365951941847988431815808,184901055572365614806284750282118082 add $0,1 seq $0,120718 ; Expansion of 3*x/(1 - 2*x^2 - 2*x + x^3). mul $0,2 pow $0,2 div $0,36 mul $0,2
/* Copyright (C) 2003, 2005, 2006 MySQL AB, 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef GET_TABLEID_HPP #define GET_TABLEID_HPP #include "SignalData.hpp" /** * Convert tabname to table id */ class GetTableIdReq { /** * Sender(s) / Reciver(s) */ // Blocks friend class Dbdict; friend bool printGET_TABLEID_REQ(FILE *, const Uint32 *, Uint32, Uint16); public: STATIC_CONST( SignalLength = 3 ); public: Uint32 senderData; Uint32 senderRef; Uint32 len; SECTION( TABLE_NAME = 0 ); }; /** * Convert tabname to table id */ class GetTableIdRef { /** * Sender(s) / Reciver(s) */ // Blocks friend class Dbdict; friend bool printGET_TABLEID_REF(FILE *, const Uint32 *, Uint32, Uint16); public: STATIC_CONST( SignalLength = 3 ); public: Uint32 senderData; Uint32 senderRef; Uint32 err; enum ErrorCode { InvalidTableId = 709, TableNotDefined = 723, TableNameTooLong = 702, EmptyTable = 1111 }; }; /** * Convert tabname to table id */ class GetTableIdConf { /** * Sender(s) / Reciver(s) */ // Blocks friend class Dbdict; friend bool printGET_TABLEID_CONF(FILE *, const Uint32 *, Uint32, Uint16); public: STATIC_CONST( SignalLength = 4 ); public: Uint32 senderData; Uint32 senderRef; Uint32 tableId; Uint32 schemaVersion; }; #endif
#include "StrategyEngines/PvZ.h" #include "Units.h" #include "Map.h" #include "Strategist.h" #include "Players.h" #include "Workers.h" #include "Plays/Macro/SaturateBases.h" #include "Plays/MainArmy/DefendMyMain.h" #include "Plays/MainArmy/AttackEnemyBase.h" #include "Plays/Scouting/EarlyGameWorkerScout.h" #include "Plays/Scouting/EjectEnemyScout.h" namespace { std::map<BWAPI::UnitType, int> emptyUnitCountMap; template<class T, class ...Args> void setMainPlay(MainArmyPlay *current, Args &&...args) { if (typeid(*current) == typeid(T)) return; current->status.transitionTo = std::make_shared<T>(std::forward<Args>(args)...); } } void PvZ::initialize(std::vector<std::shared_ptr<Play>> &plays) { plays.emplace_back(std::make_shared<SaturateBases>()); plays.emplace_back(std::make_shared<EarlyGameWorkerScout>()); plays.emplace_back(std::make_shared<EjectEnemyScout>()); plays.emplace_back(std::make_shared<DefendMyMain>()); } void PvZ::updatePlays(std::vector<std::shared_ptr<Play>> &plays) { auto newEnemyStrategy = recognizeEnemyStrategy(); auto newStrategy = chooseOurStrategy(newEnemyStrategy, plays); if (enemyStrategy != newEnemyStrategy) { Log::Get() << "Enemy strategy changed from " << ZergStrategyNames[enemyStrategy] << " to " << ZergStrategyNames[newEnemyStrategy]; #if CHERRYVIS_ENABLED CherryVis::log() << "Enemy strategy changed from " << ZergStrategyNames[enemyStrategy] << " to " << ZergStrategyNames[newEnemyStrategy]; #endif enemyStrategy = newEnemyStrategy; enemyStrategyChanged = BWAPI::Broodwar->getFrameCount(); } if (ourStrategy != newStrategy) { Log::Get() << "Our strategy changed from " << OurStrategyNames[ourStrategy] << " to " << OurStrategyNames[newStrategy]; #if CHERRYVIS_ENABLED CherryVis::log() << "Our strategy changed from " << OurStrategyNames[ourStrategy] << " to " << OurStrategyNames[newStrategy]; #endif ourStrategy = newStrategy; } bool defendOurMain; if (hasEnemyStolenOurGas()) { defendOurMain = true; } else { auto mainArmyPlay = getPlay<MainArmyPlay>(plays); auto canTransitionToAttack = [&](int requiredUnitCount, bool requireDragoon) { if (!mainArmyPlay) return false; auto vanguardCluster = mainArmyPlay->getSquad()->vanguardCluster(); if (!vanguardCluster || !vanguardCluster->vanguard) return false; bool hasDragoon = false; int count = 0; for (const auto &unit : vanguardCluster->units) { if (unit->getDistance(vanguardCluster->vanguard) < 200) { if (unit->type == BWAPI::UnitTypes::Protoss_Dragoon) hasDragoon = true; count++; } } return (count >= requiredUnitCount && (!requireDragoon || hasDragoon)); }; switch (ourStrategy) { case OurStrategy::EarlyGameDefense: case OurStrategy::AntiAllIn: defendOurMain = true; break; default: { if (!mainArmyPlay) { defendOurMain = true; break; } defendOurMain = false; // Transition from defense when appropriate if (typeid(*mainArmyPlay) == typeid(DefendMyMain)) { if (ourStrategy == OurStrategy::FastExpansion) { defendOurMain = !canTransitionToAttack(3, false); } else { defendOurMain = !canTransitionToAttack(4, true); } } break; } } } updateAttackPlays(plays, defendOurMain); // Set the worker scout to monitor the enemy choke once the pool is finished if (Strategist::getWorkerScoutStatus() == Strategist::WorkerScoutStatus::EnemyBaseScouted) { auto play = getPlay<EarlyGameWorkerScout>(plays); if (play) { auto pools = Units::allEnemyOfType(BWAPI::UnitTypes::Zerg_Spawning_Pool); if (!pools.empty() && (*pools.begin())->completed) { play->monitorEnemyChoke(); } } } updateDefendBasePlays(plays); defaultExpansions(plays); scoutExpos(plays, 10000); } void PvZ::updateProduction(std::vector<std::shared_ptr<Play>> &plays, std::map<int, std::vector<ProductionGoal>> &prioritizedProductionGoals, std::vector<std::pair<int, int>> &mineralReservations) { reserveMineralsForExpansion(mineralReservations); handleNaturalExpansion(plays, prioritizedProductionGoals); handleDetection(prioritizedProductionGoals); if (handleIslandExpansionProduction(plays, prioritizedProductionGoals)) return; auto mainArmyPlay = getPlay<MainArmyPlay>(plays); auto completedUnits = mainArmyPlay ? mainArmyPlay->getSquad()->getUnitCountByType() : emptyUnitCountMap; auto &incompleteUnits = mainArmyPlay ? mainArmyPlay->assignedIncompleteUnits : emptyUnitCountMap; int zealotCount = completedUnits[BWAPI::UnitTypes::Protoss_Zealot] + incompleteUnits[BWAPI::UnitTypes::Protoss_Zealot]; int dragoonCount = completedUnits[BWAPI::UnitTypes::Protoss_Dragoon] + incompleteUnits[BWAPI::UnitTypes::Protoss_Dragoon]; int inProgressCount = Units::countIncomplete(BWAPI::UnitTypes::Protoss_Zealot) + Units::countIncomplete(BWAPI::UnitTypes::Protoss_Dragoon) + Units::countIncomplete(BWAPI::UnitTypes::Protoss_Dark_Templar); handleGasStealProduction(prioritizedProductionGoals, zealotCount); // Main army production switch (ourStrategy) { case OurStrategy::EarlyGameDefense: { // We start with two-gate zealots until we have more scouting information prioritizedProductionGoals[PRIORITY_MAINARMY].emplace_back(std::in_place_type<UnitProductionGoal>, BWAPI::UnitTypes::Protoss_Zealot, -1, 2); break; } case OurStrategy::AntiAllIn: { // Get at least six zealots before dragoons, more if our choke is hard to defend int desiredZealots = 6; auto mainChoke = Map::getMyMainChoke(); if (mainChoke && !mainChoke->isNarrowChoke) { desiredZealots = 10; } // Also bump up the number of zealots if the enemy has a lot of lings desiredZealots = std::max(desiredZealots, 2 + Units::countEnemy(BWAPI::UnitTypes::Zerg_Zergling) / 3); int zealotsRequired = desiredZealots - zealotCount; handleAntiRushProduction(prioritizedProductionGoals, dragoonCount, zealotCount, zealotsRequired); break; } case OurStrategy::FastExpansion: { // We've scouted a non-threatening opening, so generally skip zealots and go straight for dragoons // Build a couple of zealots though if we have seen zerglings on the way and have nothing to defend with if (Units::countEnemy(BWAPI::UnitTypes::Zerg_Zergling) > 0) { int unitCount = zealotCount + dragoonCount; if (unitCount < 2) { prioritizedProductionGoals[PRIORITY_BASEDEFENSE].emplace_back(std::in_place_type<UnitProductionGoal>, BWAPI::UnitTypes::Protoss_Zealot, 2 - unitCount, 2); } } prioritizedProductionGoals[PRIORITY_MAINARMY].emplace_back(std::in_place_type<UnitProductionGoal>, BWAPI::UnitTypes::Protoss_Dragoon, -1, -1); prioritizedProductionGoals[PRIORITY_MAINARMY].emplace_back(std::in_place_type<UnitProductionGoal>, BWAPI::UnitTypes::Protoss_Zealot, -1, -1); // Default upgrades handleUpgrades(prioritizedProductionGoals); break; } case OurStrategy::Defensive: case OurStrategy::Normal: { // Scale our desired zealots based on enemy ling count // Start with three before goons int unitCount = zealotCount + dragoonCount; int desiredZealots = std::max(3 - unitCount, 1 + (Units::countEnemy(BWAPI::UnitTypes::Zerg_Zergling) + 2) / 3); if (zealotCount < desiredZealots) { prioritizedProductionGoals[PRIORITY_BASEDEFENSE].emplace_back(std::in_place_type<UnitProductionGoal>, BWAPI::UnitTypes::Protoss_Zealot, desiredZealots - zealotCount, 2); cancelTrainingUnits(prioritizedProductionGoals, BWAPI::UnitTypes::Protoss_Dragoon, desiredZealots - zealotCount, BWAPI::UnitTypes::Protoss_Zealot.buildTime()); } prioritizedProductionGoals[PRIORITY_MAINARMY].emplace_back(std::in_place_type<UnitProductionGoal>, BWAPI::UnitTypes::Protoss_Dragoon, -1, -1); prioritizedProductionGoals[PRIORITY_MAINARMY].emplace_back(std::in_place_type<UnitProductionGoal>, BWAPI::UnitTypes::Protoss_Zealot, -1, -1); // Only upgrade goon range upgradeAtCount(prioritizedProductionGoals, BWAPI::UpgradeTypes::Singularity_Charge, BWAPI::UnitTypes::Protoss_Dragoon, 2); break; } case OurStrategy::MidGame: { // TODO: Higher-tech units // Baseline production is one combat unit for every 6 workers (approximately 3 units per mining base) int higherPriorityCount = (Workers::mineralWorkers() / 6) - inProgressCount; // Keep some zealots in the mix if the opponent has a lot of lings int requiredZealots = 0; if (Units::countEnemy(BWAPI::UnitTypes::Zerg_Zergling) > 6) { requiredZealots = std::min(10, Units::countEnemy(BWAPI::UnitTypes::Zerg_Zergling) / 2) - zealotCount; } // Keep zealots in the mix in the later game if (dragoonCount > 12) { requiredZealots = std::max(requiredZealots, ((dragoonCount - 12) / 2) - zealotCount); } if (requiredZealots > 0) { mainArmyProduction(prioritizedProductionGoals, BWAPI::UnitTypes::Protoss_Zealot, requiredZealots, higherPriorityCount); } mainArmyProduction(prioritizedProductionGoals, BWAPI::UnitTypes::Protoss_Dragoon, -1, higherPriorityCount); mainArmyProduction(prioritizedProductionGoals, BWAPI::UnitTypes::Protoss_Zealot, -1, higherPriorityCount); handleUpgrades(prioritizedProductionGoals); break; } } } void PvZ::handleNaturalExpansion(std::vector<std::shared_ptr<Play>> &plays, std::map<int, std::vector<ProductionGoal>> &prioritizedProductionGoals) { // Hop out if the natural has already been taken auto natural = Map::getMyNatural(); if (!natural || natural->ownedSince != -1) { CherryVis::setBoardValue("natural", "complete"); return; } // If we have a backdoor natural, expand when our third goon is being produced or we have lots of money if (Map::mapSpecificOverride()->hasBackdoorNatural()) { if (BWAPI::Broodwar->self()->minerals() > 450 || Units::countAll(BWAPI::UnitTypes::Protoss_Dragoon) > 2) { CherryVis::setBoardValue("natural", "take-backdoor"); takeNaturalExpansion(plays, prioritizedProductionGoals); return; } } switch (ourStrategy) { case OurStrategy::EarlyGameDefense: case OurStrategy::AntiAllIn: case OurStrategy::Defensive: // Don't take our natural if the enemy could be rushing or doing an all-in CherryVis::setBoardValue("natural", "wait-defensive"); break; case OurStrategy::FastExpansion: CherryVis::setBoardValue("natural", "take-fast-expo"); takeNaturalExpansion(plays, prioritizedProductionGoals); return; case OurStrategy::Normal: case OurStrategy::MidGame: { // In this case we want to expand when we consider it safe to do so: we have an attacking or containing army // that is close to the enemy base auto mainArmyPlay = getPlay<AttackEnemyBase>(plays); if (!mainArmyPlay) { CherryVis::setBoardValue("natural", "no-attack-play"); break; } auto squad = mainArmyPlay->getSquad(); if (!squad || squad->getUnits().size() < 5) { CherryVis::setBoardValue("natural", "attack-play-too-small"); break; } int dist; auto vanguardCluster = squad->vanguardCluster(&dist); if (!vanguardCluster) { CherryVis::setBoardValue("natural", "no-vanguard-cluster"); break; } // Cluster should be past our own natural int naturalDist = PathFinding::GetGroundDistance(natural->getPosition(), mainArmyPlay->base->getPosition()); if (naturalDist != -1 && dist > (naturalDist - 320)) { CherryVis::setBoardValue("natural", "vanguard-cluster-too-close"); break; } // Cluster should not be moving or fleeing // In other words, we want the cluster to be in some kind of stable attack or contain state if (vanguardCluster->currentActivity == UnitCluster::Activity::Moving || (vanguardCluster->currentActivity == UnitCluster::Activity::Regrouping && vanguardCluster->currentSubActivity == UnitCluster::SubActivity::Flee)) { // We don't cancel a queued expansion in this case CherryVis::setBoardValue("natural", "vanguard-cluster-not-attacking"); return; } CherryVis::setBoardValue("natural", "take"); takeNaturalExpansion(plays, prioritizedProductionGoals); return; } } cancelNaturalExpansion(plays, prioritizedProductionGoals); } void PvZ::handleUpgrades(std::map<int, std::vector<ProductionGoal>> &prioritizedProductionGoals) { // Basic infantry skill upgrades are queued when we have enough of them and are still building them upgradeAtCount(prioritizedProductionGoals, BWAPI::UpgradeTypes::Leg_Enhancements, BWAPI::UnitTypes::Protoss_Zealot, 5); upgradeAtCount(prioritizedProductionGoals, BWAPI::UpgradeTypes::Singularity_Charge, BWAPI::UnitTypes::Protoss_Dragoon, 2); // Cases where we want the upgrade as soon as we start building one of the units upgradeWhenUnitCreated(prioritizedProductionGoals, BWAPI::UpgradeTypes::Gravitic_Boosters, BWAPI::UnitTypes::Protoss_Observer); upgradeWhenUnitCreated(prioritizedProductionGoals, BWAPI::UpgradeTypes::Gravitic_Drive, BWAPI::UnitTypes::Protoss_Shuttle, false, true); upgradeWhenUnitCreated(prioritizedProductionGoals, BWAPI::UpgradeTypes::Carrier_Capacity, BWAPI::UnitTypes::Protoss_Carrier, true); defaultGroundUpgrades(prioritizedProductionGoals); // TODO: Air upgrades } void PvZ::handleDetection(std::map<int, std::vector<ProductionGoal>> &prioritizedProductionGoals) { // The main army play will reactively request mobile detection when it sees a cloaked enemy unit // The logic here is to look ahead to make sure we already have detection available when we need it // Break out if we already have an observer if (Units::countCompleted(BWAPI::UnitTypes::Protoss_Observer) > 0 || Units::countIncomplete(BWAPI::UnitTypes::Protoss_Observer) > 0) { return; } // Build an observer when we are on two gas or the enemy has lurker tech if (Units::countCompleted(BWAPI::UnitTypes::Protoss_Assimilator) > 1 || (Units::countCompleted(BWAPI::UnitTypes::Protoss_Nexus) > 1 && BWAPI::Broodwar->getFrameCount() > 10000) || Units::hasEnemyBuilt(BWAPI::UnitTypes::Zerg_Lurker_Egg) || Units::hasEnemyBuilt(BWAPI::UnitTypes::Zerg_Lurker) || Players::hasResearched(BWAPI::Broodwar->enemy(), BWAPI::TechTypes::Lurker_Aspect)) { prioritizedProductionGoals[PRIORITY_NORMAL].emplace_back(std::in_place_type<UnitProductionGoal>, BWAPI::UnitTypes::Protoss_Observer, 1, 1); } }
; ; File: tasking.asm ; ; Copyright (c) 2017-2018 Sydney Erickson, John Davis ; ; Permission is hereby granted, free of charge, to any person obtaining a copy ; of this software and associated documentation files (the "Software"), to deal ; in the Software without restriction, including without limitation the rights ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ; copies of the Software, and to permit persons to whom the Software is ; furnished to do so, subject to the following conditions: ; ; The above copyright notice and this permission notice shall be included in all ; copies or substantial portions of the Software. ; ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ; SOFTWARE. ; ; 32-bit code. [bits 32] section .text extern tasking_kill_thread ; Thread execution shim. global _tasking_thread_exec _tasking_thread_exec: ; Reset ESP. EBP contains the top of the stack. mov esp, ebp ; Push args (EBX = arg1, ECX = arg2, EDX = arg3) to stack. push edx push ecx push ebx ; Clear now-unused registers. xor ebx, ebx xor ecx, ecx xor edx, edx ; Execute the thread's function. ; The function address was put into EAX when the thread was created. call eax ; Kill thread and wait to die. call tasking_kill_thread .loop: jmp .loop
; To compile: ; del integer_io.exe ; c:\masm32\bin\ml.exe /c /coff integer_io.asm ; c:\masm32\bin\polink.exe /SUBSYSTEM:console integer_io.obj ; integer_io.exe .386 ; 386 Processor Instruction Set .model flat, stdcall ; Flat memory model and stdcall method option casemap: none ; Case Sensitive include c:\\masm32\\include\\windows.inc include c:\\masm32\\include\\kernel32.inc include c:\\masm32\\include\\masm32.inc includelib c:\\masm32\\lib\\kernel32.lib includelib c:\\masm32\\m32lib\\masm32.lib .data STD_OUTPUT_HANDLE equ -11 ; https://docs.microsoft.com/en-us/windows/console/getstdhandle STD_INPUT_HANDLE equ -10 ; https://docs.microsoft.com/en-us/windows/console/getstdhandle NUMBER_BUFFER_SIZE equ 10 ; TODO: How big? How many digits? number_buffer db NUMBER_BUFFER_SIZE dup(0) cr_lf db 13, 10 test_message db "Enter a number", 13, 10 ; Example string TEST_MESSAGE_LEN equ $ - offset test_message ; Length of message .data? console_out_handle dd ? ; Our ouput handle (currently undefined) console_in_handle dd ? ; Our input handle (currently undefined) bytes_written dd ? ; Number of bytes written to output (currently undefined) bytes_read dd ? ; Number of bytes written to input (currently undefined) .code start: call get_io_handles ; Get the input/output handles push TEST_MESSAGE_LEN push offset test_message call output_string call input_signed_byte push ax call output_signed_byte push 0 ; Exit code zero for success call ExitProcess ; https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-exitprocess ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; input_signed_byte() ; Result byte read in AX ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; input_signed_byte: push -1 ; _In_opt_ LPVOID pInputControl push offset bytes_read ; _Out_ LPDWORD lpNumberOfCharsRead push NUMBER_BUFFER_SIZE ; _In_ DWORD nNumberOfCharsToRead push offset number_buffer ; _Out_ LPVOID lpBuffer push console_in_handle ; _In_ HANDLE hConsoleInput call ReadConsole ; https://docs.microsoft.com/en-us/windows/console/readconsole mov ecx, [bytes_read] ; Save number of characters read into ECX sub ecx, 2 ; Remove CR/LF from character-read-count cmp ecx, 0 ; If two or less characters read.. jle input_signed_byte ; ..read again mov esi, offset number_buffer ; Set ESI to point to number_buffer for reading mov ebx, 0 ; Set EBX to zero mov eax, 0 ; Set EAX to zero cmp byte ptr [esi], '-' ; Is first character read a minus sign? jne input_signed_byte_loop ; If not, then just process as normal inc esi ; Incremement ESI so we are past the '-' character dec ecx ; Decremement ECX since we now have one fewer characters to process input_signed_byte_loop: mov bl, 10 ; BL will be used to multiple AX by 10 for each digit read mul bx ; Multiply existing value in AX by BX (10) and put result in AX (This will be zero on first iteration) mov bl, byte ptr [esi] ; Copy character from 'number_buffer' into BL cmp bl, '0' ; Compare character with '0'.. jl input_signed_byte ; ..and if it's less then that, then read again as it's not a number cmp bl, '9' ; Compare character with '9'.. jg input_signed_byte ; ..and if it's greater then that, then read again as it's not a number sub bl, 30h ; Convert from char to number ('3' to 3) add ax, bx ; Add the number to AX inc esi ; Incremement out pointer to 'number_buffer' loop input_signed_byte_loop ; ...and do it again ECX times mov esi, offset number_buffer ; Set ESI to point to number_buffer for reading cmp byte ptr [esi], '-' ; Check if first character is '-' jne input_signed_byte_return; If no, then just return not al ; Two's complement conversion, step 1 - Negate number inc al ; Two's complement conversion, step 2 - Add 1 to number and eax, 000000FFh ; Check still in byte range input_signed_byte_return: ret ; Return to caller ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; input_unsigned_byte() ; Result byte read in AX ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; input_unsigned_byte: push -1 ; _In_opt_ LPVOID pInputControl push offset bytes_read ; _Out_ LPDWORD lpNumberOfCharsRead push NUMBER_BUFFER_SIZE ; _In_ DWORD nNumberOfCharsToRead push offset number_buffer ; _Out_ LPVOID lpBuffer push console_in_handle ; _In_ HANDLE hConsoleInput call ReadConsole ; https://docs.microsoft.com/en-us/windows/console/readconsole mov ecx, [bytes_read] ; Save number of characters read into ECX sub ecx, 2 ; Remove CR/LF from character-read-count cmp ecx, 0 ; If two or less characters read.. jle input_unsigned_byte ; ..read again mov esi, offset number_buffer ; Set ESI to point to number_buffer for reading mov ebx, 0 ; Set EBX to zero mov eax, 0 ; Set EAX to zero input_unsigned_byte_loop: mov bl, 10 ; BL will be used to multiple AX by 10 for each digit read mul bx ; Multiply existing value in AX by BX (10) and put result in AX (This will be zero on first iteration) mov bl, byte ptr [esi] ; Copy character from 'number_buffer' into BL cmp bl, '0' ; Compare character with '0'.. jl input_unsigned_byte ; ..and if it's less then that, then read again as it's not a number cmp bl, '9' ; Compare character with '9'.. jg input_unsigned_byte ; ..and if it's greater then that, then read again as it's not a number sub bl, 30h ; Convert from char to number ('3' to 3) add ax, bx ; Add the number to AX inc esi ; Incremement out pointer to 'number_buffer' loop input_unsigned_byte_loop ; ...and do it again ECX times ret ; Return to caller ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; output_signed_byte(BYTE: number) ; If most significat bit set then negative. ; otherwise, * Subtract 1 ; negate ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; output_signed_byte: pop ebp ; Pop the return address pop ax ; Pop integer to output into AX push ebp ; Push EBP back onto stack and ax, 00FFh ; Make sure AX is in range 0..255 test al, al ; Check for most significant bit set (signifies negative number in two's-complement) js output_signed_byte_is_negative_number ; Jump if SF flag is set push ax ; Number is postive, so just push it to stack.. call output_unsigned_byte ; ..and call 'output_unsigned_byte' ret ; Return to caller output_signed_byte_is_negative_number: dec al ; Two's complement conversion, step 1 - Subtract 1 from number not al ; Two's complement conversion, step 2 - Negate number and eax, 000000FFh ; Check still in byte range mov ecx, 0 ; Set digits counter to zero output_signed_byte_perform_calculation: mov dx, 0 mov bx, 10 ; Divide by 10 div bx ; Divide AX by BX ; DL contains remainer, AL contains quotient and edx, 000000FFh ; Make sure EDX (remainer) is in range 0..255 add dl, 030h ; Add 30h (the letter '0' (zero)) so we map numbers to letters push dx ; Push our letter to the stack inc ecx ; Increment digit counter cmp al, 0 ; Check if quotient is zero jne output_signed_byte_perform_calculation ; If quotient is not zero, then we need to perform the operation again mov dx, '-' ; Set DX to character '-' push dx ; Push minus sign to top of stack so that it is first character displayed inc ecx ; Increment ECX since we now have another character to pop and display mov edi, 0 ; Set EDI to zero. This will point to 'number_buffer' starting at index 0 output_signed_byte_finished_calculation: pop dx ; Read the last remainder from the stack mov byte ptr [number_buffer + edi], dl ; Copy the letter to 'number_buffer' inc edi ; Incrememnt out pointer to 'number_buffer' loop output_signed_byte_finished_calculation ; Continue looping until ECX is zero push edi ; At the end of the process, EDI will conveniently hold the number of characters written to 'number_buffer'. Pass it as a parameter to 'output_string' push offset number_buffer call output_string ret ; Return to caller ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; output_unsigned_byte(BYTE: number) ; Destroys: EBP, ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; output_unsigned_byte: pop ebp ; Pop the return address pop ax ; Pop integer to output into AX push ebp ; Push EBP back onto stack and ax, 00FFh ; Make sure AX is in range 0..255 mov ecx, 0 ; Set digits counter to zero output_unsigned_byte_perform_calculation: mov dx, 0 mov bx, 10 ; Divide by 10 div bx ; Divide AX by BX ; DL contains remainer, AL contains quotient and edx, 000000FFh ; Make sure EDX (remainer) is in range 0..255 add dl, 030h ; Add 30h (the letter '0' (zero)) so we map numbers to letters push dx ; Push our letter to the stack inc ecx ; Increment digit counter cmp al, 0 ; Check if quotient is zero jne output_unsigned_byte_perform_calculation ; If quotient is not zero, then we need to perform the operation again mov edi, 0 ; Set EDI to zero. This will point to 'number_buffer' starting at index 0 output_unsigned_byte_finished_calculation: pop dx ; Read the last remainder from the stack mov byte ptr [number_buffer + edi], dl ; Copy the letter to 'number_buffer' inc edi ; Incrememnt out pointer to 'number_buffer' loop output_unsigned_byte_finished_calculation ; Continue looping until ECX is zero push edi ; At the end of the process, EDI will conveniently hold the number of characters written to 'number_buffer'. Pass it as a parameter to 'output_string' push offset number_buffer call output_string ret ; Return to caller ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; output_string(DWORD: offset-of-string, DWORD: length-of-string) ; Destroys EBP, ESI, EDI ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; output_string: pop ebp ; Pop the return address pop esi ; Pop length-of-string into edi pop edi ; Pop offset-of-string into esi push ebp ; Push EBP back to stack push 0 ; _Reserved_ LPVOID lpReserved push offset bytes_written ; _Out_ LPDWORD lpNumberOfCharsWritten push edi ; _In_ DWORD nNumberOfCharsToWrite push esi ; _In_ const VOID * lpBuffer push console_out_handle ; _In_ HANDLE hConsoleOutput call WriteConsole ; https://docs.microsoft.com/en-us/windows/console/writeconsole ret ; Return to caller ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; output_new_line() ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; output_new_line: push 2 push offset cr_lf call output_string ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; get_io_handles() ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; get_io_handles: push STD_OUTPUT_HANDLE ; _In_ DWORD nStdHandle call GetStdHandle ; https://docs.microsoft.com/en-us/windows/console/getstdhandle mov [console_out_handle], eax; Save the output handle push STD_INPUT_HANDLE ; _In_ DWORD nStdHandle call GetStdHandle ; https://docs.microsoft.com/en-us/windows/console/getstdhandle mov [console_in_handle], eax ; Save the input handle ret end start
!general_address = $0017 ; temp variables and loop counters !loop_counter_62 = $62 !temp_62 = $62 !temp_63 = $63 !loop_counter_64 = $64 !temp_64 = $64 !temp_65 = $65 !flags_d8 = $00d8 !color_data_source_offset = $00f4 !color_data_source_offset_2 = $00f7 !ram_0111 = $0111 !tilemap_wram_source_start = $0800 !tilemap_wram_source_start_2 = $0900 !ram_0900 = $0900 !ram_1031 = $1031 !ram_1031_long = $001031 !ram_1924 = $1924 !ram_1925 = $1925 !ram_195f = $195f !ram_19a5 = $19a5 !ram_19b4 = $19b4 ; if bit 3 = 1 then !ram_1a33 => $80 else $00 !ram_19bd = $19bd ; $19bd => botttom 4 bits inversed are a dma transfer size variable !ram_19bf = $19bf ; $19bf ; $19fa => 1 byte, VMAIN flags ---- known values $80, $81 !tilemap_vram_control = $19fa ; $19fb-$1a02 => 8 bytes, 2-byte pairs, 4 of them, each is destination address in VRAM !tilemap_vram_destination_addresses = $19fb ; $1a03-$1a0a => 8 bytes, 2-byte pairs, 4 of them, each is source address offset !tilemap_wram_source_addresses = $1a03 ; $1a0b-$1a12 => 8 bytes, 2-byte pairs, 4 of them, each is DMA transfer size in bytes !tilemap_dma_transfer_sizes = $1a0b ; $1a13 => 1 byte, VMAIN flags ---- known values $80, $81 !tilemap_vram_control_2 = $1a13 ; $1a14-$1a1b => 8 bytes, 2-byte pairs, 4 of them, each is destination address in VRAM !tilemap_vram_destination_addresses_2 = $1a14 ; $1a1c-$1a23 => 8 bytes, 2-byte pairs, 4 of them, each is source address offset !tilemap_wram_source_addresses_2 = $1a1c ; $1a24-$1a2b => 8 bytes, 2-byte pairs, 4 of them, each is DMA transfer size in bytes !tilemap_dma_transfer_sizes_2 = $1a24 !ram_1a2d = $1a2d !ram_1a31 = $1a31 !ram_1a32 = $1a32 !ram_1a33 = $1a33 !ram_1a34 = $1a34 !ram_1a3d = $1a3d !ram_1a46 = $1a46 !ram_1a4c = $1a4c !menu_color = $0e9c !menu_color_high = $0e9d
dnl x86-32 mpn_mod_1_1p, requiring cmov. dnl Contributed to the GNU project by Niels Möller and Torbjorn Granlund. dnl Copyright 2010, 2011 Free Software Foundation, Inc. dnl This file is part of the GNU MP Library. dnl dnl The GNU MP Library is free software; you can redistribute it and/or modify dnl it under the terms of either: dnl dnl * the GNU Lesser General Public License as published by the Free dnl Software Foundation; either version 3 of the License, or (at your dnl option) any later version. dnl dnl or dnl dnl * the GNU General Public License as published by the Free Software dnl Foundation; either version 2 of the License, or (at your option) any dnl later version. dnl dnl or both in parallel, as here. dnl dnl The GNU MP Library is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License dnl for more details. dnl dnl You should have received copies of the GNU General Public License and the dnl GNU Lesser General Public License along with the GNU MP Library. If not, dnl see https://www.gnu.org/licenses/. include(`../config.m4') C cycles/limb C P5 ? C P6 model 0-8,10-12 ? C P6 model 9 (Banias) ? C P6 model 13 (Dothan) ? C P4 model 0 (Willamette) ? C P4 model 1 (?) ? C P4 model 2 (Northwood) ? C P4 model 3 (Prescott) ? C P4 model 4 (Nocona) ? C AMD K6 ? C AMD K7 7 C AMD K8 ? define(`B2mb', `%ebx') define(`r0', `%esi') define(`r2', `%ebp') define(`t0', `%edi') define(`ap', `%ecx') C Also shift count C Stack frame C pre 36(%esp) C b 32(%esp) C n 28(%esp) C ap 24(%esp) C return 20(%esp) C %ebp 16(%esp) C %edi 12(%esp) C %esi 8(%esp) C %ebx 4(%esp) C B2mod (%esp) define(`B2modb', `(%esp)') define(`n', `28(%esp)') define(`b', `32(%esp)') define(`pre', `36(%esp)') C mp_limb_t C mpn_mod_1_1p (mp_srcptr ap, mp_size_t n, mp_limb_t b, mp_limb_t pre[4]) C C The pre array contains bi, cnt, B1modb, B2modb C Note: This implementation needs B1modb only when cnt > 0 ASM_START() TEXT ALIGN(8) PROLOGUE(mpn_mod_1_1p) push %ebp push %edi push %esi push %ebx mov 32(%esp), %ebp C pre[] mov 12(%ebp), %eax C B2modb push %eax C Put it on stack mov n, %edx mov 24(%esp), ap lea (ap, %edx, 4), ap mov -4(ap), %eax cmp $3, %edx jnc L(first) mov -8(ap), r0 jmp L(reduce_two) L(first): C First iteration, no r2 mull B2modb mov -12(ap), r0 add %eax, r0 mov -8(ap), %eax adc %edx, %eax sbb r2, r2 subl $3, n lea -16(ap), ap jz L(reduce_three) mov B2modb, B2mb sub b, B2mb lea (B2mb, r0), t0 jmp L(mid) ALIGN(16) L(top): C Loopmixed to 7 c/l on k7 add %eax, r0 lea (B2mb, r0), t0 mov r2, %eax adc %edx, %eax sbb r2, r2 L(mid): mull B2modb and B2modb, r2 add r0, r2 decl n mov (ap), r0 cmovc( t0, r2) lea -4(ap), ap jnz L(top) add %eax, r0 mov r2, %eax adc %edx, %eax sbb r2, r2 L(reduce_three): C Eliminate r2 and b, r2 sub r2, %eax L(reduce_two): mov pre, %ebp movb 4(%ebp), %cl test %cl, %cl jz L(normalized) C Unnormalized, use B1modb to reduce to size < B b mull 8(%ebp) xor t0, t0 add %eax, r0 adc %edx, t0 mov t0, %eax C Left-shift to normalize shld %cl, r0, %eax C Always use shld? shl %cl, r0 jmp L(udiv) L(normalized): mov %eax, t0 sub b, t0 cmovnc( t0, %eax) L(udiv): lea 1(%eax), t0 mull (%ebp) mov b, %ebx C Needed in register for lea add r0, %eax adc t0, %edx imul %ebx, %edx sub %edx, r0 cmp r0, %eax lea (%ebx, r0), %eax cmovnc( r0, %eax) cmp %ebx, %eax jnc L(fix) L(ok): shr %cl, %eax add $4, %esp pop %ebx pop %esi pop %edi pop %ebp ret L(fix): sub %ebx, %eax jmp L(ok) EPILOGUE() PROLOGUE(mpn_mod_1_1p_cps) push %ebp mov 12(%esp), %ebp push %esi bsr %ebp, %ecx push %ebx xor $31, %ecx mov 16(%esp), %esi sal %cl, %ebp mov %ebp, %edx not %edx mov $-1, %eax div %ebp C On K7, invert_limb would be a few cycles faster. mov %eax, (%esi) C store bi mov %ecx, 4(%esi) C store cnt neg %ebp mov $1, %edx shld %cl, %eax, %edx imul %ebp, %edx shr %cl, %edx imul %ebp, %eax mov %edx, 8(%esi) C store B1modb mov %eax, 12(%esi) C store B2modb pop %ebx pop %esi pop %ebp ret EPILOGUE()
; F-Zero Climax Translation by Normmatt .align 4 Profile38_CharacterProfile: .sjis "" .align 4 Profile38_VehicleProfile: .sjis "" ; make sure to leave an empty line at the end
// Copyright 2021 Google LLC // // 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 // // https://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. // Generated by the Codegen C++ plugin. // If you make any local changes, they will be lost. // source: google/spanner/admin/instance/v1/spanner_instance_admin.proto #include "google/cloud/spanner/admin/internal/instance_admin_stub.h" #include "google/cloud/grpc_error_delegate.h" #include "google/cloud/status_or.h" #include <google/longrunning/operations.grpc.pb.h> #include <google/spanner/admin/instance/v1/spanner_instance_admin.grpc.pb.h> #include <memory> namespace google { namespace cloud { namespace spanner_admin_internal { inline namespace GOOGLE_CLOUD_CPP_GENERATED_NS { InstanceAdminStub::~InstanceAdminStub() = default; StatusOr<google::spanner::admin::instance::v1::ListInstanceConfigsResponse> DefaultInstanceAdminStub::ListInstanceConfigs( grpc::ClientContext& client_context, google::spanner::admin::instance::v1::ListInstanceConfigsRequest const& request) { google::spanner::admin::instance::v1::ListInstanceConfigsResponse response; auto status = grpc_stub_->ListInstanceConfigs(&client_context, request, &response); if (!status.ok()) { return google::cloud::MakeStatusFromRpcError(status); } return response; } StatusOr<google::spanner::admin::instance::v1::InstanceConfig> DefaultInstanceAdminStub::GetInstanceConfig( grpc::ClientContext& client_context, google::spanner::admin::instance::v1::GetInstanceConfigRequest const& request) { google::spanner::admin::instance::v1::InstanceConfig response; auto status = grpc_stub_->GetInstanceConfig(&client_context, request, &response); if (!status.ok()) { return google::cloud::MakeStatusFromRpcError(status); } return response; } StatusOr<google::spanner::admin::instance::v1::ListInstancesResponse> DefaultInstanceAdminStub::ListInstances( grpc::ClientContext& client_context, google::spanner::admin::instance::v1::ListInstancesRequest const& request) { google::spanner::admin::instance::v1::ListInstancesResponse response; auto status = grpc_stub_->ListInstances(&client_context, request, &response); if (!status.ok()) { return google::cloud::MakeStatusFromRpcError(status); } return response; } StatusOr<google::spanner::admin::instance::v1::Instance> DefaultInstanceAdminStub::GetInstance( grpc::ClientContext& client_context, google::spanner::admin::instance::v1::GetInstanceRequest const& request) { google::spanner::admin::instance::v1::Instance response; auto status = grpc_stub_->GetInstance(&client_context, request, &response); if (!status.ok()) { return google::cloud::MakeStatusFromRpcError(status); } return response; } future<StatusOr<google::longrunning::Operation>> DefaultInstanceAdminStub::AsyncCreateInstance( google::cloud::CompletionQueue& cq, std::unique_ptr<grpc::ClientContext> context, google::spanner::admin::instance::v1::CreateInstanceRequest const& request) { return cq.MakeUnaryRpc( [this](grpc::ClientContext* context, google::spanner::admin::instance::v1::CreateInstanceRequest const& request, grpc::CompletionQueue* cq) { return grpc_stub_->AsyncCreateInstance(context, request, cq); }, request, std::move(context)); } future<StatusOr<google::longrunning::Operation>> DefaultInstanceAdminStub::AsyncUpdateInstance( google::cloud::CompletionQueue& cq, std::unique_ptr<grpc::ClientContext> context, google::spanner::admin::instance::v1::UpdateInstanceRequest const& request) { return cq.MakeUnaryRpc( [this](grpc::ClientContext* context, google::spanner::admin::instance::v1::UpdateInstanceRequest const& request, grpc::CompletionQueue* cq) { return grpc_stub_->AsyncUpdateInstance(context, request, cq); }, request, std::move(context)); } Status DefaultInstanceAdminStub::DeleteInstance( grpc::ClientContext& client_context, google::spanner::admin::instance::v1::DeleteInstanceRequest const& request) { google::protobuf::Empty response; auto status = grpc_stub_->DeleteInstance(&client_context, request, &response); if (!status.ok()) { return google::cloud::MakeStatusFromRpcError(status); } return google::cloud::Status(); } StatusOr<google::iam::v1::Policy> DefaultInstanceAdminStub::SetIamPolicy( grpc::ClientContext& client_context, google::iam::v1::SetIamPolicyRequest const& request) { google::iam::v1::Policy response; auto status = grpc_stub_->SetIamPolicy(&client_context, request, &response); if (!status.ok()) { return google::cloud::MakeStatusFromRpcError(status); } return response; } StatusOr<google::iam::v1::Policy> DefaultInstanceAdminStub::GetIamPolicy( grpc::ClientContext& client_context, google::iam::v1::GetIamPolicyRequest const& request) { google::iam::v1::Policy response; auto status = grpc_stub_->GetIamPolicy(&client_context, request, &response); if (!status.ok()) { return google::cloud::MakeStatusFromRpcError(status); } return response; } StatusOr<google::iam::v1::TestIamPermissionsResponse> DefaultInstanceAdminStub::TestIamPermissions( grpc::ClientContext& client_context, google::iam::v1::TestIamPermissionsRequest const& request) { google::iam::v1::TestIamPermissionsResponse response; auto status = grpc_stub_->TestIamPermissions(&client_context, request, &response); if (!status.ok()) { return google::cloud::MakeStatusFromRpcError(status); } return response; } future<StatusOr<google::longrunning::Operation>> DefaultInstanceAdminStub::AsyncGetOperation( google::cloud::CompletionQueue& cq, std::unique_ptr<grpc::ClientContext> context, google::longrunning::GetOperationRequest const& request) { return cq.MakeUnaryRpc( [this](grpc::ClientContext* context, google::longrunning::GetOperationRequest const& request, grpc::CompletionQueue* cq) { return operations_->AsyncGetOperation(context, request, cq); }, request, std::move(context)); } future<Status> DefaultInstanceAdminStub::AsyncCancelOperation( google::cloud::CompletionQueue& cq, std::unique_ptr<grpc::ClientContext> context, google::longrunning::CancelOperationRequest const& request) { return cq .MakeUnaryRpc( [this](grpc::ClientContext* context, google::longrunning::CancelOperationRequest const& request, grpc::CompletionQueue* cq) { return operations_->AsyncCancelOperation(context, request, cq); }, request, std::move(context)) .then([](future<StatusOr<google::protobuf::Empty>> f) { return f.get().status(); }); } } // namespace GOOGLE_CLOUD_CPP_GENERATED_NS } // namespace spanner_admin_internal } // namespace cloud } // namespace google
; A226405: Expansion of x/((1-x-x^3)*(1-x)^3). ; 0,1,4,10,21,40,71,120,196,312,487,749,1139,1717,2571,3830,5683,8407,12408,18281,26898,39537,58071,85245,125082,183478,269074,394534,578418,847927,1242926,1821840,2670295,3913782,5736217,8407142,12321590,18058510,26466393,38788763,56848093,83315347,122105013,178954052,262270389,384376437,563331570,825603087,1209980700,1773313495,2598917857,3808899883,5582214756,8181134044,11990035412,17572251708,25753387348,37743424413,55315677832,81069066950,118812493193,174128172916,255197241819,374009737028,548137912024,803335155988,1177344895227,1725482809529,2528817967863,3706162865505,5431645677519,7960463647938,11666626516071,17098272196291,25058735847004,36725362365925,53823634565142,78882370415149,115607732784155,169431367352457,248313737770846,363921470558322,533352837914182,781666575688514,1145588046250406,1678940884168243,2460607459860498,3606195506114732,5285136390286891,7745743850151394 mov $3,$0 mov $5,$0 lpb $3,1 mov $0,$5 sub $3,1 sub $0,$3 mov $2,1 mul $2,$0 cal $0,48625 ; Pisot sequence P(4,6). sub $2,1 sub $0,$2 sub $0,6 mov $4,$0 cmp $6,0 add $4,$6 div $0,$4 add $0,$4 add $1,$0 lpe
; A192491: Molecular topological indices of the complete tripartite graphs K_{n,n,n}. ; 24,240,864,2112,4200,7344,11760,17664,25272,34800,46464,60480,77064,96432,118800,144384,173400,206064,242592,283200,328104,377520,431664,490752,555000,624624,699840,780864,867912,961200 add $0,1 mov $1,3 mul $1,$0 bin $1,2 mul $1,$0 mul $1,4 div $1,12 mul $1,24
; A107843: Number of iterations of McCarthy 91 Function until it terminates. ; 201,199,197,195,193,191,189,187,185,183,181,179,177,175,173,171,169,167,165,163,161,159,157,155,153,151,149,147,145,143,141,139,137,135,133,131,129,127,125,123,121,119,117,115,113,111,109,107,105,103,101 mov $1,19 sub $1,$0 mul $1,2 add $1,163