Publish VCC Plus OSS source distribution for 3.6.2 build 60
This commit is contained in:
commit
c652a5276d
1192 files changed
+272368
No files matched your search
@@ -0,0 +1,69 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#include <cmoc.h>
|
||||
|
||||
static const unsigned char heights[] = { 12, 34, 56, 78 };
|
||||
static unsigned char samples[258];
|
||||
|
||||
static unsigned char terrain(unsigned i)
|
||||
{
|
||||
return 184 - heights[i];
|
||||
}
|
||||
|
||||
static unsigned char fromPointer(const unsigned char *array, unsigned i, unsigned char base)
|
||||
{
|
||||
return base - array[i];
|
||||
}
|
||||
|
||||
static unsigned char differs(unsigned char actual, unsigned i)
|
||||
{
|
||||
return actual != heights[i];
|
||||
}
|
||||
|
||||
static unsigned char byteIndex(unsigned char i)
|
||||
{
|
||||
return 184 - heights[i];
|
||||
}
|
||||
|
||||
static unsigned char reversed(unsigned i)
|
||||
{
|
||||
return heights[i] - 34;
|
||||
}
|
||||
|
||||
static unsigned char twoReads(unsigned left, unsigned right)
|
||||
{
|
||||
return heights[left] - heights[right];
|
||||
}
|
||||
|
||||
// Print result bytes so that the host can check them independently of any
|
||||
// equality or subtraction code emitted by the compiler under test.
|
||||
static void emit(unsigned char value)
|
||||
{
|
||||
printf("%02x", (unsigned)value);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
unsigned i;
|
||||
printf("HX ");
|
||||
for (i = 0; i < sizeof(heights); ++i)
|
||||
emit(terrain(i));
|
||||
|
||||
// The comparison must see the same index regardless of the other operand.
|
||||
emit(differs(34, 1));
|
||||
emit(differs(12, 1));
|
||||
|
||||
// These indices have equal low bytes. Subtracting 200 from 184 must
|
||||
// wrap to 240 when the result is converted to unsigned char.
|
||||
samples[1] = 15;
|
||||
samples[257] = 200;
|
||||
emit(fromPointer(samples, 1, 184));
|
||||
emit(fromPointer(samples, 257, 184));
|
||||
emit(fromPointer(samples, 257, 200));
|
||||
emit(byteIndex(2));
|
||||
emit(reversed(1));
|
||||
emit(reversed(0));
|
||||
emit(twoReads(3, 0));
|
||||
emit(twoReads(0, 3));
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user