mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-30 16:47:43 +08:00
Added pcodetest source code to SleighDevTools module. Corrected
certification issues.
This commit is contained in:
@@ -15,6 +15,18 @@
|
|||||||
// Gradle should be invoked from the directory of the extension module to build. Please see the
|
// Gradle should be invoked from the directory of the extension module to build. Please see the
|
||||||
// application.gradle.version property in <GHIDRA_INSTALL_DIR>/Ghidra/application.properties
|
// application.gradle.version property in <GHIDRA_INSTALL_DIR>/Ghidra/application.properties
|
||||||
// for the correction version of Gradle to use for the Ghidra installation you specify.
|
// for the correction version of Gradle to use for the Ghidra installation you specify.
|
||||||
|
//
|
||||||
|
// Build Prerequisite:
|
||||||
|
// The appropriate binutils source distribution archive (see version and naming below) must be
|
||||||
|
// obtained and placed appropriately prior to building the gdis executable. If working with
|
||||||
|
// a full source distribution of Ghidra the binutils archive should be placed within the module's
|
||||||
|
// shadow directory located within ghidra.bin (ghidra.bin/GPL/GnuDisassembler/). If building within
|
||||||
|
// an unpacked distribution of Ghidra it should be placed directly within the module
|
||||||
|
// directory once the extension has been installed/unpacked by Ghidra. The binutils referenced
|
||||||
|
// by the script below may be downloaded from the following URL:
|
||||||
|
//
|
||||||
|
// https://ftp.gnu.org/pub/gnu/binutils/binutils-2.29.1.tar.bz2
|
||||||
|
//
|
||||||
|
|
||||||
ext.binutils = "binutils-2.29.1"
|
ext.binutils = "binutils-2.29.1"
|
||||||
ext.binutilsDistro = "${binutils}.tar.bz2"
|
ext.binutilsDistro = "${binutils}.tar.bz2"
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
##VERSION: 2.0
|
##VERSION: 2.0
|
||||||
##MODULE IP: GPL 2
|
##MODULE IP: GPL 2
|
||||||
##MODULE IP: Public Domain
|
##MODULE IP: Public Domain
|
||||||
.classpath||GHIDRA||||END|
|
|
||||||
.project||GHIDRA||||END|
|
.project||GHIDRA||||END|
|
||||||
Module.manifest||Public Domain||||END|
|
Module.manifest||Public Domain||||END|
|
||||||
README.txt||Public Domain||||END|
|
README.txt||Public Domain||||END|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* ###
|
/* ###
|
||||||
* IP: GPL 2
|
* IP: Public Domain
|
||||||
*/
|
*/
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* ###
|
/* ###
|
||||||
* IP: GPL 2
|
* IP: Public Domain
|
||||||
*/
|
*/
|
||||||
#ifndef _GDIS_H_
|
#ifndef _GDIS_H_
|
||||||
#define _GDIS_H_
|
#define _GDIS_H_
|
||||||
|
|||||||
@@ -6,3 +6,29 @@ build.gradle||GHIDRA||||END|
|
|||||||
data/ExtensionPoint.manifest||GHIDRA||||END|
|
data/ExtensionPoint.manifest||GHIDRA||||END|
|
||||||
data/LanguageMap.txt||GHIDRA||||END|
|
data/LanguageMap.txt||GHIDRA||||END|
|
||||||
extension.properties||GHIDRA||||END|
|
extension.properties||GHIDRA||||END|
|
||||||
|
pcodetest/.gitignore||GHIDRA||||END|
|
||||||
|
pcodetest/README.txt||GHIDRA||||END|
|
||||||
|
pcodetest/build||GHIDRA||||END|
|
||||||
|
pcodetest/build.py||GHIDRA||||END|
|
||||||
|
pcodetest/c_src/BIOPS.test||GHIDRA||||END|
|
||||||
|
pcodetest/c_src/BIOPS2.test||GHIDRA||||END|
|
||||||
|
pcodetest/c_src/BIOPS_DOUBLE.test||GHIDRA||||END|
|
||||||
|
pcodetest/c_src/BIOPS_FLOAT.test||GHIDRA||||END|
|
||||||
|
pcodetest/c_src/BIOPS_LONGLONG.test||GHIDRA||||END|
|
||||||
|
pcodetest/c_src/BitManipulation.test||GHIDRA||||END|
|
||||||
|
pcodetest/c_src/DecisionMaking.test||GHIDRA||||END|
|
||||||
|
pcodetest/c_src/GlobalVariables.test||GHIDRA||||END|
|
||||||
|
pcodetest/c_src/IterativeProcessingDoWhile.test||GHIDRA||||END|
|
||||||
|
pcodetest/c_src/IterativeProcessingFor.test||GHIDRA||||END|
|
||||||
|
pcodetest/c_src/IterativeProcessingWhile.test||GHIDRA||||END|
|
||||||
|
pcodetest/c_src/ParameterPassing1.test||GHIDRA||||END|
|
||||||
|
pcodetest/c_src/ParameterPassing2.test||GHIDRA||||END|
|
||||||
|
pcodetest/c_src/ParameterPassing3.test||GHIDRA||||END|
|
||||||
|
pcodetest/c_src/PointerManipulation.test||GHIDRA||||END|
|
||||||
|
pcodetest/c_src/StructUnionManipulation.test||GHIDRA||||END|
|
||||||
|
pcodetest/c_src/misc.test||GHIDRA||||END|
|
||||||
|
pcodetest/c_src/msp430x.ld||GHIDRA||||END|
|
||||||
|
pcodetest/defaults.py||GHIDRA||||END|
|
||||||
|
pcodetest/pcode_defs.py||GHIDRA||||END|
|
||||||
|
pcodetest/pcodetest.py||GHIDRA||||END|
|
||||||
|
pcodetest/tpp.py||GHIDRA||||END|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
*.pyc
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
OVERVIEW
|
||||||
|
--------
|
||||||
|
|
||||||
|
The executable 'build' file in this directory is a python script for
|
||||||
|
building pcode test binaries. Each pcode test binary is built using
|
||||||
|
an associated toolchain.
|
||||||
|
|
||||||
|
The list of available pcode test binaries is in the file pcode_defs.py.
|
||||||
|
Each entry in this file indicates the required toolchain, and additional
|
||||||
|
options needed to build the pcode test.
|
||||||
|
|
||||||
|
The defaults.py script should be modified to suit your environment
|
||||||
|
reflecting the installation location of your toolchains, build artifacts, etc.
|
||||||
|
|
||||||
|
USAGE
|
||||||
|
-----
|
||||||
|
|
||||||
|
To see a list of available options, run the build script without
|
||||||
|
arguments.
|
||||||
|
|
||||||
|
./build
|
||||||
|
|
||||||
|
It is possible to build everything from scratch with this command:
|
||||||
|
|
||||||
|
./build --pcodetest-all
|
||||||
|
|
||||||
|
Typically, pcode test binaries are built individually per processor,
|
||||||
|
such as:
|
||||||
|
|
||||||
|
./build --pcodetest MIPS16
|
||||||
+91
@@ -0,0 +1,91 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import argparse
|
||||||
|
import traceback
|
||||||
|
import json
|
||||||
|
|
||||||
|
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
|
||||||
|
from build import *
|
||||||
|
from pcodetest import *
|
||||||
|
|
||||||
|
# set default properties first, then update values from the command
|
||||||
|
# line before they are instantiated.
|
||||||
|
|
||||||
|
execfile('defaults.py')
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(description='''Build pcodetests.
|
||||||
|
One and only one of the following options must be given:
|
||||||
|
[--pcodetest, --pcodetest-all, --pcodetest-list]''',
|
||||||
|
epilog='(*) default properties for pcodetest instances',
|
||||||
|
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
||||||
|
|
||||||
|
# all-applicable arguments
|
||||||
|
|
||||||
|
parser.add_argument('-f', '--force', action='store_true', help='force a build')
|
||||||
|
parser.add_argument('-v', '--verbose', action='store_true', help='verbose output where available ')
|
||||||
|
parser.add_argument('--toolchain-root', default=PCodeTest.defaults.toolchain_root, help='directory where toolchain directories can be found (*)')
|
||||||
|
parser.add_argument('--build-root', default=PCodeTest.defaults.build_root, help='temporary directory to hold build files (*)')
|
||||||
|
parser.add_argument('--gcc-version', default=PCodeTest.defaults.gcc_version, help='default version of gcc (*)')
|
||||||
|
|
||||||
|
# required alternates
|
||||||
|
|
||||||
|
required_group = parser.add_mutually_exclusive_group(required=True)
|
||||||
|
required_group.add_argument('--pcodetest', help='the pcode test to build')
|
||||||
|
required_group.add_argument('--pcodetest-all', action='store_true', help='build all pcode tests')
|
||||||
|
required_group.add_argument('--pcodetest-list', action='store_true', help='list available pcode tests')
|
||||||
|
|
||||||
|
# pcodetest arguments
|
||||||
|
|
||||||
|
pcodetest_group = parser.add_argument_group('pcodetest', 'pcodetest options')
|
||||||
|
pcodetest_group.add_argument('--no-publish', action='store_true', help='do not publish pcode test binaries to pcode test root')
|
||||||
|
pcodetest_group.add_argument('--pcodetest-root', default=PCodeTest.defaults.pcodetest_root, help='location to publish pcode tests binaries (*)')
|
||||||
|
pcodetest_group.add_argument('--pcodetest-src', default=PCodeTest.defaults.pcodetest_src, help='location of pcode test .c and .h source files (*)')
|
||||||
|
pcodetest_group.add_argument('--skip-files', nargs='+', default=PCodeTest.defaults.skip_files, help='default .c files to remove from the pcode test image (*)')
|
||||||
|
pcodetest_group.add_argument('--strip-symbols', action='store_true', help='strip symbols from image')
|
||||||
|
pcodetest_group.add_argument('--add-ccflags', default='', help='additional flags to pass to compiler (must be quoted)')
|
||||||
|
pcodetest_group.add_argument('--add-info', action='store_true', help='add data to binary with information about types and symbols')
|
||||||
|
pcodetest_group.add_argument('--build-exe', action='store_true', help='build a guest executable binary (exe)')
|
||||||
|
pcodetest_group.add_argument('--variants', default=json.dumps(PCodeTest.defaults.variants, sort_keys=True, separators=(',',':')), type=json.loads, help='build the (optimization) variants, encoded as a json dict')
|
||||||
|
|
||||||
|
sys.argv.pop(0)
|
||||||
|
args = parser.parse_args(sys.argv)
|
||||||
|
|
||||||
|
PCodeTest.defaults.skip_files = args.skip_files
|
||||||
|
PCodeTest.defaults.pcodetest_root = args.pcodetest_root
|
||||||
|
PCodeTest.defaults.pcodetest_src = args.pcodetest_src
|
||||||
|
PCodeTest.defaults.strip_symbols = args.strip_symbols
|
||||||
|
PCodeTest.defaults.add_ccflags = args.add_ccflags
|
||||||
|
PCodeTest.defaults.add_info = args.add_info
|
||||||
|
PCodeTest.defaults.build_exe = args.build_exe
|
||||||
|
PCodeTest.defaults.variants = args.variants
|
||||||
|
PCodeTest.defaults.verbose = args.verbose
|
||||||
|
PCodeTest.defaults.force = args.force
|
||||||
|
PCodeTest.defaults.no_publish = args.no_publish
|
||||||
|
|
||||||
|
# load the known pcodetests
|
||||||
|
|
||||||
|
execfile('pcode_defs.py')
|
||||||
|
|
||||||
|
cwd = os.getcwd()
|
||||||
|
|
||||||
|
if args.pcodetest_list:
|
||||||
|
PCodeTest.print_all()
|
||||||
|
elif args.pcodetest_all:
|
||||||
|
for n,pct in sorted(PCodeTest.list.iteritems(), key=lambda x: x[0].lower()):
|
||||||
|
if pct.config.build_all:
|
||||||
|
try: PCodeTestBuild.factory(pct).main()
|
||||||
|
except Exception as e:
|
||||||
|
print 'unhandled exception while building %s' % n
|
||||||
|
traceback.print_exc(file=sys.stdout)
|
||||||
|
os.chdir(cwd)
|
||||||
|
elif args.pcodetest:
|
||||||
|
if args.pcodetest in PCodeTest.list:
|
||||||
|
PCodeTest = PCodeTest.list[args.pcodetest]
|
||||||
|
PCodeTestBuild.factory(PCodeTest).main()
|
||||||
|
else:
|
||||||
|
print 'the pcode test %s is not in the list' % args.pcodetest
|
||||||
|
else:
|
||||||
|
parser.print_help()
|
||||||
|
|
||||||
@@ -0,0 +1,291 @@
|
|||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import pwd
|
||||||
|
import grp
|
||||||
|
import re
|
||||||
|
|
||||||
|
class BuildUtil(object):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.log = False
|
||||||
|
self.name = False
|
||||||
|
self.num_errors = 0
|
||||||
|
self.num_warnings = 0
|
||||||
|
|
||||||
|
def run(self, cmd, stdout=False, stderr=False, verbose=True):
|
||||||
|
if isinstance(cmd, basestring):
|
||||||
|
if stdout and stderr:
|
||||||
|
cmd += ' 1>%s 2>%s' % (stdout, stderr)
|
||||||
|
elif stdout and not stderr:
|
||||||
|
cmd += ' 1>%s 2>&1' % (stdout)
|
||||||
|
elif not stdout and stderr:
|
||||||
|
cmd += ' 2>%s' % (stderr)
|
||||||
|
if verbose: self.log_info(cmd)
|
||||||
|
os.system(cmd)
|
||||||
|
else:
|
||||||
|
str = ' '.join(cmd);
|
||||||
|
if stdout:
|
||||||
|
f = file(stdout, 'w+')
|
||||||
|
str += ' 1>%s 2>&1' % (stdout)
|
||||||
|
else:
|
||||||
|
f = subprocess.PIPE
|
||||||
|
if verbose: self.log_info(str)
|
||||||
|
try:
|
||||||
|
sp = subprocess.Popen(cmd, stdout=f, stderr=subprocess.PIPE)
|
||||||
|
except OSError as e:
|
||||||
|
self.log_err(cmd)
|
||||||
|
self.log_err(e)
|
||||||
|
return 0,e.message#raise
|
||||||
|
if stdout: f.close()
|
||||||
|
out, err = sp.communicate()
|
||||||
|
# print 'run returned %d bytes stdout and %d bytes stderr' % (len(out) if out else 0, len(err) if err else 0)
|
||||||
|
return out, err
|
||||||
|
|
||||||
|
def isdir(self, dname):
|
||||||
|
return os.path.isdir(dname)
|
||||||
|
|
||||||
|
def getcwd(self):
|
||||||
|
return os.getcwd()
|
||||||
|
|
||||||
|
def basename(self, fname):
|
||||||
|
return os.path.basename(fname)
|
||||||
|
|
||||||
|
def dirname(self, fname):
|
||||||
|
return os.path.dirname(fname)
|
||||||
|
|
||||||
|
def getmtime(self, fname):
|
||||||
|
return os.path.getmtime(fname)
|
||||||
|
|
||||||
|
def isfile(self, fname):
|
||||||
|
return os.path.isfile(fname)
|
||||||
|
|
||||||
|
def getenv(self, var, dflt):
|
||||||
|
return os.getenv(var, dflt)
|
||||||
|
|
||||||
|
def pw_name(self, fname):
|
||||||
|
return pwd.getpwuid(os.stat(fname).st_uid).pw_name
|
||||||
|
|
||||||
|
def gr_name(self, fname):
|
||||||
|
return grp.getgrgid(os.stat(fname).st_gid).gr_name
|
||||||
|
|
||||||
|
def isatty(self):
|
||||||
|
return os.isatty(sys.stdin.fileno())
|
||||||
|
|
||||||
|
def is_readable_file(self, fname):
|
||||||
|
if not self.isfile(fname):
|
||||||
|
self.log_warn('%s does not exist' % fname)
|
||||||
|
return False
|
||||||
|
if os.stat(fname).st_size == 0:
|
||||||
|
self.log_warn('%s is empty' % fname)
|
||||||
|
return False
|
||||||
|
if os.access(fname, os.R_OK) == 0:
|
||||||
|
self.log_warn('%s is not readable' % fname)
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def is_executable_file(self, fname):
|
||||||
|
if not self.is_readable_file(fname): return False
|
||||||
|
if os.access(fname, os.X_OK) == 0:
|
||||||
|
self.log_warn('%s is not executable' % fname)
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
# export a file to a directory
|
||||||
|
def export_file(self, fname, dname,):
|
||||||
|
try:
|
||||||
|
if not os.path.isdir(dname):
|
||||||
|
self.makedirs(dname)
|
||||||
|
if os.path.isfile(fname):
|
||||||
|
self.copy(fname, dname, verbose=True)
|
||||||
|
elif os.path.isdir(fname):
|
||||||
|
self.copy(fname, dname, dir=True, verbose=True)
|
||||||
|
except IOError as e:
|
||||||
|
self.log_err('Error occurred exporting %s to %s' % (fname, dname))
|
||||||
|
self.log_err("Unexpected error: %s" % str(e))
|
||||||
|
|
||||||
|
def rmtree(self, dir, verbose=True):
|
||||||
|
if verbose: self.log_info('rm -r %s' % dir)
|
||||||
|
shutil.rmtree(dir)
|
||||||
|
|
||||||
|
def makedirs(self, dir, verbose=True):
|
||||||
|
if verbose: self.log_info('mkdir -p %s' % dir)
|
||||||
|
try: os.makedirs(dir)
|
||||||
|
except: pass
|
||||||
|
|
||||||
|
# copy a file to a directory
|
||||||
|
def copy(self, fname, dname, verbose=True, dir=False):
|
||||||
|
if not dir:
|
||||||
|
if verbose: self.log_info('cp -av %s %s' % (fname, dname))
|
||||||
|
shutil.copy(fname, dname)
|
||||||
|
else:
|
||||||
|
if verbose: self.log_info('cp -avr %s %s' % (fname, dname))
|
||||||
|
if os.path.exists(dname):
|
||||||
|
shutil.rmtree(dname)
|
||||||
|
shutil.copytree(fname, dname)
|
||||||
|
|
||||||
|
def chdir(self, dir, verbose=True):
|
||||||
|
if verbose: self.log_info('cd %s' % dir)
|
||||||
|
os.chdir(dir)
|
||||||
|
|
||||||
|
def remove(self, fname, verbose=True):
|
||||||
|
if verbose: self.log_info('rm -f %s' % fname)
|
||||||
|
try: os.remove(fname)
|
||||||
|
except: pass
|
||||||
|
|
||||||
|
def environment(self, var, val, verbose=True):
|
||||||
|
if verbose: self.log_info('%s=%s' % (var, val))
|
||||||
|
os.environ[var] = val
|
||||||
|
|
||||||
|
def unlink(self, targ, verbose=True):
|
||||||
|
if verbose: self.log_info('unlink %s' % targ)
|
||||||
|
os.unlink(targ)
|
||||||
|
|
||||||
|
def symlink(self, src, targ, verbose=True):
|
||||||
|
if verbose: self.log_info('ln -s %s %s' % (src, targ))
|
||||||
|
if os.path.islink(targ):
|
||||||
|
os.unlink(targ)
|
||||||
|
os.symlink(src, targ)
|
||||||
|
|
||||||
|
def build_dir(self, root, kind, what):
|
||||||
|
return root + "/" + re.sub(r'[^a-zA-Z0-9_-]+', '_', 'build-%s-%s' % (kind, what))
|
||||||
|
|
||||||
|
def log_prefix(self, kind, what):
|
||||||
|
return kind.upper() + ' ' + what
|
||||||
|
|
||||||
|
def open_log(self, root, kind, what, chdir=False):
|
||||||
|
build_dir = self.build_dir(root, kind, what)
|
||||||
|
|
||||||
|
# Get the name of the log file
|
||||||
|
logFile = '%s/log.txt' % build_dir
|
||||||
|
|
||||||
|
self.log_info('%s LOGFILE %s' % (self.log_prefix(kind, what), logFile))
|
||||||
|
|
||||||
|
try: self.rmtree(build_dir, verbose=False)
|
||||||
|
except: pass
|
||||||
|
self.makedirs(build_dir, verbose=False)
|
||||||
|
self.log_open(logFile)
|
||||||
|
if chdir: self.chdir(build_dir)
|
||||||
|
|
||||||
|
def log_open(self, name):
|
||||||
|
if self.log: self.log_close()
|
||||||
|
self.log = open(name, 'w')
|
||||||
|
self.name = name
|
||||||
|
|
||||||
|
def log_close(self):
|
||||||
|
if self.log:
|
||||||
|
if self.num_errors > 0:
|
||||||
|
print '# ERROR: There were errors, see %s' % self.name
|
||||||
|
elif self.num_warnings > 0:
|
||||||
|
print '# WARNING: There were warnings, see %s' % self.name
|
||||||
|
self.log.close()
|
||||||
|
self.log = False
|
||||||
|
self.name = False
|
||||||
|
self.num_errors = 0
|
||||||
|
self.num_warnings = 0
|
||||||
|
|
||||||
|
def log_pr(self, what):
|
||||||
|
if self.log:
|
||||||
|
self.log.write(what + '\n')
|
||||||
|
self.log.flush()
|
||||||
|
else:
|
||||||
|
print what
|
||||||
|
sys.stdout.flush()
|
||||||
|
|
||||||
|
def log_err(self, what):
|
||||||
|
self.log_pr('# ERROR: ' + what)
|
||||||
|
self.num_errors += 1
|
||||||
|
|
||||||
|
def log_warn(self, what):
|
||||||
|
self.log_pr('# WARNING: ' + what)
|
||||||
|
self.num_warnings += 1
|
||||||
|
|
||||||
|
def log_info(self, what):
|
||||||
|
self.log_pr('# INFO: ' + what)
|
||||||
|
|
||||||
|
# create a file with size, type, and symbol info
|
||||||
|
# the function is here because it is useful and has no dependencies
|
||||||
|
|
||||||
|
def mkinfo(self, fname):
|
||||||
|
ifdefs = { 'i8':'HAS_LONGLONG', 'u8':'HAS_LONGLONG', 'f4':'HAS_FLOAT', 'f8':'HAS_DOUBLE' }
|
||||||
|
|
||||||
|
sizes = [
|
||||||
|
'char', 'signed char', 'unsigned char',
|
||||||
|
'short', 'signed short', 'unsigned short',
|
||||||
|
'int', 'signed int', 'unsigned int',
|
||||||
|
'long', 'signed long', 'unsigned long',
|
||||||
|
'long long', 'signed long long', 'unsigned long long',
|
||||||
|
'float', 'double', 'float', 'long double',
|
||||||
|
'i1', 'i2', 'i4', 'u1', 'u2', 'u4', 'i8', 'u8', 'f4', 'f8']
|
||||||
|
|
||||||
|
syms = [
|
||||||
|
'__AVR32__', '__AVR_ARCH__', 'dsPIC30', '__GNUC__', '__has_feature', 'INT4_IS_LONG',
|
||||||
|
'__INT64_TYPE__', '__INT8_TYPE__', '__llvm__', '_M_ARM_FP', '__MSP430__', '_MSV_VER',
|
||||||
|
'__SDCC', '__SIZEOF_DOUBLE__', '__SIZEOF_FLOAT__', '__SIZEOF_SIZE_T__', '__TI_COMPILER_VERSION__',
|
||||||
|
'__INT8_TYPE__', '__INT16_TYPE__', '__INT32_TYPE__', '__INT64_TYPE__', '__UINT8_TYPE__',
|
||||||
|
'__UINT16_TYPE__', '__UINT32_TYPE__', '__UINT64_TYPE__', 'HAS_FLOAT', 'HAS_DOUBLE',
|
||||||
|
'HAS_LONGLONG', 'HAS_FLOAT_OVERRIDE', 'HAS_DOUBLE_OVERRIDE', 'HAS_LONGLONG_OVERRIDE']
|
||||||
|
|
||||||
|
typedefs = { 'i1':1, 'i2':2, 'i4':4, 'u1':1, 'u2':2, 'u4':4, 'i8':8, 'u8':8, 'f4':4, 'f8':8 }
|
||||||
|
|
||||||
|
f = open(fname, 'w')
|
||||||
|
|
||||||
|
f.write('#include "types.h"\n\n')
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
for s in sizes:
|
||||||
|
i += 1
|
||||||
|
d = 'INFO sizeof(%s) = ' % s
|
||||||
|
x = list(d)
|
||||||
|
x = "', '".join(x)
|
||||||
|
x = "'%s', '0'+sizeof(%s), '\\n'" % (x, s)
|
||||||
|
l = 'char size_info_%d[] = {%s};\n' % (i, x)
|
||||||
|
if s in ifdefs: f.write('#ifdef %s\n' % ifdefs[s])
|
||||||
|
f.write(l)
|
||||||
|
if s in ifdefs: f.write('#endif\n')
|
||||||
|
|
||||||
|
for s in typedefs:
|
||||||
|
if s in ifdefs: f.write('#ifdef %s\n' % ifdefs[s])
|
||||||
|
f.write('_Static_assert(sizeof(%s) == %d, "INFO %s should have size %d, is not correct\\n");\n' % (s, typedefs[s], s, typedefs[s]))
|
||||||
|
if s in ifdefs: f.write('#endif\n')
|
||||||
|
|
||||||
|
for s in syms:
|
||||||
|
i += 1
|
||||||
|
f.write('#ifdef %s\n' % s)
|
||||||
|
f.write('char sym_info_%d[] = "INFO %s is defined\\n\";\n' % (i, s))
|
||||||
|
f.write('#else\n')
|
||||||
|
f.write('char sym_info_%d[] = "INFO %s is not defined\\n\";\n' % (i, s))
|
||||||
|
f.write('#endif\n')
|
||||||
|
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
class Config(object):
|
||||||
|
|
||||||
|
def __init__(self, *obj):
|
||||||
|
for o in obj:
|
||||||
|
if isinstance(o, dict): self.__dict__.update(o)
|
||||||
|
else: self.__dict__.update(o.__dict__)
|
||||||
|
|
||||||
|
def format(self, val):
|
||||||
|
if isinstance(val, basestring) and '%' in val:
|
||||||
|
return val % self.__dict__
|
||||||
|
elif isinstance(val, dict):
|
||||||
|
return dict(map(lambda (k,v): (k,self.format(v)), val.iteritems()))
|
||||||
|
else: return val
|
||||||
|
|
||||||
|
def __getattr__(self, attr):
|
||||||
|
return ''
|
||||||
|
|
||||||
|
def expand(self):
|
||||||
|
for k,v in self.__dict__.iteritems():
|
||||||
|
self.__dict__[k] = self.format(v)
|
||||||
|
|
||||||
|
def dump(self):
|
||||||
|
ret = ''
|
||||||
|
for k,v in sorted(self.__dict__.iteritems()):
|
||||||
|
if isinstance(v, basestring): vv = "'" + v + "'"
|
||||||
|
else: vv = str(v)
|
||||||
|
ret += ' '.ljust(10) + k.ljust(20) + vv + '\n'
|
||||||
|
return ret
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,197 @@
|
|||||||
|
#include "pcode_test.h"
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
TEST biopEqf8f8_Main()
|
||||||
|
{
|
||||||
|
extern f8 biopEqf8f8(f8 lhs, f8 rhs);
|
||||||
|
f8 lhs = 2;
|
||||||
|
f8 rhs = 1;
|
||||||
|
f8 retVal;
|
||||||
|
retVal = biopEqf8f8(lhs, rhs);
|
||||||
|
ASSERTF8(retVal, 0);
|
||||||
|
ASSERTF8(biopEqf8f8(PI_SHORT, PI_SHORT), 1.0);
|
||||||
|
ASSERTF8(biopEqf8f8(PI_SHORT, 2*PI_SHORT), 0.0);
|
||||||
|
ASSERTF8(biopEqf8f8(2*PI_SHORT, PI_SHORT), 0.0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
TEST biopNef8f8_Main()
|
||||||
|
{
|
||||||
|
extern f8 biopNef8f8(f8 lhs, f8 rhs);
|
||||||
|
f8 lhs = 2;
|
||||||
|
f8 rhs = 1;
|
||||||
|
f8 retVal;
|
||||||
|
retVal = biopNef8f8(lhs, rhs);
|
||||||
|
ASSERTF8(retVal, 1);
|
||||||
|
ASSERTF8(biopNef8f8(PI_SHORT, PI_SHORT), 0.0);
|
||||||
|
ASSERTF8(biopNef8f8(PI_SHORT, 2*PI_SHORT), 1.0);
|
||||||
|
ASSERTF8(biopNef8f8(2*PI_SHORT, PI_SHORT), 1.0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
TEST biopLogicOrf8f8_Main()
|
||||||
|
{
|
||||||
|
extern f8 biopLogicOrf8f8(f8 lhs, f8 rhs);
|
||||||
|
f8 lhs = 2;
|
||||||
|
f8 rhs = 1;
|
||||||
|
f8 retVal;
|
||||||
|
retVal = biopLogicOrf8f8(lhs, rhs);
|
||||||
|
ASSERTF8(retVal, 1);
|
||||||
|
ASSERTF8(biopLogicOrf8f8(PI_SHORT, PI_SHORT), 1);
|
||||||
|
ASSERTF8(biopLogicOrf8f8(PI_SHORT, 0), 1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
TEST biopLogicAndf8f8_Main()
|
||||||
|
{
|
||||||
|
extern f8 biopLogicAndf8f8(f8 lhs, f8 rhs);
|
||||||
|
f8 lhs = 2;
|
||||||
|
f8 rhs = 1;
|
||||||
|
f8 retVal;
|
||||||
|
retVal = biopLogicAndf8f8(lhs, rhs);
|
||||||
|
ASSERTF8(retVal, 1);
|
||||||
|
ASSERTF8(biopLogicAndf8f8(PI_SHORT, PI_SHORT), 1);
|
||||||
|
ASSERTF8(biopLogicAndf8f8(PI_SHORT, 0), 0.0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
TEST unopNotf8_Main()
|
||||||
|
{
|
||||||
|
extern f8 unopNotf8(f8 lhs);
|
||||||
|
f8 lhs = 2;
|
||||||
|
f8 retVal;
|
||||||
|
retVal = unopNotf8(lhs);
|
||||||
|
ASSERTF8(retVal, 0);
|
||||||
|
ASSERTF8(unopNotf8(PI_SHORT), 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
TEST unopNegativef8_Main()
|
||||||
|
{
|
||||||
|
extern f8 unopNegativef8(f8 lhs);
|
||||||
|
f8 lhs = 2;
|
||||||
|
f8 retVal;
|
||||||
|
retVal = unopNegativef8(lhs);
|
||||||
|
ASSERTF8(retVal, -2);
|
||||||
|
ASSERTF8(unopNegativef8(PI_SHORT), -3.14);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
TEST unopPlusf8_Main()
|
||||||
|
{
|
||||||
|
extern f8 unopPlusf8(f8 lhs);
|
||||||
|
f8 lhs = 2;
|
||||||
|
f8 retVal;
|
||||||
|
retVal = unopPlusf8(lhs);
|
||||||
|
ASSERTF8(retVal, 2);
|
||||||
|
ASSERTF8(unopPlusf8(PI_SHORT), PI_SHORT);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
TEST biopMultf8f8_Main()
|
||||||
|
{
|
||||||
|
extern f8 biopMultf8f8(f8 lhs, f8 rhs);
|
||||||
|
f8 lhs = 2;
|
||||||
|
f8 rhs = 1;
|
||||||
|
f8 retVal;
|
||||||
|
retVal = biopMultf8f8(lhs, rhs);
|
||||||
|
ASSERTF8(retVal, 2);
|
||||||
|
ASSERTF8(biopMultf8f8(PI_SHORT, PI_SHORT), 9.8596);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
TEST biopSubf8f8_Main()
|
||||||
|
{
|
||||||
|
extern f8 biopSubf8f8(f8 lhs, f8 rhs);
|
||||||
|
f8 lhs = 2;
|
||||||
|
f8 rhs = 1;
|
||||||
|
f8 retVal;
|
||||||
|
retVal = biopSubf8f8(lhs, rhs);
|
||||||
|
ASSERTF8(retVal, 1);
|
||||||
|
ASSERTF8(biopSubf8f8(PI_SHORT, PI_SHORT), 0.0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
TEST biopAddf8f8_Main()
|
||||||
|
{
|
||||||
|
extern f8 biopAddf8f8(f8 lhs, f8 rhs);
|
||||||
|
f8 lhs = 2;
|
||||||
|
f8 rhs = 1;
|
||||||
|
f8 retVal;
|
||||||
|
retVal = biopAddf8f8(lhs, rhs);
|
||||||
|
ASSERTF8(retVal, 3);
|
||||||
|
ASSERTF8(biopAddf8f8(PI_SHORT, PI_SHORT), 6.28);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
TEST biopGtf8f8_Main()
|
||||||
|
{
|
||||||
|
extern f8 biopGtf8f8(f8 lhs, f8 rhs);
|
||||||
|
f8 lhs = 2;
|
||||||
|
f8 rhs = 1;
|
||||||
|
f8 retVal;
|
||||||
|
retVal = biopGtf8f8(lhs, rhs);
|
||||||
|
ASSERTF8(retVal, 1);
|
||||||
|
ASSERTF8(biopGtf8f8(PI_SHORT, PI_SHORT), 0.0);
|
||||||
|
ASSERTF8(biopGtf8f8(PI_SHORT, 2*PI_SHORT), 0.0);
|
||||||
|
ASSERTF8(biopGtf8f8(2*PI_SHORT, PI_SHORT), 1.0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
TEST biopGef8f8_Main()
|
||||||
|
{
|
||||||
|
extern f8 biopGef8f8(f8 lhs, f8 rhs);
|
||||||
|
f8 lhs = 2;
|
||||||
|
f8 rhs = 1;
|
||||||
|
f8 retVal;
|
||||||
|
retVal = biopGef8f8(lhs, rhs);
|
||||||
|
ASSERTF8(retVal, 1);
|
||||||
|
ASSERTF8(biopGef8f8(PI_SHORT, PI_SHORT), 1.0);
|
||||||
|
ASSERTF8(biopGef8f8(PI_SHORT, 2*PI_SHORT), 0.0);
|
||||||
|
ASSERTF8(biopGef8f8(2*PI_SHORT, PI_SHORT), 1.0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
TEST biopLtf8f8_Main()
|
||||||
|
{
|
||||||
|
extern f8 biopLtf8f8(f8 lhs, f8 rhs);
|
||||||
|
f8 lhs = 2;
|
||||||
|
f8 rhs = 1;
|
||||||
|
f8 retVal;
|
||||||
|
retVal = biopLtf8f8(lhs, rhs);
|
||||||
|
ASSERTF8(retVal, 0);
|
||||||
|
ASSERTF8(biopLtf8f8(PI_SHORT, PI_SHORT), 0.0);
|
||||||
|
ASSERTF8(biopLtf8f8(PI_SHORT, 2*PI_SHORT), 1.0);
|
||||||
|
ASSERTF8(biopLtf8f8(2*PI_SHORT, PI_SHORT), 0.0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
TEST biopLef8f8_Main()
|
||||||
|
{
|
||||||
|
extern f8 biopLef8f8(f8 lhs, f8 rhs);
|
||||||
|
f8 lhs = 2;
|
||||||
|
f8 rhs = 1;
|
||||||
|
f8 retVal;
|
||||||
|
retVal = biopLef8f8(lhs, rhs);
|
||||||
|
ASSERTF8(retVal, 0);
|
||||||
|
ASSERTF8(biopLef8f8(PI_SHORT, PI_SHORT), 1.0);
|
||||||
|
ASSERTF8(biopLef8f8(PI_SHORT, 2*PI_SHORT), 1.0);
|
||||||
|
ASSERTF8(biopLef8f8(2*PI_SHORT, PI_SHORT), 0.0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
MAIN BIOPS_DOUBLE_main() { }
|
||||||
|
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
/* ###
|
||||||
|
* IP: GHIDRA
|
||||||
|
*
|
||||||
|
* 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 "pcode_test.h"
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
f8 biopEqf8f8(f8 lhs, f8 rhs)
|
||||||
|
{
|
||||||
|
f8 z;
|
||||||
|
|
||||||
|
z = lhs == rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
f8 biopNef8f8(f8 lhs, f8 rhs)
|
||||||
|
{
|
||||||
|
f8 z;
|
||||||
|
|
||||||
|
z = lhs != rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
f8 biopLogicOrf8f8(f8 lhs, f8 rhs)
|
||||||
|
{
|
||||||
|
f8 z;
|
||||||
|
|
||||||
|
z = lhs || rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
f8 biopLogicAndf8f8(f8 lhs, f8 rhs)
|
||||||
|
{
|
||||||
|
f8 z;
|
||||||
|
|
||||||
|
z = lhs && rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
f8 unopNotf8(f8 lhs)
|
||||||
|
{
|
||||||
|
f8 z;
|
||||||
|
|
||||||
|
z = !lhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
f8 unopNegativef8(f8 lhs)
|
||||||
|
{
|
||||||
|
f8 z;
|
||||||
|
|
||||||
|
z = -lhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
f8 unopPlusf8(f8 lhs)
|
||||||
|
{
|
||||||
|
f8 z;
|
||||||
|
|
||||||
|
z = +lhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
f8 biopMultf8f8(f8 lhs, f8 rhs)
|
||||||
|
{
|
||||||
|
f8 z;
|
||||||
|
|
||||||
|
z = lhs * rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
f8 biopSubf8f8(f8 lhs, f8 rhs)
|
||||||
|
{
|
||||||
|
f8 z;
|
||||||
|
|
||||||
|
z = lhs - rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
f8 biopAddf8f8(f8 lhs, f8 rhs)
|
||||||
|
{
|
||||||
|
f8 z;
|
||||||
|
|
||||||
|
z = lhs + rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
f8 biopGtf8f8(f8 lhs, f8 rhs)
|
||||||
|
{
|
||||||
|
f8 z;
|
||||||
|
|
||||||
|
z = lhs > rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
f8 biopGef8f8(f8 lhs, f8 rhs)
|
||||||
|
{
|
||||||
|
f8 z;
|
||||||
|
|
||||||
|
z = lhs >= rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
f8 biopLtf8f8(f8 lhs, f8 rhs)
|
||||||
|
{
|
||||||
|
f8 z;
|
||||||
|
|
||||||
|
z = lhs < rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
f8 biopLef8f8(f8 lhs, f8 rhs)
|
||||||
|
{
|
||||||
|
f8 z;
|
||||||
|
|
||||||
|
z = lhs <= rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* #ifdef HAS_DOUBLE */
|
||||||
@@ -0,0 +1,169 @@
|
|||||||
|
#include "pcode_test.h"
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
TEST biopCmpf4f4_Main()
|
||||||
|
{
|
||||||
|
extern f4 biopCmpf4f4(f4 lhs, f4 rhs);
|
||||||
|
ASSERTF4(biopCmpf4f4(0x1, 0x1), 21);
|
||||||
|
ASSERTF4(biopCmpf4f4(0x1, 0x2), 21);
|
||||||
|
ASSERTF4(biopCmpf4f4(0x2, 0x1), 22);
|
||||||
|
ASSERTF4(biopCmpf4f4(-0x1, -0x1), 21);
|
||||||
|
ASSERTF4(biopCmpf4f4(-0x1, -0x2), 21);
|
||||||
|
ASSERTF4(biopCmpf4f4(-0x2, -0x1), 24);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
TEST biopCmpf8f8_Main()
|
||||||
|
{
|
||||||
|
extern f8 biopCmpf8f8(f8 lhs, f8 rhs);
|
||||||
|
ASSERTF8(biopCmpf8f8(0x1, 0x1), 21);
|
||||||
|
ASSERTF8(biopCmpf8f8(0x1, 0x2), 21);
|
||||||
|
ASSERTF8(biopCmpf8f8(0x2, 0x1), 22);
|
||||||
|
ASSERTF8(biopCmpf8f8(-0x1, -0x1), 21);
|
||||||
|
ASSERTF8(biopCmpf8f8(-0x1, -0x2), 21);
|
||||||
|
ASSERTF8(biopCmpf8f8(-0x2, -0x1), 24);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
TEST biopLtf4f4_Main()
|
||||||
|
{
|
||||||
|
extern f4 biopLtf4f4(f4 lhs, f4 rhs);
|
||||||
|
f4 lhs = 2;
|
||||||
|
f4 rhs = 1;
|
||||||
|
f4 retVal;
|
||||||
|
ASSERTF4(biopLtf4f4(lhs, rhs), 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
TEST biopLef4f4_Main()
|
||||||
|
{
|
||||||
|
extern f4 biopLef4f4(f4 lhs, f4 rhs);
|
||||||
|
ASSERTF4(biopLef4f4(2, 1), 0);
|
||||||
|
ASSERTF4(biopLef4f4(PI_SHORT, 2*PI_SHORT), 1.0);
|
||||||
|
ASSERTF4(biopLef4f4(PI_SHORT, PI_SHORT), 1.0);
|
||||||
|
ASSERTF4(biopLef4f4(2*PI_SHORT, PI_SHORT), 0.0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
TEST biopEqf4f4_Main()
|
||||||
|
{
|
||||||
|
extern f4 biopEqf4f4(f4 lhs, f4 rhs);
|
||||||
|
ASSERTF4(biopEqf4f4(2, 1), 0);
|
||||||
|
ASSERTF4(biopEqf4f4(PI_SHORT, PI_SHORT), 1.0);
|
||||||
|
ASSERTF4(biopEqf4f4(PI_SHORT, 2*PI_SHORT), 0.0);
|
||||||
|
ASSERTF4(biopEqf4f4(2*PI_SHORT, PI_SHORT), 0.0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
TEST biopNef4f4_Main()
|
||||||
|
{
|
||||||
|
extern f4 biopNef4f4(f4 lhs, f4 rhs);
|
||||||
|
ASSERTF4(biopNef4f4(2, 1), 1);
|
||||||
|
ASSERTF4(biopNef4f4(PI_SHORT, PI_SHORT), 0.0);
|
||||||
|
ASSERTF4(biopNef4f4(PI_SHORT, 2*PI_SHORT), 1.0);
|
||||||
|
ASSERTF4(biopNef4f4(2*PI_SHORT, PI_SHORT), 1.0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
TEST biopLogicOrf4f4_Main()
|
||||||
|
{
|
||||||
|
extern f4 biopLogicOrf4f4(f4 lhs, f4 rhs);
|
||||||
|
ASSERTF4(biopLogicOrf4f4(2, 1), 1);
|
||||||
|
ASSERTF4(biopLogicOrf4f4(PI_SHORT, PI_SHORT), 1);
|
||||||
|
ASSERTF4(biopLogicOrf4f4(PI_SHORT, 0), 1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
TEST biopLogicAndf4f4_Main()
|
||||||
|
{
|
||||||
|
extern f4 biopLogicAndf4f4(f4 lhs, f4 rhs);
|
||||||
|
ASSERTF4(biopLogicAndf4f4(2, 1), 1);
|
||||||
|
ASSERTF4(biopLogicAndf4f4(PI_SHORT, PI_SHORT), 1);
|
||||||
|
ASSERTF4(biopLogicAndf4f4(PI_SHORT, 0), 0.0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
TEST unopNotf4_Main()
|
||||||
|
{
|
||||||
|
extern f4 unopNotf4(f4 lhs);
|
||||||
|
ASSERTF4(unopNotf4(2), 0);
|
||||||
|
ASSERTF4(unopNotf4(PI_SHORT), 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
TEST unopNegativef4_Main()
|
||||||
|
{
|
||||||
|
extern f4 unopNegativef4(f4 lhs);
|
||||||
|
ASSERTF4(unopNegativef4(2), -2);
|
||||||
|
ASSERTF4(unopNegativef4(PI_SHORT), -3.14);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
TEST unopPlusf4_Main()
|
||||||
|
{
|
||||||
|
extern f4 unopPlusf4(f4 lhs);
|
||||||
|
ASSERTF4(unopPlusf4(2), 2);
|
||||||
|
ASSERTF4(unopPlusf4(PI_SHORT), PI_SHORT);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
TEST biopMultf4f4_Main()
|
||||||
|
{
|
||||||
|
extern f4 biopMultf4f4(f4 lhs, f4 rhs);
|
||||||
|
ASSERTF4(biopMultf4f4(2, 1), 2);
|
||||||
|
ASSERTF4(biopMultf4f4(PI_SHORT, PI_SHORT), 9.859601);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
TEST biopSubf4f4_Main()
|
||||||
|
{
|
||||||
|
extern f4 biopSubf4f4(f4 lhs, f4 rhs);
|
||||||
|
ASSERTF4(biopSubf4f4(2, 1), 1);
|
||||||
|
ASSERTF4(biopSubf4f4(PI_SHORT, PI_SHORT), 0.0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
TEST biopAddf4f4_Main()
|
||||||
|
{
|
||||||
|
extern f4 biopAddf4f4(f4 lhs, f4 rhs);
|
||||||
|
ASSERTF4(biopAddf4f4(2, 1), 3);
|
||||||
|
ASSERTF4(biopAddf4f4(PI_SHORT, PI_SHORT), 6.280000);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
TEST biopGtf4f4_Main()
|
||||||
|
{
|
||||||
|
extern f4 biopGtf4f4(f4 lhs, f4 rhs);
|
||||||
|
ASSERTF4(biopGtf4f4(2, 1), 1);
|
||||||
|
ASSERTF4(biopGtf4f4(PI_SHORT, PI_SHORT), 0.0);
|
||||||
|
ASSERTF4(biopGtf4f4(PI_SHORT, 2*PI_SHORT), 0.0);
|
||||||
|
ASSERTF4(biopGtf4f4(2*PI_SHORT, PI_SHORT), 1.0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
TEST biopGef4f4_Main()
|
||||||
|
{
|
||||||
|
extern f4 biopGef4f4(f4 lhs, f4 rhs);
|
||||||
|
ASSERTF4(biopGef4f4(2, 1), 1);
|
||||||
|
ASSERTF4(biopGef4f4(PI_SHORT, PI_SHORT), 1.0);
|
||||||
|
ASSERTF4(biopGef4f4(PI_SHORT, 2*PI_SHORT), 0.0);
|
||||||
|
ASSERTF4(biopGef4f4(2*PI_SHORT, PI_SHORT), 1.0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
MAIN BIOPS_FLOAT_main() { }
|
||||||
@@ -0,0 +1,157 @@
|
|||||||
|
/* ###
|
||||||
|
* IP: GHIDRA
|
||||||
|
*
|
||||||
|
* 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 "pcode_test.h"
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
f4 biopCmpf4f4(f4 lhs, f4 rhs)
|
||||||
|
{
|
||||||
|
if (lhs < 0)
|
||||||
|
lhs += 2;
|
||||||
|
if (lhs > 0)
|
||||||
|
lhs += 4;
|
||||||
|
if (lhs == 0)
|
||||||
|
lhs += 8;
|
||||||
|
if (lhs != rhs)
|
||||||
|
lhs += 16;
|
||||||
|
return lhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
f8 biopCmpf8f8(f8 lhs, f8 rhs)
|
||||||
|
{
|
||||||
|
if (lhs < 0)
|
||||||
|
lhs += 2;
|
||||||
|
if (lhs > 0)
|
||||||
|
lhs += 4;
|
||||||
|
if (lhs == 0)
|
||||||
|
lhs += 8;
|
||||||
|
if (lhs != rhs)
|
||||||
|
lhs += 16;
|
||||||
|
return lhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
f4 biopLtf4f4(f4 lhs, f4 rhs)
|
||||||
|
{
|
||||||
|
f4 z;
|
||||||
|
|
||||||
|
z = lhs < rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
f4 biopLef4f4(f4 lhs, f4 rhs)
|
||||||
|
{
|
||||||
|
f4 z;
|
||||||
|
|
||||||
|
z = lhs <= rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
f4 biopEqf4f4(f4 lhs, f4 rhs)
|
||||||
|
{
|
||||||
|
f4 z;
|
||||||
|
|
||||||
|
z = lhs == rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
f4 biopNef4f4(f4 lhs, f4 rhs)
|
||||||
|
{
|
||||||
|
f4 z;
|
||||||
|
|
||||||
|
z = lhs != rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
f4 biopLogicOrf4f4(f4 lhs, f4 rhs)
|
||||||
|
{
|
||||||
|
f4 z;
|
||||||
|
|
||||||
|
z = lhs || rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
f4 biopLogicAndf4f4(f4 lhs, f4 rhs)
|
||||||
|
{
|
||||||
|
f4 z;
|
||||||
|
|
||||||
|
z = lhs && rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
f4 unopNotf4(f4 lhs)
|
||||||
|
{
|
||||||
|
f4 z;
|
||||||
|
|
||||||
|
z = !lhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
f4 unopNegativef4(f4 lhs)
|
||||||
|
{
|
||||||
|
f4 z;
|
||||||
|
|
||||||
|
z = -lhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
f4 unopPlusf4(f4 lhs)
|
||||||
|
{
|
||||||
|
f4 z;
|
||||||
|
|
||||||
|
z = +lhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
f4 biopMultf4f4(f4 lhs, f4 rhs)
|
||||||
|
{
|
||||||
|
f4 z;
|
||||||
|
|
||||||
|
z = lhs * rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
f4 biopSubf4f4(f4 lhs, f4 rhs)
|
||||||
|
{
|
||||||
|
f4 z;
|
||||||
|
|
||||||
|
z = lhs - rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
f4 biopAddf4f4(f4 lhs, f4 rhs)
|
||||||
|
{
|
||||||
|
f4 z;
|
||||||
|
|
||||||
|
z = lhs + rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
f4 biopGtf4f4(f4 lhs, f4 rhs)
|
||||||
|
{
|
||||||
|
f4 z;
|
||||||
|
|
||||||
|
z = lhs > rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
f4 biopGef4f4(f4 lhs, f4 rhs)
|
||||||
|
{
|
||||||
|
f4 z;
|
||||||
|
|
||||||
|
z = lhs >= rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* #ifdef HAS_FLOAT */
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,403 @@
|
|||||||
|
/* ###
|
||||||
|
* IP: GHIDRA
|
||||||
|
*
|
||||||
|
* 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 "pcode_test.h"
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
i8 pcode_i8_complexLogic(i8 a, i8 b, i8 c, i8 d, i8 e, i8 f)
|
||||||
|
{
|
||||||
|
i8 ret = 0;
|
||||||
|
|
||||||
|
if (a > b && b > c || d < e && f < e) {
|
||||||
|
ret += 1;
|
||||||
|
}
|
||||||
|
if (a != b || a != c && d != e || f != e) {
|
||||||
|
ret += 2;
|
||||||
|
}
|
||||||
|
if (a && b && c || d && e && f) {
|
||||||
|
ret += 4;
|
||||||
|
}
|
||||||
|
if (a || b || c && d || e || f) {
|
||||||
|
ret += 8;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 pcode_u8_complexLogic(u8 a, u8 b, u8 c, u8 d, u8 e, u8 f)
|
||||||
|
{
|
||||||
|
u8 ret = 0;
|
||||||
|
|
||||||
|
if (a > b && b > c || d < e && f < e) {
|
||||||
|
ret += 1;
|
||||||
|
}
|
||||||
|
if (a != b || a != c && d != e || f != e) {
|
||||||
|
ret += 2;
|
||||||
|
}
|
||||||
|
if (a && b && c || d && e && f) {
|
||||||
|
ret += 4;
|
||||||
|
}
|
||||||
|
if (a || b || c && d || e || f) {
|
||||||
|
ret += 8;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
i8 biopCmpi8i8(i8 lhs, i8 rhs)
|
||||||
|
{
|
||||||
|
if (lhs < 0)
|
||||||
|
lhs += 2;
|
||||||
|
if (lhs > 0)
|
||||||
|
lhs += 4;
|
||||||
|
if (lhs == 0)
|
||||||
|
lhs += 8;
|
||||||
|
if (lhs != rhs)
|
||||||
|
lhs += 16;
|
||||||
|
return lhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 biopCmpu8u8(u8 lhs, u8 rhs)
|
||||||
|
{
|
||||||
|
if (lhs < rhs)
|
||||||
|
lhs += 2;
|
||||||
|
if (lhs > rhs)
|
||||||
|
lhs += 4;
|
||||||
|
if (lhs == 0)
|
||||||
|
lhs += 8;
|
||||||
|
if (lhs != rhs)
|
||||||
|
lhs += 16;
|
||||||
|
return lhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
i8 biopNei8i8(i8 lhs, i8 rhs)
|
||||||
|
{
|
||||||
|
i8 z;
|
||||||
|
|
||||||
|
z = lhs != rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 biopAndu8u8(u8 lhs, u8 rhs)
|
||||||
|
{
|
||||||
|
u8 z;
|
||||||
|
|
||||||
|
z = lhs & rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
i8 biopAndi8i8(i8 lhs, i8 rhs)
|
||||||
|
{
|
||||||
|
i8 z;
|
||||||
|
|
||||||
|
z = lhs & rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 biopOru8u8(u8 lhs, u8 rhs)
|
||||||
|
{
|
||||||
|
u8 z;
|
||||||
|
|
||||||
|
z = lhs | rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 biopXOru8u8(u8 lhs, u8 rhs)
|
||||||
|
{
|
||||||
|
u8 z;
|
||||||
|
|
||||||
|
z = lhs ^ rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
i8 biopOri8i8(i8 lhs, i8 rhs)
|
||||||
|
{
|
||||||
|
i8 z;
|
||||||
|
|
||||||
|
z = lhs | rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 biopLogicOru8u8(u8 lhs, u8 rhs)
|
||||||
|
{
|
||||||
|
u8 z;
|
||||||
|
|
||||||
|
z = lhs || rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
i8 biopXOri8i8(i8 lhs, i8 rhs)
|
||||||
|
{
|
||||||
|
i8 z;
|
||||||
|
|
||||||
|
z = lhs ^ rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
i8 biopRemainderi8i8(i8 lhs, i8 rhs)
|
||||||
|
{
|
||||||
|
i8 z;
|
||||||
|
|
||||||
|
z = lhs % rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
i8 biopLogicOri8i8(i8 lhs, i8 rhs)
|
||||||
|
{
|
||||||
|
i8 z;
|
||||||
|
|
||||||
|
z = lhs || rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 biopLogicAndu8u8(u8 lhs, u8 rhs)
|
||||||
|
{
|
||||||
|
u8 z;
|
||||||
|
|
||||||
|
z = lhs && rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
i8 biopDividi8i8(i8 lhs, i8 rhs)
|
||||||
|
{
|
||||||
|
i8 z;
|
||||||
|
|
||||||
|
z = lhs / rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 biopDividu8u8(u8 lhs, u8 rhs)
|
||||||
|
{
|
||||||
|
u8 z;
|
||||||
|
|
||||||
|
z = lhs / rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
i8 biopLogicAndi8i8(i8 lhs, i8 rhs)
|
||||||
|
{
|
||||||
|
i8 z;
|
||||||
|
|
||||||
|
z = lhs && rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 unopNotu8(u8 lhs)
|
||||||
|
{
|
||||||
|
u8 z;
|
||||||
|
|
||||||
|
z = !lhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
i8 unopNoti8(i8 lhs)
|
||||||
|
{
|
||||||
|
i8 z;
|
||||||
|
|
||||||
|
z = !lhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 unopPlusu8(u8 lhs)
|
||||||
|
{
|
||||||
|
u8 z;
|
||||||
|
|
||||||
|
z = +lhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
i8 unopNegativei8(i8 lhs)
|
||||||
|
{
|
||||||
|
i8 z;
|
||||||
|
|
||||||
|
z = -lhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
i8 unopPlusi8(i8 lhs)
|
||||||
|
{
|
||||||
|
i8 z;
|
||||||
|
|
||||||
|
z = +lhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 biopMultu8u8(u8 lhs, u8 rhs)
|
||||||
|
{
|
||||||
|
u8 z;
|
||||||
|
|
||||||
|
z = lhs * rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
i8 biopMulti8i8(i8 lhs, i8 rhs)
|
||||||
|
{
|
||||||
|
i8 z;
|
||||||
|
|
||||||
|
z = lhs * rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 biopSubu8u8(u8 lhs, u8 rhs)
|
||||||
|
{
|
||||||
|
u8 z;
|
||||||
|
|
||||||
|
z = lhs - rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
i8 biopSubi8i8(i8 lhs, i8 rhs)
|
||||||
|
{
|
||||||
|
i8 z;
|
||||||
|
|
||||||
|
z = lhs - rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 biopAddu8u8(u8 lhs, u8 rhs)
|
||||||
|
{
|
||||||
|
u8 z;
|
||||||
|
|
||||||
|
z = lhs + rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 biopShtLftu8u8(u8 lhs, u8 rhs)
|
||||||
|
{
|
||||||
|
u8 z;
|
||||||
|
|
||||||
|
z = lhs << rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
i8 biopAddi8i8(i8 lhs, i8 rhs)
|
||||||
|
{
|
||||||
|
i8 z;
|
||||||
|
|
||||||
|
z = lhs + rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 biopShtRhtu8u8(u8 lhs, u8 rhs)
|
||||||
|
{
|
||||||
|
u8 z;
|
||||||
|
|
||||||
|
z = lhs >> rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
i8 biopShtLfti8i8(i8 lhs, i8 rhs)
|
||||||
|
{
|
||||||
|
i8 z;
|
||||||
|
|
||||||
|
z = lhs << rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
i8 biopShtRhti8i8(i8 lhs, i8 rhs)
|
||||||
|
{
|
||||||
|
i8 z;
|
||||||
|
|
||||||
|
z = lhs >> rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 biopGtu8u8(u8 lhs, u8 rhs)
|
||||||
|
{
|
||||||
|
u8 z;
|
||||||
|
|
||||||
|
z = lhs > rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
i8 biopGti8i8(i8 lhs, i8 rhs)
|
||||||
|
{
|
||||||
|
i8 z;
|
||||||
|
|
||||||
|
z = lhs > rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 biopGeu8u8(u8 lhs, u8 rhs)
|
||||||
|
{
|
||||||
|
u8 z;
|
||||||
|
|
||||||
|
z = lhs >= rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
i8 biopGei8i8(i8 lhs, i8 rhs)
|
||||||
|
{
|
||||||
|
i8 z;
|
||||||
|
|
||||||
|
z = lhs >= rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 biopLtu8u8(u8 lhs, u8 rhs)
|
||||||
|
{
|
||||||
|
u8 z;
|
||||||
|
|
||||||
|
z = lhs < rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 biopLeu8u8(u8 lhs, u8 rhs)
|
||||||
|
{
|
||||||
|
u8 z;
|
||||||
|
|
||||||
|
z = lhs <= rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
i8 biopLti8i8(i8 lhs, i8 rhs)
|
||||||
|
{
|
||||||
|
i8 z;
|
||||||
|
|
||||||
|
z = lhs < rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 biopEqu8u8(u8 lhs, u8 rhs)
|
||||||
|
{
|
||||||
|
u8 z;
|
||||||
|
|
||||||
|
z = lhs == rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
i8 biopLei8i8(i8 lhs, i8 rhs)
|
||||||
|
{
|
||||||
|
i8 z;
|
||||||
|
|
||||||
|
z = lhs <= rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
i8 biopEqi8i8(i8 lhs, i8 rhs)
|
||||||
|
{
|
||||||
|
i8 z;
|
||||||
|
|
||||||
|
z = lhs == rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 biopNeu8u8(u8 lhs, u8 rhs)
|
||||||
|
{
|
||||||
|
u8 z;
|
||||||
|
|
||||||
|
z = lhs != rhs;
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* #ifdef HAS_LONGLONG */
|
||||||
@@ -0,0 +1,356 @@
|
|||||||
|
#include "pcode_test.h"
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
TEST pcode_BM1_GetBitLongLong_Main()
|
||||||
|
{
|
||||||
|
extern i8 pcode_BM1_GetBitLongLong(i8 arg, u4 bit);
|
||||||
|
ASSERTI8(pcode_BM1_GetBitLongLong(0xFF, 1), 2);
|
||||||
|
ASSERTI8(pcode_BM1_GetBitLongLong(I8_MAX, 8), 256);
|
||||||
|
ASSERTI8(pcode_BM1_GetBitLongLong(I8_MAX, 16), 65536);
|
||||||
|
ASSERTI8(pcode_BM1_GetBitLongLong(I8_MAX, 32), 4294967296LL);
|
||||||
|
ASSERTI8(pcode_BM1_GetBitLongLong(I8_MAX, 63), 0);
|
||||||
|
ASSERTI8(pcode_BM1_GetBitLongLong(0x0, 1), 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST pcode_BM2_GetBitInt_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_BM2_GetBitInt(i4 arg, u4 bit);
|
||||||
|
ASSERTI4(pcode_BM2_GetBitInt(0xFF, 1), 2);
|
||||||
|
ASSERTI4(pcode_BM2_GetBitInt(0, 1), 0);
|
||||||
|
ASSERTI4(pcode_BM2_GetBitInt(I4_MAX, 8), 256);
|
||||||
|
ASSERTI4(pcode_BM2_GetBitInt(I4_MAX, 16), 65536);
|
||||||
|
ASSERTI4(pcode_BM2_GetBitInt(I4_MAX, 24), 16777216);
|
||||||
|
ASSERTI4(pcode_BM2_GetBitInt(I4_MAX, 31), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_BM3_GetBitShort_Main()
|
||||||
|
{
|
||||||
|
extern i2 pcode_BM3_GetBitShort(i2 arg, u4 bit);
|
||||||
|
ASSERTI2(pcode_BM3_GetBitShort(0xFD, 1), 0);
|
||||||
|
ASSERTI2(pcode_BM3_GetBitShort(0x02, 1), 2);
|
||||||
|
ASSERTI2(pcode_BM3_GetBitShort(I2_MAX, 8), 256);
|
||||||
|
ASSERTI2(pcode_BM3_GetBitShort(I2_MAX, 14), 16384);
|
||||||
|
ASSERTI2(pcode_BM3_GetBitShort(I2_MAX, 15), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_BM4_GetBitChar_Main()
|
||||||
|
{
|
||||||
|
extern i1 pcode_BM4_GetBitChar(i1 arg, u4 bit);
|
||||||
|
ASSERTI1(pcode_BM4_GetBitChar(0xFD, 1), 0);
|
||||||
|
ASSERTI1(pcode_BM4_GetBitChar(0x02, 1), 2);
|
||||||
|
ASSERTI1(pcode_BM4_GetBitChar(0xFF, 7), -128);
|
||||||
|
ASSERTI1(pcode_BM4_GetBitChar(0x7F, 7), 0);
|
||||||
|
ASSERTI1(pcode_BM4_GetBitChar(0, 1), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
TEST pcode_BM5_GetBitUnsignedLongLong_Main()
|
||||||
|
{
|
||||||
|
extern u8 pcode_BM5_GetBitUnsignedLongLong(u8 arg, u8 bit);
|
||||||
|
ASSERTU8(pcode_BM5_GetBitUnsignedLongLong(0x02, 1), 2);
|
||||||
|
ASSERTU8(pcode_BM5_GetBitUnsignedLongLong(0xFFFFFFFFFFFFFFFDULL, 1), 0);
|
||||||
|
ASSERTU8(pcode_BM5_GetBitUnsignedLongLong(U8_MAX, 8), 256);
|
||||||
|
ASSERTU8(pcode_BM5_GetBitUnsignedLongLong(U8_MAX, 16), 65536);
|
||||||
|
ASSERTU8(pcode_BM5_GetBitUnsignedLongLong(U8_MAX, 24), 16777216ULL);
|
||||||
|
ASSERTU8(pcode_BM5_GetBitUnsignedLongLong(U8_MAX, 32), 4294967296ULL);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST pcode_BM6_GetBitUnsignedInt_Main()
|
||||||
|
{
|
||||||
|
extern u4 pcode_BM6_GetBitUnsignedInt(u4 arg, u4 bit);
|
||||||
|
ASSERTU4(pcode_BM6_GetBitUnsignedInt(0x02, 1), 2);
|
||||||
|
ASSERTU4(pcode_BM6_GetBitUnsignedInt(0xFD, 1), 0);
|
||||||
|
ASSERTU4(pcode_BM6_GetBitUnsignedInt(U4_MAX, 8), 256);
|
||||||
|
ASSERTU4(pcode_BM6_GetBitUnsignedInt(U4_MAX, 16), 65536);
|
||||||
|
ASSERTU4(pcode_BM6_GetBitUnsignedInt(U4_MAX, 24), 16777216);
|
||||||
|
ASSERTU4(pcode_BM6_GetBitUnsignedInt(U4_MAX, 31), 2147483648);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_BM7_GetBitUnsignedShort_Main()
|
||||||
|
{
|
||||||
|
extern u2 pcode_BM7_GetBitUnsignedShort(u2 arg, u4 bit);
|
||||||
|
ASSERTU2(pcode_BM7_GetBitUnsignedShort(0xFF, 1), 2);
|
||||||
|
ASSERTU2(pcode_BM7_GetBitUnsignedShort(0, 1), 0);
|
||||||
|
ASSERTU2(pcode_BM7_GetBitUnsignedShort(U2_MAX, 8), 256);
|
||||||
|
ASSERTU2(pcode_BM7_GetBitUnsignedShort(U2_MAX, 16), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_BM8_GetBitUnsignedChar_Main()
|
||||||
|
{
|
||||||
|
extern u1 pcode_BM8_GetBitUnsignedChar(u1 arg, u4 bit);
|
||||||
|
ASSERTU1(pcode_BM8_GetBitUnsignedChar(0xFF, 1), 2);
|
||||||
|
ASSERTU1(pcode_BM8_GetBitUnsignedChar(0, 1), 0);
|
||||||
|
ASSERTU1(pcode_BM8_GetBitUnsignedChar(U1_MAX, 4), 16);
|
||||||
|
ASSERTU1(pcode_BM8_GetBitUnsignedChar(U1_MAX, 8), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
TEST pcode_BM9_SetBitLongLong_Main()
|
||||||
|
{
|
||||||
|
extern i8 pcode_BM9_SetBitLongLong(i8 arg, u4 bit);
|
||||||
|
ASSERTI8(pcode_BM9_SetBitLongLong(0xFF, 1), 255);
|
||||||
|
ASSERTI8(pcode_BM9_SetBitLongLong(0, 1), 2);
|
||||||
|
ASSERTI8(pcode_BM9_SetBitLongLong(I8_MAX, 8), I8_MAX);
|
||||||
|
ASSERTI8(pcode_BM9_SetBitLongLong(I8_MAX, 16), I8_MAX);
|
||||||
|
ASSERTI8(pcode_BM9_SetBitLongLong(I8_MAX, 24), I8_MAX);
|
||||||
|
ASSERTI8(pcode_BM9_SetBitLongLong(I8_MAX, 32), I8_MAX);
|
||||||
|
ASSERTI8(pcode_BM9_SetBitLongLong(I8_MAX, 0), I8_MAX);
|
||||||
|
ASSERTI8(pcode_BM9_SetBitLongLong(4, 8), 260);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST pcode_BM10_SetBitInt_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_BM10_SetBitInt(i4 arg, u4 bit);
|
||||||
|
ASSERTI4(pcode_BM10_SetBitInt(0xFF, 1), 255);
|
||||||
|
ASSERTI4(pcode_BM10_SetBitInt(0, 1), 2);
|
||||||
|
ASSERTI4(pcode_BM10_SetBitInt(I4_MAX, 31), -1);
|
||||||
|
ASSERTI4(pcode_BM10_SetBitInt(I4_MAX, I4_MIN), I4_MAX);
|
||||||
|
ASSERTI4(pcode_BM10_SetBitInt(4, 8), 260);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_BM11_SetBitShort_Main()
|
||||||
|
{
|
||||||
|
extern i2 pcode_BM11_SetBitShort(i2 arg, i2 bit);
|
||||||
|
ASSERTI2(pcode_BM11_SetBitShort(0xFF, 1), 255);
|
||||||
|
ASSERTI2(pcode_BM11_SetBitShort(0, 1), 2);
|
||||||
|
ASSERTI2(pcode_BM11_SetBitShort(I2_MAX, 8), 32767);
|
||||||
|
ASSERTI2(pcode_BM11_SetBitShort(I2_MAX, 15), -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_BM12_SetBitChar_Main()
|
||||||
|
{
|
||||||
|
extern i1 pcode_BM12_SetBitChar(i1 arg, u1 bit);
|
||||||
|
ASSERTI1(pcode_BM12_SetBitChar(0xFF, 1), -1);
|
||||||
|
ASSERTI1(pcode_BM12_SetBitChar(0, 1), 2);
|
||||||
|
ASSERTI1(pcode_BM12_SetBitChar(I1_MAX, 8), 127);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
TEST pcode_BM12_SetBitUnsignedLongLong_Main()
|
||||||
|
{
|
||||||
|
extern u8 pcode_BM12_SetBitUnsignedLongLong(u8 arg, u8 bit);
|
||||||
|
ASSERTU8(pcode_BM12_SetBitUnsignedLongLong(0xFF, 1), 255);
|
||||||
|
ASSERTU8(pcode_BM12_SetBitUnsignedLongLong(0, 1), 2);
|
||||||
|
ASSERTU8(pcode_BM12_SetBitUnsignedLongLong(0, 8), 256);
|
||||||
|
ASSERTU8(pcode_BM12_SetBitUnsignedLongLong(0, 16), 65536);
|
||||||
|
ASSERTU8(pcode_BM12_SetBitUnsignedLongLong(0, 24), 16777216ULL);
|
||||||
|
ASSERTU8(pcode_BM12_SetBitUnsignedLongLong(0, 31), 2147483648ULL);
|
||||||
|
ASSERTU8(pcode_BM12_SetBitUnsignedLongLong(0, 32), 4294967296ULL);
|
||||||
|
ASSERTU8(pcode_BM12_SetBitUnsignedLongLong(U8_MAX, 8), U8_MAX);
|
||||||
|
ASSERTU8(pcode_BM12_SetBitUnsignedLongLong(U8_MAX, 16), U8_MAX);
|
||||||
|
ASSERTU8(pcode_BM12_SetBitUnsignedLongLong(U8_MAX, 24), U8_MAX);
|
||||||
|
ASSERTU8(pcode_BM12_SetBitUnsignedLongLong(U8_MAX, 32), U8_MAX);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
TEST pcode_BM13_SetLowBitUnsignedLongLong_Main()
|
||||||
|
{
|
||||||
|
extern u8 pcode_BM13_SetLowBitUnsignedLongLong(u8 arg, u8 bit);
|
||||||
|
ASSERTU8(pcode_BM13_SetLowBitUnsignedLongLong(0xFF, 1), 255);
|
||||||
|
ASSERTU8(pcode_BM13_SetLowBitUnsignedLongLong(0, 1), 2);
|
||||||
|
ASSERTU8(pcode_BM13_SetLowBitUnsignedLongLong(0, 8), 256);
|
||||||
|
ASSERTU8(pcode_BM13_SetLowBitUnsignedLongLong(0, 16), 65536);
|
||||||
|
ASSERTU8(pcode_BM13_SetLowBitUnsignedLongLong(0, 24), 16777216ULL);
|
||||||
|
ASSERTU8(pcode_BM13_SetLowBitUnsignedLongLong(0, 31), 2147483648ULL); // ensure no sign extension occurs
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST pcode_BM14_SetBitUnsignedInt_Main()
|
||||||
|
{
|
||||||
|
extern u4 pcode_BM14_SetBitUnsignedInt(u4 arg, u4 bit);
|
||||||
|
ASSERTU4(pcode_BM14_SetBitUnsignedInt(0xFF, 1), 255);
|
||||||
|
ASSERTU4(pcode_BM14_SetBitUnsignedInt(0, 1), 2);
|
||||||
|
ASSERTU4(pcode_BM14_SetBitUnsignedInt(0, 8), 256);
|
||||||
|
ASSERTU4(pcode_BM14_SetBitUnsignedInt(0, 16), 65536);
|
||||||
|
ASSERTU4(pcode_BM14_SetBitUnsignedInt(0, 24), 16777216);
|
||||||
|
ASSERTU4(pcode_BM14_SetBitUnsignedInt(0, 31), 2147483648);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_BM15_SetBitUnsignedShort_Main()
|
||||||
|
{
|
||||||
|
extern u2 pcode_BM15_SetBitUnsignedShort(u2 arg, u4 bit);
|
||||||
|
ASSERTU2(pcode_BM15_SetBitUnsignedShort(0xFF, 1), 255);
|
||||||
|
ASSERTU2(pcode_BM15_SetBitUnsignedShort(0, 1), 2);
|
||||||
|
ASSERTU2(pcode_BM15_SetBitUnsignedShort(0, 8), 256);
|
||||||
|
ASSERTU2(pcode_BM15_SetBitUnsignedShort(0, 15), 32768);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_BM16_SetBitUnsignedChar_Main()
|
||||||
|
{
|
||||||
|
extern u1 pcode_BM16_SetBitUnsignedChar(u1 arg, u1 bit);
|
||||||
|
ASSERTU1(pcode_BM16_SetBitUnsignedChar(0xFF, 1), 255);
|
||||||
|
ASSERTU1(pcode_BM16_SetBitUnsignedChar(0, 1), 2);
|
||||||
|
ASSERTU1(pcode_BM16_SetBitUnsignedChar(4, 1), 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
TEST pcode_BM17_ClearBitLongLong_Main()
|
||||||
|
{
|
||||||
|
extern i8 pcode_BM17_ClearBitLongLong(i8 arg, i8 bit);
|
||||||
|
ASSERTI8(pcode_BM17_ClearBitLongLong(0xFF, 1), 253);
|
||||||
|
ASSERTI8(pcode_BM17_ClearBitLongLong(0, 1), 0);
|
||||||
|
ASSERTI8(pcode_BM17_ClearBitLongLong(I8_MAX, 8), 9223372036854775551LL);
|
||||||
|
ASSERTI8(pcode_BM17_ClearBitLongLong(I8_MAX, 16), 9223372036854710271LL);
|
||||||
|
ASSERTI8(pcode_BM17_ClearBitLongLong(I8_MAX, 24), 9223372036837998591LL);
|
||||||
|
ASSERTI8(pcode_BM17_ClearBitLongLong(I8_MAX, 32), 9223372032559808511LL);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST pcode_BM18_ClearBitInt_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_BM18_ClearBitInt(i4 arg, i4 bit);
|
||||||
|
ASSERTI4(pcode_BM18_ClearBitInt(0xFF, 1), 253);
|
||||||
|
ASSERTI4(pcode_BM18_ClearBitInt(0, 1), 0);
|
||||||
|
ASSERTI4(pcode_BM18_ClearBitInt(I4_MAX, 8), 2147483391);
|
||||||
|
ASSERTI4(pcode_BM18_ClearBitInt(I4_MAX, 16), 2147418111);
|
||||||
|
ASSERTI4(pcode_BM18_ClearBitInt(I4_MAX, 31), 2147483647);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_BM19_ClearBitShort_Main()
|
||||||
|
{
|
||||||
|
extern i2 pcode_BM19_ClearBitShort(i2 arg, i2 bit);
|
||||||
|
ASSERTI2(pcode_BM19_ClearBitShort(0xFF, 1), 253);
|
||||||
|
ASSERTI2(pcode_BM19_ClearBitShort(0, 1), 0);
|
||||||
|
ASSERTI2(pcode_BM19_ClearBitShort(I2_MAX, 8), 32511);
|
||||||
|
ASSERTI2(pcode_BM19_ClearBitShort(I2_MAX, 15), 32767);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_BM20_ClearBitChar_Main()
|
||||||
|
{
|
||||||
|
extern i1 pcode_BM20_ClearBitChar(i1 arg, u1 bit);
|
||||||
|
ASSERTI1(pcode_BM20_ClearBitChar(0xFF, 1), -3);
|
||||||
|
ASSERTI1(pcode_BM20_ClearBitChar(0, 1), 0);
|
||||||
|
ASSERTI1(pcode_BM20_ClearBitChar(I1_MAX, 4), 111);
|
||||||
|
ASSERTI1(pcode_BM20_ClearBitChar(I1_MAX, 8), 127);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
TEST pcode_BM21_ClearBitUnsignedLongLong_Main()
|
||||||
|
{
|
||||||
|
extern u8 pcode_BM21_ClearBitUnsignedLongLong(u8 arg, u8 bit);
|
||||||
|
ASSERTU8(pcode_BM21_ClearBitUnsignedLongLong(0xFF, 1), 253);
|
||||||
|
ASSERTU8(pcode_BM21_ClearBitUnsignedLongLong(0, 1), 0);
|
||||||
|
ASSERTU8(pcode_BM21_ClearBitUnsignedLongLong(U8_MAX, 8), 18446744073709551359ULL);
|
||||||
|
ASSERTU8(pcode_BM21_ClearBitUnsignedLongLong(U8_MAX, 16), 18446744073709486079ULL);
|
||||||
|
ASSERTU8(pcode_BM21_ClearBitUnsignedLongLong(U8_MAX, 32), 18446744069414584319ULL);
|
||||||
|
ASSERTU8(pcode_BM21_ClearBitUnsignedLongLong(U8_MAX, 63), 9223372036854775807ULL);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST pcode_BM22_ClearBitUnsignedInt_Main()
|
||||||
|
{
|
||||||
|
extern u4 pcode_BM22_ClearBitUnsignedInt(u4 arg, u4 bit);
|
||||||
|
ASSERTU4(pcode_BM22_ClearBitUnsignedInt(0xFF, 1), 253);
|
||||||
|
ASSERTU4(pcode_BM22_ClearBitUnsignedInt(0, 1), 0);
|
||||||
|
ASSERTU4(pcode_BM22_ClearBitUnsignedInt(U4_MAX, 8), -257);
|
||||||
|
ASSERTU4(pcode_BM22_ClearBitUnsignedInt(U4_MAX, 16), -65537);
|
||||||
|
ASSERTU4(pcode_BM22_ClearBitUnsignedInt(U4_MAX, 24), -16777217);
|
||||||
|
ASSERTU4(pcode_BM22_ClearBitUnsignedInt(U4_MAX, 31), 2147483647);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_BM23_ClearBitUnsignedShort_Main()
|
||||||
|
{
|
||||||
|
extern u2 pcode_BM23_ClearBitUnsignedShort(u2 arg, u2 bit);
|
||||||
|
ASSERTU2(pcode_BM23_ClearBitUnsignedShort(0xFF, 1), 253);
|
||||||
|
ASSERTU2(pcode_BM23_ClearBitUnsignedShort(0, 1), 0);
|
||||||
|
ASSERTU2(pcode_BM23_ClearBitUnsignedShort(U2_MAX, 8), 65279);
|
||||||
|
ASSERTU2(pcode_BM23_ClearBitUnsignedShort(U2_MAX, 15), 32767);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_BM24_ClearBitUnsignedChar_Main()
|
||||||
|
{
|
||||||
|
extern u1 pcode_BM24_ClearBitUnsignedChar(u1 arg, u1 bit);
|
||||||
|
ASSERTU1(pcode_BM24_ClearBitUnsignedChar(0xFF, 1), 253);
|
||||||
|
ASSERTU1(pcode_BM24_ClearBitUnsignedChar(0, 1), 0);
|
||||||
|
ASSERTU1(pcode_BM24_ClearBitUnsignedChar(U1_MAX, 4), 239);
|
||||||
|
ASSERTU1(pcode_BM24_ClearBitUnsignedChar(U1_MAX, 8), 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
TEST pcode_BM25_ToggleBitLongLong_Main()
|
||||||
|
{
|
||||||
|
extern i8 pcode_BM25_ToggleBitLongLong(i8 arg, u4 bit);
|
||||||
|
ASSERTI8(pcode_BM25_ToggleBitLongLong(0xFF, 1), 253);
|
||||||
|
ASSERTI8(pcode_BM25_ToggleBitLongLong(0, 1), 2);
|
||||||
|
ASSERTI8(pcode_BM25_ToggleBitLongLong(I8_MAX, 8), 9223372036854775551LL);
|
||||||
|
ASSERTI8(pcode_BM25_ToggleBitLongLong(I8_MAX, 16), 9223372036854710271LL);
|
||||||
|
ASSERTI8(pcode_BM25_ToggleBitLongLong(I8_MAX, 32), 9223372032559808511LL);
|
||||||
|
ASSERTI8(pcode_BM25_ToggleBitLongLong(I8_MAX, 63), -1LL);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST pcode_BM26_ToggleBitInt_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_BM26_ToggleBitInt(i4 arg, i4 bit);
|
||||||
|
ASSERTI4(pcode_BM26_ToggleBitInt(0xFF, 1), 253);
|
||||||
|
ASSERTI4(pcode_BM26_ToggleBitInt(0, 1), 2);
|
||||||
|
ASSERTI4(pcode_BM26_ToggleBitInt(I4_MAX, 8), 2147483391);
|
||||||
|
ASSERTI4(pcode_BM26_ToggleBitInt(I4_MAX, 16), 2147418111);
|
||||||
|
ASSERTI4(pcode_BM26_ToggleBitInt(I4_MAX, 24), 2130706431);
|
||||||
|
ASSERTI4(pcode_BM26_ToggleBitInt(I4_MAX, 31), -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_BM27_ToggleBitShort_Main()
|
||||||
|
{
|
||||||
|
extern i2 pcode_BM27_ToggleBitShort(i2 arg, i2 bit);
|
||||||
|
ASSERTI2(pcode_BM27_ToggleBitShort(0xFF, 1), 253);
|
||||||
|
ASSERTI2(pcode_BM27_ToggleBitShort(0, 1), 2);
|
||||||
|
ASSERTI2(pcode_BM27_ToggleBitShort(I2_MAX, 8), 32511);
|
||||||
|
ASSERTI2(pcode_BM27_ToggleBitShort(I2_MAX, 15), -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_BM28_ToggleBitChar_Main()
|
||||||
|
{
|
||||||
|
extern i1 pcode_BM28_ToggleBitChar(i1 arg, u4 bit);
|
||||||
|
ASSERTI1(pcode_BM28_ToggleBitChar(0xFF, 1), -3);
|
||||||
|
ASSERTI1(pcode_BM28_ToggleBitChar(0, 1), 2);
|
||||||
|
ASSERTI1(pcode_BM28_ToggleBitChar(I1_MAX, 4), 111);
|
||||||
|
ASSERTI1(pcode_BM28_ToggleBitChar(I1_MAX, 8), 127);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
TEST pcode_BM29_ToggleBitUnsignedLongLong_Main()
|
||||||
|
{
|
||||||
|
extern u8 pcode_BM29_ToggleBitUnsignedLongLong(u8 arg, u4 bit);
|
||||||
|
ASSERTU8(pcode_BM29_ToggleBitUnsignedLongLong(0xFF, 1), 253);
|
||||||
|
ASSERTU8(pcode_BM29_ToggleBitUnsignedLongLong(0, 1), 2);
|
||||||
|
ASSERTU8(pcode_BM29_ToggleBitUnsignedLongLong(U8_MAX, 8), 18446744073709551359ULL);
|
||||||
|
ASSERTU8(pcode_BM29_ToggleBitUnsignedLongLong(U8_MAX, 16), 18446744073709486079ULL);
|
||||||
|
ASSERTU8(pcode_BM29_ToggleBitUnsignedLongLong(U8_MAX, 32), 18446744069414584319ULL);
|
||||||
|
ASSERTU8(pcode_BM29_ToggleBitUnsignedLongLong(U8_MAX, 63), 9223372036854775807ULL);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST pcode_BM30_ToggleBitUnsignedInt_Main()
|
||||||
|
{
|
||||||
|
extern u4 pcode_BM30_ToggleBitUnsignedInt(u4 arg, u4 bit);
|
||||||
|
ASSERTU4(pcode_BM30_ToggleBitUnsignedInt(0xFF, 1), 253);
|
||||||
|
ASSERTU4(pcode_BM30_ToggleBitUnsignedInt(0, 1), 2);
|
||||||
|
ASSERTU4(pcode_BM30_ToggleBitUnsignedInt(U4_MAX, 8), 4294967039);
|
||||||
|
ASSERTU4(pcode_BM30_ToggleBitUnsignedInt(U4_MAX, 16), 4294901759);
|
||||||
|
ASSERTU4(pcode_BM30_ToggleBitUnsignedInt(U4_MAX, 31), 2147483647);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_BM31_ToggleBitUnsignedShort_Main()
|
||||||
|
{
|
||||||
|
extern u2 pcode_BM31_ToggleBitUnsignedShort(u2 arg, u4 bit);
|
||||||
|
ASSERTU2(pcode_BM31_ToggleBitUnsignedShort(0xFF, 1), 253);
|
||||||
|
ASSERTU2(pcode_BM31_ToggleBitUnsignedShort(0, 1), 2);
|
||||||
|
ASSERTU2(pcode_BM31_ToggleBitUnsignedShort(U2_MAX, 8), 65279);
|
||||||
|
ASSERTU2(pcode_BM31_ToggleBitUnsignedShort(U2_MAX, 15), 32767);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_BM32_ToggleBitUnsignedChar_Main()
|
||||||
|
{
|
||||||
|
extern u1 pcode_BM32_ToggleBitUnsignedChar(u1 arg, u1 bit);
|
||||||
|
ASSERTU1(pcode_BM32_ToggleBitUnsignedChar(0xFF, 1), 253);
|
||||||
|
ASSERTU1(pcode_BM32_ToggleBitUnsignedChar(0, 1), 2);
|
||||||
|
ASSERTU1(pcode_BM32_ToggleBitUnsignedChar(U1_MAX, 4), 239);
|
||||||
|
ASSERTU1(pcode_BM32_ToggleBitUnsignedChar(U1_MAX, 7), 127);
|
||||||
|
}
|
||||||
|
|
||||||
|
MAIN BitManipulation_main() { }
|
||||||
@@ -0,0 +1,204 @@
|
|||||||
|
/* ###
|
||||||
|
* IP: GHIDRA
|
||||||
|
*
|
||||||
|
* 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 "pcode_test.h"
|
||||||
|
|
||||||
|
#define GET_BIT(typ, arg, bit) (arg & (((typ)1) << bit))
|
||||||
|
#define SET_BIT(typ, arg, bit) (arg | (((typ)1) << bit))
|
||||||
|
#define CLR_BIT(typ, arg, bit) (arg & (~(((typ)1) << bit)))
|
||||||
|
#define TGL_BIT(typ, arg, bit) (arg ^ (((typ)1) << bit))
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
i8 pcode_BM1_GetBitLongLong(i8 arg, u4 bit)
|
||||||
|
{
|
||||||
|
return GET_BIT(i8, arg, bit);
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_LONGLONG */
|
||||||
|
|
||||||
|
i4 pcode_BM2_GetBitInt(i4 arg, u4 bit)
|
||||||
|
{
|
||||||
|
return GET_BIT(i4, arg, bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
i2 pcode_BM3_GetBitShort(i2 arg, u4 bit)
|
||||||
|
{
|
||||||
|
return GET_BIT(i2, arg, bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
i1 pcode_BM4_GetBitChar(i1 arg, u4 bit)
|
||||||
|
{
|
||||||
|
return GET_BIT(i1, arg, bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
u8 pcode_BM5_GetBitUnsignedLongLong(u8 arg, u8 bit)
|
||||||
|
{
|
||||||
|
return GET_BIT(u8, arg, bit);
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_LONGLONG */
|
||||||
|
|
||||||
|
u4 pcode_BM6_GetBitUnsignedInt(u4 arg, u4 bit)
|
||||||
|
{
|
||||||
|
return GET_BIT(u4, arg, bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
u2 pcode_BM7_GetBitUnsignedShort(u2 arg, u4 bit)
|
||||||
|
{
|
||||||
|
return GET_BIT(u2, arg, bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
u1 pcode_BM8_GetBitUnsignedChar(u1 arg, u4 bit)
|
||||||
|
{
|
||||||
|
return GET_BIT(u1, arg, bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
i8 pcode_BM9_SetBitLongLong(i8 arg, u4 bit)
|
||||||
|
{
|
||||||
|
return SET_BIT(i8, arg, bit);
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_LONGLONG */
|
||||||
|
|
||||||
|
i4 pcode_BM10_SetBitInt(i4 arg, u4 bit)
|
||||||
|
{
|
||||||
|
return SET_BIT(i4, arg, bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
i2 pcode_BM11_SetBitShort(i2 arg, i2 bit)
|
||||||
|
{
|
||||||
|
return SET_BIT(i2, arg, bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
i1 pcode_BM12_SetBitChar(i1 arg, u1 bit)
|
||||||
|
{
|
||||||
|
return SET_BIT(i1, arg, bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
u8 pcode_BM12_SetBitUnsignedLongLong(u8 arg, u8 bit)
|
||||||
|
{
|
||||||
|
return SET_BIT(u8, arg, bit);
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_LONGLONG */
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
u8 pcode_BM13_SetLowBitUnsignedLongLong(u8 arg, u8 bit)
|
||||||
|
{
|
||||||
|
return SET_BIT(u8, arg, bit);
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_LONGLONG */
|
||||||
|
|
||||||
|
u4 pcode_BM14_SetBitUnsignedInt(u4 arg, u4 bit)
|
||||||
|
{
|
||||||
|
return SET_BIT(u4, arg, bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
u2 pcode_BM15_SetBitUnsignedShort(u2 arg, u4 bit)
|
||||||
|
{
|
||||||
|
return SET_BIT(u2, arg, bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
u1 pcode_BM16_SetBitUnsignedChar(u1 arg, u1 bit)
|
||||||
|
{
|
||||||
|
return SET_BIT(u1, arg, bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
i8 pcode_BM17_ClearBitLongLong(i8 arg, i8 bit)
|
||||||
|
{
|
||||||
|
return CLR_BIT(i8, arg, bit);
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_LONGLONG */
|
||||||
|
|
||||||
|
i4 pcode_BM18_ClearBitInt(i4 arg, i4 bit)
|
||||||
|
{
|
||||||
|
return CLR_BIT(i4, arg, bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
i2 pcode_BM19_ClearBitShort(i2 arg, i2 bit)
|
||||||
|
{
|
||||||
|
return CLR_BIT(i2, arg, bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
i1 pcode_BM20_ClearBitChar(i1 arg, u1 bit)
|
||||||
|
{
|
||||||
|
return CLR_BIT(i1, arg, bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
u8 pcode_BM21_ClearBitUnsignedLongLong(u8 arg, u8 bit)
|
||||||
|
{
|
||||||
|
return CLR_BIT(u8, arg, bit);
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_LONGLONG */
|
||||||
|
|
||||||
|
u4 pcode_BM22_ClearBitUnsignedInt(u4 arg, u4 bit)
|
||||||
|
{
|
||||||
|
return CLR_BIT(u4, arg, bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
u2 pcode_BM23_ClearBitUnsignedShort(u2 arg, u2 bit)
|
||||||
|
{
|
||||||
|
return CLR_BIT(u2, arg, bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
u1 pcode_BM24_ClearBitUnsignedChar(u1 arg, u1 bit)
|
||||||
|
{
|
||||||
|
return CLR_BIT(u1, arg, bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
i8 pcode_BM25_ToggleBitLongLong(i8 arg, u4 bit)
|
||||||
|
{
|
||||||
|
return TGL_BIT(i8, arg, bit);
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_LONGLONG */
|
||||||
|
|
||||||
|
i4 pcode_BM26_ToggleBitInt(i4 arg, i4 bit)
|
||||||
|
{
|
||||||
|
return TGL_BIT(i4, arg, bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
i2 pcode_BM27_ToggleBitShort(i2 arg, i2 bit)
|
||||||
|
{
|
||||||
|
return TGL_BIT(i2, arg, bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
i1 pcode_BM28_ToggleBitChar(i1 arg, u4 bit)
|
||||||
|
{
|
||||||
|
return TGL_BIT(i1, arg, bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
u8 pcode_BM29_ToggleBitUnsignedLongLong(u8 arg, u4 bit)
|
||||||
|
{
|
||||||
|
return TGL_BIT(u8, arg, bit);
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_LONGLONG */
|
||||||
|
|
||||||
|
u4 pcode_BM30_ToggleBitUnsignedInt(u4 arg, u4 bit)
|
||||||
|
{
|
||||||
|
return TGL_BIT(u4, arg, bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
u2 pcode_BM31_ToggleBitUnsignedShort(u2 arg, u4 bit)
|
||||||
|
{
|
||||||
|
return TGL_BIT(u2, arg, bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
u1 pcode_BM32_ToggleBitUnsignedChar(u1 arg, u1 bit)
|
||||||
|
{
|
||||||
|
return TGL_BIT(u1, arg, bit);
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
#include "pcode_test.h"
|
||||||
|
|
||||||
|
TEST pcode_DM1_IfElse_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_DM1_IfElse(i4 arg1);
|
||||||
|
ASSERTI4(pcode_DM1_IfElse(0), 0);
|
||||||
|
ASSERTI4(pcode_DM1_IfElse(0x42), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_DM2_IfElseIfElse_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_DM2_IfElseIfElse(i4 arg1);
|
||||||
|
ASSERTI4(pcode_DM2_IfElseIfElse(0), 0);
|
||||||
|
ASSERTI4(pcode_DM2_IfElseIfElse(0x42), 1);
|
||||||
|
ASSERTI4(pcode_DM2_IfElseIfElse(0x69), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_DM3_SmallSwitch_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_DM3_SmallSwitch(i4 arg1);
|
||||||
|
i4 ret = pcode_DM3_SmallSwitch(0);
|
||||||
|
ASSERTI4(pcode_DM3_SmallSwitch(0), 0);
|
||||||
|
ASSERTI4(pcode_DM3_SmallSwitch(0x42), 1);
|
||||||
|
ASSERTI4(pcode_DM3_SmallSwitch(0x69), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_DM4_MediumSwitch_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_DM4_MediumSwitch(i4 arg1);
|
||||||
|
ASSERTI4(pcode_DM4_MediumSwitch(0x42), 1);
|
||||||
|
ASSERTI4(pcode_DM4_MediumSwitch(0x69), 2);
|
||||||
|
ASSERTI4(pcode_DM4_MediumSwitch(0x101), 3);
|
||||||
|
ASSERTI4(pcode_DM4_MediumSwitch(-1), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_DM5_EQ_TernaryOperator_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_DM5_EQ_TernaryOperator(i4 arg1);
|
||||||
|
ASSERTI4(pcode_DM5_EQ_TernaryOperator(0x42), 0);
|
||||||
|
ASSERTI4(pcode_DM5_EQ_TernaryOperator(0x69), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_DM6_NE_TernaryOperator_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_DM6_NE_TernaryOperator(i4 arg1);
|
||||||
|
ASSERTI4(pcode_DM6_NE_TernaryOperator(0x42), 1);
|
||||||
|
ASSERTI4(pcode_DM6_NE_TernaryOperator(0x69), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_DM7_LT_TernaryOperator_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_DM7_LT_TernaryOperator(i4 arg1);
|
||||||
|
ASSERTI4(pcode_DM7_LT_TernaryOperator(0x42), 1);
|
||||||
|
ASSERTI4(pcode_DM7_LT_TernaryOperator(0x69), 0);
|
||||||
|
ASSERTI4(pcode_DM7_LT_TernaryOperator(0x72), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_DM8_GT_TernaryOperator_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_DM8_GT_TernaryOperator(i4 arg1);
|
||||||
|
ASSERTI4(pcode_DM8_GT_TernaryOperator(0x42), 0);
|
||||||
|
ASSERTI4(pcode_DM8_GT_TernaryOperator(0x69), 0);
|
||||||
|
ASSERTI4(pcode_DM8_GT_TernaryOperator(0x82), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_DM9_LE_TernaryOperator_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_DM9_LE_TernaryOperator(i4 arg1);
|
||||||
|
ASSERTI4(pcode_DM9_LE_TernaryOperator(0x42), 1);
|
||||||
|
ASSERTI4(pcode_DM9_LE_TernaryOperator(0x69), 1);
|
||||||
|
ASSERTI4(pcode_DM9_LE_TernaryOperator(0x72), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_DM10_GE_TernaryOperator_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_DM10_GE_TernaryOperator(i4 arg1);
|
||||||
|
ASSERTI4(pcode_DM10_GE_TernaryOperator(0x42), 0);
|
||||||
|
ASSERTI4(pcode_DM10_GE_TernaryOperator(0x69), 1);
|
||||||
|
ASSERTI4(pcode_DM10_GE_TernaryOperator(0x72), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
MAIN DecisionMaking_main() { }
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
/* ###
|
||||||
|
* IP: GHIDRA
|
||||||
|
*
|
||||||
|
* 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 "pcode_test.h"
|
||||||
|
|
||||||
|
i4 pcode_DM1_IfElse(i4 arg1)
|
||||||
|
{
|
||||||
|
if (arg1 == 0x42) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_DM2_IfElseIfElse(i4 arg1)
|
||||||
|
{
|
||||||
|
if (arg1 == 0x42) {
|
||||||
|
return 1;
|
||||||
|
} else if (arg1 == 0x69) {
|
||||||
|
return 2;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_DM3_SmallSwitch(i4 arg1)
|
||||||
|
{
|
||||||
|
switch (arg1) {
|
||||||
|
case 0x42:
|
||||||
|
return 1;
|
||||||
|
break;
|
||||||
|
case 0x69:
|
||||||
|
return 2;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_DM4_MediumSwitch(i4 arg1)
|
||||||
|
{
|
||||||
|
switch (arg1) {
|
||||||
|
case 0x42:
|
||||||
|
return 1;
|
||||||
|
break;
|
||||||
|
case 0x69:
|
||||||
|
return 2;
|
||||||
|
break;
|
||||||
|
case 0x101:
|
||||||
|
case 0x102:
|
||||||
|
case 0x103:
|
||||||
|
case 0x104:
|
||||||
|
case 0x105:
|
||||||
|
case 0x106:
|
||||||
|
case 0x107:
|
||||||
|
case 0x108:
|
||||||
|
return 3;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_DM5_EQ_TernaryOperator(i4 arg1)
|
||||||
|
{
|
||||||
|
return arg1 == 0x69 ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_DM6_NE_TernaryOperator(i4 arg1)
|
||||||
|
{
|
||||||
|
return arg1 != 0x69 ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_DM7_LT_TernaryOperator(i4 arg1)
|
||||||
|
{
|
||||||
|
return arg1 < 0x69 ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_DM8_GT_TernaryOperator(i4 arg1)
|
||||||
|
{
|
||||||
|
return arg1 > 0x69 ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_DM9_LE_TernaryOperator(i4 arg1)
|
||||||
|
{
|
||||||
|
return arg1 <= 0x69 ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_DM10_GE_TernaryOperator(i4 arg1)
|
||||||
|
{
|
||||||
|
return arg1 >= 0x69 ? 1 : 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
#include "pcode_test.h"
|
||||||
|
|
||||||
|
extern i4 GLOBAL;
|
||||||
|
|
||||||
|
TEST pcode_ModifyGlobal_Main()
|
||||||
|
{
|
||||||
|
extern void pcode_ModifyGlobal(i4 arg1);
|
||||||
|
pcode_ModifyGlobal(5);
|
||||||
|
ASSERTI4(GLOBAL, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_AccessAndModifyGlobal_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_AccessAndModifyGlobal(i4 arg1);
|
||||||
|
i4 ret = pcode_AccessAndModifyGlobal(6);
|
||||||
|
ASSERTI4(GLOBAL, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_AccessGlobal_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_AccessGlobal();
|
||||||
|
i4 ret = pcode_AccessGlobal();
|
||||||
|
ASSERTI4(GLOBAL, GLOBAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
MAIN GlobalVariables_main() { }
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/* ###
|
||||||
|
* IP: GHIDRA
|
||||||
|
*
|
||||||
|
* 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 "pcode_test.h"
|
||||||
|
|
||||||
|
extern i4 GLOBAL = 0;
|
||||||
|
|
||||||
|
void pcode_ModifyGlobal(i4 arg1)
|
||||||
|
{
|
||||||
|
GLOBAL = arg1;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_AccessAndModifyGlobal(i4 arg1)
|
||||||
|
{
|
||||||
|
i4 tmp;
|
||||||
|
|
||||||
|
tmp = GLOBAL;
|
||||||
|
GLOBAL = arg1;
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_AccessGlobal()
|
||||||
|
{
|
||||||
|
return GLOBAL;
|
||||||
|
}
|
||||||
@@ -0,0 +1,152 @@
|
|||||||
|
#include "pcode_test.h"
|
||||||
|
|
||||||
|
TEST pcode_StandardPostIncDoWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_StandardPostIncDoWhileLoop();
|
||||||
|
ASSERTI4(pcode_StandardPostIncDoWhileLoop(), 30);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_StandardPreIncDoWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_StandardPreIncDoWhileLoop();
|
||||||
|
ASSERTI4(pcode_StandardPreIncDoWhileLoop(), 30);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_StandardPostDecDoWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_StandardPostDecDoWhileLoop();
|
||||||
|
ASSERTI4(pcode_StandardPostDecDoWhileLoop(), 30);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_StandardPreDecDoWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_StandardPreDecDoWhileLoop();
|
||||||
|
ASSERTI4(pcode_StandardPreDecDoWhileLoop(), 30);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VarIncrementPostIncDoWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VarIncrementPostIncDoWhileLoop(i4 kk);
|
||||||
|
ASSERTI4(pcode_VarIncrementPostIncDoWhileLoop(5), 30);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VarIncrementPreIncDoWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VarIncrementPreIncDoWhileLoop(i4 kk);
|
||||||
|
ASSERTI4(pcode_VarIncrementPreIncDoWhileLoop(5), 30);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VarIncrementPostDecDoWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VarIncrementPostDecDoWhileLoop(i4 kk);
|
||||||
|
ASSERTI4(pcode_VarIncrementPostDecDoWhileLoop(5), 30);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VarIncrementPreDecDoWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VarIncrementPreDecDoWhileLoop(i4 kk);
|
||||||
|
ASSERTI4(pcode_VarIncrementPreDecDoWhileLoop(5), 30);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VarIterationPostIncDoWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VarIterationPostIncDoWhileLoop(i4 nn);
|
||||||
|
ASSERTI4(pcode_VarIterationPostIncDoWhileLoop(5), 30);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VarIterationPreIncDoWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VarIterationPreIncDoWhileLoop(i4 nn);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VarIterationPostDecDoWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VarIterationPostDecDoWhileLoop(i4 nn);
|
||||||
|
ASSERTI4(pcode_VarIterationPostDecDoWhileLoop(5), 30);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VarIterationPreDecDoWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VarIterationPreDecDoWhileLoop(i4 nn);
|
||||||
|
ASSERTI4(pcode_VarIterationPreDecDoWhileLoop(5), 30);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VariablePostIncDoWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VariablePostIncDoWhileLoop(i4 kk, i4 nn);
|
||||||
|
ASSERTI4(pcode_VariablePostIncDoWhileLoop(5, 10), 55);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VariablePreIncDoWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VariablePreIncDoWhileLoop(i4 kk, i4 nn);
|
||||||
|
ASSERTI4(pcode_VariablePreIncDoWhileLoop(5, 10), 55);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VariablePostDecDoWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VariablePostDecDoWhileLoop(i4 kk, i4 nn);
|
||||||
|
ASSERTI4(pcode_VariablePostDecDoWhileLoop(5, 10), 55);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VariablePreDecDoWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VariablePreDecDoWhileLoop(i4 kk, i4 nn);
|
||||||
|
ASSERTI4(pcode_VariablePreDecDoWhileLoop(5, 10), 55);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_SwitchedDoWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_SwitchedDoWhileLoop(i4 type, i4 kk, i4 jj, i4 nn);
|
||||||
|
ASSERTI4(pcode_SwitchedDoWhileLoop(5, 10, 15, 20), 315);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_UnSwitchedDoWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_UnSwitchedDoWhileLoop(i4 type, i4 kk, i4 jj, i4 nn);
|
||||||
|
ASSERTI4(pcode_UnSwitchedDoWhileLoop(5, 10, 15, 20), 315);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_JammedDoWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_JammedDoWhileLoop(i4 kk, i4 jj, i4 nn);
|
||||||
|
ASSERTI4(pcode_JammedDoWhileLoop(5, 10, 15), 5243040);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_UnJammedDoWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_UnJammedDoWhileLoop(i4 kk, i4 jj, i4 nn);
|
||||||
|
ASSERTI4(pcode_UnJammedDoWhileLoop(5, 10, 15), 5243040);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_RolledDoWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_RolledDoWhileLoop(i4 array[], i4 nn);
|
||||||
|
i4 array[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
||||||
|
ASSERTI4(pcode_RolledDoWhileLoop(array, 10), 55);
|
||||||
|
ASSERTI4(pcode_RolledDoWhileLoop(array, 5), 15);
|
||||||
|
ASSERTI4(pcode_RolledDoWhileLoop(array, 1), 1);
|
||||||
|
ASSERTI4(pcode_RolledDoWhileLoop(array, 0), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_Unrolled2DoWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_Unrolled2DoWhileLoop(i4 array[], i4 nn);
|
||||||
|
i4 array[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
||||||
|
ASSERTI4(pcode_Unrolled2DoWhileLoop(array, 10), 55);
|
||||||
|
ASSERTI4(pcode_Unrolled2DoWhileLoop(array, 5), 15);
|
||||||
|
ASSERTI4(pcode_Unrolled2DoWhileLoop(array, 1), 6);
|
||||||
|
ASSERTI4(pcode_Unrolled2DoWhileLoop(array, 0), 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_Unrolled4DoWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_Unrolled4DoWhileLoop(i4 array[], i4 nn);
|
||||||
|
i4 array[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
||||||
|
ASSERTI4(pcode_Unrolled4DoWhileLoop(array, 10), 55);
|
||||||
|
ASSERTI4(pcode_Unrolled4DoWhileLoop(array, 5), 15);
|
||||||
|
ASSERTI4(pcode_Unrolled4DoWhileLoop(array, 1), 15);
|
||||||
|
ASSERTI4(pcode_Unrolled4DoWhileLoop(array, 0), 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
MAIN IterativeProcessingDoWhile_main() { }
|
||||||
@@ -0,0 +1,303 @@
|
|||||||
|
/* ###
|
||||||
|
* IP: GHIDRA
|
||||||
|
*
|
||||||
|
* 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 "pcode_test.h"
|
||||||
|
|
||||||
|
i4 pcode_StandardPostIncDoWhileLoop()
|
||||||
|
{
|
||||||
|
i4 ii = 0;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
accum += 5;
|
||||||
|
} while (ii++ < 5);
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_StandardPreIncDoWhileLoop()
|
||||||
|
{
|
||||||
|
i4 ii = 0;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
accum += 5;
|
||||||
|
} while (++ii <= 5);
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_StandardPostDecDoWhileLoop()
|
||||||
|
{
|
||||||
|
i4 ii = 5;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
accum += 5;
|
||||||
|
} while (ii-- > 0);
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_StandardPreDecDoWhileLoop()
|
||||||
|
{
|
||||||
|
i4 ii = 5;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
accum += 5;
|
||||||
|
} while (--ii >= 0);
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VarIncrementPostIncDoWhileLoop(i4 kk)
|
||||||
|
{
|
||||||
|
i4 ii = 0;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
accum += kk;
|
||||||
|
} while (ii++ < 5);
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VarIncrementPreIncDoWhileLoop(i4 kk)
|
||||||
|
{
|
||||||
|
i4 ii = 0;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
accum += kk;
|
||||||
|
} while (++ii <= 5);
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VarIncrementPostDecDoWhileLoop(i4 kk)
|
||||||
|
{
|
||||||
|
i4 ii = 5;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
accum += kk;
|
||||||
|
} while (ii-- > 0);
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VarIncrementPreDecDoWhileLoop(i4 kk)
|
||||||
|
{
|
||||||
|
i4 ii = 5;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
accum += kk;
|
||||||
|
} while (--ii >= 0);
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VarIterationPostIncDoWhileLoop(i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii = 0;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
accum += 5;
|
||||||
|
} while (ii++ < nn);
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VarIterationPreIncDoWhileLoop(i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii = 0;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
accum += 5;
|
||||||
|
} while (++ii <= nn);
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VarIterationPostDecDoWhileLoop(i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii = nn;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
accum += 5;
|
||||||
|
} while (ii-- > 0);
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VarIterationPreDecDoWhileLoop(i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii = nn;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
accum += 5;
|
||||||
|
} while (--ii >= 0);
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VariablePostIncDoWhileLoop(i4 kk, i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii = 0;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
accum += kk;
|
||||||
|
} while (ii++ < nn);
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VariablePreIncDoWhileLoop(i4 kk, i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii = 0;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
accum += kk;
|
||||||
|
} while (++ii <= nn);
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VariablePostDecDoWhileLoop(i4 kk, i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii = nn;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
accum += kk;
|
||||||
|
} while (ii-- > 0);
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VariablePreDecDoWhileLoop(i4 kk, i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii = nn;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
accum += kk;
|
||||||
|
} while (--ii >= 0);
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_SwitchedDoWhileLoop(i4 type, i4 kk, i4 jj, i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii = 0;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
if (type == 10) {
|
||||||
|
accum += kk;
|
||||||
|
} else {
|
||||||
|
accum += jj;
|
||||||
|
}
|
||||||
|
} while (ii++ < nn);
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_UnSwitchedDoWhileLoop(i4 type, i4 kk, i4 jj, i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii = 0;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
if (type == 10) {
|
||||||
|
do {
|
||||||
|
accum += kk;
|
||||||
|
} while (ii++ < nn);
|
||||||
|
} else {
|
||||||
|
do {
|
||||||
|
accum += jj;
|
||||||
|
} while (ii++ < nn);
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_JammedDoWhileLoop(i4 kk, i4 jj, i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii = 0;
|
||||||
|
i4 accum1 = 0;
|
||||||
|
i4 accum2 = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
accum1 += kk;
|
||||||
|
accum2 += jj;
|
||||||
|
} while (ii++ < nn);
|
||||||
|
return (accum1 << 16) | accum2;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_UnJammedDoWhileLoop(i4 kk, i4 jj, i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii = 0;
|
||||||
|
i4 accum1 = 0;
|
||||||
|
i4 accum2 = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
accum1 += kk;
|
||||||
|
} while (ii++ < nn);
|
||||||
|
ii = 0;
|
||||||
|
do {
|
||||||
|
accum2 += jj;
|
||||||
|
} while (ii++ < nn);
|
||||||
|
return (accum1 << 16) | accum2;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_RolledDoWhileLoop(i4 array[], i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii = 0;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
accum += array[ii++];
|
||||||
|
} while (ii < nn);
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_Unrolled2DoWhileLoop(i4 array[], i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii = 0;
|
||||||
|
i4 accum = 0;
|
||||||
|
i4 limit = nn & (~1);
|
||||||
|
|
||||||
|
do {
|
||||||
|
accum += array[ii] + array[ii + 1];
|
||||||
|
ii += 2;
|
||||||
|
} while (ii < limit);
|
||||||
|
if (limit != nn) {
|
||||||
|
accum += array[ii];
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_Unrolled4DoWhileLoop(i4 array[], i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii = 0;
|
||||||
|
i4 accum = 0;
|
||||||
|
i4 limit = nn & (~3);
|
||||||
|
|
||||||
|
do {
|
||||||
|
accum += array[ii] + array[ii + 1] + array[ii + 2] + array[ii + 3];
|
||||||
|
ii += 4;
|
||||||
|
} while (ii < limit);
|
||||||
|
switch (nn - limit) {
|
||||||
|
case 3:
|
||||||
|
accum += array[ii++];
|
||||||
|
case 2:
|
||||||
|
accum += array[ii++];
|
||||||
|
case 1:
|
||||||
|
accum += array[ii];
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
@@ -0,0 +1,187 @@
|
|||||||
|
#include "pcode_test.h"
|
||||||
|
|
||||||
|
TEST pcode_StandardPostIncForLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_StandardPostIncForLoop();
|
||||||
|
ASSERTI4(pcode_StandardPostIncForLoop(), 25);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_StandardPreIncForLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_StandardPreIncForLoop();
|
||||||
|
ASSERTI4(pcode_StandardPreIncForLoop(), 30);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_StandardPostDecForLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_StandardPostDecForLoop();
|
||||||
|
ASSERTI4(pcode_StandardPostDecForLoop(), 25);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_StandardPreDecForLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_StandardPreDecForLoop();
|
||||||
|
ASSERTI4(pcode_StandardPreDecForLoop(), 30);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VarIncrementPostIncForLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VarIncrementPostIncForLoop(i4 kk);
|
||||||
|
ASSERTI4(pcode_VarIncrementPostIncForLoop(5), 25);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VarIncrementPreIncForLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VarIncrementPreIncForLoop(i4 kk);
|
||||||
|
ASSERTI4(pcode_VarIncrementPreIncForLoop(6), 36);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VarIncrementPreDecForLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VarIncrementPreDecForLoop(i4 kk);
|
||||||
|
ASSERTI4(pcode_VarIncrementPreDecForLoop(6), 36);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VarIncrementPostDecForLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VarIncrementPostDecForLoop(i4 kk);
|
||||||
|
ASSERTI4(pcode_VarIncrementPostDecForLoop(6), 30);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VarIterationPostIncForLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VarIterationPostIncForLoop(i4 nn);
|
||||||
|
ASSERTI4(pcode_VarIterationPostIncForLoop(6), 30);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VarIterationPreIncForLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VarIterationPreIncForLoop(i4 nn);
|
||||||
|
ASSERTI4(pcode_VarIterationPreIncForLoop(6), 35);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VarIterationPostDecForLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VarIterationPostDecForLoop(i4 nn);
|
||||||
|
ASSERTI4(pcode_VarIterationPostDecForLoop(6), 30);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VarIterationPreDecForLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VarIterationPreDecForLoop(i4 nn);
|
||||||
|
ASSERTI4(pcode_VarIterationPreDecForLoop(6), 35);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VariablePostIncForLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VariablePostIncForLoop(i4 kk, i4 nn);
|
||||||
|
ASSERTI4(pcode_VariablePostIncForLoop(6, 10), 60);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VariablePreIncForLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VariablePreIncForLoop(i4 kk, i4 nn);
|
||||||
|
ASSERTI4(pcode_VariablePreIncForLoop(6, 10), 66);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VariablePostDecForLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VariablePostDecForLoop(i4 kk, i4 nn);
|
||||||
|
ASSERTI4(pcode_VariablePostDecForLoop(6, 10), 60);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VariablePreDecForLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VariablePreDecForLoop(i4 kk, i4 nn);
|
||||||
|
ASSERTI4(pcode_VariablePreDecForLoop(6, 10), 66);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_SwitchedForLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_SwitchedForLoop(i4 type, i4 kk, i4 jj, i4 nn);
|
||||||
|
ASSERTI4(pcode_SwitchedForLoop(6, 10, 15, 20), 300);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_UnSwitchedForLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_UnSwitchedForLoop(i4 type, i4 kk, i4 jj, i4 nn);
|
||||||
|
ASSERTI4(pcode_UnSwitchedForLoop(6, 10, 15, 20), 300);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_JammedForLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_JammedForLoop(i4 kk, i4 jj, i4 nn);
|
||||||
|
ASSERTI4(pcode_JammedForLoop(6, 10, 15), 5898390);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_UnJammedForLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_UnJammedForLoop(i4 kk, i4 jj, i4 nn);
|
||||||
|
ASSERTI4(pcode_UnJammedForLoop(6, 10, 15), 5898390);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_RolledForLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_RolledForLoop(i4 array[], i4 nn);
|
||||||
|
i4 array[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
|
||||||
|
ASSERTI4(pcode_RolledForLoop(array, 5), 15);
|
||||||
|
ASSERTI4(pcode_RolledForLoop(array, 9), 45);
|
||||||
|
ASSERTI4(pcode_RolledForLoop(array, 1), 1);
|
||||||
|
ASSERTI4(pcode_RolledForLoop(array, 0), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_Unrolled2ForLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_Unrolled2ForLoop(i4 array[], i4 nn);
|
||||||
|
i4 array[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
|
||||||
|
ASSERTI4(pcode_Unrolled2ForLoop(array, 5), 15);
|
||||||
|
ASSERTI4(pcode_Unrolled2ForLoop(array, 9), 45);
|
||||||
|
ASSERTI4(pcode_Unrolled2ForLoop(array, 1), 1);
|
||||||
|
ASSERTI4(pcode_Unrolled2ForLoop(array, 0), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_Unrolled4ForLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_Unrolled4ForLoop(i4 array[], i4 nn);
|
||||||
|
i4 array[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
|
||||||
|
ASSERTI4(pcode_Unrolled4ForLoop(array, 5), 15);
|
||||||
|
ASSERTI4(pcode_Unrolled4ForLoop(array, 9), 45);
|
||||||
|
ASSERTI4(pcode_Unrolled4ForLoop(array, 1), 1);
|
||||||
|
ASSERTI4(pcode_Unrolled4ForLoop(array, 0), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_testNestedLoop1_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_testNestedLoop1(i4 a);
|
||||||
|
ASSERTI4(pcode_testNestedLoop1(-1), -80);
|
||||||
|
ASSERTI4(pcode_testNestedLoop1(1), 280);
|
||||||
|
ASSERTI4(pcode_testNestedLoop1(0), 100);
|
||||||
|
ASSERTI4(pcode_testNestedLoop1(2), 460);
|
||||||
|
ASSERTI4(pcode_testNestedLoop1(3), 640);
|
||||||
|
ASSERTI4(pcode_testNestedLoop1(257), 46360);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_testNestedLoop2_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_testNestedLoop2(i4 a);
|
||||||
|
ASSERTI4(pcode_testNestedLoop2(0), 0);
|
||||||
|
ASSERTI4(pcode_testNestedLoop2(1), 320);
|
||||||
|
ASSERTI4(pcode_testNestedLoop2(2), 640);
|
||||||
|
ASSERTI4(pcode_testNestedLoop2(257), 82240);
|
||||||
|
ASSERTI4(pcode_testNestedLoop2(3), 960);
|
||||||
|
ASSERTI4(pcode_testNestedLoop2(-1), -320);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_testNestedLoop3_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_testNestedLoop3(i4 a);
|
||||||
|
ASSERTI4(pcode_testNestedLoop3(0), 0);
|
||||||
|
ASSERTI4(pcode_testNestedLoop3(1), 12336);
|
||||||
|
ASSERTI4(pcode_testNestedLoop3(2), 24672);
|
||||||
|
ASSERTI4(pcode_testNestedLoop3(3), 37008);
|
||||||
|
ASSERTI4(pcode_testNestedLoop3(257), 3170352);
|
||||||
|
ASSERTI4(pcode_testNestedLoop3(-1), -12336);
|
||||||
|
}
|
||||||
|
|
||||||
|
MAIN IterativeProcessingFor_main() { }
|
||||||
|
|
||||||
@@ -0,0 +1,345 @@
|
|||||||
|
/* ###
|
||||||
|
* IP: GHIDRA
|
||||||
|
*
|
||||||
|
* 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 "pcode_test.h"
|
||||||
|
|
||||||
|
i4 pcode_StandardPostIncForLoop()
|
||||||
|
{
|
||||||
|
i4 ii;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
for (ii = 0; ii < 5; ii++) {
|
||||||
|
accum += 5;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_StandardPreIncForLoop()
|
||||||
|
{
|
||||||
|
i4 ii;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
for (ii = 0; ii <= 5; ++ii) {
|
||||||
|
accum += 5;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_StandardPostDecForLoop()
|
||||||
|
{
|
||||||
|
i4 ii;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
for (ii = 5; ii > 0; ii--) {
|
||||||
|
accum += 5;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_StandardPreDecForLoop()
|
||||||
|
{
|
||||||
|
i4 ii;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
for (ii = 5; ii >= 0; --ii) {
|
||||||
|
accum += 5;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VarIncrementPostIncForLoop(i4 kk)
|
||||||
|
{
|
||||||
|
i4 ii;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
for (ii = 0; ii < 5; ii++) {
|
||||||
|
accum += kk;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VarIncrementPreIncForLoop(i4 kk)
|
||||||
|
{
|
||||||
|
i4 ii;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
for (ii = 0; ii <= 5; ++ii) {
|
||||||
|
accum += kk;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VarIncrementPreDecForLoop(i4 kk)
|
||||||
|
{
|
||||||
|
i4 ii;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
for (ii = 5; ii >= 0; --ii) {
|
||||||
|
accum += kk;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VarIncrementPostDecForLoop(i4 kk)
|
||||||
|
{
|
||||||
|
i4 ii;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
for (ii = 5; ii > 0; ii--) {
|
||||||
|
accum += kk;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VarIterationPostIncForLoop(i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
for (ii = 0; ii < nn; ii++) {
|
||||||
|
accum += 5;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VarIterationPreIncForLoop(i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
for (ii = 0; ii <= nn; ++ii) {
|
||||||
|
accum += 5;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VarIterationPostDecForLoop(i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
for (ii = nn; ii > 0; ii--) {
|
||||||
|
accum += 5;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VarIterationPreDecForLoop(i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
for (ii = nn; ii >= 0; --ii) {
|
||||||
|
accum += 5;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VariablePostIncForLoop(i4 kk, i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
for (ii = 0; ii < nn; ii++) {
|
||||||
|
accum += kk;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VariablePreIncForLoop(i4 kk, i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
for (ii = 0; ii <= nn; ++ii) {
|
||||||
|
accum += kk;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VariablePostDecForLoop(i4 kk, i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
for (ii = nn; ii > 0; ii--) {
|
||||||
|
accum += kk;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VariablePreDecForLoop(i4 kk, i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
for (ii = nn; ii >= 0; --ii) {
|
||||||
|
accum += kk;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_SwitchedForLoop(i4 type, i4 kk, i4 jj, i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
for (ii = 0; ii < nn; ++ii) {
|
||||||
|
if (type == 10) {
|
||||||
|
accum += kk;
|
||||||
|
} else {
|
||||||
|
accum += jj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_UnSwitchedForLoop(i4 type, i4 kk, i4 jj, i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
if (type == 10) {
|
||||||
|
for (ii = 0; ii < nn; ++ii) {
|
||||||
|
accum += kk;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (ii = 0; ii < nn; ++ii) {
|
||||||
|
accum += jj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_JammedForLoop(i4 kk, i4 jj, i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii;
|
||||||
|
i4 accum1 = 0;
|
||||||
|
i4 accum2 = 0;
|
||||||
|
|
||||||
|
for (ii = 0; ii < nn; ++ii) {
|
||||||
|
accum1 += kk;
|
||||||
|
accum2 += jj;
|
||||||
|
}
|
||||||
|
return (accum1 << 16) | accum2;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_UnJammedForLoop(i4 kk, i4 jj, i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii;
|
||||||
|
i4 accum1 = 0;
|
||||||
|
i4 accum2 = 0;
|
||||||
|
|
||||||
|
for (ii = 0; ii < nn; ++ii) {
|
||||||
|
accum1 += kk;
|
||||||
|
}
|
||||||
|
for (ii = 0; ii < nn; ++ii) {
|
||||||
|
accum2 += jj;
|
||||||
|
}
|
||||||
|
return (accum1 << 16) | accum2;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_RolledForLoop(i4 array[], i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
for (ii = 0; ii < nn;) {
|
||||||
|
accum += array[ii++];
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_Unrolled2ForLoop(i4 array[], i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii;
|
||||||
|
i4 accum = 0;
|
||||||
|
i4 limit = nn & (~1);
|
||||||
|
|
||||||
|
for (ii = 0; ii < limit;) {
|
||||||
|
accum += array[ii] + array[ii + 1];
|
||||||
|
ii += 2;
|
||||||
|
}
|
||||||
|
if (limit != nn) {
|
||||||
|
accum += array[ii];
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_Unrolled4ForLoop(i4 array[], i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii;
|
||||||
|
i4 accum = 0;
|
||||||
|
i4 limit = nn & (~3);
|
||||||
|
|
||||||
|
for (ii = 0; ii < limit;) {
|
||||||
|
accum += array[ii] + array[ii + 1] + array[ii + 2] + array[ii + 3];
|
||||||
|
ii += 4;
|
||||||
|
}
|
||||||
|
switch (nn - limit) {
|
||||||
|
case 3:
|
||||||
|
accum += array[ii++];
|
||||||
|
case 2:
|
||||||
|
accum += array[ii++];
|
||||||
|
case 1:
|
||||||
|
accum += array[ii];
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_testNestedLoop1(i4 a)
|
||||||
|
{
|
||||||
|
i4 result = 0;
|
||||||
|
i4 i = 0, j = 0, k = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < 10; i++) {
|
||||||
|
k = i * a;
|
||||||
|
for (j = 1; j < 5; j++) {
|
||||||
|
result += k + j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_testNestedLoop2(i4 a)
|
||||||
|
{
|
||||||
|
i4 result = 0;
|
||||||
|
i4 i = 0, j = 0, k = 1;
|
||||||
|
|
||||||
|
for (i = 0; i < 10; i++) {
|
||||||
|
for (j = 1; j < 5; j++) {
|
||||||
|
result += a * (k + j);
|
||||||
|
}
|
||||||
|
k = i + 2;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_testNestedLoop3(i4 a)
|
||||||
|
{
|
||||||
|
i4 result = 0;
|
||||||
|
i4 i = 0, j = 0, k = 1;
|
||||||
|
|
||||||
|
for (i = 0; i < 10; i++) {
|
||||||
|
k += 1;
|
||||||
|
for (j = 1; j < 5; j++) {
|
||||||
|
result += a * (k + j);
|
||||||
|
}
|
||||||
|
k *= 2;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
@@ -0,0 +1,145 @@
|
|||||||
|
#include "pcode_test.h"
|
||||||
|
|
||||||
|
TEST pcode_StandardPostIncWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_StandardPostIncWhileLoop();
|
||||||
|
ASSERTI4(pcode_StandardPostIncWhileLoop(), 25);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_StandardPreIncWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_StandardPreIncWhileLoop();
|
||||||
|
ASSERTI4(pcode_StandardPreIncWhileLoop(), 25);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_StandardPostDecWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_StandardPostDecWhileLoop();
|
||||||
|
ASSERTI4(pcode_StandardPostDecWhileLoop(), 25);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_StandardPreDecWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_StandardPreDecWhileLoop();
|
||||||
|
ASSERTI4(pcode_StandardPreDecWhileLoop(), 25);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VarIncrementPostIncWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VarIncrementPostIncWhileLoop(i4 kk);
|
||||||
|
ASSERTI4(pcode_VarIncrementPostIncWhileLoop(5), 25);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VarIncrementPreIncWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VarIncrementPreIncWhileLoop(i4 kk);
|
||||||
|
ASSERTI4(pcode_VarIncrementPreIncWhileLoop(5), 25);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VarIncrementPostDecWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VarIncrementPostDecWhileLoop(i4 kk);
|
||||||
|
ASSERTI4(pcode_VarIncrementPostDecWhileLoop(5), 25);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VarIterationPostIncWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VarIterationPostIncWhileLoop(i4 nn);
|
||||||
|
ASSERTI4(pcode_VarIterationPostIncWhileLoop(5), 25);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VarIncrementPreDecWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VarIncrementPreDecWhileLoop(i4 kk);
|
||||||
|
ASSERTI4(pcode_VarIncrementPreDecWhileLoop(5), 25);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VarIterationPreIncWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VarIterationPreIncWhileLoop(i4 nn);
|
||||||
|
ASSERTI4(pcode_VarIterationPreIncWhileLoop(5), 25);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VarIterationPostDecWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VarIterationPostDecWhileLoop(i4 nn);
|
||||||
|
ASSERTI4(pcode_VarIterationPostDecWhileLoop(5), 25);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VarIterationPreDecWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VarIterationPreDecWhileLoop(i4 nn);
|
||||||
|
ASSERTI4(pcode_VarIterationPreDecWhileLoop(5), 25);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VariablePostIncWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VariablePostIncWhileLoop(i4 kk, i4 nn);
|
||||||
|
ASSERTI4(pcode_VariablePostIncWhileLoop(5, 10), 50);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VariablePreIncWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VariablePreIncWhileLoop(i4 kk, i4 nn);
|
||||||
|
ASSERTI4(pcode_VariablePreIncWhileLoop(5, 10), 50);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VariablePostDecWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VariablePostDecWhileLoop(i4 kk, i4 nn);
|
||||||
|
ASSERTI4(pcode_VariablePostDecWhileLoop(5, 10), 50);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_VariablePreDecWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_VariablePreDecWhileLoop(i4 kk, i4 nn);
|
||||||
|
ASSERTI4(pcode_VariablePreDecWhileLoop(5, 10), 50);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_UnSwitchedWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_UnSwitchedWhileLoop(i4 type, i4 kk, i4 jj, i4 nn);
|
||||||
|
ASSERTI4(pcode_UnSwitchedWhileLoop(5, 10, 15, 20), 300);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_SwitchedWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_SwitchedWhileLoop(i4 type, i4 kk, i4 jj, i4 nn);
|
||||||
|
ASSERTI4(pcode_SwitchedWhileLoop(5, 10, 15, 20), 300);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_JammedWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_JammedWhileLoop(i4 kk, i4 jj, i4 nn);
|
||||||
|
ASSERTI4(pcode_JammedWhileLoop(5, 10, 15), 4915350);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_UnJammedWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_UnJammedWhileLoop(i4 kk, i4 jj, i4 nn);
|
||||||
|
ASSERTI4(pcode_UnJammedWhileLoop(5, 10, 15), 4915350);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_RolledWhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_RolledWhileLoop(i4 array[], i4 nn);
|
||||||
|
i4 array[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||||
|
ASSERTI4(pcode_RolledWhileLoop(array, 5), 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_Unrolled2WhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_Unrolled2WhileLoop(i4 array[], i4 nn);
|
||||||
|
i4 array[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||||
|
ASSERTI4(pcode_Unrolled2WhileLoop(array, 5), 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_Unrolled4WhileLoop_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_Unrolled4WhileLoop(i4 array[], i4 nn);
|
||||||
|
i4 array[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||||
|
ASSERTI4(pcode_Unrolled4WhileLoop(array, 5), 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
MAIN IterativeProcessingWhile_main() { }
|
||||||
|
|
||||||
@@ -0,0 +1,303 @@
|
|||||||
|
/* ###
|
||||||
|
* IP: GHIDRA
|
||||||
|
*
|
||||||
|
* 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 "pcode_test.h"
|
||||||
|
|
||||||
|
i4 pcode_StandardPostIncWhileLoop()
|
||||||
|
{
|
||||||
|
i4 ii = 0;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
while (ii++ < 5) {
|
||||||
|
accum += 5;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_StandardPreIncWhileLoop()
|
||||||
|
{
|
||||||
|
i4 ii = 0;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
while (++ii <= 5) {
|
||||||
|
accum += 5;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_StandardPostDecWhileLoop()
|
||||||
|
{
|
||||||
|
i4 ii = 5;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
while (ii-- > 0) {
|
||||||
|
accum += 5;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_StandardPreDecWhileLoop()
|
||||||
|
{
|
||||||
|
i4 ii = 5;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
while (--ii >= 0) {
|
||||||
|
accum += 5;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VarIncrementPostIncWhileLoop(i4 kk)
|
||||||
|
{
|
||||||
|
i4 ii = 0;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
while (ii++ < 5) {
|
||||||
|
accum += kk;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VarIncrementPreIncWhileLoop(i4 kk)
|
||||||
|
{
|
||||||
|
i4 ii = 0;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
while (++ii <= 5) {
|
||||||
|
accum += kk;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VarIncrementPostDecWhileLoop(i4 kk)
|
||||||
|
{
|
||||||
|
i4 ii = 5;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
while (ii-- > 0) {
|
||||||
|
accum += kk;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VarIterationPostIncWhileLoop(i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii = 0;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
while (ii++ < nn) {
|
||||||
|
accum += 5;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VarIncrementPreDecWhileLoop(i4 kk)
|
||||||
|
{
|
||||||
|
i4 ii = 5;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
while (--ii >= 0) {
|
||||||
|
accum += kk;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VarIterationPreIncWhileLoop(i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii = 0;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
while (++ii <= nn) {
|
||||||
|
accum += 5;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VarIterationPostDecWhileLoop(i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii = nn;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
while (ii-- > 0) {
|
||||||
|
accum += 5;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VarIterationPreDecWhileLoop(i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii = nn;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
while (--ii >= 0) {
|
||||||
|
accum += 5;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VariablePostIncWhileLoop(i4 kk, i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii = 0;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
while (ii++ < nn) {
|
||||||
|
accum += kk;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VariablePreIncWhileLoop(i4 kk, i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii = 0;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
while (++ii <= nn) {
|
||||||
|
accum += kk;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VariablePostDecWhileLoop(i4 kk, i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii = nn;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
while (ii-- > 0) {
|
||||||
|
accum += kk;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_VariablePreDecWhileLoop(i4 kk, i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii = nn;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
while (--ii >= 0) {
|
||||||
|
accum += kk;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_UnSwitchedWhileLoop(i4 type, i4 kk, i4 jj, i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii = 0;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
if (type == 10) {
|
||||||
|
while (ii++ < nn) {
|
||||||
|
accum += kk;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
while (ii++ < nn) {
|
||||||
|
accum += jj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_SwitchedWhileLoop(i4 type, i4 kk, i4 jj, i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii = 0;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
while (ii++ < nn) {
|
||||||
|
if (type == 10) {
|
||||||
|
accum += kk;
|
||||||
|
} else {
|
||||||
|
accum += jj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_JammedWhileLoop(i4 kk, i4 jj, i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii = 0;
|
||||||
|
i4 accum1 = 0;
|
||||||
|
i4 accum2 = 0;
|
||||||
|
|
||||||
|
while (ii++ < nn) {
|
||||||
|
accum1 += kk;
|
||||||
|
accum2 += jj;
|
||||||
|
}
|
||||||
|
return (accum1 << 16) | accum2;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_UnJammedWhileLoop(i4 kk, i4 jj, i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii = 0;
|
||||||
|
i4 accum1 = 0;
|
||||||
|
i4 accum2 = 0;
|
||||||
|
|
||||||
|
while (ii++ < nn) {
|
||||||
|
accum1 += kk;
|
||||||
|
}
|
||||||
|
ii = 0;
|
||||||
|
while (ii++ < nn) {
|
||||||
|
accum2 += jj;
|
||||||
|
}
|
||||||
|
return (accum1 << 16) | accum2;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_RolledWhileLoop(i4 array[], i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii = 0;
|
||||||
|
i4 accum = 0;
|
||||||
|
|
||||||
|
while (ii < nn) {
|
||||||
|
accum += array[ii++];
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_Unrolled2WhileLoop(i4 array[], i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii = 0;
|
||||||
|
i4 accum = 0;
|
||||||
|
i4 limit = nn & (~1);
|
||||||
|
|
||||||
|
while (ii < limit) {
|
||||||
|
accum += array[ii] + array[ii + 1];
|
||||||
|
ii += 2;
|
||||||
|
}
|
||||||
|
if (limit != nn) {
|
||||||
|
accum += array[ii];
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_Unrolled4WhileLoop(i4 array[], i4 nn)
|
||||||
|
{
|
||||||
|
i4 ii = 0;
|
||||||
|
i4 accum = 0;
|
||||||
|
i4 limit = nn & (~3);
|
||||||
|
|
||||||
|
while (ii < limit) {
|
||||||
|
accum += array[ii] + array[ii + 1] + array[ii + 2] + array[ii + 3];
|
||||||
|
ii += 4;
|
||||||
|
}
|
||||||
|
switch (nn - limit) {
|
||||||
|
case 3:
|
||||||
|
accum += array[ii++];
|
||||||
|
case 2:
|
||||||
|
accum += array[ii++];
|
||||||
|
case 1:
|
||||||
|
accum += array[ii];
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
@@ -0,0 +1,256 @@
|
|||||||
|
#include "pcode_test.h"
|
||||||
|
|
||||||
|
TEST pcode_PP1_12_InferPointerArgumentInt_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_PP1_12_InferPointerArgumentInt(i4 * arg1);
|
||||||
|
i4 arg = 5;
|
||||||
|
ASSERTI4(pcode_PP1_12_InferPointerArgumentInt(&arg), -1);
|
||||||
|
arg = sizeof(i4)*8-1;
|
||||||
|
ASSERTI4(pcode_PP1_12_InferPointerArgumentInt(&arg), -1);
|
||||||
|
arg = 0;
|
||||||
|
ASSERTI4(pcode_PP1_12_InferPointerArgumentInt(&arg), -7);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP1_13_InferPointerArgumentShort_Main()
|
||||||
|
{
|
||||||
|
extern i2 pcode_PP1_13_InferPointerArgumentShort(i2 * arg1);
|
||||||
|
i2 arg = 5;
|
||||||
|
ASSERTI4(pcode_PP1_13_InferPointerArgumentShort(&arg), -1);
|
||||||
|
arg = sizeof(i2)*8-1;
|
||||||
|
ASSERTI4(pcode_PP1_13_InferPointerArgumentShort(&arg), -1);
|
||||||
|
arg = 1;
|
||||||
|
ASSERTI4(pcode_PP1_13_InferPointerArgumentShort(&arg), -4);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP1_14_InferPointerArgumentChar_Main()
|
||||||
|
{
|
||||||
|
extern i1 pcode_PP1_14_InferPointerArgumentChar(i1 * arg1);
|
||||||
|
i1 arg = 5;
|
||||||
|
ASSERTI4(pcode_PP1_14_InferPointerArgumentChar(&arg), -1);
|
||||||
|
arg = sizeof(i1)*8-1;
|
||||||
|
ASSERTI4(pcode_PP1_14_InferPointerArgumentChar(&arg), -1);
|
||||||
|
arg = 1;
|
||||||
|
ASSERTI4(pcode_PP1_14_InferPointerArgumentChar(&arg), -4);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
TEST pcode_PP1_15_InferPointerArgumentUnsignedLongLong_Main()
|
||||||
|
{
|
||||||
|
extern u8 pcode_PP1_15_InferPointerArgumentUnsignedLongLong(u8 * arg1);
|
||||||
|
u8 arg = 5;
|
||||||
|
ASSERTI4(pcode_PP1_15_InferPointerArgumentUnsignedLongLong(&arg), -1);
|
||||||
|
arg = sizeof(u8)*8-1;
|
||||||
|
ASSERTI4(pcode_PP1_15_InferPointerArgumentUnsignedLongLong(&arg), -1);
|
||||||
|
arg = 1;
|
||||||
|
ASSERTI4(pcode_PP1_15_InferPointerArgumentUnsignedLongLong(&arg), -4);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST pcode_PP1_16_InferPointerArgumentUnsignedInt_Main()
|
||||||
|
{
|
||||||
|
extern u4 pcode_PP1_16_InferPointerArgumentUnsignedInt(u4 * arg1);
|
||||||
|
u4 arg = 5;
|
||||||
|
ASSERTI4(pcode_PP1_16_InferPointerArgumentUnsignedInt(&arg), -1);
|
||||||
|
arg = sizeof(u4)*8-1;
|
||||||
|
ASSERTI4(pcode_PP1_16_InferPointerArgumentUnsignedInt(&arg), -1);
|
||||||
|
arg = 0;
|
||||||
|
ASSERTI4(pcode_PP1_16_InferPointerArgumentUnsignedInt(&arg), -7);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP1_17_InferPointerArgumentUnsignedShort_Main()
|
||||||
|
{
|
||||||
|
extern u2 pcode_PP1_17_InferPointerArgumentUnsignedShort(u2 * arg1);
|
||||||
|
u2 arg = 5;
|
||||||
|
ASSERTI4(pcode_PP1_17_InferPointerArgumentUnsignedShort(&arg), 65535);
|
||||||
|
arg = sizeof(u2)*8-1;
|
||||||
|
ASSERTI4(pcode_PP1_17_InferPointerArgumentUnsignedShort(&arg), 65535);
|
||||||
|
arg = 0;
|
||||||
|
ASSERTI4(pcode_PP1_17_InferPointerArgumentUnsignedShort(&arg), 65529);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP1_18_InferPointerArgumentUnsignedChar_Main()
|
||||||
|
{
|
||||||
|
extern u1 pcode_PP1_18_InferPointerArgumentUnsignedChar(u1 * arg1);
|
||||||
|
u1 arg = 5;
|
||||||
|
ASSERTI4(pcode_PP1_18_InferPointerArgumentUnsignedChar(&arg), 255);
|
||||||
|
arg = sizeof(u1)*8-1;
|
||||||
|
ASSERTI4(pcode_PP1_18_InferPointerArgumentUnsignedChar(&arg), 255);
|
||||||
|
arg = 0;
|
||||||
|
ASSERTI4(pcode_PP1_18_InferPointerArgumentUnsignedChar(&arg), 249);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
TEST pcode_PP1_19_InferPointerArgumentFloat_Main()
|
||||||
|
{
|
||||||
|
extern f4 pcode_PP1_19_InferPointerArgumentFloat(f4 * arg1);
|
||||||
|
f4 arg = 5;
|
||||||
|
ASSERTF4(pcode_PP1_19_InferPointerArgumentFloat(&arg), -2.0);
|
||||||
|
arg = PI_SHORT;
|
||||||
|
ASSERTF4(pcode_PP1_19_InferPointerArgumentFloat(&arg), -3.860000);
|
||||||
|
arg = -PI_SHORT;
|
||||||
|
ASSERTF4(pcode_PP1_19_InferPointerArgumentFloat(&arg), -10.1400000);
|
||||||
|
arg = 0.0;
|
||||||
|
ASSERTF4(pcode_PP1_19_InferPointerArgumentFloat(&arg), -7.000000);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
TEST pcode_PP1_20_InferPointerArgumentDouble_Main()
|
||||||
|
{
|
||||||
|
extern f8 pcode_PP1_20_InferPointerArgumentDouble(f8 * arg1);
|
||||||
|
f8 arg = 5;
|
||||||
|
ASSERTF8(pcode_PP1_20_InferPointerArgumentDouble(&arg), -2.0);
|
||||||
|
arg = PI_SHORT;
|
||||||
|
ASSERTF8(pcode_PP1_20_InferPointerArgumentDouble(&arg), -3.86);
|
||||||
|
arg = -PI_SHORT;
|
||||||
|
ASSERTF8(pcode_PP1_20_InferPointerArgumentDouble(&arg), -10.14);
|
||||||
|
arg = 0.0;
|
||||||
|
ASSERTF8(pcode_PP1_20_InferPointerArgumentDouble(&arg), -7);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
TEST pcode_PP1_1_InferArgumentLongLong_Main()
|
||||||
|
{
|
||||||
|
extern i8 pcode_PP1_1_InferArgumentLongLong(i8* arg1);
|
||||||
|
i8 arg = 5;
|
||||||
|
ASSERTI4(pcode_PP1_1_InferArgumentLongLong(&arg), -1);
|
||||||
|
arg = sizeof(i8)*8-1;
|
||||||
|
ASSERTI4(pcode_PP1_1_InferArgumentLongLong(&arg), -1);
|
||||||
|
arg = 1;
|
||||||
|
ASSERTI4(pcode_PP1_1_InferArgumentLongLong(&arg), -4);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST pcode_PP1_2_InferArgumentInt_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_PP1_2_InferArgumentInt(i4 arg1);
|
||||||
|
i4 arg = 5;
|
||||||
|
ASSERTI4(pcode_PP1_2_InferArgumentInt(arg), -1);
|
||||||
|
arg = sizeof(i4)*8-1;
|
||||||
|
ASSERTI4(pcode_PP1_2_InferArgumentInt(arg), -1);
|
||||||
|
arg = 1;
|
||||||
|
ASSERTI4(pcode_PP1_2_InferArgumentInt(arg), -4);
|
||||||
|
arg = 0;
|
||||||
|
ASSERTI4(pcode_PP1_2_InferArgumentInt(arg), -7);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP1_3_InferArgumentShort_Main()
|
||||||
|
{
|
||||||
|
extern i2 pcode_PP1_3_InferArgumentShort(i2 arg1);
|
||||||
|
i2 arg = 5;
|
||||||
|
ASSERTI4(pcode_PP1_3_InferArgumentShort(arg), -1);
|
||||||
|
arg = sizeof(i2)*8-1;
|
||||||
|
ASSERTI4(pcode_PP1_3_InferArgumentShort(arg), -1);
|
||||||
|
arg = 1;
|
||||||
|
ASSERTI4(pcode_PP1_3_InferArgumentShort(arg), -4);
|
||||||
|
arg = 0;
|
||||||
|
ASSERTI4(pcode_PP1_3_InferArgumentShort(arg), -7);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP1_4_InferArgumentChar_Main()
|
||||||
|
{
|
||||||
|
extern i1 pcode_PP1_4_InferArgumentChar(i1 arg1);
|
||||||
|
i1 arg = 5;
|
||||||
|
ASSERTI4(pcode_PP1_4_InferArgumentChar(arg), -1);
|
||||||
|
arg = sizeof(i1)*8-1;
|
||||||
|
ASSERTI4(pcode_PP1_4_InferArgumentChar(arg), -1);
|
||||||
|
arg = 1;
|
||||||
|
ASSERTI4(pcode_PP1_4_InferArgumentChar(arg), -4);
|
||||||
|
arg = 0;
|
||||||
|
ASSERTI4(pcode_PP1_4_InferArgumentChar(arg), -7);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
TEST pcode_PP1_5_InferArgumentUnsignedLongLong_Main()
|
||||||
|
{
|
||||||
|
extern u8 pcode_PP1_5_InferArgumentUnsignedLongLong(u8 arg1);
|
||||||
|
u8 arg = 5;
|
||||||
|
ASSERTI4(pcode_PP1_5_InferArgumentUnsignedLongLong(arg), -1);
|
||||||
|
arg = sizeof(u8)*8-1;
|
||||||
|
ASSERTI4(pcode_PP1_5_InferArgumentUnsignedLongLong(arg), -1);
|
||||||
|
arg = 0;
|
||||||
|
ASSERTI4(pcode_PP1_5_InferArgumentUnsignedLongLong(arg), -7);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST pcode_PP1_6_InferArgumentUnsignedInt_Main()
|
||||||
|
{
|
||||||
|
extern u4 pcode_PP1_6_InferArgumentUnsignedInt(u4 arg1);
|
||||||
|
u4 arg = 5;
|
||||||
|
ASSERTI4(pcode_PP1_6_InferArgumentUnsignedInt(arg), -1);
|
||||||
|
arg = sizeof(u4)*8-1;
|
||||||
|
ASSERTI4(pcode_PP1_6_InferArgumentUnsignedInt(arg), -1);
|
||||||
|
arg = 0;
|
||||||
|
ASSERTI4(pcode_PP1_6_InferArgumentUnsignedInt(arg), -7);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP1_7_InferArgumentUnsignedShort_Main()
|
||||||
|
{
|
||||||
|
extern u2 pcode_PP1_7_InferArgumentUnsignedShort(u2 arg1);
|
||||||
|
u2 arg = 5;
|
||||||
|
ASSERTI4(pcode_PP1_7_InferArgumentUnsignedShort(arg), 65535);
|
||||||
|
arg = sizeof(u2)*8-1;
|
||||||
|
ASSERTI4(pcode_PP1_7_InferArgumentUnsignedShort(arg), 65535);
|
||||||
|
arg = 0;
|
||||||
|
ASSERTI4(pcode_PP1_7_InferArgumentUnsignedShort(arg), 65529);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP1_8_InferArgumentUnsignedChar_Main()
|
||||||
|
{
|
||||||
|
extern u1 pcode_PP1_8_InferArgumentUnsignedChar(u1 arg1);
|
||||||
|
u1 arg = 5;
|
||||||
|
ASSERTI4(pcode_PP1_8_InferArgumentUnsignedChar(arg), 255);
|
||||||
|
arg = sizeof(u2)*8-1;
|
||||||
|
ASSERTI4(pcode_PP1_8_InferArgumentUnsignedChar(arg), 255);
|
||||||
|
arg = 0;
|
||||||
|
ASSERTI4(pcode_PP1_8_InferArgumentUnsignedChar(arg), 249);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
TEST pcode_PP1_9_InferArgumentFloat_Main()
|
||||||
|
{
|
||||||
|
extern f4 pcode_PP1_9_InferArgumentFloat(f4 arg1);
|
||||||
|
f4 arg = 5;
|
||||||
|
ASSERTF4(pcode_PP1_9_InferArgumentFloat(arg), (f4) -2.0);
|
||||||
|
arg = PI_SHORT;
|
||||||
|
ASSERTF4(pcode_PP1_9_InferArgumentFloat(arg), (f4) -3.860000);
|
||||||
|
arg = -PI_SHORT;
|
||||||
|
ASSERTF4(pcode_PP1_9_InferArgumentFloat(arg), (f4) -10.140000);
|
||||||
|
arg = 0.0;
|
||||||
|
ASSERTF4(pcode_PP1_9_InferArgumentFloat(arg), (f4) -7.000000);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
TEST pcode_PP1_10_InferArgumentDouble_Main()
|
||||||
|
{
|
||||||
|
extern f8 pcode_PP1_10_InferArgumentDouble(f8 arg1);
|
||||||
|
f8 arg = 5;
|
||||||
|
ASSERTF8(pcode_PP1_10_InferArgumentDouble(arg), (f8) -2.0);
|
||||||
|
arg = PI_SHORT;
|
||||||
|
ASSERTF8(pcode_PP1_10_InferArgumentDouble(arg), (f8) -3.86);
|
||||||
|
arg = -PI_SHORT;
|
||||||
|
ASSERTF8(pcode_PP1_10_InferArgumentDouble(arg), (f8) -10.14);
|
||||||
|
arg = 0.0;
|
||||||
|
ASSERTF8(pcode_PP1_10_InferArgumentDouble(arg), (f8) -7);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
TEST pcode_PP1_11_InferPointerArgumentLongLong_Main()
|
||||||
|
{
|
||||||
|
extern i8 pcode_PP1_11_InferPointerArgumentLongLong(i8 * arg1);
|
||||||
|
i8 arg = 5;
|
||||||
|
ASSERTI4(pcode_PP1_11_InferPointerArgumentLongLong(&arg), -1);
|
||||||
|
arg = sizeof(i8)*8-1;
|
||||||
|
ASSERTI4(pcode_PP1_11_InferPointerArgumentLongLong(&arg), -1);
|
||||||
|
arg = 1;
|
||||||
|
ASSERTI4(pcode_PP1_11_InferPointerArgumentLongLong(&arg), -4);
|
||||||
|
arg = 0;
|
||||||
|
ASSERTI4(pcode_PP1_11_InferPointerArgumentLongLong(&arg), -7);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
MAIN ParameterPassing1_main() { }
|
||||||
|
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
/* ###
|
||||||
|
* IP: GHIDRA
|
||||||
|
*
|
||||||
|
* 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 "pcode_test.h"
|
||||||
|
|
||||||
|
i4 pcode_PP1_12_InferPointerArgumentInt(i4 * arg1)
|
||||||
|
{
|
||||||
|
return (-7) >> (*arg1);
|
||||||
|
}
|
||||||
|
|
||||||
|
i2 pcode_PP1_13_InferPointerArgumentShort(i2 * arg1)
|
||||||
|
{
|
||||||
|
return (-7) >> (*arg1);
|
||||||
|
}
|
||||||
|
|
||||||
|
i1 pcode_PP1_14_InferPointerArgumentChar(i1 * arg1)
|
||||||
|
{
|
||||||
|
return (-7) >> (*arg1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
u8 pcode_PP1_15_InferPointerArgumentUnsignedLongLong(u8 * arg1)
|
||||||
|
{
|
||||||
|
return (-7) >> (*arg1);
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_LONGLONG */
|
||||||
|
|
||||||
|
u4 pcode_PP1_16_InferPointerArgumentUnsignedInt(u4 * arg1)
|
||||||
|
{
|
||||||
|
return (-7) >> (*arg1);
|
||||||
|
}
|
||||||
|
|
||||||
|
u2 pcode_PP1_17_InferPointerArgumentUnsignedShort(u2 * arg1)
|
||||||
|
{
|
||||||
|
return (-7) >> (*arg1);
|
||||||
|
}
|
||||||
|
|
||||||
|
u1 pcode_PP1_18_InferPointerArgumentUnsignedChar(u1 * arg1)
|
||||||
|
{
|
||||||
|
return (-7) >> (*arg1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
f4 pcode_PP1_19_InferPointerArgumentFloat(f4 * arg1)
|
||||||
|
{
|
||||||
|
return (-7) + (*arg1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
f8 pcode_PP1_20_InferPointerArgumentDouble(f8 * arg1)
|
||||||
|
{
|
||||||
|
return (-7) + (*arg1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
i8 pcode_PP1_1_InferArgumentLongLong(i8 * arg1)
|
||||||
|
{
|
||||||
|
return (-7) >> *arg1;
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_LONGLONG */
|
||||||
|
|
||||||
|
i4 pcode_PP1_2_InferArgumentInt(i4 arg1)
|
||||||
|
{
|
||||||
|
return (-7) >> arg1;
|
||||||
|
}
|
||||||
|
|
||||||
|
i2 pcode_PP1_3_InferArgumentShort(i2 arg1)
|
||||||
|
{
|
||||||
|
return (-7) >> arg1;
|
||||||
|
}
|
||||||
|
|
||||||
|
i1 pcode_PP1_4_InferArgumentChar(i1 arg1)
|
||||||
|
{
|
||||||
|
return (-7) >> arg1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
u8 pcode_PP1_5_InferArgumentUnsignedLongLong(u8 arg1)
|
||||||
|
{
|
||||||
|
return (-7) >> arg1;
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_LONGLONG */
|
||||||
|
|
||||||
|
u4 pcode_PP1_6_InferArgumentUnsignedInt(u4 arg1)
|
||||||
|
{
|
||||||
|
return (-7) >> arg1;
|
||||||
|
}
|
||||||
|
|
||||||
|
u2 pcode_PP1_7_InferArgumentUnsignedShort(u2 arg1)
|
||||||
|
{
|
||||||
|
return (-7) >> arg1;
|
||||||
|
}
|
||||||
|
|
||||||
|
u1 pcode_PP1_8_InferArgumentUnsignedChar(u1 arg1)
|
||||||
|
{
|
||||||
|
return (-7) >> arg1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
f4 pcode_PP1_9_InferArgumentFloat(f4 arg1)
|
||||||
|
{
|
||||||
|
return ((f4) - 7) + arg1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
f8 pcode_PP1_10_InferArgumentDouble(f8 arg1)
|
||||||
|
{
|
||||||
|
return ((f8) - 7) + arg1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
i8 pcode_PP1_11_InferPointerArgumentLongLong(i8 * arg1)
|
||||||
|
{
|
||||||
|
return (-7) >> (*arg1);
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_LONGLONG */
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
#include "pcode_test.h"
|
||||||
|
|
||||||
|
TEST pcode_PP2_1_OrderingIntShortChar_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_PP2_1_OrderingIntShortChar(i4 i, i2 s, i1 c);
|
||||||
|
ASSERTI4(pcode_PP2_1_OrderingIntShortChar(1, 2, 3), 1);
|
||||||
|
ASSERTI4(pcode_PP2_1_OrderingIntShortChar(I4_MAX, I2_MAX, I1_MAX), -2147450754);
|
||||||
|
ASSERTI4(pcode_PP2_1_OrderingIntShortChar(I4_MIN, I2_MIN, I1_MIN), -128);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP2_2_OrderingShortIntChar_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_PP2_2_OrderingShortIntChar(i2 s, i4 i, i1 c);
|
||||||
|
ASSERTI4(pcode_PP2_2_OrderingShortIntChar(2, 1, 3), 1);
|
||||||
|
ASSERTI4(pcode_PP2_2_OrderingShortIntChar(I2_MAX, I4_MAX, I1_MAX), -2147450754);
|
||||||
|
ASSERTI4(pcode_PP2_2_OrderingShortIntChar(I2_MIN, I4_MIN, I1_MIN), -128);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP2_3_OrderingIntCharShort_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_PP2_3_OrderingIntCharShort(i4 i, i1 c, i2 s);
|
||||||
|
ASSERTI4(pcode_PP2_3_OrderingIntCharShort(1, 3, 2), -1);
|
||||||
|
ASSERTI4(pcode_PP2_3_OrderingIntCharShort(I4_MAX, I1_MAX, I2_MAX), -2147450754);
|
||||||
|
ASSERTI4(pcode_PP2_3_OrderingIntCharShort(I4_MIN, I1_MIN, I2_MIN), -32768);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP2_4_OrderingShortCharInt_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_PP2_4_OrderingShortCharInt(i2 s, i1 c, i4 i);
|
||||||
|
ASSERTI4(pcode_PP2_4_OrderingShortCharInt(2, 3, 1), -5);
|
||||||
|
ASSERTI4(pcode_PP2_4_OrderingShortCharInt(I2_MAX, I1_MAX, I4_MAX), 2143322238);
|
||||||
|
ASSERTI4(pcode_PP2_4_OrderingShortCharInt(I2_MIN, I1_MIN, I4_MIN), 2143289344);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP2_5_OrderingCharShortInt_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_PP2_5_OrderingCharShortInt(i1 c, i2 s, i4 i);
|
||||||
|
ASSERTI4(pcode_PP2_5_OrderingCharShortInt(3, 2, 1), -5);
|
||||||
|
ASSERTI4(pcode_PP2_5_OrderingCharShortInt(I1_MAX, I2_MAX, I4_MAX), 2143322238);
|
||||||
|
ASSERTI4(pcode_PP2_5_OrderingCharShortInt(I1_MIN, I2_MIN, I4_MIN), 2143289344);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP2_6_OrderingCharIntShort_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_PP2_6_OrderingCharIntShort(i1 c, i4 i, i2 s);
|
||||||
|
ASSERTI4(pcode_PP2_6_OrderingCharIntShort(3, 1, 2), -1);
|
||||||
|
ASSERTI4(pcode_PP2_6_OrderingCharIntShort(I1_MAX, I4_MAX, I2_MAX), -2147450754);
|
||||||
|
ASSERTI4(pcode_PP2_6_OrderingCharIntShort(I1_MIN, I4_MIN, I2_MIN), -32768);
|
||||||
|
}
|
||||||
|
|
||||||
|
MAIN ParameterPassing2_main() { }
|
||||||
|
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
/* ###
|
||||||
|
* IP: GHIDRA
|
||||||
|
*
|
||||||
|
* 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 "pcode_test.h"
|
||||||
|
|
||||||
|
#define PARAMS(typ,a,b,c) (( (-((typ) (a))) * ((typ) (b)) ) + ((typ) (c)))
|
||||||
|
|
||||||
|
i4 pcode_PP2_1_OrderingIntShortChar(i4 i, i2 s, i1 c)
|
||||||
|
{
|
||||||
|
return PARAMS(i4, i, s, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_PP2_2_OrderingShortIntChar(i2 s, i4 i, i1 c)
|
||||||
|
{
|
||||||
|
return PARAMS(i4, s, i, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_PP2_3_OrderingIntCharShort(i4 i, i1 c, i2 s)
|
||||||
|
{
|
||||||
|
return PARAMS(i4, i, c, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_PP2_4_OrderingShortCharInt(i2 s, i1 c, i4 i)
|
||||||
|
{
|
||||||
|
return PARAMS(i4, s, c, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_PP2_5_OrderingCharShortInt(i1 c, i2 s, i4 i)
|
||||||
|
{
|
||||||
|
return PARAMS(i4, c, s, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_PP2_6_OrderingCharIntShort(i1 c, i4 i, i2 s)
|
||||||
|
{
|
||||||
|
return PARAMS(i4, c, i, s);
|
||||||
|
}
|
||||||
@@ -0,0 +1,173 @@
|
|||||||
|
#include "pcode_test.h"
|
||||||
|
|
||||||
|
TEST pcode_PP3_5thMultipleArg_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_PP3_5thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5);
|
||||||
|
ASSERTI4(pcode_PP3_5thMultipleArg(1, 2, 3, 4, 5), 61);
|
||||||
|
ASSERTI4(pcode_PP3_5thMultipleArg(1000, 2000, 3000, 4000, 5000), 55006);
|
||||||
|
ASSERTI4(pcode_PP3_5thMultipleArg(1000000, 2000000, 3000000, 4000000, 5000000), 55000006);
|
||||||
|
ASSERTI4(pcode_PP3_5thMultipleArg(-1, -2, -3, -4, -5), -49);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP3_6thMultipleArg_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_PP3_6thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5, i4 arg6);
|
||||||
|
ASSERTI4(pcode_PP3_6thMultipleArg(1, 2, 3, 4, 5, 6), 98);
|
||||||
|
ASSERTI4(pcode_PP3_6thMultipleArg(1000, 2000, 3000, 4000, 5000, 6000), 91007);
|
||||||
|
ASSERTI4(pcode_PP3_6thMultipleArg(1000000, 2000000, 3000000, 4000000, 5000000, 6000000), 91000007);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP3_7thMultipleArg_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_PP3_7thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5, i4 arg6, i4 arg7);
|
||||||
|
ASSERTI4(pcode_PP3_7thMultipleArg(1, 2, 3, 4, 5, 6, 7), 148);
|
||||||
|
ASSERTI4(pcode_PP3_7thMultipleArg(1000, 2000, 3000, 4000, 5000, 6000, 7000), 140008);
|
||||||
|
ASSERTI4(pcode_PP3_7thMultipleArg(1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000), 140000008);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP3_8thMultipleArg_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_PP3_8thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5, i4 arg6, i4 arg7, i4 arg8);
|
||||||
|
ASSERTI4(pcode_PP3_8thMultipleArg(1, 2, 3, 4, 5, 6, 7, 8), 213);
|
||||||
|
ASSERTI4(pcode_PP3_8thMultipleArg(1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000), 204009);
|
||||||
|
ASSERTI4(pcode_PP3_8thMultipleArg(1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000), 204000009);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP3_9thMultipleArg_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_PP3_9thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5, i4 arg6, i4 arg7, i4 arg8, i4 arg9);
|
||||||
|
ASSERTI4(pcode_PP3_9thMultipleArg(1, 2, 3, 4, 5, 6, 7, 8, 9), 295);
|
||||||
|
ASSERTI4(pcode_PP3_9thMultipleArg(1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000), 285010);
|
||||||
|
ASSERTI4(pcode_PP3_9thMultipleArg(1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000), 285000010);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP3_10thMultipleArg_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_PP3_10thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5, i4 arg6, i4 arg7, i4 arg8, i4 arg9, i4 arg10);
|
||||||
|
ASSERTI4(pcode_PP3_10thMultipleArg(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), 396);
|
||||||
|
ASSERTI4(pcode_PP3_10thMultipleArg(1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000), 385011);
|
||||||
|
ASSERTI4(pcode_PP3_10thMultipleArg(1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000), 385000011);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP3_11thMultipleArg_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_PP3_11thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5, i4 arg6, i4 arg7, i4 arg8, i4 arg9, i4 arg10, i4 arg11);
|
||||||
|
ASSERTI4(pcode_PP3_11thMultipleArg(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11), 518);
|
||||||
|
ASSERTI4(pcode_PP3_11thMultipleArg(1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000), 506012);
|
||||||
|
ASSERTI4(pcode_PP3_11thMultipleArg(1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000, 11000000), 506000012);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP3_12thMultipleArg_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_PP3_12thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5, i4 arg6, i4 arg7, i4 arg8, i4 arg9, i4 arg10, i4 arg11, i4 arg12);
|
||||||
|
ASSERTI4(pcode_PP3_12thMultipleArg(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), 663);
|
||||||
|
ASSERTI4(pcode_PP3_12thMultipleArg(1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000), 650013);
|
||||||
|
ASSERTI4(pcode_PP3_12thMultipleArg(1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000, 11000000, 12000000), 650000013);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP3_13thMultipleArg_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_PP3_13thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5, i4 arg6, i4 arg7, i4 arg8, i4 arg9, i4 arg10, i4 arg11, i4 arg12, i4 arg13);
|
||||||
|
ASSERTI4(pcode_PP3_13thMultipleArg(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1), 677);
|
||||||
|
ASSERTI4(pcode_PP3_13thMultipleArg(1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 1000), 663014);
|
||||||
|
ASSERTI4(pcode_PP3_13thMultipleArg(1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000, 11000000, 12000000, 1000000), 663000014);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP3_14thMultipleArg_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_PP3_14thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5, i4 arg6, i4 arg7, i4 arg8, i4 arg9, i4 arg10, i4 arg11, i4 arg12, i4 arg13, i4 arg14);
|
||||||
|
ASSERTI4(pcode_PP3_14thMultipleArg(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2), 706);
|
||||||
|
ASSERTI4(pcode_PP3_14thMultipleArg(1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 1000, 2000), 691015);
|
||||||
|
ASSERTI4(pcode_PP3_14thMultipleArg(1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000, 11000000, 12000000, 1000000, 2000000), 691000015);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP3_15thMultipleArg_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_PP3_15thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5, i4 arg6, i4 arg7, i4 arg8, i4 arg9, i4 arg10, i4 arg11, i4 arg12, i4 arg13, i4 arg14, i4 arg15);
|
||||||
|
ASSERTI4(pcode_PP3_15thMultipleArg(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 1), 722);
|
||||||
|
ASSERTI4(pcode_PP3_15thMultipleArg(1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 1000, 2000, 1000), 706016);
|
||||||
|
ASSERTI4(pcode_PP3_15thMultipleArg(1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000, 11000000, 12000000, 1000000, 2000000, 1000000), 706000016);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP3_16thMultipleArg_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_PP3_16thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5, i4 arg6, i4 arg7, i4 arg8, i4 arg9, i4 arg10, i4 arg11, i4 arg12, i4 arg13, i4 arg14, i4 arg15, i4 arg16);
|
||||||
|
ASSERTI4(pcode_PP3_16thMultipleArg(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 1, 1, 1), 725);
|
||||||
|
ASSERTI4(pcode_PP3_16thMultipleArg(1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 1000, 1000, 1000, 1000), 708017);
|
||||||
|
ASSERTI4(pcode_PP3_16thMultipleArg(1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000, 11000000, 12000000, 1000000, 1000000, 1000000, 1000000), 708000017);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP3_17thMultipleArg_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_PP3_17thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5, i4 arg6, i4 arg7, i4 arg8, i4 arg9, i4 arg10, i4 arg11, i4 arg12, i4 arg13, i4 arg14, i4 arg15, i4 arg16, i4 arg17);
|
||||||
|
ASSERTI4(pcode_PP3_17thMultipleArg(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 1, 1, 1, 1), 743);
|
||||||
|
ASSERTI4(pcode_PP3_17thMultipleArg(1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 1000, 1000, 1000, 1000, 1000), 725018);
|
||||||
|
ASSERTI4(pcode_PP3_17thMultipleArg(1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000, 11000000, 12000000, 1000000, 1000000, 1000000, 1000000, 1000000), 725000018);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP3_18thMultipleArg_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_PP3_18thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5, i4 arg6, i4 arg7, i4 arg8, i4 arg9, i4 arg10, i4 arg11, i4 arg12, i4 arg13, i4 arg14, i4 arg15, i4 arg16, i4 arg17, i4 arg18);
|
||||||
|
ASSERTI4(pcode_PP3_18thMultipleArg(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 1, 1, 1, 1, 1), 762);
|
||||||
|
ASSERTI4(pcode_PP3_18thMultipleArg(1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 1000, 1000, 1000, 1000, 1000, 1000), 743019);
|
||||||
|
ASSERTI4(pcode_PP3_18thMultipleArg(1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000, 11000000, 12000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000), 743000019);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP3_19thMultipleArg_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_PP3_19thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5, i4 arg6, i4 arg7, i4 arg8, i4 arg9, i4 arg10, i4 arg11, i4 arg12, i4 arg13, i4 arg14, i4 arg15, i4 arg16, i4 arg17, i4 arg18, i4 arg19);
|
||||||
|
ASSERTI4(pcode_PP3_19thMultipleArg(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 1, 1, 1, 1, 1), 938);
|
||||||
|
ASSERTI4(pcode_PP3_19thMultipleArg(1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 1000, 1000, 1000, 1000, 1000, 1000), 918020);
|
||||||
|
ASSERTI4(pcode_PP3_19thMultipleArg(1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000, 11000000, 12000000, 13000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000), 918000020);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP3_20thMultipleArg_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_PP3_20thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5, i4 arg6, i4 arg7, i4 arg8, i4 arg9, i4 arg10, i4 arg11, i4 arg12, i4 arg13, i4 arg14, i4 arg15, i4 arg16, i4 arg17, i4 arg18, i4 arg19, i4 arg20);
|
||||||
|
ASSERTI4(pcode_PP3_20thMultipleArg(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 1, 1, 1, 1, 1, 1), 959);
|
||||||
|
ASSERTI4(pcode_PP3_20thMultipleArg(1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 1000, 1000, 1000, 1000, 1000, 1000, 1000), 938021);
|
||||||
|
ASSERTI4(pcode_PP3_20thMultipleArg(1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000, 11000000, 12000000, 13000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000), 938000021);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP3_0thMultipleArg_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_PP3_0thMultipleArg();
|
||||||
|
ASSERTI4(pcode_PP3_0thMultipleArg(), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP3_1stMultipleArg_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_PP3_1stMultipleArg(i4 arg1);
|
||||||
|
ASSERTI4(pcode_PP3_1stMultipleArg(1), 3);
|
||||||
|
ASSERTI4(pcode_PP3_1stMultipleArg(I4_MAX), -2147483647);
|
||||||
|
ASSERTI4(pcode_PP3_1stMultipleArg(I4_MIN), -2147483646);
|
||||||
|
ASSERTI4(pcode_PP3_1stMultipleArg(0), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP3_2ndMultipleArg_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_PP3_2ndMultipleArg(i4 arg1, i4 arg2);
|
||||||
|
ASSERTI4(pcode_PP3_2ndMultipleArg(1, 2), 8);
|
||||||
|
ASSERTI4(pcode_PP3_2ndMultipleArg(I4_MAX, I4_MIN), -2147483646);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP3_3rdMultipleArg_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_PP3_3rdMultipleArg(i4 arg1, i4 arg2, i4 arg3);
|
||||||
|
ASSERTI4(pcode_PP3_3rdMultipleArg(1, 2, 3), 18);
|
||||||
|
ASSERTI4(pcode_PP3_3rdMultipleArg(I4_MAX, 2, 3), -2147483632);
|
||||||
|
ASSERTI4(pcode_PP3_3rdMultipleArg(1, I4_MAX, 3), 12);
|
||||||
|
ASSERTI4(pcode_PP3_3rdMultipleArg(1, I4_MAX, I4_MAX), -2147483648);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_PP3_4thMultipleArg_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_PP3_4thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4);
|
||||||
|
ASSERTI4(pcode_PP3_4thMultipleArg(1, 2, 3, 4), 35);
|
||||||
|
ASSERTI4(pcode_PP3_4thMultipleArg(I4_MAX, 2, 3, 4), -2147483615);
|
||||||
|
ASSERTI4(pcode_PP3_4thMultipleArg(1, I4_MAX, 3, 4), 29);
|
||||||
|
ASSERTI4(pcode_PP3_4thMultipleArg(1, 2, I4_MAX, 4), -2147483625);
|
||||||
|
ASSERTI4(pcode_PP3_4thMultipleArg(1, 2, 3, I4_MAX), 15);
|
||||||
|
}
|
||||||
|
|
||||||
|
MAIN ParameterPassing3_main() { }
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
/* ###
|
||||||
|
* IP: GHIDRA
|
||||||
|
*
|
||||||
|
* 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 "pcode_test.h"
|
||||||
|
|
||||||
|
i4 pcode_PP3_5thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5)
|
||||||
|
{
|
||||||
|
return 6 + arg1 * 1 + arg2 * 2 + arg3 * 3 + arg4 * 4 + arg5 * 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_PP3_6thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5, i4 arg6)
|
||||||
|
{
|
||||||
|
return 7 + arg1 * 1 + arg2 * 2 + arg3 * 3 + arg4 * 4 + arg5 * 5 + arg6 * 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_PP3_7thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5, i4 arg6, i4 arg7)
|
||||||
|
{
|
||||||
|
return 8 + arg1 * 1 + arg2 * 2 + arg3 * 3 + arg4 * 4 + arg5 * 5 + arg6 * 6 + arg7 * 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_PP3_8thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5, i4 arg6, i4 arg7, i4 arg8)
|
||||||
|
{
|
||||||
|
return 9 + arg1 * 1 + arg2 * 2 + arg3 * 3 + arg4 * 4 + arg5 * 5 + arg6 * 6 + arg7 * 7 + arg8 * 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_PP3_9thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5, i4 arg6, i4 arg7, i4 arg8, i4 arg9)
|
||||||
|
{
|
||||||
|
return 10 + arg1 * 1 + arg2 * 2 + arg3 * 3 + arg4 * 4 + arg5 * 5 + arg6 * 6 + arg7 * 7 + arg8 * 8 + arg9 * 9;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_PP3_10thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5, i4 arg6, i4 arg7, i4 arg8, i4 arg9, i4 arg10)
|
||||||
|
{
|
||||||
|
return 11 + arg1 * 1 + arg2 * 2 + arg3 * 3 + arg4 * 4 + arg5 * 5 + arg6 * 6 + arg7 * 7 + arg8 * 8 + arg9 * 9 + arg10 * 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_PP3_11thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5, i4 arg6, i4 arg7, i4 arg8, i4 arg9, i4 arg10, i4 arg11)
|
||||||
|
{
|
||||||
|
return 12 + arg1 * 1 + arg2 * 2 + arg3 * 3 + arg4 * 4 + arg5 * 5 + arg6 * 6 + arg7 * 7 + arg8 * 8 + arg9 * 9 + arg10 * 10 + arg11 * 11;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_PP3_12thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5, i4 arg6, i4 arg7, i4 arg8, i4 arg9, i4 arg10, i4 arg11, i4 arg12)
|
||||||
|
{
|
||||||
|
return 13 + arg1 * 1 + arg2 * 2 + arg3 * 3 + arg4 * 4 + arg5 * 5 + arg6 * 6 + arg7 * 7 + arg8 * 8 + arg9 * 9 + arg10 * 10 + arg11 * 11 + arg12 * 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_PP3_13thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5, i4 arg6, i4 arg7, i4 arg8, i4 arg9, i4 arg10, i4 arg11, i4 arg12, i4 arg13)
|
||||||
|
{
|
||||||
|
return 14 + arg1 * 1 + arg2 * 2 + arg3 * 3 + arg4 * 4 + arg5 * 5 + arg6 * 6 + arg7 * 7 + arg8 * 8 + arg9 * 9 + arg10 * 10 + arg11 * 11 + arg12 * 12 + arg13 * 13;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_PP3_14thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5, i4 arg6, i4 arg7, i4 arg8, i4 arg9, i4 arg10, i4 arg11, i4 arg12, i4 arg13, i4 arg14)
|
||||||
|
{
|
||||||
|
return 15 + arg1 * 1 + arg2 * 2 + arg3 * 3 + arg4 * 4 + arg5 * 5 + arg6 * 6 + arg7 * 7 + arg8 * 8 + arg9 * 9 + arg10 * 10 + arg11 * 11 + arg12 * 12 + arg13 * 13 + arg14 * 14;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_PP3_15thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5, i4 arg6, i4 arg7, i4 arg8, i4 arg9, i4 arg10, i4 arg11, i4 arg12, i4 arg13, i4 arg14, i4 arg15)
|
||||||
|
{
|
||||||
|
return 16 + arg1 * 1 + arg2 * 2 + arg3 * 3 + arg4 * 4 + arg5 * 5 + arg6 * 6 + arg7 * 7 + arg8 * 8 + arg9 * 9 + arg10 * 10 + arg11 * 11 + arg12 * 12 + arg13 * 13 + arg14 * 14 + arg15 * 15;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_PP3_16thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5, i4 arg6, i4 arg7, i4 arg8, i4 arg9, i4 arg10, i4 arg11, i4 arg12, i4 arg13, i4 arg14, i4 arg15, i4 arg16)
|
||||||
|
{
|
||||||
|
return 17 + arg1 * 1 + arg2 * 2 + arg3 * 3 + arg4 * 4 + arg5 * 5 + arg6 * 6 + arg7 * 7 + arg8 * 8 + arg9 * 9 + arg10 * 10 + arg11 * 11 + arg12 * 12 + arg13 * 13 + arg14 * 14 + arg15 * 15 + arg16 * 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_PP3_17thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5, i4 arg6, i4 arg7, i4 arg8, i4 arg9, i4 arg10, i4 arg11, i4 arg12, i4 arg13, i4 arg14, i4 arg15, i4 arg16, i4 arg17)
|
||||||
|
{
|
||||||
|
return 18 + arg1 * 1 + arg2 * 2 + arg3 * 3 + arg4 * 4 + arg5 * 5 + arg6 * 6 + arg7 * 7 + arg8 * 8 + arg9 * 9 + arg10 * 10 + arg11 * 11 + arg12 * 12 + arg13 * 13 + arg14 * 14 + arg15 * 15 + arg16 * 16 + arg17 * 17;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_PP3_18thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5, i4 arg6, i4 arg7, i4 arg8, i4 arg9, i4 arg10, i4 arg11, i4 arg12, i4 arg13, i4 arg14, i4 arg15, i4 arg16, i4 arg17, i4 arg18)
|
||||||
|
{
|
||||||
|
return 19 + arg1 * 1 + arg2 * 2 + arg3 * 3 + arg4 * 4 + arg5 * 5 + arg6 * 6 + arg7 * 7 + arg8 * 8 + arg9 * 9 + arg10 * 10 + arg11 * 11 + arg12 * 12 + arg13 * 13 + arg14 * 14 + arg15 * 15 + arg16 * 16 + arg17 * 17 + arg18 * 18;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_PP3_19thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5, i4 arg6, i4 arg7, i4 arg8, i4 arg9, i4 arg10, i4 arg11, i4 arg12, i4 arg13, i4 arg14, i4 arg15, i4 arg16, i4 arg17, i4 arg18, i4 arg19)
|
||||||
|
{
|
||||||
|
return 20 + arg1 * 1 + arg2 * 2 + arg3 * 3 + arg4 * 4 + arg5 * 5 + arg6 * 6 + arg7 * 7 + arg8 * 8 + arg9 * 9 + arg10 * 10 + arg11 * 11 + arg12 * 12 + arg13 * 13 + arg14 * 14 + arg15 * 15 + arg16 * 16 + arg17 * 17 + arg18 * 18 + arg19 * 19;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_PP3_20thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4, i4 arg5, i4 arg6, i4 arg7, i4 arg8, i4 arg9, i4 arg10, i4 arg11, i4 arg12, i4 arg13, i4 arg14, i4 arg15, i4 arg16, i4 arg17, i4 arg18, i4 arg19, i4 arg20)
|
||||||
|
{
|
||||||
|
return 21 + arg1 * 1 + arg2 * 2 + arg3 * 3 + arg4 * 4 + arg5 * 5 + arg6 * 6 + arg7 * 7 + arg8 * 8 + arg9 * 9 + arg10 * 10 + arg11 * 11 + arg12 * 12 + arg13 * 13 + arg14 * 14 + arg15 * 15 + arg16 * 16 + arg17 * 17 + arg18 * 18 + arg19 * 19 +
|
||||||
|
arg20 * 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_PP3_0thMultipleArg()
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_PP3_1stMultipleArg(i4 arg1)
|
||||||
|
{
|
||||||
|
return 2 + arg1 * 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_PP3_2ndMultipleArg(i4 arg1, i4 arg2)
|
||||||
|
{
|
||||||
|
return 3 + arg1 * 1 + arg2 * 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_PP3_3rdMultipleArg(i4 arg1, i4 arg2, i4 arg3)
|
||||||
|
{
|
||||||
|
return 4 + arg1 * 1 + arg2 * 2 + arg3 * 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_PP3_4thMultipleArg(i4 arg1, i4 arg2, i4 arg3, i4 arg4)
|
||||||
|
{
|
||||||
|
return 5 + arg1 * 1 + arg2 * 2 + arg3 * 3 + arg4 * 4;
|
||||||
|
}
|
||||||
@@ -0,0 +1,400 @@
|
|||||||
|
#include "pcode_test.h"
|
||||||
|
#include "big_struct.h"
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
TEST pcode_P30_GetDecrementedDouble_Main()
|
||||||
|
{
|
||||||
|
extern f8 pcode_P30_GetDecrementedDouble(f8 * ptr);
|
||||||
|
f8 arg[2] = { 3.14, 1.18 };
|
||||||
|
f8 *argPtr = &arg[1];
|
||||||
|
ASSERTF8(pcode_P30_GetDecrementedDouble(argPtr), 3.14);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST pcode_P58_UnionGetAddressOfUnsignedChar_Main()
|
||||||
|
{
|
||||||
|
extern u1 *pcode_P58_UnionGetAddressOfUnsignedChar(big_union_type *ptr, i4 index);
|
||||||
|
big_union_type testUnion[1] = {0};
|
||||||
|
ASSERTU1(* (u1 *) pcode_P58_UnionGetAddressOfUnsignedChar(testUnion, 0), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
TEST pcode_P9_GetAddressOfFloat_Main()
|
||||||
|
{
|
||||||
|
extern f4 *pcode_P9_GetAddressOfFloat(f4 *ptr, i4 index);
|
||||||
|
f4 array[] = { 1, 2, 3, 4, 5 };
|
||||||
|
ASSERTF4(*pcode_P9_GetAddressOfFloat(array, 3), 4.0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
TEST pcode_P59_UnionGetAddressOfFloat_Main()
|
||||||
|
{
|
||||||
|
extern f4 *pcode_P59_UnionGetAddressOfFloat(big_union_type *ptr, i4 index);
|
||||||
|
big_union_type testUnion[1] = {0};
|
||||||
|
f4 *ret = pcode_P59_UnionGetAddressOfFloat(testUnion, 0);
|
||||||
|
ASSERTF4(*ret, 0.0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
TEST pcode_P10_GetAddressOfDouble_Main()
|
||||||
|
{
|
||||||
|
extern f8 *pcode_P10_GetAddressOfDouble(f8 * ptr, i4 index);
|
||||||
|
f8 array[] = { 1, 2, 3, 4, 5 };
|
||||||
|
f8 *ret;
|
||||||
|
ret = pcode_P10_GetAddressOfDouble(array, 3);
|
||||||
|
ASSERTF8(*ret, 4.0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST pcode_P32_ModifyContentsOfInt_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_P32_ModifyContentsOfInt(i4 * ptr, i4 index, i4 value);
|
||||||
|
i4 array[] = { 1, 2, 3, 4, 5 };
|
||||||
|
i4 ret;
|
||||||
|
ret = pcode_P32_ModifyContentsOfInt (array, 3, 5);
|
||||||
|
ASSERTI4(ret, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_P33_ModifyContentsOfShort_Main()
|
||||||
|
{
|
||||||
|
extern i2 pcode_P33_ModifyContentsOfShort(i2 * ptr, i4 index, i2 value);
|
||||||
|
i2 array[] = { 1, 2, 3, 4, 5 };
|
||||||
|
i2 ret;
|
||||||
|
ret = pcode_P33_ModifyContentsOfShort(array, 3, 5);
|
||||||
|
ASSERTI2(ret, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
TEST pcode_P60_UnionGetAddressOfDouble_Main()
|
||||||
|
{
|
||||||
|
extern f8 *pcode_P60_UnionGetAddressOfDouble(big_union_type *ptr, i4 index);
|
||||||
|
big_union_type testUnion[5] = {0};
|
||||||
|
f8 *ret = pcode_P60_UnionGetAddressOfDouble(testUnion, 3);
|
||||||
|
ASSERTF8(*ret, 0.0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
TEST pcode_P11_GetIncrementedLongLong_Main()
|
||||||
|
{
|
||||||
|
extern i8 pcode_P11_GetIncrementedLongLong(i8 * ptr);
|
||||||
|
i8 array[] = { 1, 2, 3, 4, 5 };
|
||||||
|
i8 ret;
|
||||||
|
ret = pcode_P11_GetIncrementedLongLong(array + 2);
|
||||||
|
ASSERTI8 (ret, 4);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST pcode_P34_ModifyContentsOfChar_Main()
|
||||||
|
{
|
||||||
|
extern i1 pcode_P34_ModifyContentsOfChar(i1 * ptr, i4 index, i1 value);
|
||||||
|
i1 array[] = { 1, 2, 3, 4, 5 };
|
||||||
|
i1 ret;
|
||||||
|
ret = pcode_P34_ModifyContentsOfChar(array, 3, 5);
|
||||||
|
ASSERTI1(ret, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_P12_GetIncrementedInt_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_P12_GetIncrementedInt(i4 * ptr);
|
||||||
|
i4 array[] = { 1, 2, 3, 4, 5 };
|
||||||
|
i4 ret;
|
||||||
|
ret = pcode_P12_GetIncrementedInt(array);
|
||||||
|
ASSERTI4(ret, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_P13_GetIncrementedShort_Main()
|
||||||
|
{
|
||||||
|
extern i2 pcode_P13_GetIncrementedShort(i2 * ptr);
|
||||||
|
i2 array[] = { 1, 2, 3, 4, 5 };
|
||||||
|
i2 ret;
|
||||||
|
ret = pcode_P13_GetIncrementedShort(array);
|
||||||
|
ASSERTI4(ret, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_P36_ModifyContentsOfUnsignedInt_Main()
|
||||||
|
{
|
||||||
|
extern u4 pcode_P36_ModifyContentsOfUnsignedInt(u4 * ptr, i4 index, u4 value);
|
||||||
|
u4 array[] = { 1, 2, 3, 4, 5 };
|
||||||
|
u4 ret;
|
||||||
|
ret = pcode_P36_ModifyContentsOfUnsignedInt(array, 3, 5);
|
||||||
|
ASSERTU4(ret, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
TEST pcode_P35_ModifyContentsOfUnsignedLongLong_Main()
|
||||||
|
{
|
||||||
|
extern u8 pcode_P35_ModifyContentsOfUnsignedLongLong(u8 * ptr, i4 index, u8 value);
|
||||||
|
u8 array[] = { 1, 2, 3, 4, 5 };
|
||||||
|
u8 ret;
|
||||||
|
ret = pcode_P35_ModifyContentsOfUnsignedLongLong(array, 3, 5);
|
||||||
|
ASSERTU8(ret, 5);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST pcode_P14_GetIncrementedChar_Main()
|
||||||
|
{
|
||||||
|
extern i1 pcode_P14_GetIncrementedChar (i1 * ptr);
|
||||||
|
i1 array[] = { 1, 2, 3, 4, 5 };
|
||||||
|
i1 ret;
|
||||||
|
ret = pcode_P14_GetIncrementedChar(array);
|
||||||
|
ASSERTI4(ret, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_P37_ModifyContentsOfUnsignedShort_Main()
|
||||||
|
{
|
||||||
|
extern u2 pcode_P37_ModifyContentsOfUnsignedShort(u2 * ptr, i4 index, u2 value);
|
||||||
|
u2 array[] = { 1, 2, 3, 4, 5 };
|
||||||
|
u2 ret;
|
||||||
|
ret = pcode_P37_ModifyContentsOfUnsignedShort(array, 3, 5);
|
||||||
|
ASSERTU2(ret, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_P38_ModifyContentsOfUnsignedChar_Main()
|
||||||
|
{
|
||||||
|
extern u1 pcode_P38_ModifyContentsOfUnsignedChar(u1 * ptr, i4 index, u1 value);
|
||||||
|
u1 array[] = { 1, 2, 3, 4, 5 };
|
||||||
|
u1 ret;
|
||||||
|
ret = pcode_P38_ModifyContentsOfUnsignedChar(array, 3, 5);
|
||||||
|
ASSERTU1(ret, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
TEST pcode_P15_GetIncrementedUnsignedLongLong_Main()
|
||||||
|
{
|
||||||
|
extern u8 pcode_P15_GetIncrementedUnsignedLongLong(u8 * ptr);
|
||||||
|
u8 array[] = { 1, 2, 3, 4, 5 };
|
||||||
|
u8 ret;
|
||||||
|
ret = pcode_P15_GetIncrementedUnsignedLongLong(array);
|
||||||
|
ASSERTI4(ret, 2);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
TEST pcode_P39_ModifyContentsOfFloat_Main()
|
||||||
|
{
|
||||||
|
extern f4 pcode_P39_ModifyContentsOfFloat(f4 * ptr, i4 index, f4 value);
|
||||||
|
f4 array[] = { 1, 2, 3, 4, 5 };
|
||||||
|
f4 ret;
|
||||||
|
ret = pcode_P39_ModifyContentsOfFloat(array, 3, 5.0);
|
||||||
|
ASSERTF4(ret, 5.0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST pcode_P17_GetIncrementedUnsignedShort_Main()
|
||||||
|
{
|
||||||
|
extern u2 pcode_P17_GetIncrementedUnsignedShort(u2 * ptr);
|
||||||
|
u2 array[] = { 1, 2, 3, 4, 5 };
|
||||||
|
u2 ret;
|
||||||
|
ret = pcode_P17_GetIncrementedUnsignedShort(array);
|
||||||
|
ASSERTI4(ret, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_P16_GetIncrementedUnsignedInt_Main()
|
||||||
|
{
|
||||||
|
extern u4 pcode_P16_GetIncrementedUnsignedInt(u4 * ptr);
|
||||||
|
u4 array[] = { 1, 2, 3, 4, 5 };
|
||||||
|
u4 ret;
|
||||||
|
ret = pcode_P16_GetIncrementedUnsignedInt(array);
|
||||||
|
ASSERTI4(ret, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_P18_GetIncrementedUnsignedChar_Main()
|
||||||
|
{
|
||||||
|
extern u1 pcode_P18_GetIncrementedUnsignedChar(u1 * ptr);
|
||||||
|
u1 array[] = { 1, 2, 3, 4, 5 };
|
||||||
|
u1 ret;
|
||||||
|
ret = pcode_P18_GetIncrementedUnsignedChar(array);
|
||||||
|
ASSERTI4(ret, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
TEST pcode_P40_ModifyContentsOfDouble_Main()
|
||||||
|
{
|
||||||
|
extern f8 pcode_P40_ModifyContentsOfDouble(f8 * ptr, i4 index, f8 value);
|
||||||
|
f8 array[] = { 1, 2, 3, 4, 5 };
|
||||||
|
f8 ret;
|
||||||
|
ret = pcode_P40_ModifyContentsOfDouble(array, 3, 5.0);
|
||||||
|
ASSERTF8(ret, 5.0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
TEST pcode_P41_StructGetAddressOfLongLong_Main()
|
||||||
|
{
|
||||||
|
extern i8 *pcode_P41_StructGetAddressOfLongLong(big_struct_type *ptr, i4 index);
|
||||||
|
big_struct_type bst[5] = {0};
|
||||||
|
i8 *ret;
|
||||||
|
ret = pcode_P41_StructGetAddressOfLongLong(bst, 3);
|
||||||
|
ASSERTI8(*ret, 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
TEST pcode_P19_GetIncrementedFloat_Main()
|
||||||
|
{
|
||||||
|
extern f4 pcode_P19_GetIncrementedFloat(f4 * ptr);
|
||||||
|
f4 array[] = { 1.0, 2.0, 3.0, 4.0, 5.0 };
|
||||||
|
f4 ret;
|
||||||
|
ret = pcode_P19_GetIncrementedFloat((f4 *) array);
|
||||||
|
ASSERTF4(ret, 2);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST pcode_P42_StructGetAddressOfInt_Main()
|
||||||
|
{
|
||||||
|
extern i4 *pcode_P42_StructGetAddressOfInt(big_struct_type *ptr, i4 index);
|
||||||
|
big_struct_type bst[5] = {0};
|
||||||
|
i4 *ret;
|
||||||
|
ret= pcode_P42_StructGetAddressOfInt(bst, 3);
|
||||||
|
ASSERTI4(*ret, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_P43_StructGetAddressOfShort_Main()
|
||||||
|
{
|
||||||
|
extern i2 *pcode_P43_StructGetAddressOfShort(big_struct_type *ptr, i4 index);
|
||||||
|
big_struct_type bst[5] = {0};
|
||||||
|
i2 *ret;
|
||||||
|
ret = pcode_P43_StructGetAddressOfShort(bst, 3);
|
||||||
|
ASSERTI4(*ret, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_P44_StructGetAddressOfChar_Main()
|
||||||
|
{
|
||||||
|
extern i1 *pcode_P44_StructGetAddressOfChar(big_struct_type *ptr, i4 index);
|
||||||
|
big_struct_type bst[5] = {0};
|
||||||
|
i1 *ret;
|
||||||
|
ret = pcode_P44_StructGetAddressOfChar(bst, 3);
|
||||||
|
ASSERTI1(*ret, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
TEST pcode_P20_GetIncrementedDouble_Main()
|
||||||
|
{
|
||||||
|
extern f8 pcode_P20_GetIncrementedDouble(f8 * ptr);
|
||||||
|
f8 array[] = { 1.0, 2.0, 3.0, 4.0, 5.0 };
|
||||||
|
f8 ret;
|
||||||
|
ret = pcode_P20_GetIncrementedDouble((f8 *) array);
|
||||||
|
ASSERTF8(ret, 2.0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
TEST pcode_P45_StructGetAddressOfUnsignedLongLong_Main()
|
||||||
|
{
|
||||||
|
extern u8 *pcode_P45_StructGetAddressOfUnsignedLongLong(big_struct_type *ptr, i4 index);
|
||||||
|
big_struct_type bst[5] = {0};
|
||||||
|
u8 *ret;
|
||||||
|
ret = pcode_P45_StructGetAddressOfUnsignedLongLong(bst, 3);
|
||||||
|
ASSERTU8(*ret, 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
TEST pcode_P21_GetDecrementedLongLong_Main()
|
||||||
|
{
|
||||||
|
extern i8 pcode_P21_GetDecrementedLongLong(i8 * ptr);
|
||||||
|
i8 val[] = {100, 200, 300};
|
||||||
|
i8 ret;
|
||||||
|
ret = pcode_P21_GetDecrementedLongLong(&val[1]);
|
||||||
|
ASSERTI8(ret, 100);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST pcode_P47_StructGetAddressOfUnsignedShort_Main()
|
||||||
|
{
|
||||||
|
extern u2 *pcode_P47_StructGetAddressOfUnsignedShort(big_struct_type *ptr, i4 index);
|
||||||
|
big_struct_type bst[5] = {0};
|
||||||
|
u2 *ret;
|
||||||
|
ret = pcode_P47_StructGetAddressOfUnsignedShort(bst, 3);
|
||||||
|
ASSERTU2(*ret, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_P46_StructGetAddressOfUnsignedInt_Main()
|
||||||
|
{
|
||||||
|
extern u4 *pcode_P46_StructGetAddressOfUnsignedInt(big_struct_type *ptr, i4 index);
|
||||||
|
big_struct_type bst[5] = {0};
|
||||||
|
u4 *ret;
|
||||||
|
ret = pcode_P46_StructGetAddressOfUnsignedInt(bst, 3);
|
||||||
|
ASSERTU2(*ret, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
TEST pcode_P1_GetAddressOfLongLong_Main()
|
||||||
|
{
|
||||||
|
extern i8 *pcode_P1_GetAddressOfLongLong(i8 * ptr, i4 index);
|
||||||
|
i8 array[] = { 1, 2, 3, 4, 5 };
|
||||||
|
i8 *ret;
|
||||||
|
ret = pcode_P1_GetAddressOfLongLong(array, 3);
|
||||||
|
ASSERTI8(*ret, 4);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST pcode_P2_GetAddressOfInt_Main()
|
||||||
|
{
|
||||||
|
extern i4 *pcode_P2_GetAddressOfInt(i4 * ptr, i4 index);
|
||||||
|
i4 array[] = { 1, 2, 3, 4, 5 };
|
||||||
|
i4 *ret;
|
||||||
|
ret = pcode_P2_GetAddressOfInt(array, 3);
|
||||||
|
ASSERTI4(*ret, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_P3_GetAddressOfShort_Main()
|
||||||
|
{
|
||||||
|
extern i2 *pcode_P3_GetAddressOfShort(i2 * ptr, i4 index);
|
||||||
|
i2 array[] = { 1, 2, 3, 4, 5 };
|
||||||
|
i2 *ret;
|
||||||
|
ret = pcode_P3_GetAddressOfShort(array, 3);
|
||||||
|
ASSERTI2(*ret, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_P4_GetAddressOfChar_Main()
|
||||||
|
{
|
||||||
|
extern i1 *pcode_P4_GetAddressOfChar(i1 * ptr, i4 index);
|
||||||
|
i1 array[] = { 1, 2, 3, 4, 5 };
|
||||||
|
i1 *ret;
|
||||||
|
ret = pcode_P4_GetAddressOfChar(array, 3);
|
||||||
|
ASSERTI1(*ret, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_P6_GetAddressOfUnsignedInt_Main()
|
||||||
|
{
|
||||||
|
extern u4 *pcode_P6_GetAddressOfUnsignedInt(u4 * ptr, i4 index);
|
||||||
|
u4 array[] = { 1, 2, 3, 4, 5 };
|
||||||
|
u4 *ret;
|
||||||
|
ret = pcode_P6_GetAddressOfUnsignedInt(array, 3);
|
||||||
|
ASSERTU4(*ret, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
TEST pcode_P5_GetAddressOfUnsignedLongLong_Main()
|
||||||
|
{
|
||||||
|
extern u8 *pcode_P5_GetAddressOfUnsignedLongLong(u8 * ptr, i4 index);
|
||||||
|
u8 array[] = { 1, 2, 3, 4, 5 };
|
||||||
|
u8 *ret;
|
||||||
|
ret = pcode_P5_GetAddressOfUnsignedLongLong(array, 3);
|
||||||
|
ASSERTU8(*ret, 4);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST pcode_P7_GetAddressOfUnsignedShort_Main()
|
||||||
|
{
|
||||||
|
extern u2 *pcode_P7_GetAddressOfUnsignedShort(u2 * ptr, i4 index);
|
||||||
|
u2 array[] = { 1, 2, 3, 4, 5 };
|
||||||
|
u2 *ret;
|
||||||
|
ret = pcode_P7_GetAddressOfUnsignedShort(array, 3);
|
||||||
|
ASSERTU2(*ret, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_P8_GetAddressOfUnsignedChar_Main()
|
||||||
|
{
|
||||||
|
extern u1 *pcode_P8_GetAddressOfUnsignedChar(u1 * ptr, i4 index);
|
||||||
|
u1 array[] = { 1, 2, 3, 4, 5 };
|
||||||
|
u1 *ret;
|
||||||
|
ret = pcode_P8_GetAddressOfUnsignedChar(array, 3);
|
||||||
|
ASSERTU1(*ret, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
MAIN PointerManipulation_main() { }
|
||||||
@@ -0,0 +1,442 @@
|
|||||||
|
/* ###
|
||||||
|
* IP: GHIDRA
|
||||||
|
*
|
||||||
|
* 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 "pcode_test.h"
|
||||||
|
#include "big_struct.h"
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
f8 pcode_P30_GetDecrementedDouble(f8 * ptr)
|
||||||
|
{
|
||||||
|
return *--ptr;
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_DOUBLE */
|
||||||
|
|
||||||
|
u1 *pcode_P58_UnionGetAddressOfUnsignedChar(big_union_type *ptr, i4 index)
|
||||||
|
{
|
||||||
|
return (u1 *) & (*(ptr + index)).uc;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
f4 *pcode_P9_GetAddressOfFloat(f4 * ptr, i4 index)
|
||||||
|
{
|
||||||
|
return ptr + index;
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_FLOAT */
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
f4 *pcode_P59_UnionGetAddressOfFloat(big_union_type *ptr, i4 index)
|
||||||
|
{
|
||||||
|
return (f4 *) & (*(ptr + index)).f;
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_FLOAT */
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
f8 *pcode_P10_GetAddressOfDouble(f8 * ptr, i4 index)
|
||||||
|
{
|
||||||
|
return ptr + index;
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_DOUBLE */
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
void pcode_P31_ModifyContentsOfLongLong(i8 * ptr, i4 index, i8 value)
|
||||||
|
{
|
||||||
|
*(ptr + index) = value;
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_LONGLONG */
|
||||||
|
|
||||||
|
i4 pcode_P32_ModifyContentsOfInt(i4 * ptr, i4 index, i4 value)
|
||||||
|
{
|
||||||
|
*(ptr + index) = value;
|
||||||
|
return *(ptr + index);
|
||||||
|
}
|
||||||
|
|
||||||
|
i2 pcode_P33_ModifyContentsOfShort(i2 * ptr, i4 index, i2 value)
|
||||||
|
{
|
||||||
|
*(ptr + index) = value;
|
||||||
|
return *(ptr + index);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
f8 *pcode_P60_UnionGetAddressOfDouble(big_union_type *ptr, i4 index)
|
||||||
|
{
|
||||||
|
return (f8 *) & (*(ptr + index)).d;
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_DOUBLE */
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
i8 pcode_P11_GetIncrementedLongLong(i8 * ptr)
|
||||||
|
{
|
||||||
|
ptr++;
|
||||||
|
return *ptr;
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_LONGLONG */
|
||||||
|
|
||||||
|
i1 pcode_P34_ModifyContentsOfChar(i1 * ptr, i4 index, i1 value)
|
||||||
|
{
|
||||||
|
*(ptr + index) = value;
|
||||||
|
return *(ptr + index);
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_P12_GetIncrementedInt(i4 * ptr)
|
||||||
|
{
|
||||||
|
ptr++;
|
||||||
|
return *ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
i2 pcode_P13_GetIncrementedShort(i2 * ptr)
|
||||||
|
{
|
||||||
|
ptr++;
|
||||||
|
return *ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
u4 pcode_P36_ModifyContentsOfUnsignedInt(u4 * ptr, i4 index, u4 value)
|
||||||
|
{
|
||||||
|
*(ptr + index) = value;
|
||||||
|
return *(ptr + index);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
u8 pcode_P35_ModifyContentsOfUnsignedLongLong(u8 * ptr, i4 index, u8 value)
|
||||||
|
{
|
||||||
|
*(ptr + index) = value;
|
||||||
|
return *(ptr + index);
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_LONGLONG */
|
||||||
|
|
||||||
|
i1 pcode_P14_GetIncrementedChar(i1 * ptr)
|
||||||
|
{
|
||||||
|
ptr++;
|
||||||
|
return *ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
u2 pcode_P37_ModifyContentsOfUnsignedShort(u2 * ptr, i4 index, u2 value)
|
||||||
|
{
|
||||||
|
*(ptr + index) = value;
|
||||||
|
return *(ptr + index);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
i8 *pcode_P61_GetIndexOfLongLong(i8 * base_ptr, i8 * el_ptr)
|
||||||
|
{
|
||||||
|
return (i8 *) (el_ptr - base_ptr);
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_LONGLONG */
|
||||||
|
|
||||||
|
u1 pcode_P38_ModifyContentsOfUnsignedChar(u1 * ptr, i4 index, u1 value)
|
||||||
|
{
|
||||||
|
*(ptr + index) = value;
|
||||||
|
return *(ptr + index);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
u8 pcode_P15_GetIncrementedUnsignedLongLong(u8 * ptr)
|
||||||
|
{
|
||||||
|
ptr++;
|
||||||
|
return *ptr;
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_LONGLONG */
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
f4 pcode_P39_ModifyContentsOfFloat(f4 * ptr, i4 index, f4 value)
|
||||||
|
{
|
||||||
|
*(ptr + index) = value;
|
||||||
|
return *(ptr + index);
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_FLOAT */
|
||||||
|
|
||||||
|
i4 pcode_P63_GetIndexOfShort(i2 * base_ptr, i2 * el_ptr)
|
||||||
|
{
|
||||||
|
return el_ptr - base_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_P62_GetIndexOfInt(i4 * base_ptr, i4 * el_ptr)
|
||||||
|
{
|
||||||
|
return el_ptr - base_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
u2 pcode_P17_GetIncrementedUnsignedShort(u2 * ptr)
|
||||||
|
{
|
||||||
|
ptr++;
|
||||||
|
return *ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
u4 pcode_P16_GetIncrementedUnsignedInt(u4 * ptr)
|
||||||
|
{
|
||||||
|
++ptr;
|
||||||
|
return *ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_P64_GetIndexOfChar(i1 * base_ptr, i1 * el_ptr)
|
||||||
|
{
|
||||||
|
return el_ptr - base_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
u1 pcode_P18_GetIncrementedUnsignedChar(u1 * ptr)
|
||||||
|
{
|
||||||
|
++ptr;
|
||||||
|
return *ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
f8 pcode_P40_ModifyContentsOfDouble(f8 * ptr, i4 index, f8 value)
|
||||||
|
{
|
||||||
|
*(ptr + index) = value;
|
||||||
|
return *(ptr + index);
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_DOUBLE */
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
i8 *pcode_P41_StructGetAddressOfLongLong(big_struct_type *ptr, i4 index)
|
||||||
|
{
|
||||||
|
return (i8 *) & (*(ptr + index)).ll;
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_LONGLONG */
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
i4 pcode_P65_GetIndexOfUnsignedLongLong(u8 * base_ptr, u8 * el_ptr)
|
||||||
|
{
|
||||||
|
return el_ptr - base_ptr;
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_LONGLONG */
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
f4 pcode_P19_GetIncrementedFloat(f4 * ptr)
|
||||||
|
{
|
||||||
|
ptr++;
|
||||||
|
return *ptr;
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_FLOAT */
|
||||||
|
|
||||||
|
i4 *pcode_P42_StructGetAddressOfInt(big_struct_type *ptr, i4 index)
|
||||||
|
{
|
||||||
|
return (i4 *) & (*(ptr + index)).i;
|
||||||
|
}
|
||||||
|
|
||||||
|
i2 *pcode_P43_StructGetAddressOfShort(big_struct_type *ptr, i4 index)
|
||||||
|
{
|
||||||
|
return (i2 *) & (*(ptr + index)).s;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_P66_GetIndexOfUnsignedInt(u4 * base_ptr, u4 * el_ptr)
|
||||||
|
{
|
||||||
|
return el_ptr - base_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
i1 *pcode_P44_StructGetAddressOfChar(big_struct_type *ptr, i4 index)
|
||||||
|
{
|
||||||
|
return (i1 *) & (*(ptr + index)).c;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_P67_GetIndexOfUnsignedShort(u2 * base_ptr, u2 * el_ptr)
|
||||||
|
{
|
||||||
|
return el_ptr - base_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
f8 pcode_P20_GetIncrementedDouble(f8 * ptr)
|
||||||
|
{
|
||||||
|
ptr++;
|
||||||
|
return *ptr;
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_DOUBLE */
|
||||||
|
|
||||||
|
i4 pcode_P68_GetIndexOfUnsignedChar(u1 * base_ptr, u1 * el_ptr)
|
||||||
|
{
|
||||||
|
return el_ptr - base_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
u8 *pcode_P45_StructGetAddressOfUnsignedLongLong(big_struct_type *ptr, i4 index)
|
||||||
|
{
|
||||||
|
return (u8 *) & (*(ptr + index)).ull;
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_LONGLONG */
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
i4 pcode_P69_GetIndexOfFloat(f4 * base_ptr, f4 * el_ptr)
|
||||||
|
{
|
||||||
|
return el_ptr - base_ptr;
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_FLOAT */
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
i8 pcode_P21_GetDecrementedLongLong(i8 * ptr)
|
||||||
|
{
|
||||||
|
return *--ptr;
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_LONGLONG */
|
||||||
|
|
||||||
|
u2 *pcode_P47_StructGetAddressOfUnsignedShort(big_struct_type *ptr, i4 index)
|
||||||
|
{
|
||||||
|
return (u2 *) & (*(ptr + index)).us;
|
||||||
|
}
|
||||||
|
|
||||||
|
u4 *pcode_P46_StructGetAddressOfUnsignedInt(big_struct_type *ptr, i4 index)
|
||||||
|
{
|
||||||
|
return (u4 *) & (*(ptr + index)).ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_P22_GetDecrementedInt(i4 * ptr)
|
||||||
|
{
|
||||||
|
return *--ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
u1 *pcode_P48_StructGetAddressOfUnsignedChar(big_struct_type *ptr, i4 index)
|
||||||
|
{
|
||||||
|
return (u1 *) & (*(ptr + index)).uc;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
i4 pcode_P70_GetIndexOfDouble(f8 * base_ptr, f8 * el_ptr)
|
||||||
|
{
|
||||||
|
return el_ptr - base_ptr;
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_DOUBLE */
|
||||||
|
|
||||||
|
i2 pcode_P23_GetDecrementedShort(i2 * ptr)
|
||||||
|
{
|
||||||
|
return *--ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
i8 *pcode_P51_UnionGetAddressOfLongLong(big_union_type *ptr, i4 index)
|
||||||
|
{
|
||||||
|
return (i8 *) & (*(ptr + index)).ll;
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_LONGLONG */
|
||||||
|
|
||||||
|
i1 pcode_P24_GetDecrementedChar(i1 * ptr)
|
||||||
|
{
|
||||||
|
return *--ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
i8 *pcode_P1_GetAddressOfLongLong(i8 * ptr, i4 index)
|
||||||
|
{
|
||||||
|
return ptr + index;
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_LONGLONG */
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
f4 *pcode_P49_StructGetAddressOfFloat(big_struct_type *ptr, i4 index)
|
||||||
|
{
|
||||||
|
return (f4 *) & (*(ptr + index)).f;
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_FLOAT */
|
||||||
|
|
||||||
|
i4 *pcode_P2_GetAddressOfInt(i4 * ptr, i4 index)
|
||||||
|
{
|
||||||
|
return ptr + index;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
u8 pcode_P25_GetDecrementedUnsignedLongLong(u8 * ptr)
|
||||||
|
{
|
||||||
|
return *--ptr;
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_LONGLONG */
|
||||||
|
|
||||||
|
i4 *pcode_P52_UnionGetAddressOfInt(big_union_type *ptr, i4 index)
|
||||||
|
{
|
||||||
|
return (i4 *) & (*(ptr + index)).i;
|
||||||
|
}
|
||||||
|
|
||||||
|
i2 *pcode_P3_GetAddressOfShort(i2 * ptr, i4 index)
|
||||||
|
{
|
||||||
|
return ptr + index;
|
||||||
|
}
|
||||||
|
|
||||||
|
u4 pcode_P26_GetDecrementedUnsignedInt(u4 * ptr)
|
||||||
|
{
|
||||||
|
return *--ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
i2 *pcode_P53_UnionGetAddressOfShort(big_union_type *ptr, i4 index)
|
||||||
|
{
|
||||||
|
return (i2 *) & (*(ptr + index)).s;
|
||||||
|
}
|
||||||
|
|
||||||
|
i1 *pcode_P4_GetAddressOfChar(i1 * ptr, i4 index)
|
||||||
|
{
|
||||||
|
return ptr + index;
|
||||||
|
}
|
||||||
|
|
||||||
|
u2 pcode_P27_GetDecrementedUnsignedShort(u2 * ptr)
|
||||||
|
{
|
||||||
|
return *--ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
i1 *pcode_P54_UnionGetAddressOfChar(big_union_type *ptr, i4 index)
|
||||||
|
{
|
||||||
|
return (i1 *) & (*(ptr + index)).c;
|
||||||
|
}
|
||||||
|
|
||||||
|
u1 pcode_P28_GetDecrementedUnsignedChar(u1 * ptr)
|
||||||
|
{
|
||||||
|
return *--ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
f8 *pcode_P50_StructGetAddressOfDouble(big_struct_type *ptr, i4 index)
|
||||||
|
{
|
||||||
|
return (f8 *) & (*(ptr + index)).d;
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_DOUBLE */
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
u8 *pcode_P55_UnionGetAddressOfUnsignedLongLong(big_union_type *ptr, i4 index)
|
||||||
|
{
|
||||||
|
return (u8 *) & (*(ptr + index)).ull;
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_LONGLONG */
|
||||||
|
|
||||||
|
u4 *pcode_P6_GetAddressOfUnsignedInt(u4 * ptr, i4 index)
|
||||||
|
{
|
||||||
|
return ptr + index;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
u8 *pcode_P5_GetAddressOfUnsignedLongLong(u8 * ptr, i4 index)
|
||||||
|
{
|
||||||
|
return ptr + index;
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_LONGLONG */
|
||||||
|
|
||||||
|
u2 *pcode_P7_GetAddressOfUnsignedShort(u2 * ptr, i4 index)
|
||||||
|
{
|
||||||
|
return ptr + index;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
f4 pcode_P29_GetDecrementedFloat(f4 * ptr)
|
||||||
|
{
|
||||||
|
return *--ptr;
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_FLOAT */
|
||||||
|
|
||||||
|
u1 *pcode_P8_GetAddressOfUnsignedChar(u1 * ptr, i4 index)
|
||||||
|
{
|
||||||
|
return ptr + index;
|
||||||
|
}
|
||||||
|
|
||||||
|
u4 *pcode_P56_UnionGetAddressOfUnsignedInt(big_union_type *ptr, i4 index)
|
||||||
|
{
|
||||||
|
return (u4 *) & (*(ptr + index)).ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
u2 *pcode_P57_UnionGetAddressOfUnsignedShort(big_union_type *ptr, i4 index)
|
||||||
|
{
|
||||||
|
return (u2 *) & (*(ptr + index)).us;
|
||||||
|
}
|
||||||
@@ -0,0 +1,339 @@
|
|||||||
|
#include "pcode_test.h"
|
||||||
|
#include "big_struct.h"
|
||||||
|
|
||||||
|
extern void bs_init(big_struct_type *);
|
||||||
|
|
||||||
|
TEST pcode_SUM28_BigStructPtrAccessUnsignedInt_Main()
|
||||||
|
{
|
||||||
|
extern u4 pcode_SUM28_BigStructPtrAccessUnsignedInt(big_struct_type *arg);
|
||||||
|
big_struct_type bs;
|
||||||
|
bs_init(&bs);
|
||||||
|
ASSERTU4(pcode_SUM28_BigStructPtrAccessUnsignedInt(&bs), 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_SUM29_BigStructPtrAccessUnsignedShort_Main()
|
||||||
|
{
|
||||||
|
extern u2 pcode_SUM29_BigStructPtrAccessUnsignedShort(big_struct_type *arg);
|
||||||
|
big_struct_type bs;
|
||||||
|
bs_init(&bs);
|
||||||
|
ASSERTU2(pcode_SUM29_BigStructPtrAccessUnsignedShort(&bs), 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_SUM30_BigStructPtrAccessUnsignedChar_Main()
|
||||||
|
{
|
||||||
|
extern u1 pcode_SUM30_BigStructPtrAccessUnsignedChar(big_struct_type *arg);
|
||||||
|
big_struct_type bs;
|
||||||
|
bs_init(&bs);
|
||||||
|
ASSERTU1(pcode_SUM30_BigStructPtrAccessUnsignedChar(&bs), 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
TEST pcode_SUM31_BigStructPtrAccessFloat_Main()
|
||||||
|
{
|
||||||
|
extern f4 pcode_SUM31_BigStructPtrAccessFloat(big_struct_type *arg);
|
||||||
|
big_struct_type bs;
|
||||||
|
bs_init(&bs);
|
||||||
|
ASSERTF4(pcode_SUM31_BigStructPtrAccessFloat(&bs), 8);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
TEST pcode_SUM32_BigStructPtrAccessDouble_Main()
|
||||||
|
{
|
||||||
|
extern f8 pcode_SUM32_BigStructPtrAccessDouble(big_struct_type *arg);
|
||||||
|
big_struct_type bs;
|
||||||
|
bs_init(&bs);
|
||||||
|
ASSERTF8(pcode_SUM32_BigStructPtrAccessDouble(&bs), 8);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
TEST pcode_SUM34_BigUnionPtrAccessLongLong_Main()
|
||||||
|
{
|
||||||
|
extern i8 pcode_SUM34_BigUnionPtrAccessLongLong(big_union_type *arg);
|
||||||
|
big_union_type bu = { 0 };
|
||||||
|
ASSERTI8(pcode_SUM34_BigUnionPtrAccessLongLong(&bu), 7);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST pcode_SUM35_BigUnionPtrAccessInt_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_SUM35_BigUnionPtrAccessInt(big_union_type *arg);
|
||||||
|
big_union_type bu = { 0 };
|
||||||
|
ASSERTI4(pcode_SUM35_BigUnionPtrAccessInt(&bu), 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
TEST pcode_SUM1_BigStructAccessLongLong_Main()
|
||||||
|
{
|
||||||
|
extern i8 pcode_SUM1_BigStructAccessLongLong(big_struct_type arg);
|
||||||
|
big_struct_type bs;
|
||||||
|
bs_init(&bs);
|
||||||
|
ASSERTI8(pcode_SUM1_BigStructAccessLongLong(bs), 8);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST pcode_SUM36_BigUnionPtrAccessShort_Main()
|
||||||
|
{
|
||||||
|
extern i2 pcode_SUM36_BigUnionPtrAccessShort(big_union_type *arg);
|
||||||
|
big_union_type bu = { 0 };
|
||||||
|
ASSERTI2(pcode_SUM36_BigUnionPtrAccessShort(&bu), 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_SUM2_BigStructAccessInt_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_SUM2_BigStructAccessInt(big_struct_type arg);
|
||||||
|
big_struct_type bs;
|
||||||
|
bs_init(&bs);
|
||||||
|
ASSERTI4(pcode_SUM2_BigStructAccessInt(bs), 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_SUM37_BigUnionPtrAccessChar_Main()
|
||||||
|
{
|
||||||
|
extern i1 pcode_SUM37_BigUnionPtrAccessChar(big_union_type *arg);
|
||||||
|
big_union_type bu = { 0 };
|
||||||
|
ASSERTI1(pcode_SUM37_BigUnionPtrAccessChar(&bu), 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TEST pcode_SUM3_BigStructAccessShort_Main()
|
||||||
|
{
|
||||||
|
extern i2 pcode_SUM3_BigStructAccessShort(big_struct_type arg);
|
||||||
|
big_struct_type bs;
|
||||||
|
bs_init(&bs);
|
||||||
|
ASSERTI2(pcode_SUM3_BigStructAccessShort(bs), 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
TEST pcode_SUM38_BigUnionPtrAccessUnsignedLongLong_Main()
|
||||||
|
{
|
||||||
|
extern u8 pcode_SUM38_BigUnionPtrAccessUnsignedLongLong(big_union_type *arg);
|
||||||
|
big_union_type bu = { 0 };
|
||||||
|
ASSERTU8(pcode_SUM38_BigUnionPtrAccessUnsignedLongLong(&bu), 7);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST pcode_SUM4_BigStructAccessChar_Main()
|
||||||
|
{
|
||||||
|
extern i1 pcode_SUM4_BigStructAccessChar(big_struct_type arg);
|
||||||
|
big_struct_type bs;
|
||||||
|
bs_init(&bs);
|
||||||
|
ASSERTI1(pcode_SUM4_BigStructAccessChar(bs), 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_SUM39_BigUnionPtrAccessUnsignedInt_Main()
|
||||||
|
{
|
||||||
|
extern u4 pcode_SUM39_BigUnionPtrAccessUnsignedInt(big_union_type *arg);
|
||||||
|
big_union_type bu = { 0 };
|
||||||
|
ASSERTU4(pcode_SUM39_BigUnionPtrAccessUnsignedInt(&bu), 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_SUM40_BigUnionPtrAccessUnsignedShort_Main()
|
||||||
|
{
|
||||||
|
extern u2 pcode_SUM40_BigUnionPtrAccessUnsignedShort(big_union_type *arg);
|
||||||
|
big_union_type bu = { 0 };
|
||||||
|
ASSERTU2(pcode_SUM40_BigUnionPtrAccessUnsignedShort(&bu), 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
TEST pcode_SUM5_BigStructAccessUnsignedLongLong_Main()
|
||||||
|
{
|
||||||
|
extern u8 pcode_SUM5_BigStructAccessUnsignedLongLong(big_struct_type arg);
|
||||||
|
big_struct_type bs;
|
||||||
|
bs_init(&bs);
|
||||||
|
ASSERTU8(pcode_SUM5_BigStructAccessUnsignedLongLong(bs), 8);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST pcode_SUM41_BigUnionPtrAccessUnsignedChar_Main()
|
||||||
|
{
|
||||||
|
extern u1 pcode_SUM41_BigUnionPtrAccessUnsignedChar(big_union_type *arg);
|
||||||
|
big_union_type bu = { 0 };
|
||||||
|
ASSERTU1(pcode_SUM41_BigUnionPtrAccessUnsignedChar(&bu), 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_SUM6_BigStructAccessUnsignedInt_Main()
|
||||||
|
{
|
||||||
|
extern u4 pcode_SUM6_BigStructAccessUnsignedInt(big_struct_type arg);
|
||||||
|
big_struct_type bs;
|
||||||
|
bs_init(&bs);
|
||||||
|
ASSERTU4(pcode_SUM6_BigStructAccessUnsignedInt(bs), 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_SUM8_BigStructAccessUnsignedChar_Main()
|
||||||
|
{
|
||||||
|
extern u1 pcode_SUM8_BigStructAccessUnsignedChar(big_struct_type arg);
|
||||||
|
big_struct_type bs;
|
||||||
|
bs_init(&bs);
|
||||||
|
ASSERTU1(pcode_SUM8_BigStructAccessUnsignedChar(bs), 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_SUM7_BigStructAccessUnsignedShort_Main()
|
||||||
|
{
|
||||||
|
extern u2 pcode_SUM7_BigStructAccessUnsignedShort(big_struct_type arg);
|
||||||
|
big_struct_type bs;
|
||||||
|
bs_init(&bs);
|
||||||
|
ASSERTU2(pcode_SUM7_BigStructAccessUnsignedShort(bs), 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
TEST pcode_SUM42_BigUnionPtrAccessFloat_Main()
|
||||||
|
{
|
||||||
|
extern f4 pcode_SUM42_BigUnionPtrAccessFloat(big_union_type *arg);
|
||||||
|
big_union_type bu = { 0 };
|
||||||
|
ASSERTF4(pcode_SUM42_BigUnionPtrAccessFloat(&bu), 7);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
TEST pcode_SUM43_BigUnionPtrAccessDouble_Main()
|
||||||
|
{
|
||||||
|
extern f8 pcode_SUM43_BigUnionPtrAccessDouble(big_union_type *arg);
|
||||||
|
big_union_type bu = { 0 };
|
||||||
|
ASSERTF8(pcode_SUM43_BigUnionPtrAccessDouble(&bu), 7);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
TEST pcode_SUM9_BigStructAccessFloat_Main()
|
||||||
|
{
|
||||||
|
extern f4 pcode_SUM9_BigStructAccessFloat(big_struct_type arg);
|
||||||
|
big_struct_type bs;
|
||||||
|
bs_init(&bs);
|
||||||
|
ASSERTF4(pcode_SUM9_BigStructAccessFloat(bs), 8);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
TEST pcode_SUM10_BigStructAccessDouble_Main()
|
||||||
|
{
|
||||||
|
extern f8 pcode_SUM10_BigStructAccessDouble(big_struct_type arg);
|
||||||
|
big_struct_type bs;
|
||||||
|
bs_init(&bs);
|
||||||
|
ASSERTF8(pcode_SUM10_BigStructAccessDouble(bs), 8);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
TEST pcode_SUM12_BigUnionAccessLongLong_Main()
|
||||||
|
{
|
||||||
|
extern i8 pcode_SUM12_BigUnionAccessLongLong(big_union_type arg);
|
||||||
|
big_union_type bu = { 0 };
|
||||||
|
ASSERTI8(pcode_SUM12_BigUnionAccessLongLong(bu), 7);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST pcode_SUM13_BigUnionAccessInt_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_SUM13_BigUnionAccessInt(big_union_type arg);
|
||||||
|
big_union_type bu = { 0 };
|
||||||
|
ASSERTI4(pcode_SUM13_BigUnionAccessInt(bu), 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_SUM14_BigUnionAccessShort_Main()
|
||||||
|
{
|
||||||
|
extern i2 pcode_SUM14_BigUnionAccessShort(big_union_type arg);
|
||||||
|
big_union_type bu = { 0 };
|
||||||
|
ASSERTI2(pcode_SUM14_BigUnionAccessShort(bu), 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_SUM15_BigUnionAccessChar_Main()
|
||||||
|
{
|
||||||
|
extern i1 pcode_SUM15_BigUnionAccessChar(big_union_type arg);
|
||||||
|
big_union_type bu = { 0 };
|
||||||
|
ASSERTI1(pcode_SUM15_BigUnionAccessChar(bu), 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
TEST pcode_SUM16_BigUnionAccessUnsignedLongLong_Main()
|
||||||
|
{
|
||||||
|
extern u8 pcode_SUM16_BigUnionAccessUnsignedLongLong(big_union_type arg);
|
||||||
|
big_union_type bu = { 0 };
|
||||||
|
ASSERTU8(pcode_SUM16_BigUnionAccessUnsignedLongLong(bu), 7);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST pcode_SUM17_BigUnionAccessUnsignedInt_Main()
|
||||||
|
{
|
||||||
|
extern u4 pcode_SUM17_BigUnionAccessUnsignedInt(big_union_type arg);
|
||||||
|
big_union_type bu = { 0 };
|
||||||
|
ASSERTU4(pcode_SUM17_BigUnionAccessUnsignedInt(bu), 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_SUM18_BigUnionAccessUnsignedShort_Main()
|
||||||
|
{
|
||||||
|
extern u2 pcode_SUM18_BigUnionAccessUnsignedShort(big_union_type arg);
|
||||||
|
big_union_type bu = { 0 };
|
||||||
|
ASSERTU2(pcode_SUM18_BigUnionAccessUnsignedShort(bu), 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_SUM19_BigUnionAccessUnsignedChar_Main()
|
||||||
|
{
|
||||||
|
extern u1 pcode_SUM19_BigUnionAccessUnsignedChar(big_union_type arg);
|
||||||
|
big_union_type bu = { 0 };
|
||||||
|
ASSERTU1(pcode_SUM19_BigUnionAccessUnsignedChar(bu), 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
TEST pcode_SUM20_BigUnionAccessFloat_Main()
|
||||||
|
{
|
||||||
|
extern f4 pcode_SUM20_BigUnionAccessFloat(big_union_type arg);
|
||||||
|
big_union_type bu = { 0 };
|
||||||
|
ASSERTF4(pcode_SUM20_BigUnionAccessFloat(bu), 7);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
TEST pcode_SUM21_BigUnionAccessDouble_Main()
|
||||||
|
{
|
||||||
|
extern f8 pcode_SUM21_BigUnionAccessDouble(big_union_type arg);
|
||||||
|
big_union_type bu = { 0 };
|
||||||
|
ASSERTF8(pcode_SUM21_BigUnionAccessDouble(bu), 7);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
TEST pcode_SUM23_BigStructPtrAccessLongLong_Main()
|
||||||
|
{
|
||||||
|
extern i8 pcode_SUM23_BigStructPtrAccessLongLong(big_struct_type *arg);
|
||||||
|
big_struct_type bs;
|
||||||
|
bs_init(&bs);
|
||||||
|
ASSERTI8(pcode_SUM23_BigStructPtrAccessLongLong(&bs), 8);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST pcode_SUM24_BigStructPtrAccessInt_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_SUM24_BigStructPtrAccessInt(big_struct_type *arg);
|
||||||
|
big_struct_type bs;
|
||||||
|
bs_init(&bs);
|
||||||
|
ASSERTI4(pcode_SUM24_BigStructPtrAccessInt(&bs), 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_SUM25_BigStructPtrAccessShort_Main()
|
||||||
|
{
|
||||||
|
extern i2 pcode_SUM25_BigStructPtrAccessShort(big_struct_type *arg);
|
||||||
|
big_struct_type bs;
|
||||||
|
bs_init(&bs);
|
||||||
|
ASSERTI2(pcode_SUM25_BigStructPtrAccessShort(&bs), 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_SUM26_BigStructPtrAccessChar_Main()
|
||||||
|
{
|
||||||
|
extern i1 pcode_SUM26_BigStructPtrAccessChar(big_struct_type *arg);
|
||||||
|
big_struct_type bs;
|
||||||
|
bs_init(&bs);
|
||||||
|
ASSERTI1(pcode_SUM26_BigStructPtrAccessChar(&bs), 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
TEST pcode_SUM27_BigStructPtrAccessUnsignedLongLong_Main()
|
||||||
|
{
|
||||||
|
extern u8 pcode_SUM27_BigStructPtrAccessUnsignedLongLong(big_struct_type *arg);
|
||||||
|
big_struct_type bs;
|
||||||
|
bs_init(&bs);
|
||||||
|
ASSERTU8(pcode_SUM27_BigStructPtrAccessUnsignedLongLong(&bs), 8);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
MAIN StructUnionManipulation_main() { }
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,81 @@
|
|||||||
|
/* ###
|
||||||
|
* IP: GHIDRA
|
||||||
|
*
|
||||||
|
* 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 "pcode_test.h"
|
||||||
|
|
||||||
|
/* A struct to use in testing */
|
||||||
|
|
||||||
|
typedef struct big_struct
|
||||||
|
{
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
long long ll;
|
||||||
|
#else
|
||||||
|
char ll[8];
|
||||||
|
#endif
|
||||||
|
int i;
|
||||||
|
short s;
|
||||||
|
char c;
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
unsigned long long ull;
|
||||||
|
#else
|
||||||
|
char ull[8];
|
||||||
|
#endif
|
||||||
|
unsigned int ui;
|
||||||
|
unsigned short us;
|
||||||
|
unsigned char uc;
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
float f;
|
||||||
|
#else
|
||||||
|
char f[4];
|
||||||
|
#endif
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
double d;
|
||||||
|
#else
|
||||||
|
char d[8];
|
||||||
|
#endif
|
||||||
|
struct big_struct *b;
|
||||||
|
} big_struct_type;
|
||||||
|
|
||||||
|
typedef union big_union
|
||||||
|
{
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
long long ll;
|
||||||
|
#else
|
||||||
|
char ll[8];
|
||||||
|
#endif
|
||||||
|
int i;
|
||||||
|
short s;
|
||||||
|
char c;
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
unsigned long long ull;
|
||||||
|
#else
|
||||||
|
char ull[8];
|
||||||
|
#endif
|
||||||
|
unsigned int ui;
|
||||||
|
unsigned short us;
|
||||||
|
unsigned char uc;
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
float f;
|
||||||
|
#else
|
||||||
|
char f[4];
|
||||||
|
#endif
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
double d;
|
||||||
|
#else
|
||||||
|
char d[8];
|
||||||
|
#endif
|
||||||
|
union big_union *b;
|
||||||
|
} big_union_type;
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,90 @@
|
|||||||
|
#include "pcode_test.h"
|
||||||
|
#include "big_struct.h"
|
||||||
|
|
||||||
|
TEST recursionTestLevel_Main()
|
||||||
|
{
|
||||||
|
extern i4 recursionTestLevel (i4 level, u1 * array, i4 len);
|
||||||
|
i4 i;
|
||||||
|
u1 localArray[128];
|
||||||
|
i4 level = 0;
|
||||||
|
for (i = 0; i < sizeof(localArray); i++) localArray[i] = (8 * level) + i;
|
||||||
|
ASSERTI4(recursionTestLevel(1, localArray, sizeof(localArray)), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST nalign_i2_Main()
|
||||||
|
{
|
||||||
|
extern i2 nalign_i2(i2 in);
|
||||||
|
ASSERTI2(nalign_i2(1), 16);
|
||||||
|
ASSERTI2(nalign_i2(128), 2048);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST nalign_i4_Main()
|
||||||
|
{
|
||||||
|
extern i4 nalign_i4(i4 in);
|
||||||
|
ASSERTI4(nalign_i4(1), 16);
|
||||||
|
ASSERTI4(nalign_i4(1000), 16000);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
TEST nalign_i8_Main()
|
||||||
|
{
|
||||||
|
extern i8 nalign_i8(i8 in);
|
||||||
|
ASSERTI8(nalign_i8(1), 16);
|
||||||
|
ASSERTI8(nalign_i8(128), 2048);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST nalign_struct_Main()
|
||||||
|
{
|
||||||
|
extern i4 nalign_struct(big_struct_type * in);
|
||||||
|
big_struct_type bstruct;
|
||||||
|
ASSERTI4(nalign_struct(&bstruct), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(HAS_FLOAT) && defined(HAS_DOUBLE) && defined(HAS_LONGLONG)
|
||||||
|
TEST pcode_conversions_Main()
|
||||||
|
{
|
||||||
|
extern i4 pcode_conversions(int argc);
|
||||||
|
ASSERTI4(pcode_conversions(0), 0 );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST pcode_memcpy_Main()
|
||||||
|
{
|
||||||
|
extern void *pcode_memcpy(u1* lhs, u1* rhs, u4 len);
|
||||||
|
char buff1[32] = { 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 };
|
||||||
|
char buff2[32] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 };
|
||||||
|
char ret[32];
|
||||||
|
ASSERTU4(* (u4 *) pcode_memcpy((u1*) ret, (u1*) buff1, 32), 0x01010101);
|
||||||
|
ASSERTU4(* (u4 *) pcode_memcpy((u1*) ret, (u1*) buff2, 32), 0x02020202);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_memcmp_u4_Main()
|
||||||
|
{
|
||||||
|
extern u4 pcode_memcmp_u4(u4 lhs, u4 rhs);
|
||||||
|
u1 buff1[] = "this is a test string1";
|
||||||
|
u1 buff2[] = "this is a test string1";
|
||||||
|
u1 buff3[] = "this is a test string2";
|
||||||
|
ASSERTU4(pcode_memcmp_u4(0x1F1F1F1F, 0x1F1F1F1F), 0);
|
||||||
|
ASSERTU4(pcode_memcmp_u4(0x1F1F1F1F, 0x1F1E1F1F), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_memcmp_n_Main()
|
||||||
|
{
|
||||||
|
extern u4 pcode_memcmp_n(u1* lhs, u1* rhs, u4 len);
|
||||||
|
u1 buff1[] = "this is a test string1";
|
||||||
|
u1 buff2[] = "this is a test string1";
|
||||||
|
u1 buff3[] = "this is a test string2";
|
||||||
|
ASSERTU4(pcode_memcmp_n(buff1, buff2, 22), 0);
|
||||||
|
ASSERTU4(pcode_memcmp_n(buff1, buff3, 22), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST pcode_memset_Main()
|
||||||
|
{
|
||||||
|
extern u4 pcode_memset(u1* lhs, u1 val, u4 len);
|
||||||
|
u1 buff[32];
|
||||||
|
ASSERTU4(pcode_memset(buff, 1, 4), 0x01010101);
|
||||||
|
ASSERTU4(pcode_memset(buff, 2, 4), 0x02020202);
|
||||||
|
}
|
||||||
|
|
||||||
|
MAIN misc_main() { }
|
||||||
@@ -0,0 +1,260 @@
|
|||||||
|
/* ###
|
||||||
|
* IP: GHIDRA
|
||||||
|
*
|
||||||
|
* 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 "pcode_test.h"
|
||||||
|
#include "big_struct.h"
|
||||||
|
|
||||||
|
static i4 int_expectedValue;
|
||||||
|
static i4 int_actualValue;
|
||||||
|
|
||||||
|
static i4 breakPointHere(void)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 recursionTestLevel(i4 level, u1 * array, i4 len)
|
||||||
|
{
|
||||||
|
i4 i, ret = 0;
|
||||||
|
u1 localArray[128];
|
||||||
|
|
||||||
|
for (i = 0; i < sizeof(localArray); i++) {
|
||||||
|
localArray[i] = (8 * level) + i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (level < 4 && (ret = recursionTestLevel(level + 1, localArray, len))) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/* verify array integrity */
|
||||||
|
for (i = 0; i < sizeof(localArray); i++) {
|
||||||
|
if (localArray[i] != ((8 * level) + i)) {
|
||||||
|
return ret + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* verify array integrity */
|
||||||
|
for (i = 0; i < sizeof(localArray); i++) {
|
||||||
|
if (array[i] != ((8 * (level - 1)) + i)) {
|
||||||
|
return ret + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
i2 nalign_i2(i2 in)
|
||||||
|
{
|
||||||
|
char buffer[128];
|
||||||
|
|
||||||
|
*(i2 *) (buffer + 1) = in;
|
||||||
|
in += *(i2 *) (buffer + 1);
|
||||||
|
*(i2 *) (buffer + 2) = in;
|
||||||
|
in += *(i2 *) (buffer + 2);
|
||||||
|
*(i2 *) (buffer + 3) = in;
|
||||||
|
in += *(i2 *) (buffer + 3);
|
||||||
|
*(i2 *) (buffer + 4) = in;
|
||||||
|
in += *(i2 *) (buffer + 4);
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 nalign_i4(i4 in)
|
||||||
|
{
|
||||||
|
char buffer[128];
|
||||||
|
|
||||||
|
*(i4 *) (buffer + 1) = in;
|
||||||
|
in += *(i4 *) (buffer + 1);
|
||||||
|
*(i4 *) (buffer + 2) = in;
|
||||||
|
in += *(i4 *) (buffer + 2);
|
||||||
|
*(i4 *) (buffer + 3) = in;
|
||||||
|
in += *(i4 *) (buffer + 3);
|
||||||
|
*(i4 *) (buffer + 4) = in;
|
||||||
|
in += *(i4 *) (buffer + 4);
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
i8 nalign_i8(i8 in)
|
||||||
|
{
|
||||||
|
char buffer[128];
|
||||||
|
*(i8 *) (buffer + 1) = in;
|
||||||
|
in += *(i8 *) (buffer + 1);
|
||||||
|
*(i8 *) (buffer + 2) = in;
|
||||||
|
in += *(i8 *) (buffer + 2);
|
||||||
|
*(i8 *) (buffer + 3) = in;
|
||||||
|
in += *(i8 *) (buffer + 3);
|
||||||
|
*(i8 *) (buffer + 4) = in;
|
||||||
|
in += *(i8 *) (buffer + 4);
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
#endif /* #ifdef HAS_LONGLONG */
|
||||||
|
|
||||||
|
i4 nalign_struct(big_struct_type * in)
|
||||||
|
{
|
||||||
|
i4 ret = 0;
|
||||||
|
char buffer[128];
|
||||||
|
|
||||||
|
in->i = 0x5;
|
||||||
|
if (in->i != 0x5)
|
||||||
|
ret++;
|
||||||
|
in->s = 0x6;
|
||||||
|
if (in->s != 0x6)
|
||||||
|
ret++;
|
||||||
|
in->c = 0x7;
|
||||||
|
if (in->c != 0x7)
|
||||||
|
ret++;
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
in->ll = 0x8;
|
||||||
|
if (in->ll != 0x8)
|
||||||
|
ret++;
|
||||||
|
#endif
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
u4 pcode_memset(u1 *lhs, u1 val, u4 len)
|
||||||
|
{
|
||||||
|
memset(lhs, val, len);
|
||||||
|
return *(u4 *) lhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *pcode_memcpy(u1 * lhs, u1 * rhs, u4 len)
|
||||||
|
{
|
||||||
|
return memcpy(lhs, rhs, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
u4 pcode_memcmp_u4(u4 lhs, u4 rhs)
|
||||||
|
{
|
||||||
|
return (u4) (memcmp(&lhs, &rhs, 4) == 0 ? 0 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
u4 pcode_memcmp_n(u1 * lhs, u1 * rhs, u4 len)
|
||||||
|
{
|
||||||
|
return (u4) (memcmp(lhs, rhs, len) == 0 ? 0 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(HAS_FLOAT) && defined(HAS_DOUBLE) && defined(HAS_LONGLONG)
|
||||||
|
|
||||||
|
/* Almost equal here means a difference between f1 and f2 that is less
|
||||||
|
* than 1% of f2. Naturally, f2 != 0. Implement it without calling
|
||||||
|
* fabs, which would cast everything to double anyway.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int FLOAT_ALMOST_EQUAL(double f1, double f2)
|
||||||
|
{
|
||||||
|
double d = (f1 >= f2 ? f1 - f2 : f2 - f1);
|
||||||
|
double m = (f2 >= 0.0 ? f2 : -f2) * 0.01;
|
||||||
|
return d < m;
|
||||||
|
}
|
||||||
|
|
||||||
|
i4 pcode_conversions(int argc)
|
||||||
|
{
|
||||||
|
i1 u1buff[8];
|
||||||
|
u2 u2buff[8];
|
||||||
|
u4 u4buff[8];
|
||||||
|
u8 u8buff[8];
|
||||||
|
f4 f4buff[8];
|
||||||
|
f8 f8buff[8];
|
||||||
|
u8 ret = 0;
|
||||||
|
i4 i = 0;
|
||||||
|
|
||||||
|
f4 f4_1 = argc;
|
||||||
|
f4 f4_2 = 4.0 - f4_1;
|
||||||
|
if (f4_2 != 4.0)
|
||||||
|
return 101;
|
||||||
|
|
||||||
|
f4 f4_3 = f4_1 + 5.0;
|
||||||
|
if (f4_3 != 5.0)
|
||||||
|
return 102;
|
||||||
|
|
||||||
|
f8 f8_1 = argc;
|
||||||
|
f8 f8_2 = 4.0 - f8_1;
|
||||||
|
if (f8_2 != 4.0)
|
||||||
|
return 103;
|
||||||
|
|
||||||
|
f8 f8_3 = f8_1 + 5.0;
|
||||||
|
if (f8_3 != 5.0)
|
||||||
|
return 104;
|
||||||
|
|
||||||
|
for (i = 0; i < 8; i++) {
|
||||||
|
u1buff[i] = 0;
|
||||||
|
u2buff[i] = 0;
|
||||||
|
u4buff[i] = 0;
|
||||||
|
u8buff[i] = 0;
|
||||||
|
f4buff[i] = 0;
|
||||||
|
f8buff[i] = 0;
|
||||||
|
}
|
||||||
|
u8buff[0] = 0x0FFFFFFFFFFFFFFFULL;
|
||||||
|
|
||||||
|
u4buff[0] = u8buff[0] + argc;
|
||||||
|
|
||||||
|
u2buff[0] = u8buff[0] + argc;
|
||||||
|
u2buff[1] = u4buff[0] + argc;
|
||||||
|
|
||||||
|
u1buff[0] = u8buff[0] + argc;
|
||||||
|
u1buff[1] = u4buff[0] + argc;
|
||||||
|
u1buff[2] = u2buff[0] + argc;
|
||||||
|
|
||||||
|
if (u1buff[0] != (i1) 0xff || u1buff[1] != (i1) 0xff || u1buff[2] != (i1) 0xff || u2buff[0] != 0xffff || u2buff[1] != 0xffff || u4buff[0] != 0xffffffff || u8buff[0] != 0x0fffffffffffffffULL)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
f4buff[0] = 1.0 + argc;
|
||||||
|
if (!FLOAT_ALMOST_EQUAL(f4buff[0], 1.0))
|
||||||
|
return 21;
|
||||||
|
|
||||||
|
f4buff[0] = u8buff[0] + argc;
|
||||||
|
if (!FLOAT_ALMOST_EQUAL(f4buff[0], 1.152921504606846976e+18))
|
||||||
|
return 2;
|
||||||
|
|
||||||
|
f4buff[1] = u4buff[0] + argc;
|
||||||
|
if (!FLOAT_ALMOST_EQUAL(f4buff[1], 4.294967296e+09))
|
||||||
|
return 3;
|
||||||
|
|
||||||
|
f4buff[2] = u2buff[0] + argc;
|
||||||
|
if (!FLOAT_ALMOST_EQUAL(f4buff[2], 6.5535e+04))
|
||||||
|
return 4;
|
||||||
|
|
||||||
|
f4buff[3] = u1buff[0] + argc;
|
||||||
|
if (!FLOAT_ALMOST_EQUAL(f4buff[3], -1.0e+00))
|
||||||
|
return 5;
|
||||||
|
|
||||||
|
f8buff[0] = u8buff[0] + argc;
|
||||||
|
if (!FLOAT_ALMOST_EQUAL(f8buff[0], 1.152921504606846976e+18))
|
||||||
|
return 6;
|
||||||
|
|
||||||
|
f8buff[1] = u4buff[0] + argc;
|
||||||
|
if (!FLOAT_ALMOST_EQUAL(f8buff[1], 4.294967295e+09))
|
||||||
|
return 7;
|
||||||
|
f8buff[2] = u2buff[0] + argc;
|
||||||
|
if (!FLOAT_ALMOST_EQUAL(f8buff[2], 6.5535e+04))
|
||||||
|
return 8;
|
||||||
|
|
||||||
|
f8buff[3] = u1buff[0] + argc;
|
||||||
|
if (!FLOAT_ALMOST_EQUAL(f8buff[3], -1.0e+00))
|
||||||
|
return 9;
|
||||||
|
|
||||||
|
f8buff[4] = f4buff[0] + argc;
|
||||||
|
if (!FLOAT_ALMOST_EQUAL(f8buff[4], 1.152921504606846976e+18))
|
||||||
|
return 10;
|
||||||
|
|
||||||
|
f8 tmpf8 = f8buff[4] + f8buff[3] - f8buff[2] + f8buff[1] - f8buff[0]
|
||||||
|
+ f4buff[4] + f4buff[3] - f4buff[2] + f4buff[1] - f4buff[0];
|
||||||
|
|
||||||
|
if (!FLOAT_ALMOST_EQUAL(tmpf8, -1.15292149601704345600e+18))
|
||||||
|
return 11;
|
||||||
|
|
||||||
|
u8 retll = u1buff[0] + u1buff[1] - u1buff[2] + u4buff[0] + u8buff[0];
|
||||||
|
|
||||||
|
if (retll != 0x10000000fffffffdULL)
|
||||||
|
return 12;
|
||||||
|
|
||||||
|
return 0; // OK
|
||||||
|
}
|
||||||
|
#endif /* #if defined(HAS_FLOAT) && defined(HAS_DOUBLE) && defined(HAS_LONGLONG) */
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
MEMORY {
|
||||||
|
RAM : ORIGIN = 0, LENGTH = 0x4000
|
||||||
|
ROM (rx) : ORIGIN = 0x4000, LENGTH = 32k
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTIONS {
|
||||||
|
.rodata : { *(.eh_frame) } >ROM
|
||||||
|
.data : { } >RAM
|
||||||
|
.bss : { } >RAM
|
||||||
|
}
|
||||||
@@ -0,0 +1,300 @@
|
|||||||
|
/* ###
|
||||||
|
* IP: GHIDRA
|
||||||
|
*
|
||||||
|
* 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 "pcode_test.h"
|
||||||
|
|
||||||
|
#define STRINGIFY(x) #x
|
||||||
|
#define TOSTRING(x) STRINGIFY(x)
|
||||||
|
|
||||||
|
NOINLINE i4 breakOnPass(void);
|
||||||
|
NOINLINE i4 breakOnError(void);
|
||||||
|
void nosprintf5() { } /* sprintf5 function was removed, but java is still looking for it. */
|
||||||
|
|
||||||
|
FunctionInfo mainFunctionInfoTable[] = {
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
{"assertF4", (testFuncPtr) assertF4, 0},
|
||||||
|
#endif
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
{"assertF8", (testFuncPtr) assertF8, 0},
|
||||||
|
#endif
|
||||||
|
{"assertI1", (testFuncPtr) assertI1, 0},
|
||||||
|
{"assertI2", (testFuncPtr) assertI2, 0},
|
||||||
|
{"assertI4", (testFuncPtr) assertI4, 0},
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
{"assertI8", (testFuncPtr) assertI8, 0},
|
||||||
|
#endif
|
||||||
|
{"assertU1", (testFuncPtr) assertU1, 0},
|
||||||
|
{"assertU2", (testFuncPtr) assertU2, 0},
|
||||||
|
{"assertU4", (testFuncPtr) assertU4, 0},
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
{"assertU8", (testFuncPtr) assertU8, 0},
|
||||||
|
#endif
|
||||||
|
{"breakOnDone", (testFuncPtr) breakOnDone, 0},
|
||||||
|
{"breakOnError", (testFuncPtr) breakOnError, 0},
|
||||||
|
{"breakOnPass", (testFuncPtr) breakOnPass, 0},
|
||||||
|
{"breakOnSubDone", (testFuncPtr) breakOnSubDone, 0},
|
||||||
|
{"noteTestMain", (testFuncPtr) noteTestMain, 0},
|
||||||
|
{0, 0, 0},
|
||||||
|
};
|
||||||
|
|
||||||
|
static TestInfo MainInfo = {
|
||||||
|
{'A', 'b', 'C', 'd', 'E', 'F', 'g', 'H'},
|
||||||
|
sizeof(i1 *), /* ptrSz */
|
||||||
|
0x01020304, /* byteOrder */
|
||||||
|
breakOnPass, /* onPass function ptr */
|
||||||
|
breakOnError, /* onError function ptr */
|
||||||
|
breakOnDone, /* onDone function ptr */
|
||||||
|
0, /* numpass */
|
||||||
|
0, /* numfail */
|
||||||
|
0, /* lastTestPos */
|
||||||
|
0, /* lastErrorLine */
|
||||||
|
"none", /* lastErrorFile */
|
||||||
|
"none", /* lasFunc */
|
||||||
|
nosprintf5, /* sprintf5 function ptr */
|
||||||
|
0, /* sprintf5 buffer */
|
||||||
|
0, /* sprintf5 enabled flag */
|
||||||
|
__VERSION__, /* compiler version */
|
||||||
|
TOSTRING(NAME), /* value of name symbol */
|
||||||
|
TOSTRING(THECCFLAGS), /* value of THECCFLAGS symbol */
|
||||||
|
"BUILDDATE: " __DATE__, /* build date */
|
||||||
|
mainFunctionInfoTable, /* function table */
|
||||||
|
};
|
||||||
|
|
||||||
|
NOINLINE void TestInfo_reset(void)
|
||||||
|
{
|
||||||
|
MainInfo.numpass = 0;
|
||||||
|
MainInfo.numfail = 0;
|
||||||
|
MainInfo.lastTestPos = 0;
|
||||||
|
MainInfo.lastErrorFile = "none";
|
||||||
|
MainInfo.lastFunc = "none";
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Injected call when a test is done */
|
||||||
|
|
||||||
|
NOINLINE i4 breakOnDone(const char *file, int line, const char *func)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Called from assert when a test passes */
|
||||||
|
|
||||||
|
NOINLINE i4 breakOnPass(void)
|
||||||
|
{
|
||||||
|
MainInfo.numpass++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Called from assert when a test fails */
|
||||||
|
|
||||||
|
NOINLINE i4 breakOnError(void)
|
||||||
|
{
|
||||||
|
MainInfo.numfail++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Injected call when a subtest is done */
|
||||||
|
|
||||||
|
NOINLINE i4 breakOnSubDone(const char *file, int line, const char *func)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Injected at start of a test to record file position */
|
||||||
|
|
||||||
|
void noteTestMain(const char *file, int line, const char *func)
|
||||||
|
{
|
||||||
|
MainInfo.lastFunc = (char *) func;
|
||||||
|
MainInfo.lastTestPos = line;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(BUILD_EXE)
|
||||||
|
#define DO_PRINT_INT(ok) print_int(file, line, MainInfo.lastFunc, expected, val, (ok) ? "OK" : "ERROR");
|
||||||
|
#define DO_PRINT_LONG(ok) print_long(file, line, MainInfo.lastFunc, expected, val, (ok) ? "OK" : "ERROR");
|
||||||
|
/* for ARM platform, and possibly others, printf does not properly handle long long args */
|
||||||
|
#define DO_PRINT_LONGLONG(ok) print_long(file, line, MainInfo.lastFunc, (long) expected, (long) val, (ok) ? "OK" : "ERROR");
|
||||||
|
#define DO_PRINT_UINT(ok) print_uint(file, line, MainInfo.lastFunc, expected, val, (ok) ? "OK" : "ERROR");
|
||||||
|
#define DO_PRINT_ULONG(ok) print_ulong(file, line, MainInfo.lastFunc, expected, val, (ok) ? "OK" : "ERROR");
|
||||||
|
#define DO_PRINT_ULONGLONG(ok) print_ulong(file, line, MainInfo.lastFunc, (long) expected, (long) val, (ok) ? "OK" : "ERROR");
|
||||||
|
#define DO_PRINT_FLOAT(ok) print_float(file, line, MainInfo.lastFunc, expected, val, (ok) ? "OK" : "ERROR");
|
||||||
|
#else
|
||||||
|
#define DO_PRINT_INT(ok)
|
||||||
|
#define DO_PRINT_LONG(ok)
|
||||||
|
#define DO_PRINT_LONGLONG(ok)
|
||||||
|
#define DO_PRINT_UINT(ok)
|
||||||
|
#define DO_PRINT_ULONG(ok)
|
||||||
|
#define DO_PRINT_ULONGLONG(ok)
|
||||||
|
#define DO_PRINT_FLOAT(ok)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* The remaining functions are asserts. Assert functions perform
|
||||||
|
* comparison of expected and actual values, record location of
|
||||||
|
* errors, and call breakOnPass or breakOnError.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void assertI1(const char *file, int line, const char *func, i1 val, i1 expected)
|
||||||
|
{
|
||||||
|
if (val == expected) {
|
||||||
|
breakOnPass();
|
||||||
|
} else {
|
||||||
|
MainInfo.lastErrorLine = line;
|
||||||
|
MainInfo.lastErrorFile = (char *) file;
|
||||||
|
breakOnError();
|
||||||
|
}
|
||||||
|
MainInfo.lastTestPos = line;
|
||||||
|
DO_PRINT_INT(val == expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
void assertI2(const char *file, int line, const char *func, i2 val, i2 expected)
|
||||||
|
{
|
||||||
|
if (val == expected) {
|
||||||
|
breakOnPass();
|
||||||
|
} else {
|
||||||
|
MainInfo.lastErrorLine = line;
|
||||||
|
MainInfo.lastErrorFile = (char *) file;
|
||||||
|
breakOnError();
|
||||||
|
}
|
||||||
|
MainInfo.lastTestPos = line;
|
||||||
|
DO_PRINT_INT(val == expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
void assertI4(const char *file, int line, const char *func, i4 val, i4 expected)
|
||||||
|
{
|
||||||
|
if (val == expected) {
|
||||||
|
breakOnPass();
|
||||||
|
} else {
|
||||||
|
MainInfo.lastErrorLine = line;
|
||||||
|
MainInfo.lastErrorFile = (char *) file;
|
||||||
|
breakOnError();
|
||||||
|
}
|
||||||
|
MainInfo.lastTestPos = line;
|
||||||
|
DO_PRINT_INT(val == expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
void assertI8(const char *file, int line, const char *func, i8 val, i8 expected)
|
||||||
|
{
|
||||||
|
if (val == expected) {
|
||||||
|
breakOnPass();
|
||||||
|
} else {
|
||||||
|
MainInfo.lastErrorLine = line;
|
||||||
|
MainInfo.lastErrorFile = (char *) file;
|
||||||
|
breakOnError();
|
||||||
|
}
|
||||||
|
MainInfo.lastTestPos = line;
|
||||||
|
DO_PRINT_LONGLONG(val == expected);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void assertU1(const char *file, int line, const char *func, u1 val, u1 expected)
|
||||||
|
{
|
||||||
|
if (val == expected) {
|
||||||
|
breakOnPass();
|
||||||
|
} else {
|
||||||
|
MainInfo.lastErrorLine = line;
|
||||||
|
MainInfo.lastErrorFile = (char *) file;
|
||||||
|
breakOnError();
|
||||||
|
}
|
||||||
|
MainInfo.lastTestPos = line;
|
||||||
|
DO_PRINT_UINT(val == expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
void assertU2(const char *file, int line, const char *func, u2 val, u2 expected)
|
||||||
|
{
|
||||||
|
if (val == expected) {
|
||||||
|
breakOnPass();
|
||||||
|
} else {
|
||||||
|
MainInfo.lastErrorLine = line;
|
||||||
|
MainInfo.lastErrorFile = (char *) file;
|
||||||
|
breakOnError();
|
||||||
|
}
|
||||||
|
MainInfo.lastTestPos = line;
|
||||||
|
DO_PRINT_UINT(val == expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
void assertU4(const char *file, int line, const char *func, u4 val, u4 expected)
|
||||||
|
{
|
||||||
|
if (val == expected) {
|
||||||
|
breakOnPass();
|
||||||
|
} else {
|
||||||
|
MainInfo.lastErrorLine = line;
|
||||||
|
MainInfo.lastErrorFile = (char *) file;
|
||||||
|
breakOnError();
|
||||||
|
MainInfo.numfail++;
|
||||||
|
}
|
||||||
|
MainInfo.lastTestPos = line;
|
||||||
|
DO_PRINT_UINT(val == expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
void assertU8(const char *file, int line, const char *func, u8 val, u8 expected)
|
||||||
|
{
|
||||||
|
if (val == expected) {
|
||||||
|
breakOnPass();
|
||||||
|
} else {
|
||||||
|
MainInfo.lastErrorLine = line;
|
||||||
|
MainInfo.lastErrorFile = (char *) file;
|
||||||
|
breakOnError();
|
||||||
|
}
|
||||||
|
MainInfo.lastTestPos = line;
|
||||||
|
DO_PRINT_ULONGLONG(val == expected);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
void assertF4(const char *file, int line, const char *func, f4 val, f4 expected)
|
||||||
|
{
|
||||||
|
u4 u4Val = *(u4 *) & val;
|
||||||
|
u4 u4Expected = *(u4 *) & expected;
|
||||||
|
|
||||||
|
/* Mask off last byte from value and expected */
|
||||||
|
u4Val &= 0xFFFFFF00;
|
||||||
|
u4Expected &= 0xFFFFFF00;
|
||||||
|
|
||||||
|
/* Should fail if diff in sign/exponent/or more than (0xFF * eplison) */
|
||||||
|
if (u4Val == u4Expected) {
|
||||||
|
breakOnPass();
|
||||||
|
} else {
|
||||||
|
MainInfo.lastErrorLine = line;
|
||||||
|
MainInfo.lastErrorFile = (char *) file;
|
||||||
|
breakOnError();
|
||||||
|
}
|
||||||
|
MainInfo.lastTestPos = line;
|
||||||
|
DO_PRINT_FLOAT(u4Val == u4Expected);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
void assertF8(const char *file, int line, const char *func, f8 val, f8 expected)
|
||||||
|
{
|
||||||
|
u8 u8Val = *(u8 *) & val;
|
||||||
|
u8 u8Expected = *(u8 *) & expected;
|
||||||
|
|
||||||
|
/* Mask off last 2 bytes from value and expected */
|
||||||
|
u8Val &= 0xFFFFFFFFFFFF0000ULL;
|
||||||
|
u8Expected &= 0xFFFFFFFFFFFF0000ULL;
|
||||||
|
|
||||||
|
/* Should fail if diff in sign/exponent/or more than (0xFFFF * eplison) */
|
||||||
|
if (u8Val == u8Expected) {
|
||||||
|
breakOnPass();
|
||||||
|
} else {
|
||||||
|
MainInfo.lastErrorLine = line;
|
||||||
|
MainInfo.lastErrorFile = (char *) file;
|
||||||
|
breakOnError();
|
||||||
|
}
|
||||||
|
MainInfo.lastTestPos = line;
|
||||||
|
DO_PRINT_FLOAT(u8Val == u8Expected);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
/* ###
|
||||||
|
* IP: GHIDRA
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#ifndef PCODE_TEST_H
|
||||||
|
#define PCODE_TEST_H
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
#define TEST void
|
||||||
|
#define MAIN void
|
||||||
|
|
||||||
|
#ifdef HAS_GNU_ATTRIBUTES
|
||||||
|
#define NOINLINE __attribute__ ((__noinline__))
|
||||||
|
#define PACKED_STRUCTURE __attribute__((__packed__))
|
||||||
|
#else
|
||||||
|
#define NOINLINE
|
||||||
|
#define PACKED_STRUCTURE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef i4 (*entryFunc)(i4 * val);
|
||||||
|
typedef i4 (*breakOn)(void);
|
||||||
|
typedef i4 (*testFuncPtr)(void);
|
||||||
|
|
||||||
|
typedef struct PACKED_STRUCTURE FunctionInfo
|
||||||
|
{
|
||||||
|
char *name; /* Name of function, used in pcode test reporting */
|
||||||
|
testFuncPtr func; /* Pointer to function */
|
||||||
|
i4 numTest; /* Number of expected tests */
|
||||||
|
} FunctionInfo;
|
||||||
|
|
||||||
|
typedef struct PACKED_STRUCTURE TestInfo
|
||||||
|
{
|
||||||
|
char id[8]; /* id constains a "Magic Number" which will allow us to find this in a binary */
|
||||||
|
u4 ptrSz; /* how many bytes in a pointer? */
|
||||||
|
u4 byteOrder; /* value 0x01020304 used to detect endianess */
|
||||||
|
breakOn onPass; /* address of breakOnPass function, (where it goes on test pass) */
|
||||||
|
breakOn onError; /* address of breakOnError function, (where it goes on test failure) */
|
||||||
|
breakOn onDone; /* address of breakOnDone function, (where it goes when all test done) */
|
||||||
|
u4 numpass; /* How many test passed */
|
||||||
|
u4 numfail; /* How many test failed */
|
||||||
|
u4 lastTestPos; /* Last test index number */
|
||||||
|
u4 lastErrorLine; /* Line number of last error. */
|
||||||
|
char *lastErrorFile; /* File name of last error. */
|
||||||
|
char *lastFunc; /* Last function ran. */
|
||||||
|
void *sprintf5; /* Our embedded sprintf function */
|
||||||
|
void *sprintf5buffer; /* Buffer where our embedded sprintf write to */
|
||||||
|
u4 sprintf5Enabled; /* Turn on off our embedded sprintf */
|
||||||
|
char *compilerVersion; /* Compiler version info (gcc specific) */
|
||||||
|
char *name; /* Test binary name */
|
||||||
|
char *ccflags; /* Flags used to compile this */
|
||||||
|
char *buildDate; /* when this was compiled */
|
||||||
|
FunctionInfo *funcTable; /* a function table */
|
||||||
|
} TestInfo;
|
||||||
|
|
||||||
|
typedef struct PACKED_STRUCTURE GroupInfo
|
||||||
|
{
|
||||||
|
char id[8]; /* id constains a "Magic Number" which will allow us to find this in a binary */
|
||||||
|
FunctionInfo *funcTable; /* Table of test functions in this group */
|
||||||
|
} GroupInfo;
|
||||||
|
|
||||||
|
void noteTestMain(const char *file, int line, const char *func);
|
||||||
|
void assertI1(const char *file, int line, const char *func, i1 val, i1 expected);
|
||||||
|
void assertI2(const char *file, int line, const char *func, i2 val, i2 expected);
|
||||||
|
void assertI4(const char *file, int line, const char *func, i4 val, i4 expected);
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
void assertI8(const char *file, int line, const char *func, i8 val, i8 expected);
|
||||||
|
#endif
|
||||||
|
void assertU1(const char *file, int line, const char *func, u1 val, u1 expected);
|
||||||
|
void assertU2(const char *file, int line, const char *func, u2 val, u2 expected);
|
||||||
|
void assertU4(const char *file, int line, const char *func, u4 val, u4 expected);
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
void assertU8(const char *file, int line, const char *func, u8 val, u8 expected);
|
||||||
|
#endif
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
void assertF4(const char *file, int line, const char *func, f4 val, f4 expected);
|
||||||
|
#endif
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
void assertF8(const char *file, int line, const char *func, f8 val, f8 expected);
|
||||||
|
#endif
|
||||||
|
NOINLINE i4 breakOnDone(const char *file, int line, const char *func);
|
||||||
|
// NOINLINE void TestInfo_register(void); /* Register a TestInfo */
|
||||||
|
NOINLINE void TestInfo_reset(void);
|
||||||
|
NOINLINE i4 breakOnSubDone(const char *file, int line, const char *func);
|
||||||
|
|
||||||
|
#define ASSERTI1(val, exp) assertI1(__FILE__, __LINE__, 0, val, exp);
|
||||||
|
#define ASSERTI2(val, exp) assertI2(__FILE__, __LINE__, 0, val, exp);
|
||||||
|
#define ASSERTI4(val, exp) assertI4(__FILE__, __LINE__, 0, val, exp);
|
||||||
|
#define ASSERTI8(val, exp) assertI8(__FILE__, __LINE__, 0, val, exp);
|
||||||
|
#define ASSERTU1(val, exp) assertU1(__FILE__, __LINE__, 0, val, exp);
|
||||||
|
#define ASSERTU2(val, exp) assertU2(__FILE__, __LINE__, 0, val, exp);
|
||||||
|
#define ASSERTU4(val, exp) assertU4(__FILE__, __LINE__, 0, val, exp);
|
||||||
|
#define ASSERTU8(val, exp) assertU8(__FILE__, __LINE__, 0, val, exp);
|
||||||
|
#define ASSERTF4(val, exp) assertF4(__FILE__, __LINE__, 0, val, exp);
|
||||||
|
#define ASSERTF8(val, exp) assertF8(__FILE__, __LINE__, 0, val, exp);
|
||||||
|
|
||||||
|
#endif /* PCODE_TEST_H */
|
||||||
|
|
||||||
@@ -0,0 +1,364 @@
|
|||||||
|
/* ###
|
||||||
|
* IP: GHIDRA
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#if defined(__GNUC__) && !defined(__llvm__)
|
||||||
|
#define HAS_GNU_ATTRIBUTES 1
|
||||||
|
#define FUNCNAME __FUNCTION__
|
||||||
|
|
||||||
|
#define NO_OPTIMIZE __attribute__((optimize("O0")))
|
||||||
|
#elif defined(__llvm__)
|
||||||
|
#define HAS_GNU_ATTRIBUTES 1
|
||||||
|
#define FUNCNAME __FUNCTION__
|
||||||
|
#define NO_OPTIMIZE __attribute__((optimize("O0")))
|
||||||
|
#elif defined(__SDCC)
|
||||||
|
#define FUNCNAME __func__
|
||||||
|
#define NO_OPTIMIZE
|
||||||
|
#else
|
||||||
|
#if !defined(__MSP430__)
|
||||||
|
#define __VERSION__ "version"
|
||||||
|
#endif
|
||||||
|
#define FUNCNAME __FUNCTION__
|
||||||
|
#define NO_OPTIMIZE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Make the default to have float double and long long types defined
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define HAS_FLOAT 1
|
||||||
|
#define HAS_DOUBLE 1
|
||||||
|
#define HAS_LONGLONG 1
|
||||||
|
|
||||||
|
#ifdef HAS_FLOAT_OVERRIDE
|
||||||
|
#undef HAS_FLOAT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_DOUBLE_OVERRIDE
|
||||||
|
#undef HAS_DOUBLE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG_OVERRIDE
|
||||||
|
#undef HAS_LONGLONG
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Define some standard types, these are defined to be the same on
|
||||||
|
* different platforms and compilers
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(_MSV_VER)
|
||||||
|
#define IS_COMPILER_MSVC 1
|
||||||
|
#elif defined(__TI_COMPILER_VERSION__)
|
||||||
|
#define IS_COMPILER_CODECOMPOSERSTUDIO 1
|
||||||
|
#elif defined(__GNUC__) && !defined(__INT8_TYPE__) && !defined(__llvm__)
|
||||||
|
#define IS_COMPILER_PRE48_GCC
|
||||||
|
#elif defined(__GNUC__) && defined(__INT8_TYPE__) && !defined(__llvm__)
|
||||||
|
#define IS_COMPILER_POST48_GCC
|
||||||
|
#elif defined(__llvm__)
|
||||||
|
#if !defined(__INT8_TYPE__)
|
||||||
|
#define IS_COMPILER_PRE48_GCC
|
||||||
|
#else
|
||||||
|
#define IS_COMPILER_LLVM
|
||||||
|
#endif
|
||||||
|
#else /* defined(MSV_VER) */
|
||||||
|
#define IS_COMPILER_UNKNOWN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(IS_COMPILER_UNKNOWN) || defined(IS_COMPILER_PRE48_GCC)
|
||||||
|
|
||||||
|
/* Catch specific platforms */
|
||||||
|
#ifdef __AVR_ARCH__ /* defined(IS_COMPILER_UNKNOWN) || defined(IS_COMPILER_PRE48_GCC) && defined(__AVR_ARCH__) */
|
||||||
|
typedef unsigned char u1;
|
||||||
|
typedef signed char i1;
|
||||||
|
typedef unsigned short u2;
|
||||||
|
typedef signed short i2;
|
||||||
|
typedef unsigned long u4;
|
||||||
|
typedef signed long i4;
|
||||||
|
typedef long long i8;
|
||||||
|
typedef unsigned long long u8;
|
||||||
|
typedef float f4;
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
#endif
|
||||||
|
typedef i4 size_t;
|
||||||
|
#elif __AVR32__
|
||||||
|
typedef unsigned char u1;
|
||||||
|
typedef signed char i1;
|
||||||
|
typedef unsigned short u2;
|
||||||
|
typedef signed short i2;
|
||||||
|
typedef unsigned int u4;
|
||||||
|
typedef signed int i4;
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
typedef long long i8;
|
||||||
|
typedef unsigned long long u8;
|
||||||
|
#endif
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
typedef float f4;
|
||||||
|
#endif
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
typedef double f8;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef __SIZE_TYPE__ size_t;
|
||||||
|
#else /* defined(IS_COMPILER_UNKNOWN) || defined(IS_COMPILER_PRE48_GCC) && !defined(__AVR_ARCH__) */
|
||||||
|
/* This is for non-GNU non CodeComposerStudio generic case. */
|
||||||
|
typedef unsigned char u1;
|
||||||
|
typedef signed char i1;
|
||||||
|
typedef unsigned short u2;
|
||||||
|
typedef signed short i2;
|
||||||
|
#ifdef INT4_IS_LONG
|
||||||
|
typedef unsigned long u4;
|
||||||
|
typedef signed long i4;
|
||||||
|
#else
|
||||||
|
typedef unsigned int u4;
|
||||||
|
typedef signed int i4;
|
||||||
|
#endif
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
typedef long long i8;
|
||||||
|
typedef unsigned long long u8;
|
||||||
|
#endif
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
typedef float f4;
|
||||||
|
#endif
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
#ifdef dsPIC30
|
||||||
|
typedef long double f8;
|
||||||
|
#else
|
||||||
|
typedef double f8;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
typedef i8 size_t;
|
||||||
|
#else
|
||||||
|
typedef i4 size_t;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* #if defined(IS_COMPILER_UNKNOWN) || defined(IS_COMPILER_PRE48_GCC) */
|
||||||
|
|
||||||
|
/* For CodeComposerStudio */
|
||||||
|
#if defined(IS_COMPILER_CODECOMPOSERSTUDIO)
|
||||||
|
|
||||||
|
#if defined(__MSP430__) /* defined(IS_COMPILER_CODECOMPOSERSTUDIO) && defined(__MSP430__) */
|
||||||
|
|
||||||
|
typedef unsigned char u1;
|
||||||
|
typedef signed char i1;
|
||||||
|
typedef unsigned short u2;
|
||||||
|
typedef signed short i2;
|
||||||
|
typedef unsigned long u4;
|
||||||
|
typedef signed long i4;
|
||||||
|
|
||||||
|
#undef HAS_FLOAT
|
||||||
|
#undef HAS_DOUBLE
|
||||||
|
#undef HAS_LONGLONG
|
||||||
|
#undef HAS_GNU_ATTRIBUTES
|
||||||
|
|
||||||
|
typedef unsigned int size_t;
|
||||||
|
|
||||||
|
#endif /* #if defined(__MSP430__) */
|
||||||
|
|
||||||
|
#endif /* #if defined(IS_COMPILER_CODECOMPOSERSTUDIO) */
|
||||||
|
|
||||||
|
/* For GNU compilers */
|
||||||
|
/* Modern GNU compilers > 4.7 have size macros to uses to give us definitions. */
|
||||||
|
|
||||||
|
#if defined(IS_COMPILER_POST48_GCC)
|
||||||
|
|
||||||
|
typedef __SIZE_TYPE__ size_t;
|
||||||
|
|
||||||
|
typedef __INT8_TYPE__ i1;
|
||||||
|
typedef __INT16_TYPE__ i2;
|
||||||
|
typedef __INT32_TYPE__ i4;
|
||||||
|
#if defined(__INT64_TYPE__)
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
typedef __INT64_TYPE__ i8;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef __UINT8_TYPE__ u1;
|
||||||
|
typedef __UINT16_TYPE__ u2;
|
||||||
|
typedef __UINT32_TYPE__ u4;
|
||||||
|
#if defined(__UINT64_TYPE__)
|
||||||
|
#ifdef HAS_LONGLONG
|
||||||
|
typedef __UINT64_TYPE__ u8;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __SIZEOF_FLOAT__
|
||||||
|
#ifdef HAS_FLOAT
|
||||||
|
typedef float f4;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __SIZEOF_DOUBLE__
|
||||||
|
#ifdef HAS_DOUBLE
|
||||||
|
typedef double f8;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define TYPES_ARE_DEFINED 1
|
||||||
|
#endif /* #if defined(IS_COMPILER_POST48_GCC) */
|
||||||
|
|
||||||
|
/* Microsoft VisualC++ compiler */
|
||||||
|
#if defined(IS_COMPILER_MSVC)
|
||||||
|
|
||||||
|
/* ARM on Visual C++ */
|
||||||
|
#if defined(_M_ARM_FP) /* defined(IS_COMPILER_MSVC) && defined(_M_ARM_FP) */
|
||||||
|
typedef unsigned char u1;
|
||||||
|
typedef signed char i1;
|
||||||
|
typedef unsigned short u2;
|
||||||
|
typedef signed short i2;
|
||||||
|
typedef unsigned long u4;
|
||||||
|
typedef signed long i4;
|
||||||
|
|
||||||
|
#undef HAS_FLOAT
|
||||||
|
#undef HAS_DOUBLE
|
||||||
|
#undef HAS_LONGLONG
|
||||||
|
#undef HAS_GNU_ATTRIBUTES
|
||||||
|
|
||||||
|
typedef unsigned int size_t;
|
||||||
|
|
||||||
|
#endif /* #if defined(IS_COMPILER_MSVC) */
|
||||||
|
|
||||||
|
#endif /* #if defined(_M_ARM_FP) */
|
||||||
|
|
||||||
|
#ifdef IS_COMPILER_LLVM
|
||||||
|
typedef unsigned char u1;
|
||||||
|
typedef signed char i1;
|
||||||
|
typedef unsigned short u2;
|
||||||
|
typedef signed short i2;
|
||||||
|
typedef unsigned __INT32_TYPE__ u4;
|
||||||
|
typedef signed __INT32_TYPE__ i4;
|
||||||
|
#ifdef __INT64_TYPE__
|
||||||
|
typedef unsigned long long u8;
|
||||||
|
typedef signed long long i8;
|
||||||
|
#define HAS_LONGLONG
|
||||||
|
#else
|
||||||
|
#undef HAS_LONGLONG
|
||||||
|
#endif /* LONGLONG */
|
||||||
|
#ifdef __SIZEOF_FLOAT__
|
||||||
|
typedef float f4;
|
||||||
|
#define HAS_FLOAT
|
||||||
|
#else
|
||||||
|
#undef HAS_FLOAT
|
||||||
|
#endif /* FLOAT */
|
||||||
|
#ifdef __SIZEOF_DOUBLE__
|
||||||
|
typedef double f8;
|
||||||
|
#define HAS_DOUBLE
|
||||||
|
#else
|
||||||
|
#undef HAS_DOUBLE
|
||||||
|
#endif /* DOUBLE */
|
||||||
|
|
||||||
|
/* __is_identifier __has_feature */
|
||||||
|
#ifdef __has_feature /* LLVM clang magic (see clang docs) */
|
||||||
|
#pragma message "has __has_feature"
|
||||||
|
#if __has_feature(size_t)
|
||||||
|
#pragma message "has size_t"
|
||||||
|
#else
|
||||||
|
#pragma message "define size_t"
|
||||||
|
#if __SIZEOF_SIZE_T__ == 8
|
||||||
|
typedef u8 size_t;
|
||||||
|
#elif __SIZEOF_SIZE_T__== 4
|
||||||
|
typedef u4 size_t;
|
||||||
|
#elif __SIZEOF_SIZE_T__ == 2
|
||||||
|
typedef u2 size_t;
|
||||||
|
#elif __SIZEOF_SIZE_T__ == 1
|
||||||
|
typedef i1 size_t;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#pragma message "has NOT __has_feature"
|
||||||
|
#endif /* #ifdef __has_feature */
|
||||||
|
|
||||||
|
#endif /* #ifdef IS_COMPILER_LLVM */
|
||||||
|
|
||||||
|
/* Simulated limit.h */
|
||||||
|
#define U1_MAX 0xFF
|
||||||
|
#define U1_MIN 0
|
||||||
|
#define U2_MAX 0xFFFF
|
||||||
|
#define U2_MIN 0
|
||||||
|
#define U4_MAX 0xFFFFFFFFU
|
||||||
|
#define U4_MIN 0
|
||||||
|
#define U8_MAX 0xFFFFFFFFFFFFFFFFULL
|
||||||
|
#define U8_MIN 0
|
||||||
|
#define I1_MAX 0x7F
|
||||||
|
#define I1_MIN (-128)
|
||||||
|
#define I2_MAX 0x7FFF
|
||||||
|
#define I2_MIN (-32768)
|
||||||
|
#define I4_MAX 0x7FFFFFFF
|
||||||
|
#define I4_MIN (-I4_MAX - 1)
|
||||||
|
#define I8_MAX 9223372036854775807LL
|
||||||
|
#define I8_MIN (-I8_MAX - 1LL)
|
||||||
|
|
||||||
|
/* Simulate float.h assumes IEEE standard format and 4 8 10 byte formats (FLT_, DBL_, LDBL_) (FLT_ maps to F4, DBL_ maps to F8) */
|
||||||
|
|
||||||
|
#define DBL_DIG 15
|
||||||
|
#define DBL_EPSILON 2.2204460492503131e-16
|
||||||
|
#define DBL_MANT_DIG 53
|
||||||
|
#define DBL_MAX_10_EXP 308
|
||||||
|
#define DBL_MAX 1.7976931348623157e+308
|
||||||
|
|
||||||
|
#define DBL_MAX_EXP 1024
|
||||||
|
#define DBL_MIN_10_EXP (-307)
|
||||||
|
#define DBL_MIN 2.2250738585072014e-308
|
||||||
|
#define DBL_MIN_EXP (-1021)
|
||||||
|
|
||||||
|
#define LDBL_DIG 18
|
||||||
|
#define LDBL_EPSILON 1.08420217248550443401e-19L
|
||||||
|
#define LDBL_MANT_DIG 64
|
||||||
|
#define LDBL_MAX_10_EXP 4932
|
||||||
|
#define LDBL_MAX_EXP 16384
|
||||||
|
|
||||||
|
#define LDBL_MAX 1.18973149535723176502e+4932L
|
||||||
|
#define LDBL_MIN_10_EXP (-4931)
|
||||||
|
#define LDBL_MIN_EXP (-16381)
|
||||||
|
#define LDBL_MIN 3.36210314311209350626e-4932L
|
||||||
|
|
||||||
|
#define FLT_DIG 6
|
||||||
|
#define FLT_EPSILON 1.19209290e-7F
|
||||||
|
#define FLT_MANT_DIG 24
|
||||||
|
#define FLT_MAX_10_EXP 38
|
||||||
|
#define FLT_MAX_EXP 128
|
||||||
|
|
||||||
|
#define FLT_MAX 3.40282347e+38F
|
||||||
|
#define FLT_MIN_10_EXP (-37)
|
||||||
|
#define FLT_MIN_EXP (-125)
|
||||||
|
#define FLT_MIN 1.17549435e-38F
|
||||||
|
#define FLT_RADIX 2
|
||||||
|
|
||||||
|
#define FLT_ROUNDS 1
|
||||||
|
|
||||||
|
#define PI_SHORT 3.14
|
||||||
|
|
||||||
|
#ifdef HAS_LIBC
|
||||||
|
#include <stdio.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAS_LIBC
|
||||||
|
void *memcpy(void *dest, const void *src, size_t n);
|
||||||
|
void *memset(void *s, int c, size_t n);
|
||||||
|
int memcmp(void *s1, void *s2, size_t n);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef BUILD_EXE
|
||||||
|
#ifndef HAS_LIBC
|
||||||
|
void write(int fd, char *buf, int count);
|
||||||
|
void exit(int stat);
|
||||||
|
#endif
|
||||||
|
void print_int(char *file, int line, char *func, int expected, int val, char *ok);
|
||||||
|
void print_long(char *file, int line, char *func, long expected, long val, char *ok);
|
||||||
|
void print_uint(char *file, int line, char *func, unsigned int expected, unsigned int val, char *ok);
|
||||||
|
void print_ulong(char *file, int line, char *func, unsigned long expected, unsigned long val, char *ok);
|
||||||
|
void print_float(char *file, int line, char *func, float expected, float val, char *ok);
|
||||||
|
void print_val(char *name, int val);
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
|
||||||
|
# Default values can be modified here, or (in
|
||||||
|
# some cases) on the build command line (see ./build --help)
|
||||||
|
|
||||||
|
# PCodeTest.defaults that can be overridden on command line
|
||||||
|
|
||||||
|
PCodeTest.defaults.toolchain_root = '/local/ToolChains'
|
||||||
|
PCodeTest.defaults.build_root = '/local/build-pcodetest'
|
||||||
|
PCodeTest.defaults.gcc_version = '7.3.0'
|
||||||
|
PCodeTest.defaults.skip_files = []
|
||||||
|
PCodeTest.defaults.export_root = os.getcwd() + '/../../../../../../ghidra.bin/Ghidra/Test/TestResources/data/pcodetests/'
|
||||||
|
PCodeTest.defaults.pcodetest_src = os.getcwd() + '/c_src'
|
||||||
|
|
||||||
|
# PCodeTest.defaults that cannot be overridden on the command line
|
||||||
|
|
||||||
|
PCodeTest.defaults.build_all = 0
|
||||||
|
PCodeTest.defaults.ccflags = ''
|
||||||
|
PCodeTest.defaults.has_decimal128 = 0
|
||||||
|
PCodeTest.defaults.has_decimal32 = 0
|
||||||
|
|
||||||
|
|
||||||
|
PCodeTest.defaults.has_decimal64 = 0
|
||||||
|
PCodeTest.defaults.has_double = 1
|
||||||
|
PCodeTest.defaults.has_float = 1
|
||||||
|
PCodeTest.defaults.has_longlong = 1
|
||||||
|
PCodeTest.defaults.has_shortfloat = 0
|
||||||
|
PCodeTest.defaults.has_vector = 0
|
||||||
|
PCodeTest.defaults.small_build = 0
|
||||||
|
PCodeTest.defaults.ld_library_path = ''
|
||||||
|
PCodeTest.defaults.toolchain_type = 'gcc'
|
||||||
|
PCodeTest.defaults.compile_exe = 'bin/gcc'
|
||||||
|
PCodeTest.defaults.objdump_exe = 'bin/objdump'
|
||||||
|
PCodeTest.defaults.objdump_option = ''
|
||||||
|
PCodeTest.defaults.readelf_exe = 'bin/readelf'
|
||||||
|
PCodeTest.defaults.nm_exe = 'bin/nm'
|
||||||
|
PCodeTest.defaults.strip_exe = 'bin/strip'
|
||||||
|
PCodeTest.defaults.variants = {'O0': '-O0', 'O3': '-O3'}
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user